diff mbox series

[2/5] btrfs: don't BUG_ON in create_subvol

Message ID 20191206143718.167998-3-josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Various fixes | expand

Commit Message

Josef Bacik Dec. 6, 2019, 2:37 p.m. UTC
We can just abort the transaction here, and in fact do that for every
other failure in this function except these two cases.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/ioctl.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Filipe Manana Dec. 6, 2019, 3:03 p.m. UTC | #1
On Fri, Dec 6, 2019 at 2:38 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> We can just abort the transaction here, and in fact do that for every
> other failure in this function except these two cases.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good, thanks.

> ---
>  fs/btrfs/ioctl.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index a1ee0b775e65..375befdecc19 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -704,11 +704,17 @@ static noinline int create_subvol(struct inode *dir,
>
>         btrfs_i_size_write(BTRFS_I(dir), dir->i_size + namelen * 2);
>         ret = btrfs_update_inode(trans, root, dir);
> -       BUG_ON(ret);
> +       if (ret) {
> +               btrfs_abort_transaction(trans, ret);
> +               goto fail;
> +       }
>
>         ret = btrfs_add_root_ref(trans, objectid, root->root_key.objectid,
>                                  btrfs_ino(BTRFS_I(dir)), index, name, namelen);
> -       BUG_ON(ret);
> +       if (ret) {
> +               btrfs_abort_transaction(trans, ret);
> +               goto fail;
> +       }
>
>         ret = btrfs_uuid_tree_add(trans, root_item->uuid,
>                                   BTRFS_UUID_KEY_SUBVOL, objectid);
> --
> 2.23.0
>
Johannes Thumshirn Dec. 9, 2019, 10:49 a.m. UTC | #2
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
diff mbox series

Patch

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index a1ee0b775e65..375befdecc19 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -704,11 +704,17 @@  static noinline int create_subvol(struct inode *dir,
 
 	btrfs_i_size_write(BTRFS_I(dir), dir->i_size + namelen * 2);
 	ret = btrfs_update_inode(trans, root, dir);
-	BUG_ON(ret);
+	if (ret) {
+		btrfs_abort_transaction(trans, ret);
+		goto fail;
+	}
 
 	ret = btrfs_add_root_ref(trans, objectid, root->root_key.objectid,
 				 btrfs_ino(BTRFS_I(dir)), index, name, namelen);
-	BUG_ON(ret);
+	if (ret) {
+		btrfs_abort_transaction(trans, ret);
+		goto fail;
+	}
 
 	ret = btrfs_uuid_tree_add(trans, root_item->uuid,
 				  BTRFS_UUID_KEY_SUBVOL, objectid);