Re: [RFC PATCH v2 2/4] btrfs: don't BUG_ON() in btrfs_link_subvol()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2018/9/11 下午7:29, Lu Fengqi wrote:
> Both of btrfs_update_inode() and btrfs_add_root_ref() may fail because
> of ENOMEM.

Not only ENOMEM, but also EEXIST/EIO from btrfs_insert_empty_item().

> So there's no reason to panic here, we can replace BUG_ON()
> with btrfs_abort_transaction() here.

Valid cleanup.

Reviewed-by: Qu Wenruo <wqu@xxxxxxxx>

Thanks,
Qu

> 
> Signed-off-by: Lu Fengqi <lufq.fnst@xxxxxxxxxxxxxx>
> ---
>  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 1b03d07acde2..f6173d4e7ced 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -572,11 +572,17 @@ static int btrfs_link_subvol(struct btrfs_trans_handle *trans,
>  
>  	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);
> +		return ret;
> +	}
>  
>  	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);
> +		return ret;
> +	}
>  
>  	return ret;
>  }
> 

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux