Commit 9b4851bc authored by Goldwyn Rodrigues's avatar Goldwyn Rodrigues Committed by David Sterba

btrfs: Simplify update of space_info in __reserve_metadata_bytes()

We don't need an if-else-if chain where we can use a simple OR since
both conditions are performing the same action. The short-circuit for OR
will ensure that if the first condition is true, can_overcommit() is not
called.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 83d731a5
...@@ -967,18 +967,12 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, ...@@ -967,18 +967,12 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
used = btrfs_space_info_used(space_info, true); used = btrfs_space_info_used(space_info, true);
/* /*
* If we have enough space then hooray, make our reservation and carry * Carry on if we have enough space (short-circuit) OR call
* on. If not see if we can overcommit, and if we can, hooray carry on. * can_overcommit() to ensure we can overcommit to continue.
* If not things get more complicated.
*/ */
if (used + orig_bytes <= space_info->total_bytes) { if ((used + orig_bytes <= space_info->total_bytes) ||
btrfs_space_info_update_bytes_may_use(fs_info, space_info, can_overcommit(fs_info, space_info, orig_bytes, flush,
orig_bytes); system_chunk)) {
trace_btrfs_space_reservation(fs_info, "space_info",
space_info->flags, orig_bytes, 1);
ret = 0;
} else if (can_overcommit(fs_info, space_info, orig_bytes, flush,
system_chunk)) {
btrfs_space_info_update_bytes_may_use(fs_info, space_info, btrfs_space_info_update_bytes_may_use(fs_info, space_info,
orig_bytes); orig_bytes);
trace_btrfs_space_reservation(fs_info, "space_info", trace_btrfs_space_reservation(fs_info, "space_info",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment