]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/nfs/nfs_srvcache.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / bsd / nfs / nfs_srvcache.c
index 5addbf6fbac7175270d355dcf1d7d9f82ca26045..a934d4d078082bd83d1f8efd2c03896b4fcfe100 100644 (file)
@@ -100,8 +100,8 @@ LIST_HEAD(nfsrv_reqcache_hash, nfsrvcache) * nfsrv_reqcache_hashtbl;
 TAILQ_HEAD(nfsrv_reqcache_lru, nfsrvcache) nfsrv_reqcache_lruhead;
 u_long nfsrv_reqcache_hash;
 
 TAILQ_HEAD(nfsrv_reqcache_lru, nfsrvcache) nfsrv_reqcache_lruhead;
 u_long nfsrv_reqcache_hash;
 
-lck_grp_t *nfsrv_reqcache_lck_grp;
-lck_mtx_t *nfsrv_reqcache_mutex;
+static LCK_GRP_DECLARE(nfsrv_reqcache_lck_grp, "nfsrv_reqcache");
+LCK_MTX_DECLARE(nfsrv_reqcache_mutex, &nfsrv_reqcache_lck_grp);
 
 /*
  * Static array that defines which nfs rpc's are nonidempotent
 
 /*
  * Static array that defines which nfs rpc's are nonidempotent
@@ -164,11 +164,11 @@ nfsrv_initcache(void)
                return;
        }
 
                return;
        }
 
-       lck_mtx_lock(nfsrv_reqcache_mutex);
+       lck_mtx_lock(&nfsrv_reqcache_mutex);
        /* init nfs server request cache hash table */
        nfsrv_reqcache_hashtbl = hashinit(nfsrv_reqcache_size, M_NFSD, &nfsrv_reqcache_hash);
        TAILQ_INIT(&nfsrv_reqcache_lruhead);
        /* init nfs server request cache hash table */
        nfsrv_reqcache_hashtbl = hashinit(nfsrv_reqcache_size, M_NFSD, &nfsrv_reqcache_hash);
        TAILQ_INIT(&nfsrv_reqcache_lruhead);
-       lck_mtx_unlock(nfsrv_reqcache_mutex);
+       lck_mtx_unlock(&nfsrv_reqcache_mutex);
 }
 
 /*
 }
 
 /*
@@ -239,7 +239,7 @@ nfsrv_getcache(
        if (!nd->nd_nam2) {
                return RC_DOIT;
        }
        if (!nd->nd_nam2) {
                return RC_DOIT;
        }
-       lck_mtx_lock(nfsrv_reqcache_mutex);
+       lck_mtx_lock(&nfsrv_reqcache_mutex);
 loop:
        for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != 0;
            rp = rp->rc_hash.le_next) {
 loop:
        for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != 0;
            rp = rp->rc_hash.le_next) {
@@ -247,7 +247,7 @@ loop:
                    netaddr_match(rp->rc_family, &rp->rc_haddr, nd->nd_nam)) {
                        if ((rp->rc_flag & RC_LOCKED) != 0) {
                                rp->rc_flag |= RC_WANTED;
                    netaddr_match(rp->rc_family, &rp->rc_haddr, nd->nd_nam)) {
                        if ((rp->rc_flag & RC_LOCKED) != 0) {
                                rp->rc_flag |= RC_WANTED;
-                               msleep(rp, nfsrv_reqcache_mutex, PZERO - 1, "nfsrc", NULL);
+                               msleep(rp, &nfsrv_reqcache_mutex, PZERO - 1, "nfsrc", NULL);
                                goto loop;
                        }
                        rp->rc_flag |= RC_LOCKED;
                                goto loop;
                        }
                        rp->rc_flag |= RC_LOCKED;
@@ -293,7 +293,7 @@ loop:
                                rp->rc_flag &= ~RC_WANTED;
                                wakeup(rp);
                        }
                                rp->rc_flag &= ~RC_WANTED;
                                wakeup(rp);
                        }
-                       lck_mtx_unlock(nfsrv_reqcache_mutex);
+                       lck_mtx_unlock(&nfsrv_reqcache_mutex);
                        return ret;
                }
        }
                        return ret;
                }
        }
@@ -315,12 +315,12 @@ loop:
                if (!rp) {
                        /* no entry to reuse? */
                        /* OK, we just won't be able to cache this request */
                if (!rp) {
                        /* no entry to reuse? */
                        /* OK, we just won't be able to cache this request */
-                       lck_mtx_unlock(nfsrv_reqcache_mutex);
+                       lck_mtx_unlock(&nfsrv_reqcache_mutex);
                        return RC_DOIT;
                }
                while ((rp->rc_flag & RC_LOCKED) != 0) {
                        rp->rc_flag |= RC_WANTED;
                        return RC_DOIT;
                }
                while ((rp->rc_flag & RC_LOCKED) != 0) {
                        rp->rc_flag |= RC_WANTED;
-                       msleep(rp, nfsrv_reqcache_mutex, PZERO - 1, "nfsrc", NULL);
+                       msleep(rp, &nfsrv_reqcache_mutex, PZERO - 1, "nfsrc", NULL);
                        rp = nfsrv_reqcache_lruhead.tqh_first;
                }
                rp->rc_flag |= RC_LOCKED;
                        rp = nfsrv_reqcache_lruhead.tqh_first;
                }
                rp->rc_flag |= RC_LOCKED;
