Message ID | 20200212072048.629856-3-naohiro.aota@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: refactor and generalize chunk/dev_extent/extent allocation | expand |
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
On 2/12/20 2:20 AM, Naohiro Aota wrote: > Do not BUG_ON() when an invalid profile is passed to __btrfs_alloc_chunk(). > Instead return -EINVAL with ASSERT() to catch a bug in the development > stage. > > Suggested-by: Johannes Thumshirn <Johannes.Thumshirn@wdc.com> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Thanks, Josef
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 9cfc668f91f4..911c6b7c650b 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4809,7 +4809,10 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, int j; int index; - BUG_ON(!alloc_profile_is_valid(type, 0)); + if (!alloc_profile_is_valid(type, 0)) { + ASSERT(0); + return -EINVAL; + } if (list_empty(&fs_devices->alloc_list)) { if (btrfs_test_opt(info, ENOSPC_DEBUG))
Do not BUG_ON() when an invalid profile is passed to __btrfs_alloc_chunk(). Instead return -EINVAL with ASSERT() to catch a bug in the development stage. Suggested-by: Johannes Thumshirn <Johannes.Thumshirn@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- fs/btrfs/volumes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)