Skip to content

Commit 7b7f2bd

Browse files
longlimsftSteve French
authored andcommitted
CIFS: Introduce helper function to get page offset and length in smb_rqst
Introduce a function rqst_page_get_length to return the page offset and length for a given page in smb_rqst. This function is to be used by following patches. Signed-off-by: Long Li <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent c06a0f2 commit 7b7f2bd

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

fs/cifs/cifsproto.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,4 +557,7 @@ int cifs_alloc_hash(const char *name, struct crypto_shash **shash,
557557
struct sdesc **sdesc);
558558
void cifs_free_hash(struct crypto_shash **shash, struct sdesc **sdesc);
559559

560+
extern void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page,
561+
unsigned int *len, unsigned int *offset);
562+
560563
#endif /* _CIFSPROTO_H */

fs/cifs/misc.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,3 +905,20 @@ cifs_free_hash(struct crypto_shash **shash, struct sdesc **sdesc)
905905
crypto_free_shash(*shash);
906906
*shash = NULL;
907907
}
908+
909+
/**
910+
* rqst_page_get_length - obtain the length and offset for a page in smb_rqst
911+
* Input: rqst - a smb_rqst, page - a page index for rqst
912+
* Output: *len - the length for this page, *offset - the offset for this page
913+
*/
914+
void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page,
915+
unsigned int *len, unsigned int *offset)
916+
{
917+
*len = rqst->rq_pagesz;
918+
*offset = (page == 0) ? rqst->rq_offset : 0;
919+
920+
if (rqst->rq_npages == 1 || page == rqst->rq_npages-1)
921+
*len = rqst->rq_tailsz;
922+
else if (page == 0)
923+
*len = rqst->rq_pagesz - rqst->rq_offset;
924+
}

0 commit comments

Comments
 (0)