btrfs: Use WARN_ON()'s return value in place of WARN_ON(1)
Use WARN_ON()'s return value in place of WARN_ON(1) for cleaner source code that outputs a more descriptive warnings. Also fix the styling warning of redundant braces that came up as a result of this fix. Signed-off-by: Dulshani Gunawardhana <dulshani.gunawardhana89@gmail.com> Reviewed-by: Zach Brown <zab@redhat.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This commit is contained in:
parent
b19e684393
commit
fae7f21cec
@ -326,8 +326,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
|
|||||||
|
|
||||||
eb = path->nodes[level];
|
eb = path->nodes[level];
|
||||||
while (!eb) {
|
while (!eb) {
|
||||||
if (!level) {
|
if (WARN_ON(!level)) {
|
||||||
WARN_ON(1);
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -2464,10 +2464,8 @@ static int btrfsic_process_written_superblock(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1 == btrfsic_check_all_ref_blocks(state, superblock, 0)) {
|
if (WARN_ON(-1 == btrfsic_check_all_ref_blocks(state, superblock, 0)))
|
||||||
WARN_ON(1);
|
|
||||||
btrfsic_dump_tree(state);
|
btrfsic_dump_tree(state);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2907,7 +2905,7 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,
|
|||||||
btrfsic_release_block_ctx(&block_ctx);
|
btrfsic_release_block_ctx(&block_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match) {
|
if (WARN_ON(!match)) {
|
||||||
printk(KERN_INFO "btrfs: attempt to write M-block which contains logical bytenr that doesn't map to dev+physical bytenr of submit_bio,"
|
printk(KERN_INFO "btrfs: attempt to write M-block which contains logical bytenr that doesn't map to dev+physical bytenr of submit_bio,"
|
||||||
" buffer->log_bytenr=%llu, submit_bio(bdev=%s,"
|
" buffer->log_bytenr=%llu, submit_bio(bdev=%s,"
|
||||||
" phys_bytenr=%llu)!\n",
|
" phys_bytenr=%llu)!\n",
|
||||||
@ -2924,7 +2922,6 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,
|
|||||||
bytenr, block_ctx.dev->name,
|
bytenr, block_ctx.dev->name,
|
||||||
block_ctx.dev_bytenr, mirror_num);
|
block_ctx.dev_bytenr, mirror_num);
|
||||||
}
|
}
|
||||||
WARN_ON(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1285,11 +1285,10 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
|
|||||||
free_extent_buffer(eb_root);
|
free_extent_buffer(eb_root);
|
||||||
blocksize = btrfs_level_size(root, old_root->level);
|
blocksize = btrfs_level_size(root, old_root->level);
|
||||||
old = read_tree_block(root, logical, blocksize, 0);
|
old = read_tree_block(root, logical, blocksize, 0);
|
||||||
if (!old || !extent_buffer_uptodate(old)) {
|
if (WARN_ON(!old || !extent_buffer_uptodate(old))) {
|
||||||
free_extent_buffer(old);
|
free_extent_buffer(old);
|
||||||
pr_warn("btrfs: failed to read tree block %llu from get_old_root\n",
|
pr_warn("btrfs: failed to read tree block %llu from get_old_root\n",
|
||||||
logical);
|
logical);
|
||||||
WARN_ON(1);
|
|
||||||
} else {
|
} else {
|
||||||
eb = btrfs_clone_extent_buffer(old);
|
eb = btrfs_clone_extent_buffer(old);
|
||||||
free_extent_buffer(old);
|
free_extent_buffer(old);
|
||||||
@ -3643,8 +3642,7 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans,
|
|||||||
ret = 1;
|
ret = 1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!empty && push_items == btrfs_header_nritems(right))
|
WARN_ON(!empty && push_items == btrfs_header_nritems(right));
|
||||||
WARN_ON(1);
|
|
||||||
|
|
||||||
/* push data from right to left */
|
/* push data from right to left */
|
||||||
copy_extent_buffer(left, right,
|
copy_extent_buffer(left, right,
|
||||||
|
@ -649,14 +649,13 @@ static int btrfs_delayed_inode_reserve_metadata(
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
|
ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
|
||||||
if (!ret)
|
if (!WARN_ON(ret))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ok this is a problem, let's just steal from the global rsv
|
* Ok this is a problem, let's just steal from the global rsv
|
||||||
* since this really shouldn't happen that often.
|
* since this really shouldn't happen that often.
|
||||||
*/
|
*/
|
||||||
WARN_ON(1);
|
|
||||||
ret = btrfs_block_rsv_migrate(&root->fs_info->global_block_rsv,
|
ret = btrfs_block_rsv_migrate(&root->fs_info->global_block_rsv,
|
||||||
dst_rsv, num_bytes);
|
dst_rsv, num_bytes);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -475,14 +475,8 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
|
|||||||
if (page != eb->pages[0])
|
if (page != eb->pages[0])
|
||||||
return 0;
|
return 0;
|
||||||
found_start = btrfs_header_bytenr(eb);
|
found_start = btrfs_header_bytenr(eb);
|
||||||
if (found_start != start) {
|
if (WARN_ON(found_start != start || !PageUptodate(page)))
|
||||||
WARN_ON(1);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
if (!PageUptodate(page)) {
|
|
||||||
WARN_ON(1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
csum_tree_block(root, eb, 0);
|
csum_tree_block(root, eb, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1550,9 +1550,8 @@ again:
|
|||||||
if (ret && !insert) {
|
if (ret && !insert) {
|
||||||
err = -ENOENT;
|
err = -ENOENT;
|
||||||
goto out;
|
goto out;
|
||||||
} else if (ret) {
|
} else if (WARN_ON(ret)) {
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
WARN_ON(1);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5752,9 +5751,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
|
|||||||
}
|
}
|
||||||
extent_slot = path->slots[0];
|
extent_slot = path->slots[0];
|
||||||
}
|
}
|
||||||
} else if (ret == -ENOENT) {
|
} else if (WARN_ON(ret == -ENOENT)) {
|
||||||
btrfs_print_leaf(extent_root, path->nodes[0]);
|
btrfs_print_leaf(extent_root, path->nodes[0]);
|
||||||
WARN_ON(1);
|
|
||||||
btrfs_err(info,
|
btrfs_err(info,
|
||||||
"unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu",
|
"unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu",
|
||||||
bytenr, parent, root_objectid, owner_objectid,
|
bytenr, parent, root_objectid, owner_objectid,
|
||||||
@ -8317,10 +8315,9 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
|
|||||||
struct btrfs_space_info,
|
struct btrfs_space_info,
|
||||||
list);
|
list);
|
||||||
if (btrfs_test_opt(info->tree_root, ENOSPC_DEBUG)) {
|
if (btrfs_test_opt(info->tree_root, ENOSPC_DEBUG)) {
|
||||||
if (space_info->bytes_pinned > 0 ||
|
if (WARN_ON(space_info->bytes_pinned > 0 ||
|
||||||
space_info->bytes_reserved > 0 ||
|
space_info->bytes_reserved > 0 ||
|
||||||
space_info->bytes_may_use > 0) {
|
space_info->bytes_may_use > 0)) {
|
||||||
WARN_ON(1);
|
|
||||||
dump_space_info(space_info, 0, 0);
|
dump_space_info(space_info, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1739,10 +1739,8 @@ u64 count_range_bits(struct extent_io_tree *tree,
|
|||||||
u64 last = 0;
|
u64 last = 0;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
if (search_end <= cur_start) {
|
if (WARN_ON(search_end <= cur_start))
|
||||||
WARN_ON(1);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock(&tree->lock);
|
spin_lock(&tree->lock);
|
||||||
if (cur_start == 0 && bits == EXTENT_DIRTY) {
|
if (cur_start == 0 && bits == EXTENT_DIRTY) {
|
||||||
@ -3568,9 +3566,8 @@ retry:
|
|||||||
* but no sense in crashing the users box for something
|
* but no sense in crashing the users box for something
|
||||||
* we can survive anyway.
|
* we can survive anyway.
|
||||||
*/
|
*/
|
||||||
if (!eb) {
|
if (WARN_ON(!eb)) {
|
||||||
spin_unlock(&mapping->private_lock);
|
spin_unlock(&mapping->private_lock);
|
||||||
WARN_ON(1);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,10 +849,8 @@ insert:
|
|||||||
path->leave_spinning = 0;
|
path->leave_spinning = 0;
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail_unlock;
|
goto fail_unlock;
|
||||||
if (ret != 0) {
|
if (WARN_ON(ret != 0))
|
||||||
WARN_ON(1);
|
|
||||||
goto fail_unlock;
|
goto fail_unlock;
|
||||||
}
|
|
||||||
leaf = path->nodes[0];
|
leaf = path->nodes[0];
|
||||||
csum:
|
csum:
|
||||||
item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_csum_item);
|
item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_csum_item);
|
||||||
|
@ -78,10 +78,8 @@ again:
|
|||||||
btrfs_transaction_in_commit(fs_info)) {
|
btrfs_transaction_in_commit(fs_info)) {
|
||||||
leaf = path->nodes[0];
|
leaf = path->nodes[0];
|
||||||
|
|
||||||
if (btrfs_header_nritems(leaf) == 0) {
|
if (WARN_ON(btrfs_header_nritems(leaf) == 0))
|
||||||
WARN_ON(1);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save the key so we can advances forward
|
* Save the key so we can advances forward
|
||||||
|
@ -2039,10 +2039,8 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id,
|
|||||||
key.offset = offset;
|
key.offset = offset;
|
||||||
|
|
||||||
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
|
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
|
||||||
if (ret < 0) {
|
if (WARN_ON(ret < 0))
|
||||||
WARN_ON(1);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -3182,8 +3180,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
|
|||||||
|
|
||||||
/* if we have links, this was a truncate, lets do that */
|
/* if we have links, this was a truncate, lets do that */
|
||||||
if (inode->i_nlink) {
|
if (inode->i_nlink) {
|
||||||
if (!S_ISREG(inode->i_mode)) {
|
if (WARN_ON(!S_ISREG(inode->i_mode))) {
|
||||||
WARN_ON(1);
|
|
||||||
iput(inode);
|
iput(inode);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -8023,8 +8020,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||||||
if (ret == -EEXIST) {
|
if (ret == -EEXIST) {
|
||||||
/* we shouldn't get
|
/* we shouldn't get
|
||||||
* eexist without a new_inode */
|
* eexist without a new_inode */
|
||||||
if (!new_inode) {
|
if (WARN_ON(!new_inode)) {
|
||||||
WARN_ON(1);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1777,8 +1777,7 @@ again:
|
|||||||
new_ptr_gen = 0;
|
new_ptr_gen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_bytenr > 0 && new_bytenr == old_bytenr) {
|
if (WARN_ON(new_bytenr > 0 && new_bytenr == old_bytenr)) {
|
||||||
WARN_ON(1);
|
|
||||||
ret = level;
|
ret = level;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3545,10 +3544,8 @@ static int find_data_references(struct reloc_control *rc,
|
|||||||
err = ret;
|
err = ret;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (ret > 0) {
|
if (WARN_ON(ret > 0))
|
||||||
WARN_ON(1);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
leaf = path->nodes[0];
|
leaf = path->nodes[0];
|
||||||
nritems = btrfs_header_nritems(leaf);
|
nritems = btrfs_header_nritems(leaf);
|
||||||
@ -3568,11 +3565,9 @@ static int find_data_references(struct reloc_control *rc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
|
btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
|
||||||
if (key.objectid != ref_objectid ||
|
if (WARN_ON(key.objectid != ref_objectid ||
|
||||||
key.type != BTRFS_EXTENT_DATA_KEY) {
|
key.type != BTRFS_EXTENT_DATA_KEY))
|
||||||
WARN_ON(1);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
fi = btrfs_item_ptr(leaf, path->slots[0],
|
fi = btrfs_item_ptr(leaf, path->slots[0],
|
||||||
struct btrfs_file_extent_item);
|
struct btrfs_file_extent_item);
|
||||||
|
@ -564,10 +564,8 @@ static int begin_cmd(struct send_ctx *sctx, int cmd)
|
|||||||
{
|
{
|
||||||
struct btrfs_cmd_header *hdr;
|
struct btrfs_cmd_header *hdr;
|
||||||
|
|
||||||
if (!sctx->send_buf) {
|
if (WARN_ON(!sctx->send_buf))
|
||||||
WARN_ON(1);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
|
|
||||||
BUG_ON(sctx->send_size);
|
BUG_ON(sctx->send_size);
|
||||||
|
|
||||||
|
@ -2130,8 +2130,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
|
|||||||
WARN_ON(*level >= BTRFS_MAX_LEVEL);
|
WARN_ON(*level >= BTRFS_MAX_LEVEL);
|
||||||
cur = path->nodes[*level];
|
cur = path->nodes[*level];
|
||||||
|
|
||||||
if (btrfs_header_level(cur) != *level)
|
WARN_ON(btrfs_header_level(cur) != *level);
|
||||||
WARN_ON(1);
|
|
||||||
|
|
||||||
if (path->slots[*level] >=
|
if (path->slots[*level] >=
|
||||||
btrfs_header_nritems(cur))
|
btrfs_header_nritems(cur))
|
||||||
@ -2951,10 +2950,8 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
|
|||||||
|
|
||||||
/* find the first key from this transaction again */
|
/* find the first key from this transaction again */
|
||||||
ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0);
|
ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0);
|
||||||
if (ret != 0) {
|
if (WARN_ON(ret != 0))
|
||||||
WARN_ON(1);
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we have a block from this transaction, log every item in it
|
* we have a block from this transaction, log every item in it
|
||||||
|
@ -2552,8 +2552,7 @@ again:
|
|||||||
failed = 0;
|
failed = 0;
|
||||||
retried = true;
|
retried = true;
|
||||||
goto again;
|
goto again;
|
||||||
} else if (failed && retried) {
|
} else if (WARN_ON(failed && retried)) {
|
||||||
WARN_ON(1);
|
|
||||||
ret = -ENOSPC;
|
ret = -ENOSPC;
|
||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
@ -5402,10 +5401,8 @@ static int bio_size_ok(struct block_device *bdev, struct bio *bio,
|
|||||||
.bi_rw = bio->bi_rw,
|
.bi_rw = bio->bi_rw,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (bio->bi_vcnt == 0) {
|
if (WARN_ON(bio->bi_vcnt == 0))
|
||||||
WARN_ON(1);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
prev = &bio->bi_io_vec[bio->bi_vcnt - 1];
|
prev = &bio->bi_io_vec[bio->bi_vcnt - 1];
|
||||||
if (bio_sectors(bio) > max_sectors)
|
if (bio_sectors(bio) > max_sectors)
|
||||||
@ -5638,10 +5635,8 @@ struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info,
|
|||||||
struct btrfs_device *dev;
|
struct btrfs_device *dev;
|
||||||
u64 tmp;
|
u64 tmp;
|
||||||
|
|
||||||
if (!devid && !fs_info) {
|
if (WARN_ON(!devid && !fs_info))
|
||||||
WARN_ON(1);
|
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
}
|
|
||||||
|
|
||||||
dev = __alloc_device();
|
dev = __alloc_device();
|
||||||
if (IS_ERR(dev))
|
if (IS_ERR(dev))
|
||||||
|
Loading…
Reference in New Issue
Block a user