Skip to content

Commit ce59897

Browse files
Mark Fashehkdave
authored andcommitted
btrfs: Don't BUG_ON errors from btrfs_create_subvol_root()
This is called from only one place - create_subvol() which passes errors safely back out to it's caller, btrfs_mksubvol where they are handled. Additionally, btrfs_create_subvol_root() itself bug's needlessly from error return of btrfs_update_inode(). Since create_subvol() was fixed to catch errors we can bubble this one up too. Signed-off-by: Mark Fasheh <[email protected]>
1 parent 2c53679 commit ce59897

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

fs/btrfs/inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6734,10 +6734,9 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
67346734
btrfs_i_size_write(inode, 0);
67356735

67366736
err = btrfs_update_inode(trans, new_root, inode);
6737-
BUG_ON(err);
67386737

67396738
iput(inode);
6740-
return 0;
6739+
return err;
67416740
}
67426741

67436742
struct inode *btrfs_alloc_inode(struct super_block *sb)

fs/btrfs/ioctl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@ static noinline int create_subvol(struct btrfs_root *root,
430430
btrfs_record_root_in_trans(trans, new_root);
431431

432432
ret = btrfs_create_subvol_root(trans, new_root, new_dirid);
433+
if (ret) {
434+
/* We potentially lose an unused inode item here */
435+
goto fail;
436+
}
437+
433438
/*
434439
* insert the directory item
435440
*/

0 commit comments

Comments
 (0)