Skip to content

Commit f2a26a3

Browse files
committed
SMB3: fix readpage for large swap cache
readpage was calculating the offset of the page incorrectly for the case of large swapcaches. loff_t offset = (loff_t)page->index << PAGE_SHIFT; As pointed out by Matthew Wilcox, this needs to use page_file_offset() to calculate the offset instead. Pages coming from the swap cache have page->index set to their index within the swapcache, not within the backing file. For a sufficiently large swapcache, we could have overlapping values of page->index within the same backing file. Suggested by: Matthew Wilcox (Oracle) <[email protected]> Cc: <[email protected]> # v5.7+ Reviewed-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent ff11764 commit f2a26a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/cifs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4619,7 +4619,7 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
46194619

46204620
static int cifs_readpage(struct file *file, struct page *page)
46214621
{
4622-
loff_t offset = (loff_t)page->index << PAGE_SHIFT;
4622+
loff_t offset = page_file_offset(page);
46234623
int rc = -EACCES;
46244624
unsigned int xid;
46254625

0 commit comments

Comments
 (0)