@@ -365,7 +365,7 @@ loop:
                rp->rc_flag &= ~RC_WANTED;
                wakeup(rp);
        }
                rp->rc_flag &= ~RC_WANTED;
                wakeup(rp);
        }
-       lck_mtx_unlock(nfsrv_reqcache_mutex);
+       lck_mtx_unlock(&nfsrv_reqcache_mutex);
        return RC_DOIT;
 }
 
        return RC_DOIT;
 }
 
@@ -384,7 +384,7 @@ nfsrv_updatecache(
        if (!nd->nd_nam2) {
                return;
        }
        if (!nd->nd_nam2) {
                return;
        }
-       lck_mtx_lock(nfsrv_reqcache_mutex);
+       lck_mtx_lock(&nfsrv_reqcache_mutex);
 loop:
        for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != 0;
            rp = rp->rc_hash.le_next) {
 loop:
        for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != 0;
            rp = rp->rc_hash.le_next) {
@@ -392,7 +392,7 @@ loop:
                    netaddr_match(rp->rc_family, &rp->rc_haddr, nd->nd_nam)) {
                        if ((rp->rc_flag & RC_LOCKED) != 0) {
                                rp->rc_flag |= RC_WANTED;
                    netaddr_match(rp->rc_family, &rp->rc_haddr, nd->nd_nam)) {
                        if ((rp->rc_flag & RC_LOCKED) != 0) {
                                rp->rc_flag |= RC_WANTED;
-                               msleep(rp, nfsrv_reqcache_mutex, PZERO - 1, "nfsrc", NULL);
+                               msleep(rp, &nfsrv_reqcache_mutex, PZERO - 1, "nfsrc", NULL);
                                goto loop;
                        }
                        rp->rc_flag |= RC_LOCKED;
                                goto loop;
                        }
                        rp->rc_flag |= RC_LOCKED;
@@ -430,11 +430,11 @@ loop:
                                rp->rc_flag &= ~RC_WANTED;
                                wakeup(rp);
                        }
                                rp->rc_flag &= ~RC_WANTED;
                                wakeup(rp);
                        }
-                       lck_mtx_unlock(nfsrv_reqcache_mutex);
+                       lck_mtx_unlock(&nfsrv_reqcache_mutex);
                        return;
                }
        }
                        return;
                }
        }
-       lck_mtx_unlock(nfsrv_reqcache_mutex);
+       lck_mtx_unlock(&nfsrv_reqcache_mutex);
 }
 
 /*
 }
 
 /*
@@ -445,7 +445,7 @@ nfsrv_cleancache(void)
 {
        struct nfsrvcache *rp, *nextrp;
 
 {
        struct nfsrvcache *rp, *nextrp;
 
-       lck_mtx_lock(nfsrv_reqcache_mutex);
+       lck_mtx_lock(&nfsrv_reqcache_mutex);
        for (rp = nfsrv_reqcache_lruhead.tqh_first; rp != 0; rp = nextrp) {
                nextrp = rp->rc_lru.tqe_next;
                LIST_REMOVE(rp, rc_hash);
        for (rp = nfsrv_reqcache_lruhead.tqh_first; rp != 0; rp = nextrp) {
                nextrp = rp->rc_lru.tqe_next;
                LIST_REMOVE(rp, rc_hash);
@@ -454,7 +454,7 @@ nfsrv_cleancache(void)
        }
        nfsrv_reqcache_count = 0;
        FREE(nfsrv_reqcache_hashtbl, M_TEMP);
        }
        nfsrv_reqcache_count = 0;
        FREE(nfsrv_reqcache_hashtbl, M_TEMP);
-       lck_mtx_unlock(nfsrv_reqcache_mutex);
+       lck_mtx_unlock(&nfsrv_reqcache_mutex);
 }
 
 #endif /* CONFIG_NFS_SERVER */
 }
 
 #endif /* CONFIG_NFS_SERVER */