]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
btrfs: record all roots for rename exchange on a subvol
authorJosef Bacik <josef@toxicpanda.com>
Fri, 15 Nov 2019 20:43:06 +0000 (15:43 -0500)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:22:38 +0000 (14:22 -0300)
BugLink: https://bugs.launchpad.net/bugs/1857158
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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
fs/btrfs/inode.c

index 43d5b7ef50f1a9a0f7bc239b977a96f1fcbc751d..c6e1a7d52bea5ad2fcf15a4f7967fbf0df87fb3e 100644 (file)
@@ -9774,6 +9774,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.