btrfs: honor FMODE_NOCMTIME in fallocate
btrfs_fallocate() calls file_modified(), which skips the c/mtime update
for FMODE_NOCMTIME files. But the helpers that btrfs_fallocate() calls
update the times anyway:
- btrfs_prealloc_file_range() sets ctime. Its
insert_prealloc_file_extent() tells btrfs_replace_file_extents() to
update c/mtime.
- btrfs_fallocate_update_isize() sets ctime.
btrfs_zero_range() also calls these helpers. nfsd sets FMODE_NOCMTIME
while a client holds delegated timestamps. Thus an ALLOCATE from the
holder advances the server's ctime, and the times that the holder
returns cannot move it back.
Pass an update_times flag from btrfs_fallocate() to these helpers. Set
the flag from btrfs_should_update_cmtime(). Relocation still updates the
times.
btrfs_fallocate_update_isize() never incremented i_version. When a size
extension stayed within existing preallocation, only the ctime update
changed the NFS change attribute. Increment i_version unconditionally
there, as btrfs_prealloc_file_range() does.
[zygo: 7.3 port: 7.3 still has the __btrfs_prealloc_file_range() wrapper
and btrfs_prealloc_file_range_trans() for the v1 space cache.
update_times goes through insert_prealloc_file_extent() and
__btrfs_prealloc_file_range(); btrfs_prealloc_file_range_trans() passes
true, so the v1 cache inode keeps updating its times as before]
Fixes: e5e9b24ab8fa ("nfsd: freeze c/mtime updates with outstanding WRITE_ATTRS delegation")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20261105-delegts-btrfs-v1-3-a42a2b93cdc2@kernel.org
Assisted-by: Claude:claude-opus-5-5