From 1759ae751aae8830e38faaeea1248667f5aac1aa Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Tue, 17 Oct 2023 13:52:31 +0530 Subject: [PATCH] LU-16796 ofd: Change struct ofd_seq to use refcount_t This patch changes struct ofd_seq to use refcount_t instead of atomic_t Signed-off-by: Arshad Hussain Change-Id: Ie149a6812671ea872e17d2881e52cf6096d147ff Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52722 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Neil Brown Reviewed-by: Timothy Day Reviewed-by: Oleg Drokin --- lustre/ofd/ofd_fs.c | 11 +++++------ lustre/ofd/ofd_internal.h | 2 +- lustre/ofd/ofd_objects.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lustre/ofd/ofd_fs.c b/lustre/ofd/ofd_fs.c index 4b56664..2c2bea9 100644 --- a/lustre/ofd/ofd_fs.c +++ b/lustre/ofd/ofd_fs.c @@ -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); diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 8c7100e..5634ca4 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -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, diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c index c258bed..02b4248 100644 --- a/lustre/ofd/ofd_objects.c +++ b/lustre/ofd/ofd_objects.c @@ -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", -- 1.8.3.1