]> git.hungrycats.org Git - linux/commitdiff
btrfs: don't BUG_ON in create_subvol
authorJosef Bacik <josef@toxicpanda.com>
Wed, 4 Dec 2019 16:15:53 +0000 (08:15 -0800)
committerJosef Bacik <josef@toxicpanda.com>
Wed, 4 Dec 2019 16:49:22 +0000 (08:49 -0800)
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

index a1ee0b775e652b16f9abe3134e3ae2226ba3ab9c..375befdecc19ccc6d9162f444195c43b63e7fb8b 100644 (file)
@@ -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);