summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2002-02-17 07:30:34 +0000
committerdillon <dillon@FreeBSD.org>2002-02-17 07:30:34 +0000
commit683d9b041ddcdf95d5f347177477800fc0d33892 (patch)
treede6525efcef65a9db225bae69c57c6fd50a8b95f
parent77f77a885c6ecd4289ef689cfd206aabb1fbf5a7 (diff)
downloadFreeBSD-src-683d9b041ddcdf95d5f347177477800fc0d33892.zip
FreeBSD-src-683d9b041ddcdf95d5f347177477800fc0d33892.tar.gz
replace the embedded cr_mtx in the ucred structure with cr_mtxp (a mutex
pointer), and use the mutex pool routines. This greatly reduces the size of the ucred structure.
-rw-r--r--sys/kern/kern_prot.c20
-rw-r--r--sys/sys/ucred.h4
2 files changed, 13 insertions, 11 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index f7056a0..76b0c72 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -1586,7 +1586,7 @@ crget()
MALLOC(cr, struct ucred *, sizeof(*cr), M_CRED, M_WAITOK | M_ZERO);
cr->cr_ref = 1;
- mtx_init(&cr->cr_mtx, "ucred", MTX_DEF);
+ cr->cr_mtxp = mtx_pool_find(cr);
return (cr);
}
@@ -1598,9 +1598,9 @@ crhold(cr)
struct ucred *cr;
{
- mtx_lock(&cr->cr_mtx);
+ mtx_lock(cr->cr_mtxp);
cr->cr_ref++;
- mtx_unlock(&cr->cr_mtx);
+ mtx_unlock(cr->cr_mtxp);
return (cr);
}
@@ -1612,16 +1612,17 @@ void
crfree(cr)
struct ucred *cr;
{
+ struct mtx *mtxp = cr->cr_mtxp;
- mtx_lock(&cr->cr_mtx);
+ mtx_lock(mtxp);
KASSERT(cr->cr_ref > 0, ("bad ucred refcount: %d", cr->cr_ref));
if (--cr->cr_ref == 0) {
- mtx_destroy(&cr->cr_mtx);
/*
* Some callers of crget(), such as nfs_statfs(),
* allocate a temporary credential, but don't
* allocate a uidinfo structure.
*/
+ mtx_unlock(mtxp);
if (cr->cr_uidinfo != NULL)
uifree(cr->cr_uidinfo);
if (cr->cr_ruidinfo != NULL)
@@ -1632,8 +1633,9 @@ crfree(cr)
if (jailed(cr))
prison_free(cr->cr_prison);
FREE((caddr_t)cr, M_CRED);
- } else
- mtx_unlock(&cr->cr_mtx);
+ } else {
+ mtx_unlock(mtxp);
+ }
}
/*
@@ -1645,9 +1647,9 @@ crshared(cr)
{
int shared;
- mtx_lock(&cr->cr_mtx);
+ mtx_lock(cr->cr_mtxp);
shared = (cr->cr_ref > 1);
- mtx_unlock(&cr->cr_mtx);
+ mtx_unlock(cr->cr_mtxp);
return (shared);
}
diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h
index d26f318..8e33d32 100644
--- a/sys/sys/ucred.h
+++ b/sys/sys/ucred.h
@@ -60,8 +60,8 @@ struct ucred {
struct uidinfo *cr_uidinfo; /* per euid resource consumption */
struct uidinfo *cr_ruidinfo; /* per ruid resource consumption */
struct prison *cr_prison; /* jail(4) */
-#define cr_endcopy cr_mtx
- struct mtx cr_mtx; /* protect refcount */
+#define cr_endcopy cr_mtxp
+ struct mtx *cr_mtxp; /* protect refcount */
};
#define cr_gid cr_groups[0]
#define NOCRED ((struct ucred *)0) /* no credential available */
OpenPOWER on IntegriCloud