]> git.hungrycats.org Git - linux/commit
btrfs: do not corrupt the fs with rename exchange on a subvol
authorJosef Bacik <josef@toxicpanda.com>
Fri, 15 Nov 2019 20:43:06 +0000 (15:43 -0500)
committerJosef Bacik <josef@toxicpanda.com>
Mon, 18 Nov 2019 14:27:19 +0000 (06:27 -0800)
commitccfa4291f746bfa5d75ea3fdf6820c4bfef4dfb2
tree407adcea83c6655c12c0eba3b63ca82032f31e1e
parented65a872c210756c820f70cc8a336a6039ab3d30
btrfs: do not corrupt the fs with rename exchange on a subvol

Testing with the new fsstress support for subvolumes uncovered a pretty
bad problem with rename exchange on subvolumes.  We're modifying two
different subvolumes, but we only start the transaction on one of them,
so the other one is not added to the dirty root list.  This is caught by
btrfs_cow_block() with a warning because the root has not been updated,
however if we do not modify this root again we'll end up pointing at an
invalid root because the root item is never updated.

Fix this by making sure we add the destination root to the trans list,
the same as we do with normal renames.  This fixes the corruption.

Fixes: cdd1fedf8261 ("btrfs: add support for RENAME_EXCHANGE and RENAME_WHITEOUT")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
fs/btrfs/inode.c