linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] mm/filemap: fix that first page is not mark accessed in filemap_read()
@ 2022-06-02  8:21 Yu Kuai
  2022-06-02 18:22 ` Andrew Morton
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Yu Kuai @ 2022-06-02  8:21 UTC (permalink / raw)
  To: willy, akpm, kent.overstreet
  Cc: axboe, linux-fsdevel, linux-mm, linux-kernel, yukuai3, yi.zhang

In filemap_read(), 'ra->prev_pos' is set to 'iocb->ki_pos + copied',
while it should be 'iocb->ki_ops'. For consequence,
folio_mark_accessed() will not be called for 'fbatch.folios[0]' since
'iocb->ki_pos' is always equal to 'ra->prev_pos'.

Fixes: 06c0444290ce ("mm/filemap.c: generic_file_buffered_read() now uses find_get_pages_contig")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 mm/filemap.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 9daeaab36081..0b776e504d35 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2728,10 +2728,11 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter,
 				flush_dcache_folio(folio);
 
 			copied = copy_folio_to_iter(folio, offset, bytes, iter);
-
-			already_read += copied;
-			iocb->ki_pos += copied;
-			ra->prev_pos = iocb->ki_pos;
+			if (copied) {
+				ra->prev_pos = iocb->ki_pos;
+				already_read += copied;
+				iocb->ki_pos += copied;
+			}
 
 			if (copied < bytes) {
 				error = -EFAULT;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-06-15  8:37 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02  8:21 [PATCH -next] mm/filemap: fix that first page is not mark accessed in filemap_read() Yu Kuai
2022-06-02 18:22 ` Andrew Morton
2022-06-06  1:11   ` Yu Kuai
2022-06-02 18:30 ` Matthew Wilcox
2022-06-06  1:10   ` Yu Kuai
2022-06-10 14:34     ` Matthew Wilcox
2022-06-10 14:36       ` Matthew Wilcox
2022-06-10 17:23         ` Kent Overstreet
2022-06-10 17:47         ` Kent Overstreet
2022-06-10 18:34           ` Matthew Wilcox
2022-06-10 18:48             ` Kent Overstreet
2022-06-11  8:23             ` Yu Kuai
2022-06-11 17:42               ` Matthew Wilcox
2022-06-13  1:31                 ` Yu Kuai
2022-06-09  0:59 ` Yu Kuai
2022-06-15  8:36 ` [mm/filemap] 8b157c14b5: phoronix-test-suite.fio.SequentialRead.LinuxAIO.Yes.Yes.4KB.DefaultTestDirectory.mb_s -8.1% regression kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).