btrfs: reduce indentation in btrfs_may_alloc_data_chunk
In btrfs_may_alloc_data_chunk() we're checking if the chunk type is of type BTRFS_BLOCK_GROUP_DATA and if it is we process it. Instead of checking if the chunk type is a BTRFS_BLOCK_GROUP_DATA chunk we can negate the check and bail out early if it isn't. This makes the code a bit more readable. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
721860d578
commit
5ae2169290
|
@ -2982,27 +2982,28 @@ static int btrfs_may_alloc_data_chunk(struct btrfs_fs_info *fs_info,
|
||||||
chunk_type = cache->flags;
|
chunk_type = cache->flags;
|
||||||
btrfs_put_block_group(cache);
|
btrfs_put_block_group(cache);
|
||||||
|
|
||||||
if (chunk_type & BTRFS_BLOCK_GROUP_DATA) {
|
if (!(chunk_type & BTRFS_BLOCK_GROUP_DATA))
|
||||||
spin_lock(&fs_info->data_sinfo->lock);
|
return 0;
|
||||||
bytes_used = fs_info->data_sinfo->bytes_used;
|
|
||||||
spin_unlock(&fs_info->data_sinfo->lock);
|
|
||||||
|
|
||||||
if (!bytes_used) {
|
spin_lock(&fs_info->data_sinfo->lock);
|
||||||
struct btrfs_trans_handle *trans;
|
bytes_used = fs_info->data_sinfo->bytes_used;
|
||||||
int ret;
|
spin_unlock(&fs_info->data_sinfo->lock);
|
||||||
|
|
||||||
trans = btrfs_join_transaction(fs_info->tree_root);
|
if (!bytes_used) {
|
||||||
if (IS_ERR(trans))
|
struct btrfs_trans_handle *trans;
|
||||||
return PTR_ERR(trans);
|
int ret;
|
||||||
|
|
||||||
ret = btrfs_force_chunk_alloc(trans,
|
trans = btrfs_join_transaction(fs_info->tree_root);
|
||||||
BTRFS_BLOCK_GROUP_DATA);
|
if (IS_ERR(trans))
|
||||||
btrfs_end_transaction(trans);
|
return PTR_ERR(trans);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
ret = btrfs_force_chunk_alloc(trans, BTRFS_BLOCK_GROUP_DATA);
|
||||||
return 1;
|
btrfs_end_transaction(trans);
|
||||||
}
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue