The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jimmy Zuber <jamz@amazon.com>
To: <miklos@szeredi.hu>, <shuah@kernel.org>
Cc: <fuse-devel@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<linux-kselftest@vger.kernel.org>, <jack@suse.com>,
	<joannelkoong@gmail.com>, <bfoster@redhat.com>
Subject: [PATCH v3 0/2] fuse: zero the partial EOF page when extending a file
Date: Thu, 20 Aug 2026 12:35:31 +0000	[thread overview]
Message-ID: <20260820123533.190470-1-jamz@amazon.com> (raw)

v3 is a resend of v2 [2] with no code or commit-message changes; the v2
posting went out with malformed To/Cc headers, so most recipients did not
get a direct copy.

Extending a fuse file past a non-page-aligned EOF does not zero the tail of
the old last page.  When that page is cached and has been mmap-dirtied beyond
the old EOF, the now in-bounds tail is served to later reads as stale data
rather than zeros, which violates POSIX file-extension semantics.

Some file systems get this zeroing automatically at writeback time
(block_write_full_folio() / iomap_writeback_handle_eof() zero the tail of the
folio straddling i_size).  A non-writeback caching fuse file system uses neither
path, so it has to zero the tail itself from the size-extending paths, like
XFS (xfs_file_write_zero_eof()) and ext4 (ext4_block_zero_eof()) do.
pagecache_isize_extended() cannot be reused: it is a no-op when
i_blocksize() >= PAGE_SIZE, and would increase the work in that function
for use cases that don't need it, if changed to support this situation.

Patch 1 adds fuse_zero_partial_eof_folio() and calls it up front from the
three paths that extend a file: buffered write, setattr, and
fallocate.  Patch 2 adds a self-contained raw /dev/fuse selftest covering each
path.

Tested by booting the patched kernel under User-Mode Linux and running the new
selftest, and reproduced against libfuse's passthrough_ll example daemon.

Changes since v1 [1]:
- Miklos and Jan Kara discussed whether there was a better pattern with less
  duplication between file systems.  Jan confirmed that other file systems do
  this zeroing themselves from their write/setattr paths (e.g. XFS
  xfs_file_write_zero_eof(), ext4 ext4_block_zero_eof()), because the block /
  iomap writeback that would otherwise zero the straddling folio does not run
  on this path.  File systems currently implement this separately.  It is
  beyond me to pursue unifying it.  Restructure to match the pattern in other
  file systems: zero [old EOF, write start) up front from fuse_perform_write()
  rather than after the fact from fuse_write_update_attr(), keyed on the write
  starting beyond EOF.
- This keeps the zeroed range disjoint from the written data, so a write that
  lands inside the old EOF folio is preserved by construction; the v1
  "pos - written" arithmetic and the fallocate double-call are gone.
- fuse_write_update_attr() goes back to being a pure attr update; the
  setattr/truncate call in fuse_do_setattr() is unchanged.
- The selftest is unchanged from v1.

[1] https://lore.kernel.org/all/20260731203842.540798-1-jamz@amazon.com/
[2] https://lore.kernel.org/all/20260820122627.156961-1-jamz@amazon.com/

Jimmy Zuber (2):
  fuse: zero the partial EOF page when extending a file
  selftests/fuse: test post-EOF page zeroing when a file is extended

 fs/fuse/dir.c                                 |   3 +
 fs/fuse/file.c                                |  56 +++
 fs/fuse/fuse_i.h                              |   1 +
 .../selftests/filesystems/fuse/.gitignore     |   1 +
 .../selftests/filesystems/fuse/Makefile       |   3 +
 .../filesystems/fuse/write_extend_eof_test.c  | 368 ++++++++++++++++++
 6 files changed, 432 insertions(+)
 create mode 100644 tools/testing/selftests/filesystems/fuse/write_extend_eof_test.c


base-commit: 7d87a5a284bb34edb3f4e7e312ef403b3385a7b7
-- 
2.50.1


             reply	other threads:[~2026-08-20 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20 12:35 Jimmy Zuber [this message]
2026-08-20 12:35 ` [PATCH v3 1/2] fuse: zero the partial EOF page when extending a file Jimmy Zuber
2026-08-20 12:35 ` [PATCH v3 2/2] selftests/fuse: test post-EOF page zeroing when a file is extended Jimmy Zuber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260820123533.190470-1-jamz@amazon.com \
    --to=jamz@amazon.com \
    --cc=bfoster@redhat.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=jack@suse.com \
    --cc=joannelkoong@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox