btrfs: do not set mtime/ctime to current time when unlinking for log replay
authorFilipe Manana <fdmanana@suse.com>
Fri, 1 Aug 2025 15:39:49 +0000 (16:39 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 13 Aug 2025 12:08:44 +0000 (14:08 +0200)
commitf022499f24e520706b9a8238746e1cacc37eb4e0
tree30ac2ab23f28103b7b169b14212bac43d5524f67
parent05b372862600e551bbf86e7f24a1caeed5e06150
btrfs: do not set mtime/ctime to current time when unlinking for log replay

If we are doing an unlink for log replay, we are updating the directory's
mtime and ctime to the current time, and this is incorrect since it should
stay with the mtime and ctime that were set when the directory was logged.

This is the same as when adding a link to an inode during log replay (with
btrfs_add_link()), where we want the mtime and ctime to be the values that
were in place when the inode was logged.

This was found with generic/547 using LOAD_FACTOR=20 and TIME_FACTOR=20,
where due to large log trees we have longer log replay times and fssum
could detect a mismatch of the mtime and ctime of a directory.

Fix this by skipping the mtime and ctime update at __btrfs_unlink_inode()
if we are in log replay context (just like btrfs_add_link()).

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c