Whamcloud - gitweb
LU-16796 ofd: Change struct ofd_seq to use refcount_t 22/52722/7
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Tue, 17 Oct 2023 08:22:31 +0000 (13:52 +0530)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 Nov 2023 22:04:36 +0000 (22:04 +0000)
This patch changes struct ofd_seq to use refcount_t
instead of atomic_t

Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: Ie149a6812671ea872e17d2881e52cf6096d147ff
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52722
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ofd/ofd_fs.c
lustre/ofd/ofd_internal.h
lustre/ofd/ofd_objects.c

index 4b56664..2c2bea9 100644 (file)
@@ -87,7 +87,7 @@ struct ofd_seq *ofd_seq_get(struct ofd_device *ofd, u64 seq)
        read_lock(&ofd->ofd_seq_list_lock);
        list_for_each_entry(oseq, &ofd->ofd_seq_list, os_list) {
                if (ostid_seq(&oseq->os_oi) == seq) {
-                       atomic_inc(&oseq->os_refc);
+                       refcount_inc(&oseq->os_refc);
                        read_unlock(&ofd->ofd_seq_list_lock);
                        return oseq;
                }
@@ -107,7 +107,7 @@ struct ofd_seq *ofd_seq_get(struct ofd_device *ofd, u64 seq)
  */
 void ofd_seq_put(const struct lu_env *env, struct ofd_seq *oseq)
 {
-       if (atomic_dec_and_test(&oseq->os_refc)) {
+       if (refcount_dec_and_test(&oseq->os_refc)) {
                LASSERT(list_empty(&oseq->os_list));
                LASSERT(oseq->os_lastid_obj != NULL);
                dt_object_put(env, oseq->os_lastid_obj);
@@ -139,14 +139,14 @@ static struct ofd_seq *ofd_seq_add(const struct lu_env *env,
        write_lock(&ofd->ofd_seq_list_lock);
        list_for_each_entry(os, &ofd->ofd_seq_list, os_list) {
                if (ostid_seq(&os->os_oi) == ostid_seq(&new_seq->os_oi)) {
-                       atomic_inc(&os->os_refc);
+                       refcount_inc(&os->os_refc);
                        write_unlock(&ofd->ofd_seq_list_lock);
                        /* The seq has not been added to the list */
                        ofd_seq_put(env, new_seq);
                        return os;
                }
        }
-       atomic_inc(&new_seq->os_refc);
+       refcount_inc(&new_seq->os_refc);
        list_add_tail(&new_seq->os_list, &ofd->ofd_seq_list);
        ofd->ofd_seq_count++;
        write_unlock(&ofd->ofd_seq_list_lock);
@@ -409,8 +409,7 @@ struct ofd_seq *ofd_seq_load(const struct lu_env *env, struct ofd_device *ofd,
        spin_lock_init(&oseq->os_last_oid_lock);
        ostid_set_seq(&oseq->os_oi, seq);
        oseq->os_last_id_synced = 0;
-
-       atomic_set(&oseq->os_refc, 1);
+       refcount_set(&oseq->os_refc, 1);
        atomic_set(&oseq->os_precreate_in_progress, 0);
 
        rc = dt_attr_get(env, dob, &info->fti_attr);
index 8c7100e..5634ca4 100644 (file)
@@ -100,7 +100,7 @@ struct ofd_seq {
        struct ost_id           os_oi;
        spinlock_t              os_last_oid_lock;
        struct mutex            os_create_lock;
-       atomic_t                os_refc;
+       refcount_t              os_refc;
        atomic_t                os_precreate_in_progress;
        struct dt_object        *os_lastid_obj;
        unsigned long           os_destroys_in_progress:1,
index c258bed..02b4248 100644 (file)
@@ -193,7 +193,7 @@ static int ofd_precreate_cb_add(const struct lu_env *env, struct thandle *th,
                return -ENOMEM;
 
        precreate = atomic_read(&oseq->os_precreate_in_progress);
-       atomic_inc(&oseq->os_refc);
+       refcount_inc(&oseq->os_refc);
        opc->opc_oseq = oseq;
        opc->opc_objects = objects;
        CDEBUG(D_OTHER, "Add %d to %d for "DFID", th_sync %d\n",