From 776f9430201d26af4e1167e8c5fea6f4012bc641 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 17 Mar 2025 13:45:03 -0600 Subject: [PATCH] LU-16796 nodemap: Change nm_refcount to refcount This patch changes struct lu_nodemap to use refcount_t instead of atomic_t. Using refcount adds new functionally that we can use with rhashtable which will be done in an follow on patch for nodemaps. Test-Parameters: trivial testlist=sanity-sec Change-Id: I2651c24740ea43486398a200b76cf9eb29cdcdf7 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58453 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Timothy Day Reviewed-by: Arshad Hussain Reviewed-by: Marc Vef Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- lustre/include/lustre_nodemap.h | 2 +- lustre/ptlrpc/nodemap_handler.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lustre/include/lustre_nodemap.h b/lustre/include/lustre_nodemap.h index 122693f..54c0add 100644 --- a/lustre/include/lustre_nodemap.h +++ b/lustre/include/lustre_nodemap.h @@ -68,7 +68,7 @@ struct lu_nodemap { /* unique ID set by MGS */ unsigned int nm_id; /* nodemap ref counter */ - atomic_t nm_refcount; + refcount_t nm_refcount; /* UID to squash unmapped UIDs */ uid_t nm_squash_uid; /* GID to squash unmapped GIDs */ diff --git a/lustre/ptlrpc/nodemap_handler.c b/lustre/ptlrpc/nodemap_handler.c index 5233bb7..20fa97d 100644 --- a/lustre/ptlrpc/nodemap_handler.c +++ b/lustre/ptlrpc/nodemap_handler.c @@ -75,9 +75,9 @@ static void nodemap_destroy(struct lu_nodemap *nodemap) */ void nodemap_getref(struct lu_nodemap *nodemap) { - atomic_inc(&nodemap->nm_refcount); + refcount_inc(&nodemap->nm_refcount); CDEBUG(D_INFO, "GETting nodemap %s(p=%p) : new refcount %d\n", - nodemap->nm_name, nodemap, atomic_read(&nodemap->nm_refcount)); + nodemap->nm_name, nodemap, refcount_read(&nodemap->nm_refcount)); } /** @@ -89,13 +89,13 @@ void nodemap_putref(struct lu_nodemap *nodemap) if (!nodemap) return; - LASSERT(atomic_read(&nodemap->nm_refcount) > 0); + LASSERT(refcount_read(&nodemap->nm_refcount) > 0); CDEBUG(D_INFO, "PUTting nodemap %s(p=%p) : new refcount %d\n", nodemap->nm_name, nodemap, - atomic_read(&nodemap->nm_refcount) - 1); + refcount_read(&nodemap->nm_refcount) - 1); - if (atomic_dec_and_test(&nodemap->nm_refcount)) + if (refcount_dec_and_test(&nodemap->nm_refcount)) nodemap_destroy(nodemap); } EXPORT_SYMBOL(nodemap_putref); @@ -1516,7 +1516,7 @@ struct lu_nodemap *nodemap_create(const char *name, * take an extra reference to prevent nodemap from being destroyed * while it's being created. */ - atomic_set(&nodemap->nm_refcount, 2); + refcount_set(&nodemap->nm_refcount, 2); snprintf(nodemap->nm_name, sizeof(nodemap->nm_name), "%s", name); rc = cfs_hash_add_unique(hash, name, &nodemap->nm_hash); if (rc != 0) { -- 1.8.3.1