Browse Source

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>
master
Dulshani Gunawardhana 8 years ago
committed by Chris Mason
parent
commit
fae7f21cec
  1. 3
      fs/btrfs/backref.c
  2. 7
      fs/btrfs/check-integrity.c
  3. 6
      fs/btrfs/ctree.c
  4. 3
      fs/btrfs/delayed-inode.c
  5. 8
      fs/btrfs/disk-io.c
  6. 11
      fs/btrfs/extent-tree.c
  7. 7
      fs/btrfs/extent_io.c
  8. 4
      fs/btrfs/file-item.c
  9. 4
      fs/btrfs/inode-map.c
  10. 10
      fs/btrfs/inode.c
  11. 13
      fs/btrfs/relocation.c
  12. 4
      fs/btrfs/send.c
  13. 7
      fs/btrfs/tree-log.c
  14. 11
      fs/btrfs/volumes.c

3
fs/btrfs/backref.c

@ -326,8 +326,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
eb = path->nodes[level];
while (!eb) {
if (!level) {
WARN_ON(1);
if (WARN_ON(!level)) {
ret = 1;
goto out;
}

7
fs/btrfs/check-integrity.c

@ -2464,10 +2464,8 @@ static int btrfsic_process_written_superblock(
}
}
if (-1 == btrfsic_check_all_ref_blocks(state, superblock, 0)) {
WARN_ON(1);
if (WARN_ON(-1 == btrfsic_check_all_ref_blocks(state, superblock, 0)))
btrfsic_dump_tree(state);
}
return 0;
}
@ -2907,7 +2905,7 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,
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,"
" buffer->log_bytenr=%llu, submit_bio(bdev=%s,"
" 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,
block_ctx.dev_bytenr, mirror_num);
}
WARN_ON(1);
}
}

6
fs/btrfs/ctree.c

@ -1285,11 +1285,10 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
free_extent_buffer(eb_root);
blocksize = btrfs_level_size(root, old_root->level);
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);
pr_warn("btrfs: failed to read tree block %llu from get_old_root\n",
logical);
WARN_ON(1);
} else {
eb = btrfs_clone_extent_buffer(old);
free_extent_buffer(old);
@ -3643,8 +3642,7 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans,
ret = 1;
goto out;
}
if (!empty && push_items == btrfs_header_nritems(right))
WARN_ON(1);
WARN_ON(!empty && push_items == btrfs_header_nritems(right));
/* push data from right to left */
copy_extent_buffer(left, right,

3
fs/btrfs/delayed-inode.c

@ -649,14 +649,13 @@ static int btrfs_delayed_inode_reserve_metadata(
goto out;
ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes);
if (!ret)
if (!WARN_ON(ret))
goto out;
/*
* Ok this is a problem, let's just steal from the global rsv
* since this really shouldn't happen that often.
*/
WARN_ON(1);
ret = btrfs_block_rsv_migrate(&root->fs_info->global_block_rsv,
dst_rsv, num_bytes);
goto out;

8
fs/btrfs/disk-io.c

@ -475,14 +475,8 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
if (page != eb->pages[0])
return 0;
found_start = btrfs_header_bytenr(eb);
if (found_start != start) {
WARN_ON(1);
if (WARN_ON(found_start != start || !PageUptodate(page)))
return 0;
}
if (!PageUptodate(page)) {
WARN_ON(1);
return 0;
}
csum_tree_block(root, eb, 0);
return 0;
}

11
fs/btrfs/extent-tree.c

@ -1550,9 +1550,8 @@ again:
if (ret && !insert) {
err = -ENOENT;
goto out;
} else if (ret) {
} else if (WARN_ON(ret)) {
err = -EIO;
WARN_ON(1);
goto out;
}
@ -5752,9 +5751,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
}
extent_slot = path->slots[0];
}
} else if (ret == -ENOENT) {
} else if (WARN_ON(ret == -ENOENT)) {
btrfs_print_leaf(extent_root, path->nodes[0]);
WARN_ON(1);
btrfs_err(info,
"unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu",
bytenr, parent, root_objectid, owner_objectid,
@ -8317,10 +8315,9 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
struct btrfs_space_info,
list);
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_may_use > 0) {
WARN_ON(1);
space_info->bytes_may_use > 0)) {
dump_space_info(space_info, 0, 0);
}
}

7
fs/btrfs/extent_io.c

