Re: [PATCH] fuse: invalidate page cache after DIO and async DIO writes
From: Miklos Szeredi
Date: Thu Jun 11 2026 - 04:48:49 EST
On Mon, 20 Apr 2026 at 10:39, Cheng Ding via B4 Relay
<devnull+cding.ddn.com@xxxxxxxxxx> wrote:
>
> From: Cheng Ding <cding@xxxxxxx>
>
> This fixe does page cache invalidation after DIO and async DIO writes for
> both O_DIRECT and FOPEN_DIRECT_IO cases.
>
> Commit b359af8275a9 ("fuse: Invalidate the page cache after FOPEN_DIRECT_IO
> write") fixed xfstests generic/209 for DIO writes in the FOPEN_DIRECT_IO
> path. DIO writes without FOPEN_DIRECT_IO are already handled by
> generic_file_direct_write().
> However, async DIO writes (xfstests generic/451) remain unhandled.
>
> After this fix:
> - Async write with FUSE_ASYNC_DIO:
> invalidate in fuse_aio_invalidate_worker()
>
> - Otherwise (Sync or async write without FUSE_ASYNC_DIO):
> - With FOPEN_DIRECT_IO:
> invalidate in fuse_direct_write_iter()
> - Without FOPEN_DIRECT_IO:
> invalidate in generic_file_direct_write()
>
> Workqueue is required for async write invalidation to prevent deadlock:
> calling it directly in the I/O end routine (which is in fuse worker thread
> context) can block on a folio lock held by a buffered I/O thread waiting
> for the same fuse worker thread.
>
> Co-developed-by: Jingbo Xu <jefflexu@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Jingbo Xu <jefflexu@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Cheng Ding <cding@xxxxxxx>
Applied, thanks.
Miklos