]> git.hungrycats.org Git - linux/commit
btrfs: honor FMODE_NOCMTIME when cloning 6.18/topics/nocmtime
authorJeff Layton <jlayton@kernel.org>
Thu, 5 Nov 2026 20:07:45 +0000 (15:07 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 9 Nov 2026 00:18:39 +0000 (19:18 -0500)
commit9b2eef73fad08fb3db1931dbe9650c6fa853a4b4
tree83da66e9c46f4b84134e8b619b7090420e4a9d26
parentf9317e0c164ccc8697355477f35ed43d558f5e1c
btrfs: honor FMODE_NOCMTIME when cloning

btrfs_remap_file_range() calls generic_remap_file_range_prep() through
btrfs_remap_file_range_prep(). The file_modified() call in
generic_remap_file_range_prep() skips the c/mtime update for
FMODE_NOCMTIME files, but btrfs_clone_files() then always tells
btrfs_clone() to update the c/mtime of the destination.

nfsd sets FMODE_NOCMTIME while a client holds delegated timestamps. Thus
a CLONE from the holder advances the server's ctime, and the times that
the holder returns cannot move it back.

Pass no_time_update for FMODE_NOCMTIME destinations, as dedupe already
does. Make btrfs_should_update_cmtime() available to reflink.c.

[zygo: 6.18 backport: 6.18's btrfs_clone_files() locks up to destoff +
len - 1 and passes 0 as no_time_update; context adjusted, the change
itself is unchanged]

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-4-a42a2b93cdc2@kernel.org
Assisted-by: Claude:claude-opus-5-5
fs/btrfs/file.c
fs/btrfs/file.h
fs/btrfs/reflink.c