@ -1739,10 +1739,8 @@ u64 count_range_bits(struct extent_io_tree *tree,
u64 last = 0;
int found = 0;
if (search_end <= cur_start) {
WARN_ON(1);
if (WARN_ON(search_end <= cur_start))
return 0;
}
spin_lock(&tree->lock);
if (cur_start == 0 && bits == EXTENT_DIRTY) {
@ -3568,9 +3566,8 @@ retry:
* but no sense in crashing the users box for something
* we can survive anyway.
*/
if (!eb) {
if (WARN_ON(!eb)) {
spin_unlock(&mapping->private_lock);
WARN_ON(1);
continue;
}

4
fs/btrfs/file-item.c

@ -849,10 +849,8 @@ insert:
path->leave_spinning = 0;
if (ret < 0)
goto fail_unlock;
if (ret != 0) {
WARN_ON(1);
if (WARN_ON(ret != 0))
goto fail_unlock;
}
leaf = path->nodes[0];
csum:
item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_csum_item);

4
fs/btrfs/inode-map.c

@ -78,10 +78,8 @@ again:
btrfs_transaction_in_commit(fs_info)) {
leaf = path->nodes[0];
if (btrfs_header_nritems(leaf) == 0) {
WARN_ON(1);
if (WARN_ON(btrfs_header_nritems(leaf) == 0))
break;
}
/*
* Save the key so we can advances forward

10
fs/btrfs/inode.c

@ -2039,10 +2039,8 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id,
key.offset = offset;
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0) {
WARN_ON(1);
if (WARN_ON(ret < 0))
return ret;
}
ret = 0;
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 (inode->i_nlink) {
if (!S_ISREG(inode->i_mode)) {
WARN_ON(1);
if (WARN_ON(!S_ISREG(inode->i_mode))) {
iput(inode);
continue;
}
@ -8023,8 +8020,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (ret == -EEXIST) {
/* we shouldn't get
* eexist without a new_inode */
if (!new_inode) {
WARN_ON(1);
if (WARN_ON(!new_inode)) {
return ret;
}
} else {

13
fs/btrfs/relocation.c

@ -1777,8 +1777,7 @@ again:
new_ptr_gen = 0;
}
if (new_bytenr > 0 && new_bytenr == old_bytenr) {
WARN_ON(1);
if (WARN_ON(new_bytenr > 0 && new_bytenr == old_bytenr)) {
ret = level;
break;
}
@ -3545,10 +3544,8 @@ static int find_data_references(struct reloc_control *rc,
err = ret;
goto out;
}
if (ret > 0) {
WARN_ON(1);
if (WARN_ON(ret > 0))
goto out;
}
leaf = path->nodes[0];
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]);
if (key.objectid != ref_objectid ||
key.type != BTRFS_EXTENT_DATA_KEY) {
WARN_ON(1);
if (WARN_ON(key.objectid != ref_objectid ||
key.type != BTRFS_EXTENT_DATA_KEY))
break;
}
fi = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_file_extent_item);

4
fs/btrfs/send.c

@ -564,10 +564,8 @@ static int begin_cmd(struct send_ctx *sctx, int cmd)
{
struct btrfs_cmd_header *hdr;
if (!sctx->send_buf) {
WARN_ON(1);
if (WARN_ON(!sctx->send_buf))
return -EINVAL;
}
BUG_ON(sctx->send_size);

7
fs/btrfs/tree-log.c

@ -2130,8 +2130,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
WARN_ON(*level >= BTRFS_MAX_LEVEL);
cur = path->nodes[*level];
if (btrfs_header_level(cur) != *level)
WARN_ON(1);
WARN_ON(btrfs_header_level(cur) != *level);
if (path->slots[*level] >=
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 */
ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0);
if (ret != 0) {
WARN_ON(1);
if (WARN_ON(ret != 0))
goto done;
}
/*
* we have a block from this transaction, log every item in it

11
fs/btrfs/volumes.c

@ -2552,8 +2552,7 @@ again:
failed = 0;
retried = true;
goto again;
} else if (failed && retried) {
WARN_ON(1);
} else if (WARN_ON(failed && retried)) {
ret = -ENOSPC;
}
error:
@ -5402,10 +5401,8 @@ static int bio_size_ok(struct block_device *bdev, struct bio *bio,
.bi_rw = bio->bi_rw,
};
if (bio->bi_vcnt == 0) {
WARN_ON(1);
if (WARN_ON(bio->bi_vcnt == 0))
return 1;
}
prev = &bio->bi_io_vec[bio->bi_vcnt - 1];
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;
u64 tmp;
if (!devid && !fs_info) {
WARN_ON(1);
if (WARN_ON(!devid && !fs_info))
return ERR_PTR(-EINVAL);
}
dev = __alloc_device();
if (IS_ERR(dev))

Loading…
Cancel
Save