diff options
author | Josef Bacik <josef@toxicpanda.com> | 2019-11-15 23:43:06 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-12-17 21:56:07 +0300 |
commit | cab5f4c6fdbde86056f8c98e580cc002175bb242 (patch) | |
tree | 4638e78c7c51795c3c31cc525536267bdb917725 /fs/btrfs | |
parent | cb7c10c675e8844a13b8168a0c5ae428a5dc8199 (diff) | |
download | linux-cab5f4c6fdbde86056f8c98e580cc002175bb242.tar.xz |
btrfs: record all roots for rename exchange on a subvol
commit 3e1740993e43116b3bc71b0aad1e6872f6ccf341 upstream.
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")
CC: stable@vger.kernel.org # 4.9+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/inode.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 2d23df72e091..10a01dd0c4e6 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -9554,6 +9554,9 @@ static int btrfs_rename_exchange(struct inode *old_dir, goto out_notrans; } + if (dest != root) + btrfs_record_root_in_trans(trans, dest); + /* * We need to find a free sequence number both in the source and * in the destination directory for the exchange. |