* [PATCH 0/3] btrfs: minor block group cleanups
@ 2020-06-03 10:10 Anand Jain
2020-06-03 10:10 ` [PATCH 1/3] btrfs: fix btrfs_return_cluster_to_free_space() return Anand Jain
` (3 more replies)
0 siblings, 4 replies; 15+ messages in thread
From: Anand Jain @ 2020-06-03 10:10 UTC (permalink / raw)
To: linux-btrfs
Minor cleanup patches.
1/3 cleansup the return value of btrfs_return_cluster_to_free_space().
2/3 and 3/3 together cleanups block group reference count.
2/3 and 3/3 are related. However 1/3 is independent to the rest of the
patches in this set.
Anand Jain (3):
btrfs: fix btrfs_return_cluster_to_free_space() return
btrfs: rename btrfs_block_group::count
btrfs: use helper btrfs_get_block_group
fs/btrfs/block-group.c | 8 ++++----
fs/btrfs/block-group.h | 2 +-
fs/btrfs/free-space-cache.c | 17 +++++++----------
fs/btrfs/free-space-cache.h | 2 +-
4 files changed, 13 insertions(+), 16 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/3] btrfs: fix btrfs_return_cluster_to_free_space() return
2020-06-03 10:10 [PATCH 0/3] btrfs: minor block group cleanups Anand Jain
@ 2020-06-03 10:10 ` Anand Jain
2020-06-03 10:17 ` Nikolay Borisov
2020-06-03 10:33 ` Johannes Thumshirn
2020-06-03 10:10 ` [PATCH 2/3] btrfs: rename btrfs_block_group::count Anand Jain
` (2 subsequent siblings)
3 siblings, 2 replies; 15+ messages in thread
From: Anand Jain @ 2020-06-03 10:10 UTC (permalink / raw)
To: linux-btrfs
__btrfs_return_cluster_to_free_space() returns only 0. And all its parent
functions don't need the return value either so make this a void function.
Further, as none of the callers of btrfs_return_cluster_to_free_space() is
actually using the return from this function, make this function also
return void.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/free-space-cache.c | 13 +++++--------
fs/btrfs/free-space-cache.h | 2 +-
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 55955bd424d7..1bf08c855edb 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -2703,7 +2703,7 @@ void btrfs_init_free_space_ctl(struct btrfs_block_group *block_group)
* pointed to by the cluster, someone else raced in and freed the
* cluster already. In that case, we just return without changing anything
*/
-static int
+static void
__btrfs_return_cluster_to_free_space(
struct btrfs_block_group *block_group,
struct btrfs_free_cluster *cluster)
@@ -2756,7 +2756,6 @@ __btrfs_return_cluster_to_free_space(
out:
spin_unlock(&cluster->lock);
btrfs_put_block_group(block_group);
- return 0;
}
static void __btrfs_remove_free_space_cache_locked(
@@ -2907,12 +2906,11 @@ u64 btrfs_find_space_for_alloc(struct btrfs_block_group *block_group,
* Otherwise, it'll get a reference on the block group pointed to by the
* cluster and remove the cluster from it.
*/
-int btrfs_return_cluster_to_free_space(
+void btrfs_return_cluster_to_free_space(
struct btrfs_block_group *block_group,
struct btrfs_free_cluster *cluster)
{
struct btrfs_free_space_ctl *ctl;
- int ret;
/* first, get a safe pointer to the block group */
spin_lock(&cluster->lock);
@@ -2920,12 +2918,12 @@ int btrfs_return_cluster_to_free_space(
block_group = cluster->block_group;
if (!block_group) {
spin_unlock(&cluster->lock);
- return 0;
+ return;
}
} else if (cluster->block_group != block_group) {
/* someone else has already freed it don't redo their work */
spin_unlock(&cluster->lock);
- return 0;
+ return;
}
atomic_inc(&block_group->count);
spin_unlock(&cluster->lock);
@@ -2934,14 +2932,13 @@ int btrfs_return_cluster_to_free_space(
/* now return any extents the cluster had on it */
spin_lock(&ctl->tree_lock);
- ret = __btrfs_return_cluster_to_free_space(block_group, cluster);
+ __btrfs_return_cluster_to_free_space(block_group, cluster);
spin_unlock(&ctl->tree_lock);
btrfs_discard_queue_work(&block_group->fs_info->discard_ctl, block_group);
/* finally drop our ref */
btrfs_put_block_group(block_group);
- return ret;
}
static u64 btrfs_alloc_from_bitmap(struct btrfs_block_group *block_group,
diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h
index 2e0a8077aa74..e3d5e0ad8f8e 100644
--- a/fs/btrfs/free-space-cache.h
+++ b/fs/btrfs/free-space-cache.h
@@ -136,7 +136,7 @@ void btrfs_init_free_cluster(struct btrfs_free_cluster *cluster);
u64 btrfs_alloc_from_cluster(struct btrfs_block_group *block_group,
struct btrfs_free_cluster *cluster, u64 bytes,
u64 min_start, u64 *max_extent_size);
-int btrfs_return_cluster_to_free_space(
+void btrfs_return_cluster_to_free_space(
struct btrfs_block_group *block_group,
struct btrfs_free_cluster *cluster);
int btrfs_trim_block_group(struct btrfs_block_group *block_group,
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/3] btrfs: rename btrfs_block_group::count
2020-06-03 10:10 [PATCH 0/3] btrfs: minor block group cleanups Anand Jain
2020-06-03 10:10 ` [PATCH 1/3] btrfs: fix btrfs_return_cluster_to_free_space() return Anand Jain
@ 2020-06-03 10:10 ` Anand Jain
2020-06-03 10:19 ` Filipe Manana
2020-06-03 10:23 ` Nikolay Borisov
2020-06-03 10:10 ` [PATCH 3/3] btrfs: use helper btrfs_get_block_group Anand Jain
2020-06-04 16:56 ` [PATCH 0/3] btrfs: minor block group cleanups David Sterba
3 siblings, 2 replies; 15+ messages in thread
From: Anand Jain @ 2020-06-03 10:10 UTC (permalink / raw)
To: linux-btrfs
The name 'count' is a very commonly used name. It is often difficult to
review the code to check if there is any leak. So rename it to
'bg_count', which is unique enough.
This patch also serves as a preparatory patch to either make sure
btrfs_get_block_group() is used instead of open coded the same or just
open code every where as btrfs_get_block_group() is a one-liner.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/block-group.c | 8 ++++----
fs/btrfs/block-group.h | 2 +-
fs/btrfs/free-space-cache.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 31ca2cfb7e3e..8111f6750063 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -118,12 +118,12 @@ u64 btrfs_get_alloc_profile(struct btrfs_fs_info *fs_info, u64 orig_flags)
void btrfs_get_block_group(struct btrfs_block_group *cache)
{
- atomic_inc(&cache->count);
+ atomic_inc(&cache->bg_count);
}
void btrfs_put_block_group(struct btrfs_block_group *cache)
{
- if (atomic_dec_and_test(&cache->count)) {
+ if (atomic_dec_and_test(&cache->bg_count)) {
WARN_ON(cache->pinned > 0);
WARN_ON(cache->reserved > 0);
@@ -1805,7 +1805,7 @@ static struct btrfs_block_group *btrfs_create_block_group_cache(
cache->discard_index = BTRFS_DISCARD_INDEX_UNUSED;
- atomic_set(&cache->count, 1);
+ atomic_set(&cache->bg_count, 1);
spin_lock_init(&cache->lock);
init_rwsem(&cache->data_rwsem);
INIT_LIST_HEAD(&cache->list);
@@ -3379,7 +3379,7 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
ASSERT(list_empty(&block_group->dirty_list));
ASSERT(list_empty(&block_group->io_list));
ASSERT(list_empty(&block_group->bg_list));
- ASSERT(atomic_read(&block_group->count) == 1);
+ ASSERT(atomic_read(&block_group->bg_count) == 1);
btrfs_put_block_group(block_group);
spin_lock(&info->block_group_cache_lock);
diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h
index b6ee70a039c7..f0ef8be08747 100644
--- a/fs/btrfs/block-group.h
+++ b/fs/btrfs/block-group.h
@@ -115,7 +115,7 @@ struct btrfs_block_group {
struct list_head list;
/* Usage count */
- atomic_t count;
+ atomic_t bg_count;
/*
* List of struct btrfs_free_clusters for this block group.
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 1bf08c855edb..169b1117c1a3 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->count);
+ atomic_inc(&block_group->bg_count);
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->count);
+ atomic_inc(&block_group->bg_count);
list_add_tail(&cluster->block_group_list,
&block_group->cluster_list);
cluster->block_group = block_group;
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/3] btrfs: use helper btrfs_get_block_group
2020-06-03 10:10 [PATCH 0/3] btrfs: minor block group cleanups Anand Jain
2020-06-03 10:10 ` [PATCH 1/3] btrfs: fix btrfs_return_cluster_to_free_space() return Anand Jain
2020-06-03 10:10 ` [PATCH 2/3] btrfs: rename btrfs_block_group::count Anand Jain
@ 2020-06-03 10:10 ` Anand Jain
2020-06-03 10:24 ` Nikolay Borisov
2020-06-03 10:34 ` Johannes Thumshirn
2020-06-04 16:56 ` [PATCH 0/3] btrfs: minor block group cleanups David Sterba
3 siblings, 2 replies; 15+ messages in thread
From: Anand Jain @ 2020-06-03 10:10 UTC (permalink / raw)
To: linux-btrfs
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(-)
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] btrfs: fix btrfs_return_cluster_to_free_space() return
2020-06-03 10:10 ` [PATCH 1/3] btrfs: fix btrfs_return_cluster_to_free_space() return Anand Jain
@ 2020-06-03 10:17 ` Nikolay Borisov
2020-06-03 10:33 ` Johannes Thumshirn
1 sibling, 0 replies; 15+ messages in thread
From: Nikolay Borisov @ 2020-06-03 10:17 UTC (permalink / raw)
To: Anand Jain, linux-btrfs
On 3.06.20 г. 13:10 ч., Anand Jain wrote:
> __btrfs_return_cluster_to_free_space() returns only 0. And all its parent
> functions don't need the return value either so make this a void function.
>
> Further, as none of the callers of btrfs_return_cluster_to_free_space() is
> actually using the return from this function, make this function also
> return void.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] btrfs: rename btrfs_block_group::count
2020-06-03 10:10 ` [PATCH 2/3] btrfs: rename btrfs_block_group::count Anand Jain
@ 2020-06-03 10:19 ` Filipe Manana
2020-06-03 10:43 ` Anand Jain
2020-06-03 10:23 ` Nikolay Borisov
1 sibling, 1 reply; 15+ messages in thread
From: Filipe Manana @ 2020-06-03 10:19 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Wed, Jun 3, 2020 at 11:13 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> The name 'count' is a very commonly used name. It is often difficult to
> review the code to check if there is any leak. So rename it to
> 'bg_count', which is unique enough.
Hum? Seriously?
count to bg_count?
It's a member of the block group structure, adding a bg_ prefix adds
no value at all, we know the count is related to the block group.
I could somewhat understand if you named it 'refcount' instead.
Thanks.
>
> This patch also serves as a preparatory patch to either make sure
> btrfs_get_block_group() is used instead of open coded the same or just
> open code every where as btrfs_get_block_group() is a one-liner.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> fs/btrfs/block-group.c | 8 ++++----
> fs/btrfs/block-group.h | 2 +-
> fs/btrfs/free-space-cache.c | 4 ++--
> 3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index 31ca2cfb7e3e..8111f6750063 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -118,12 +118,12 @@ u64 btrfs_get_alloc_profile(struct btrfs_fs_info *fs_info, u64 orig_flags)
>
> void btrfs_get_block_group(struct btrfs_block_group *cache)
> {
> - atomic_inc(&cache->count);
> + atomic_inc(&cache->bg_count);
> }
>
> void btrfs_put_block_group(struct btrfs_block_group *cache)
> {
> - if (atomic_dec_and_test(&cache->count)) {
> + if (atomic_dec_and_test(&cache->bg_count)) {
> WARN_ON(cache->pinned > 0);
> WARN_ON(cache->reserved > 0);
>
> @@ -1805,7 +1805,7 @@ static struct btrfs_block_group *btrfs_create_block_group_cache(
>
> cache->discard_index = BTRFS_DISCARD_INDEX_UNUSED;
>
> - atomic_set(&cache->count, 1);
> + atomic_set(&cache->bg_count, 1);
> spin_lock_init(&cache->lock);
> init_rwsem(&cache->data_rwsem);
> INIT_LIST_HEAD(&cache->list);
> @@ -3379,7 +3379,7 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
> ASSERT(list_empty(&block_group->dirty_list));
> ASSERT(list_empty(&block_group->io_list));
> ASSERT(list_empty(&block_group->bg_list));
> - ASSERT(atomic_read(&block_group->count) == 1);
> + ASSERT(atomic_read(&block_group->bg_count) == 1);
> btrfs_put_block_group(block_group);
>
> spin_lock(&info->block_group_cache_lock);
> diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h
> index b6ee70a039c7..f0ef8be08747 100644
> --- a/fs/btrfs/block-group.h
> +++ b/fs/btrfs/block-group.h
> @@ -115,7 +115,7 @@ struct btrfs_block_group {
> struct list_head list;
>
> /* Usage count */
> - atomic_t count;
> + atomic_t bg_count;
>
> /*
> * List of struct btrfs_free_clusters for this block group.
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index 1bf08c855edb..169b1117c1a3 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->count);
> + atomic_inc(&block_group->bg_count);
> 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->count);
> + atomic_inc(&block_group->bg_count);
> list_add_tail(&cluster->block_group_list,
> &block_group->cluster_list);
> cluster->block_group = block_group;
> --
> 2.25.1
>
--
Filipe David Manana,
“Whether you think you can, or you think you can't — you're right.”
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] btrfs: rename btrfs_block_group::count
2020-06-03 10:10 ` [PATCH 2/3] btrfs: rename btrfs_block_group::count Anand Jain
2020-06-03 10:19 ` Filipe Manana
@ 2020-06-03 10:23 ` Nikolay Borisov
1 sibling, 0 replies; 15+ messages in thread
From: Nikolay Borisov @ 2020-06-03 10:23 UTC (permalink / raw)
To: Anand Jain, linux-btrfs
On 3.06.20 г. 13:10 ч., Anand Jain wrote:
> The name 'count' is a very commonly used name. It is often difficult to
> review the code to check if there is any leak. So rename it to
> 'bg_count', which is unique enough.
>
> This patch also serves as a preparatory patch to either make sure
> btrfs_get_block_group() is used instead of open coded the same or just
> open code every where as btrfs_get_block_group() is a one-liner.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
This introduces unnecessary churn, instead if all uses happen through
the btrfs_get_block_group/put apis you can simply grep for those. All
other uses are RO. Also bg_count is not very descriptive given this is
really a refcount. Open-coding probably would be fine if this type is
switched to refcount_t rather than an atomic_t.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] btrfs: use helper btrfs_get_block_group
2020-06-03 10:10 ` [PATCH 3/3] btrfs: use helper btrfs_get_block_group Anand Jain
@ 2020-06-03 10:24 ` Nikolay Borisov
2020-06-03 10:34 ` Johannes Thumshirn
1 sibling, 0 replies; 15+ messages in thread
From: Nikolay Borisov @ 2020-06-03 10:24 UTC (permalink / raw)
To: Anand Jain, linux-btrfs
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>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] btrfs: fix btrfs_return_cluster_to_free_space() return
2020-06-03 10:10 ` [PATCH 1/3] btrfs: fix btrfs_return_cluster_to_free_space() return Anand Jain
2020-06-03 10:17 ` Nikolay Borisov
@ 2020-06-03 10:33 ` Johannes Thumshirn
1 sibling, 0 replies; 15+ messages in thread
From: Johannes Thumshirn @ 2020-06-03 10:33 UTC (permalink / raw)
To: Anand Jain, linux-btrfs
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] btrfs: use helper btrfs_get_block_group
2020-06-03 10:10 ` [PATCH 3/3] btrfs: use helper btrfs_get_block_group Anand Jain
2020-06-03 10:24 ` Nikolay Borisov
@ 2020-06-03 10:34 ` Johannes Thumshirn
1 sibling, 0 replies; 15+ messages in thread
From: Johannes Thumshirn @ 2020-06-03 10:34 UTC (permalink / raw)
To: Anand Jain, linux-btrfs
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] btrfs: rename btrfs_block_group::count
2020-06-03 10:19 ` Filipe Manana
@ 2020-06-03 10:43 ` Anand Jain
2020-06-03 10:49 ` Filipe Manana
0 siblings, 1 reply; 15+ messages in thread
From: Anand Jain @ 2020-06-03 10:43 UTC (permalink / raw)
To: fdmanana; +Cc: linux-btrfs
On 3/6/20 6:19 pm, Filipe Manana wrote:
> On Wed, Jun 3, 2020 at 11:13 AM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> The name 'count' is a very commonly used name. It is often difficult to
>> review the code to check if there is any leak. So rename it to
>> 'bg_count', which is unique enough.
>
> Hum? Seriously?
>
> count to bg_count?
> It's a member of the block group structure, adding a bg_ prefix adds
> no value at all, we know the count is related to the block group.
> I could somewhat understand if you named it 'refcount' instead.
Oh right. Now, bg_count does not make sense to me as well.
Something like bg_refcount is better so that it is easy to search
where all its been used. IMO.
Are we ok with btrfs_block_group::bg_refcount instead ?
Thanks,
Anand
> Thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] btrfs: rename btrfs_block_group::count
2020-06-03 10:43 ` Anand Jain
@ 2020-06-03 10:49 ` Filipe Manana
2020-06-03 11:38 ` Anand Jain
0 siblings, 1 reply; 15+ messages in thread
From: Filipe Manana @ 2020-06-03 10:49 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Wed, Jun 3, 2020 at 11:43 AM Anand Jain <anand.jain@oracle.com> wrote:
>
>
>
> On 3/6/20 6:19 pm, Filipe Manana wrote:
> > On Wed, Jun 3, 2020 at 11:13 AM Anand Jain <anand.jain@oracle.com> wrote:
> >>
> >> The name 'count' is a very commonly used name. It is often difficult to
> >> review the code to check if there is any leak. So rename it to
> >> 'bg_count', which is unique enough.
> >
> > Hum? Seriously?
> >
> > count to bg_count?
> > It's a member of the block group structure, adding a bg_ prefix adds
> > no value at all, we know the count is related to the block group.
> > I could somewhat understand if you named it 'refcount' instead.
>
>
> Oh right. Now, bg_count does not make sense to me as well.
>
> Something like bg_refcount is better so that it is easy to search
> where all its been used. IMO.
>
> Are we ok with btrfs_block_group::bg_refcount instead ?
Why rename at all?
It's pretty obvious it's a reference count. Count/counter is not an
unusual name to use for a reference count, it even has get and put
helpers...
>
> Thanks,
> Anand
>
>
> > Thanks.
--
Filipe David Manana,
“Whether you think you can, or you think you can't — you're right.”
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] btrfs: rename btrfs_block_group::count
2020-06-03 10:49 ` Filipe Manana
@ 2020-06-03 11:38 ` Anand Jain
2020-06-03 11:54 ` Filipe Manana
0 siblings, 1 reply; 15+ messages in thread
From: Anand Jain @ 2020-06-03 11:38 UTC (permalink / raw)
To: fdmanana; +Cc: linux-btrfs
>
> Why rename at all?
> It's pretty obvious it's a reference count. Count/counter is not an
> unusual name to use for a reference count, it even has get and put
> helpers...
I understand as the member count is in btrfs_block_group so prefix bg_
looks redundant, but prefix bg_ is still useful. With out the prefix,
the grep ">count" *.c didn't help straight away to verify where is
block_group count used. At two places we missed using the get helper
which the patch 3/3 fixed.
It's ok to drop this rename patch if you find it's not inline with the
rest of the codes.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] btrfs: rename btrfs_block_group::count
2020-06-03 11:38 ` Anand Jain
@ 2020-06-03 11:54 ` Filipe Manana
0 siblings, 0 replies; 15+ messages in thread
From: Filipe Manana @ 2020-06-03 11:54 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Wed, Jun 3, 2020 at 12:38 PM Anand Jain <anandsuveer@gmail.com> wrote:
>
>
> >
> > Why rename at all?
> > It's pretty obvious it's a reference count. Count/counter is not an
> > unusual name to use for a reference count, it even has get and put
> > helpers...
>
> I understand as the member count is in btrfs_block_group so prefix bg_
> looks redundant, but prefix bg_ is still useful. With out the prefix,
> the grep ">count" *.c didn't help straight away to verify where is
Following that logic, we would add the bg_ prefix to most members of
block_group...
It has members named 'start', 'length', 'flags', etc. Those are
generic too, many other structures have members with exactly those
names...
Don't take it wrong, but I don't find it useful at all.
Thanks.
> block_group count used. At two places we missed using the get helper
> which the patch 3/3 fixed.
>
> It's ok to drop this rename patch if you find it's not inline with the
> rest of the codes.
--
Filipe David Manana,
“Whether you think you can, or you think you can't — you're right.”
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 0/3] btrfs: minor block group cleanups
2020-06-03 10:10 [PATCH 0/3] btrfs: minor block group cleanups Anand Jain
` (2 preceding siblings ...)
2020-06-03 10:10 ` [PATCH 3/3] btrfs: use helper btrfs_get_block_group Anand Jain
@ 2020-06-04 16:56 ` David Sterba
3 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2020-06-04 16:56 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Wed, Jun 03, 2020 at 06:10:17PM +0800, Anand Jain wrote:
> Minor cleanup patches.
> 1/3 cleansup the return value of btrfs_return_cluster_to_free_space().
> 2/3 and 3/3 together cleanups block group reference count.
>
> 2/3 and 3/3 are related. However 1/3 is independent to the rest of the
> patches in this set.
>
> Anand Jain (3):
> btrfs: fix btrfs_return_cluster_to_free_space() return
> btrfs: rename btrfs_block_group::count
> btrfs: use helper btrfs_get_block_group
1 and 3 applied but I don't recommend to spend time on cleaning up
free-space-cache.[ch] as it's going to be phased out.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2020-06-04 16:56 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 10:10 [PATCH 0/3] btrfs: minor block group cleanups Anand Jain
2020-06-03 10:10 ` [PATCH 1/3] btrfs: fix btrfs_return_cluster_to_free_space() return Anand Jain
2020-06-03 10:17 ` Nikolay Borisov
2020-06-03 10:33 ` Johannes Thumshirn
2020-06-03 10:10 ` [PATCH 2/3] btrfs: rename btrfs_block_group::count Anand Jain
2020-06-03 10:19 ` Filipe Manana
2020-06-03 10:43 ` Anand Jain
2020-06-03 10:49 ` Filipe Manana
2020-06-03 11:38 ` Anand Jain
2020-06-03 11:54 ` Filipe Manana
2020-06-03 10:23 ` Nikolay Borisov
2020-06-03 10:10 ` [PATCH 3/3] btrfs: use helper btrfs_get_block_group Anand Jain
2020-06-03 10:24 ` Nikolay Borisov
2020-06-03 10:34 ` Johannes Thumshirn
2020-06-04 16:56 ` [PATCH 0/3] btrfs: minor block group cleanups David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).