btrfs: remove pointless code when creating and deleting a subvolume
authorFilipe Manana <fdmanana@suse.com>
Thu, 6 Jun 2024 08:20:18 +0000 (09:20 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 11 Jul 2024 13:33:24 +0000 (15:33 +0200)
When creating and deleting a subvolume, after starting a transaction we
are explicitly calling btrfs_record_root_in_trans() for the root which we
passed to btrfs_start_transaction(). This is pointless because at
transaction.c:start_transaction() we end up doing that call, regardless
of whether we actually start a new transaction or join an existing one,
and if we were not it would mean the root item of that root would not
be updated in the root tree when committing the transaction, leading to
problems easy to spot with fstests for example.

Remove these redundant calls. They were introduced with commit
74e97958121a ("btrfs: qgroup: fix qgroup prealloc rsv leak in subvolume
operations").

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
fs/btrfs/ioctl.c

index eb3c44c..cc8db6b 100644 (file)
@@ -4552,11 +4552,6 @@ int btrfs_delete_subvolume(struct btrfs_inode *dir, struct dentry *dentry)
                ret = PTR_ERR(trans);
                goto out_release;
        }
-       ret = btrfs_record_root_in_trans(trans, root);
-       if (ret) {
-               btrfs_abort_transaction(trans, ret);
-               goto out_end_trans;
-       }
        btrfs_qgroup_convert_reserved_meta(root, qgroup_reserved);
        qgroup_reserved = 0;
        trans->block_rsv = &block_rsv;
index 5e3cb02..d00d493 100644 (file)
@@ -658,9 +658,6 @@ static noinline int create_subvol(struct mnt_idmap *idmap,
                ret = PTR_ERR(trans);
                goto out_release_rsv;
        }
-       ret = btrfs_record_root_in_trans(trans, BTRFS_I(dir)->root);
-       if (ret)
-               goto out;
        btrfs_qgroup_convert_reserved_meta(root, qgroup_reserved);
        qgroup_reserved = 0;
        trans->block_rsv = &block_rsv;