Whamcloud - gitweb
LU-16796 nodemap: Change nm_refcount to refcount 53/58453/2
authorJames Simmons <jsimmons@infradead.org>
Mon, 17 Mar 2025 19:45:03 +0000 (13:45 -0600)
committerOleg Drokin <green@whamcloud.com>
Wed, 26 Mar 2025 04:06:48 +0000 (04:06 +0000)
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 <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58453
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Marc Vef <mvef@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_nodemap.h
lustre/ptlrpc/nodemap_handler.c

index 122693f..54c0add 100644 (file)
@@ -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 */
index 5233bb7..20fa97d 100644 (file)
@@ -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) {