diff mbox series

[3/3] btrfs: use helper btrfs_get_block_group

Message ID 20200603101020.143372-4-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs: minor block group cleanups | expand

Commit Message

Anand Jain June 3, 2020, 10:10 a.m. UTC
Use the helper function where it is open coded to increment the
block_group reference count 'bg_count' so that it is less confusing
while reviewing the code. As btrfs_get_block_group() is a one-liner
we could have open-coded it, but its partner function
btrfs_put_block_group() isn't one-liner which does the free part in it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/free-space-cache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Nikolay Borisov June 3, 2020, 10:24 a.m. UTC | #1
On 3.06.20 г. 13:10 ч., Anand Jain wrote:
> Use the helper function where it is open coded to increment the
> block_group reference count 'bg_count' so that it is less confusing
> while reviewing the code. As btrfs_get_block_group() is a one-liner
> we could have open-coded it, but its partner function
> btrfs_put_block_group() isn't one-liner which does the free part in it.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>


Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Johannes Thumshirn June 3, 2020, 10:34 a.m. UTC | #2
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
diff mbox series

Patch

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 169b1117c1a3..867204b48ccf 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -2925,7 +2925,7 @@  void btrfs_return_cluster_to_free_space(
 		spin_unlock(&cluster->lock);
 		return;
 	}
-	atomic_inc(&block_group->bg_count);
+	btrfs_get_block_group(block_group);
 	spin_unlock(&cluster->lock);
 
 	ctl = block_group->free_space_ctl;
@@ -3355,7 +3355,7 @@  int btrfs_find_space_cluster(struct btrfs_block_group *block_group,
 		list_del_init(&entry->list);
 
 	if (!ret) {
-		atomic_inc(&block_group->bg_count);
+		btrfs_get_block_group(block_group);
 		list_add_tail(&cluster->block_group_list,
 			      &block_group->cluster_list);
 		cluster->block_group = block_group;