[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <07dd7e42-b2c4-4fbb-87f3-ab888d11256d@163.com>
Date: Thu, 24 Jul 2025 09:54:24 +0800
From: Chi Zhiling <chizhiling@....com>
To: Matthew Wilcox <willy@...radead.org>
Cc: akpm@...ux-foundation.org, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Chi Zhiling <chizhiling@...inos.cn>
Subject: Re: [RFC PATCH 2/3] mm/filemap: Avoid modifying iocb->ki_flags for
AIO in filemap_get_pages()
On 2025/7/23 22:33, Matthew Wilcox wrote:
> On Wed, Jul 23, 2025 at 06:18:24PM +0800, Chi Zhiling wrote:
>> From: Chi Zhiling <chizhiling@...inos.cn>
>>
>> Setting IOCB_NOWAIT in filemap_get_pages() for AIO is only used to
>> indicate not to block in the filemap_update_page(), with no other purpose.
>> Moreover, in filemap_read(), IOCB_NOWAIT will be set again for AIO.
>>
>> Therefore, adding a parameter to the filemap_update_page function to
>> explicitly indicate not to block serves the same purpose as indicating
>> through iocb->ki_flags, thus avoiding modifications to iocb->ki_flags.
>>
>> This patch does not change the original logic and is preparation for the
>> next patch.
>
> Passing multiple booleans to a function is an antipattern.
> Particularly in this case, since we could just pass iocb->ki_flags
> to the function.
>
> But I think there's a less complicated way to do what you want.
> Just don't call filemap_update_page() if there are uptodate folios
> in the batch:
>
> +++ b/mm/filemap.c
> @@ -2616,9 +2616,10 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count,
> goto err;
> }
> if (!folio_test_uptodate(folio)) {
> - if ((iocb->ki_flags & IOCB_WAITQ) &&
> - folio_batch_count(fbatch) > 1)
> - iocb->ki_flags |= IOCB_NOWAIT;
> + if (folio_batch_count(fbatch) > 1) {
> + err = -EAGAIN;
> + goto err;
> + }
Yes, this is a completely better way.
Would you mind if I add
"Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>"
in the next version?
> err = filemap_update_page(iocb, mapping, count, folio,
> need_uptodate);
> if (err)
Thanks,
Powered by blists - more mailing lists