]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: propagate last_unlink_trans earlier when doing a rmdir
authorFilipe Manana <fdmanana@suse.com>
Sat, 12 Jul 2025 04:45:48 +0000 (00:45 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jul 2025 16:32:10 +0000 (18:32 +0200)
commit72be0d6b305a115c3fd80cbfaff206658cc9f43b
tree4acc32b5c1747b254e406ba6def08c9413118660
parent66d29d757c968d2bee9124816da5d718eb352959
btrfs: propagate last_unlink_trans earlier when doing a rmdir

[ Upstream commit c466e33e729a0ee017d10d919cba18f503853c60 ]

In case the removed directory had a snapshot that was deleted, we are
propagating its inode's last_unlink_trans to the parent directory after
we removed the entry from the parent directory. This leaves a small race
window where someone can log the parent directory after we removed the
entry and before we updated last_unlink_trans, and as a result if we ever
try to replay such a log tree, we will fail since we will attempt to
remove a snapshot during log replay, which is currently not possible and
results in the log replay (and mount) to fail. This is the type of failure
described in commit 1ec9a1ae1e30 ("Btrfs: fix unreplayable log after
snapshot delete + parent dir fsync").

So fix this by propagating the last_unlink_trans to the parent directory
before we remove the entry from it.

Fixes: 44f714dae50a ("Btrfs: improve performance on fsync against new inode after rename/unlink")
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/inode.c