Re: [PATCH 3/4] ceph: use type refcount_t for refcount of ceph_snapid_map

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

 



On Tue, Jul 31, 2018 at 11:11 PM Chengguang Xu <cgxu519@xxxxxxx> wrote:
>
> Use refcount_t to replace atomic_t when operating refcount.
>
> Signed-off-by: Chengguang Xu <cgxu519@xxxxxxx>
> ---
>  fs/ceph/mds_client.h |  2 +-
>  fs/ceph/snap.c       | 10 +++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
> index 27f83dd55edb..a89f9c10729b 100644
> --- a/fs/ceph/mds_client.h
> +++ b/fs/ceph/mds_client.h
> @@ -311,7 +311,7 @@ struct ceph_pool_perm {
>  struct ceph_snapid_map {
>         struct rb_node node;
>         struct list_head lru;
> -       atomic_t ref;
> +       refcount_t ref;
>         u64 snap;
>         dev_t dev;
>         unsigned long last_used;
> diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
> index b5cff23d9ea2..6b34ccad9d75 100644
> --- a/fs/ceph/snap.c
> +++ b/fs/ceph/snap.c
> @@ -1005,7 +1005,7 @@ struct ceph_snapid_map* ceph_get_snapid_map(struct ceph_mds_client *mdsc,
>                 } else if (snap < exist->snap) {
>                         p = &(*p)->rb_right;
>                 } else {
> -                       if (atomic_inc_return(&exist->ref) == 1)
> +                       if (refcount_inc_not_zero(&exist->ref))
>                                 list_del_init(&exist->lru);
>                         break;
>                 }
> @@ -1028,7 +1028,7 @@ struct ceph_snapid_map* ceph_get_snapid_map(struct ceph_mds_client *mdsc,
>         }
>
>         INIT_LIST_HEAD(&sm->lru);
> -       atomic_set(&sm->ref, 1);
> +       refcount_set(&sm->ref, 1);
>         sm->snap = snap;
>
>         exist = NULL;
> @@ -1047,7 +1047,7 @@ struct ceph_snapid_map* ceph_get_snapid_map(struct ceph_mds_client *mdsc,
>                 exist = NULL;
>         }
>         if (exist) {
> -               if (atomic_inc_return(&exist->ref) == 1)
> +               if (refcount_inc_not_zero(&exist->ref))

inc_return and inc_not_zero are complete different

>                         list_del_init(&exist->lru);
>         } else {
>                 rb_link_node(&sm->node, parent, p);
> @@ -1070,7 +1070,7 @@ void ceph_put_snapid_map(struct ceph_mds_client* mdsc,
>  {
>         if (!sm)
>                 return;
> -       if (atomic_dec_and_lock(&sm->ref, &mdsc->snapid_map_lock)) {
> +       if (refcount_dec_and_lock(&sm->ref, &mdsc->snapid_map_lock)) {
>                 sm->last_used = jiffies;
>                 list_add_tail(&sm->lru, &mdsc->snapid_map_lru);
>                 spin_unlock(&mdsc->snapid_map_lock);
> @@ -1127,7 +1127,7 @@ void ceph_cleanup_snapid_map(struct ceph_mds_client *mdsc)
>                 sm = list_first_entry(&to_free, struct ceph_snapid_map, lru);
>                 list_del(&sm->lru);
>                 free_anon_bdev(sm->dev);
> -               if (WARN_ON_ONCE(atomic_read(&sm->ref))) {
> +               if (WARN_ON_ONCE(refcount_read(&sm->ref))) {
>                         pr_err("snapid map %llx -> %x still in use\n",
>                                sm->snap, sm->dev);
>                 }
> --
> 2.17.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux