Re: [PATCH 2/3] btrfs: rename btrfs_block_group::count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 3, 2020 at 11:13 AM Anand Jain <anand.jain@xxxxxxxxxx> 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@xxxxxxxxxx>
> ---
>  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.”




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux