From: Johannes Thumshirn <jthumshirn@suse.de>
To: David Sterba <dsterba@suse.com>
Cc: Linux BTRFS Mailinglist <linux-btrfs@vger.kernel.org>,
Johannes Thumshirn <jthumshirn@suse.de>
Subject: [PATCH 3/4] btrfs: reduce indentation in btrfs_may_alloc_data_chunk
Date: Fri, 18 Oct 2019 11:58:22 +0200 [thread overview]
Message-ID: <20191018095823.15282-4-jthumshirn@suse.de> (raw)
In-Reply-To: <20191018095823.15282-1-jthumshirn@suse.de>
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.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
fs/btrfs/volumes.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index bba74e3bd9d8..4c630356bb30 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2982,27 +2982,28 @@ static int btrfs_may_alloc_data_chunk(struct btrfs_fs_info *fs_info,
chunk_type = cache->flags;
btrfs_put_block_group(cache);
- if (chunk_type & BTRFS_BLOCK_GROUP_DATA) {
- spin_lock(&fs_info->data_sinfo->lock);
- bytes_used = fs_info->data_sinfo->bytes_used;
- spin_unlock(&fs_info->data_sinfo->lock);
-
- if (!bytes_used) {
- struct btrfs_trans_handle *trans;
- int ret;
-
- trans = btrfs_join_transaction(fs_info->tree_root);
- if (IS_ERR(trans))
- return PTR_ERR(trans);
-
- ret = btrfs_force_chunk_alloc(trans,
- BTRFS_BLOCK_GROUP_DATA);
- btrfs_end_transaction(trans);
- if (ret < 0)
- return ret;
- return 1;
- }
+ if (!(chunk_type & BTRFS_BLOCK_GROUP_DATA))
+ return 0;
+
+ spin_lock(&fs_info->data_sinfo->lock);
+ bytes_used = fs_info->data_sinfo->bytes_used;
+ spin_unlock(&fs_info->data_sinfo->lock);
+
+ if (!bytes_used) {
+ struct btrfs_trans_handle *trans;
+ int ret;
+
+ trans = btrfs_join_transaction(fs_info->tree_root);
+ if (IS_ERR(trans))
+ return PTR_ERR(trans);
+
+ ret = btrfs_force_chunk_alloc(trans, BTRFS_BLOCK_GROUP_DATA);
+ btrfs_end_transaction(trans);
+ if (ret < 0)
+ return ret;
+ return 1;
}
+
return 0;
}
--
2.16.4
next prev parent reply other threads:[~2019-10-18 9:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 9:58 [PATCH 0/4] Small coding style cleanups Johannes Thumshirn
2019-10-18 9:58 ` [PATCH 1/4] btrfs: reduce indentation in lock_stripe_add Johannes Thumshirn
2019-10-21 12:45 ` Nikolay Borisov
2019-10-21 13:30 ` David Sterba
2019-10-18 9:58 ` [PATCH 2/4] btrfs: remove pointless local variable in lock_stripe_add() Johannes Thumshirn
2019-10-18 9:58 ` Johannes Thumshirn [this message]
2019-10-18 9:58 ` [PATCH 4/4] btrfs: remove pointless indentation in btrfs_read_sys_array() Johannes Thumshirn
2019-10-18 12:02 ` [PATCH 0/4] Small coding style cleanups Nikolay Borisov
2019-10-21 8:06 ` Johannes Thumshirn
2019-10-21 12:32 ` Nikolay Borisov
2019-10-21 12:42 ` Johannes Thumshirn
2019-10-21 13:38 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191018095823.15282-4-jthumshirn@suse.de \
--to=jthumshirn@suse.de \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox