Skip to content

fuse: invalidate the page cache after direct write#94

Merged
bsbernd merged 1 commit intoredfs-ubuntu-noble-6.8.0-58.60from
async-dio-ra-redfs-ubuntu-noble-6.8.0-58.60
Feb 13, 2026
Merged

fuse: invalidate the page cache after direct write#94
bsbernd merged 1 commit intoredfs-ubuntu-noble-6.8.0-58.60from
async-dio-ra-redfs-ubuntu-noble-6.8.0-58.60

Conversation

@bsbernd
Copy link
Collaborator

@bsbernd bsbernd commented Feb 11, 2026

This fixes xfstests generic/451 (for both O_DIRECT and FOPEN_DIRECT_IO direct write).

Commit b359af8 ("fuse: Invalidate the page cache after FOPEN_DIRECT_IO write") tries to fix the similar issue for FOPEN_DIRECT_IO write, which can be reproduced by xfstests generic/209. It only fixes the issue for synchronous direct write, while omitting the case for asynchronous direct write (exactly targeted by generic/451).

While for O_DIRECT direct write, it's somewhat more complicated. For synchronous direct write, generic_file_direct_write() will invalidate the page cache after the write, and thus it can pass generic/209. While for asynchronous direct write, the invalidation in generic_file_direct_write() is bypassed since the invalidation shall be done when the asynchronous IO completes. This is omitted in FUSE and generic/451 fails whereby.

Fix this by conveying the invalidation for both synchronous and asynchronous write.

  • with FOPEN_DIRECT_IO
    • sync write, invalidate in fuse_send_write()
    • async write, invalidate in fuse_aio_complete() with FUSE_ASYNC_DIO, fuse_send_write() otherwise
  • without FOPEN_DIRECT_IO
    • sync write, invalidate in generic_file_direct_write()
    • async write, invalidate in fuse_aio_complete() with FUSE_ASYNC_DIO, generic_file_direct_write() otherwise

Reviewed-by: Bernd Schubert bschubert@ddn.com

This fixes xfstests generic/451 (for both O_DIRECT and FOPEN_DIRECT_IO
direct write).

Commit b359af8 ("fuse: Invalidate the page cache after
FOPEN_DIRECT_IO write") tries to fix the similar issue for
FOPEN_DIRECT_IO write, which can be reproduced by xfstests generic/209.
It only fixes the issue for synchronous direct write, while omitting
the case for asynchronous direct write (exactly targeted by
generic/451).

While for O_DIRECT direct write, it's somewhat more complicated.  For
synchronous direct write, generic_file_direct_write() will invalidate
the page cache after the write, and thus it can pass generic/209.  While
for asynchronous direct write, the invalidation in
generic_file_direct_write() is bypassed since the invalidation shall be
done when the asynchronous IO completes.  This is omitted in FUSE and
generic/451 fails whereby.

Fix this by conveying the invalidation for both synchronous and
asynchronous write.

- with FOPEN_DIRECT_IO
  - sync write,  invalidate in fuse_send_write()
  - async write, invalidate in fuse_aio_complete() with FUSE_ASYNC_DIO,
		 fuse_send_write() otherwise
- without FOPEN_DIRECT_IO
  - sync write,  invalidate in generic_file_direct_write()
  - async write, invalidate in fuse_aio_complete() with FUSE_ASYNC_DIO,
		 generic_file_direct_write() otherwise

Reviewed-by: Bernd Schubert <bschubert@ddn.com>
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
@bsbernd bsbernd requested review from hbirth and yongzech February 11, 2026 16:29
@bsbernd bsbernd merged commit f6de786 into redfs-ubuntu-noble-6.8.0-58.60 Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments