From nobody Tue Apr 28 09:10:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC7C4C43334 for ; Thu, 2 Jun 2022 08:08:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232071AbiFBIIO (ORCPT ); Thu, 2 Jun 2022 04:08:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232062AbiFBIIL (ORCPT ); Thu, 2 Jun 2022 04:08:11 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75DDB25FE; Thu, 2 Jun 2022 01:08:08 -0700 (PDT) Received: from kwepemi500025.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LDJTR4TJ2zRhYy; Thu, 2 Jun 2022 16:04:59 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi500025.china.huawei.com (7.221.188.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 2 Jun 2022 16:08:06 +0800 Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 2 Jun 2022 16:08:05 +0800 From: Yu Kuai To: , , CC: , , , , , Subject: [PATCH -next] mm/filemap: fix that first page is not mark accessed in filemap_read() Date: Thu, 2 Jun 2022 16:21:29 +0800 Message-ID: <20220602082129.2805890-1-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 f= ind_get_pages_contig") Signed-off-by: Yu Kuai Reported-by: Yu Kuai Reported-by: kernel test robot --- 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); =20 copied =3D copy_folio_to_iter(folio, offset, bytes, iter); - - already_read +=3D copied; - iocb->ki_pos +=3D copied; - ra->prev_pos =3D iocb->ki_pos; + if (copied) { + ra->prev_pos =3D iocb->ki_pos; + already_read +=3D copied; + iocb->ki_pos +=3D copied; + } =20 if (copied < bytes) { error =3D -EFAULT; --=20 2.31.1