summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGoldwyn Rodrigues <rgoldwyn@suse.com>2019-06-25 20:11:31 +0200
committerDavid Sterba <dsterba@suse.com>2019-07-02 12:30:53 +0200
commit9b4851bc48b9346a957a71ca355ecdb7f2759fb8 (patch)
tree19dbfddad6b7158dd57f3cebddf028e7335a3687
parent83d731a5b228454d7c29ec64fdd93426698f97f6 (diff)
downloadlinux-9b4851bc48b9346a957a71ca355ecdb7f2759fb8.tar.gz
linux-9b4851bc48b9346a957a71ca355ecdb7f2759fb8.tar.bz2
linux-9b4851bc48b9346a957a71ca355ecdb7f2759fb8.zip
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: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/space-info.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index ce33b1addf55..ab7b9ec4c240 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -967,18 +967,12 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
used = btrfs_space_info_used(space_info, true);
/*
- * If we have enough space then hooray, make our reservation and carry
- * on. If not see if we can overcommit, and if we can, hooray carry on.
- * If not things get more complicated.
+ * Carry on if we have enough space (short-circuit) OR call
+ * can_overcommit() to ensure we can overcommit to continue.
*/
- if (used + orig_bytes <= space_info->total_bytes) {
- btrfs_space_info_update_bytes_may_use(fs_info, space_info,
- orig_bytes);
- 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)) {
+ if ((used + orig_bytes <= space_info->total_bytes) ||
+ can_overcommit(fs_info, space_info, orig_bytes, flush,
+ system_chunk)) {
btrfs_space_info_update_bytes_may_use(fs_info, space_info,
orig_bytes);
trace_btrfs_space_reservation(fs_info, "space_info",