OSDN Git Service

btrfs: skip transaction commit after failure to create subvolume
authorFilipe Manana <fdmanana@suse.com>
Mon, 13 Dec 2021 08:45:14 +0000 (08:45 +0000)
committerDavid Sterba <dsterba@suse.com>
Fri, 7 Jan 2022 13:18:26 +0000 (14:18 +0100)
commit1b58ae0e4d3ede95ee968a3f097298a57cf711ba
tree57be27468fa015f25fe8bfc100223e6e6975825b
parent82187d2ecdfb22ab7ee05f388402a39236d31428
btrfs: skip transaction commit after failure to create subvolume

At ioctl.c:create_subvol(), when we fail to create a subvolume we always
commit the transaction. In most cases this is a no-op, since all the error
paths, except for one, abort the transaction - the only exception is when
we fail to insert the new root item into the root tree, in that case we
don't abort the transaction because we didn't do anything that is
irreversible - however we end up committing the transaction which although
is not a functional problem, it adds unnecessary rotation of the backup
roots in the superblock and unnecessary work.

So change that to commit a transaction only when no error happened,
otherwise just call btrfs_end_transaction() to release our reference on
the transaction.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c