]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitea8bc5071d82b2b64b1c885b8a15c55fad38f452
tree57be27468fa015f25fe8bfc100223e6e6975825b
parentb21a055ebfdebd7f53c75fa999e9caa8ab666cd0
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