PERFORCE change 33524 for review
Robert Watson
rwatson at FreeBSD.org
Sun Jun 22 15:25:18 GMT 2003
http://perforce.freebsd.org/chv.cgi?CH=33524
Change 33524 by rwatson at rwatson_powerbook on 2003/06/22 08:25:00
Substitute Mach mutex_t calls for FreeBSD struct mtx calls;
lock using mutex_lock(), allocate using mutex_alloc(). The
Mach API prevents us from storing the mutex statically; we
must pass around the pointers.
"#if 0" all mutex references to Giant; we'll need to look at
the funnel issues here; the BSD funnel is probably right
one for all of these cases, since they generally have to do
with VFS, but we'll need to check that.
Affected files ...
.. //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/kern/kern_mac.c#8 edit
Differences ...
==== //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/kern/kern_mac.c#8 (text+ko) ====
@@ -259,7 +259,7 @@
* exclusive consumers that they should try to acquire the lock if a
* first attempt at exclusive access fails.
*/
-static mutex_t mac_policy_mtx;
+static mutex_t *mac_policy_mtx;
static struct cv mac_policy_cv;
static int mac_policy_count;
static LIST_HEAD(, mac_policy_conf) mac_policy_list;
@@ -279,9 +279,9 @@
{
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
"mac_policy_grab_exclusive() at %s:%d", __FILE__, __LINE__);
- mtx_lock(&mac_policy_mtx);
+ mutex_lock(mac_policy_mtx);
while (mac_policy_count != 0)
- cv_wait(&mac_policy_cv, &mac_policy_mtx);
+ cv_wait(&mac_policy_cv, mac_policy_mtx);
}
static __inline void
@@ -298,16 +298,16 @@
KASSERT(mac_policy_count == 0,
("mac_policy_release_exclusive(): not exclusive"));
- mtx_unlock(&mac_policy_mtx);
+ mutex_unlock(mac_policy_mtx);
cv_signal(&mac_policy_cv);
}
static __inline void
mac_policy_list_busy(void)
{
- mtx_lock(&mac_policy_mtx);
+ mutex_lock(mac_policy_mtx);
mac_policy_count++;
- mtx_unlock(&mac_policy_mtx);
+ mutex_unlock(mac_policy_mtx);
}
static __inline int
@@ -315,25 +315,25 @@
{
int ret;
- mtx_lock(&mac_policy_mtx);
+ mutex_lock(mac_policy_mtx);
if (!LIST_EMPTY(&mac_policy_list)) {
mac_policy_count++;
ret = 1;
} else
ret = 0;
- mtx_unlock(&mac_policy_mtx);
+ mutex_unlock(mac_policy_mtx);
return (ret);
}
static __inline void
mac_policy_list_unbusy(void)
{
- mtx_lock(&mac_policy_mtx);
+ mutex_lock(mac_policy_mtx);
mac_policy_count--;
KASSERT(mac_policy_count >= 0, ("MAC_POLICY_LIST_LOCK"));
if (mac_policy_count == 0)
cv_signal(&mac_policy_cv);
- mtx_unlock(&mac_policy_mtx);
+ mutex_unlock(mac_policy_mtx);
}
/*
@@ -491,7 +491,7 @@
LIST_INIT(&mac_static_policy_list);
LIST_INIT(&mac_policy_list);
- mtx_init(&mac_policy_mtx, "mac_policy_mtx", NULL, MTX_DEF);
+ mac_policy_mtx = mutex_alloc(ETAP_NO_TRACE);
cv_init(&mac_policy_cv, "mac_policy_cv");
}
@@ -3514,9 +3514,9 @@
#if 0
if (mac_enforce_vm) {
- mtx_lock(&Giant);
+ mutex_lock(Giant); /* XXX FUNNEL? */
mac_cred_mmapped_drop_perms(td, newcred);
- mtx_unlock(&Giant);
+ mutex_unlock(Giant); /* XXX FUNNEL? */
}
#endif
@@ -3561,7 +3561,9 @@
}
buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
- mtx_lock(&Giant); /* VFS */
+#if 0
+ mutex_lock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
error = fget(td, uap->fd, &fp);
if (error)
goto out;
@@ -3620,7 +3622,9 @@
error = copyout(buffer, mac.m_string, strlen(buffer)+1);
out:
- mtx_unlock(&Giant); /* VFS */
+#if 0
+ mutex_unlock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
free(buffer, M_MACTEMP);
free(elements, M_MACTEMP);
@@ -3655,7 +3659,9 @@
}
buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
- mtx_lock(&Giant); /* VFS */
+#if 0
+ mutex_lock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_USERSPACE, uap->path_p,
td);
error = namei(&nd);
@@ -3674,7 +3680,9 @@
error = copyout(buffer, mac.m_string, strlen(buffer)+1);
out:
- mtx_unlock(&Giant); /* VFS */
+#if 0
+ mutex_unlock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
free(buffer, M_MACTEMP);
free(elements, M_MACTEMP);
@@ -3710,7 +3718,9 @@
}
buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
- mtx_lock(&Giant); /* VFS */
+#if 0
+ mutex_lock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
NDINIT(&nd, LOOKUP, LOCKLEAF | NOFOLLOW, UIO_USERSPACE, uap->path_p,
td);
error = namei(&nd);
@@ -3728,7 +3738,9 @@
error = copyout(buffer, mac.m_string, strlen(buffer)+1);
out:
- mtx_unlock(&Giant); /* VFS */
+#if 0
+ mutex_unlock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
free(buffer, M_MACTEMP);
free(elements, M_MACTEMP);
@@ -3768,7 +3780,9 @@
return (error);
}
- mtx_lock(&Giant); /* VFS */
+#if 0
+ mutex_lock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
error = fget(td, uap->fd, &fp);
if (error)
@@ -3821,7 +3835,9 @@
fdrop(fp, td);
out:
- mtx_unlock(&Giant); /* VFS */
+#if 0
+ mutex_unlock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
free(buffer, M_MACTEMP);
@@ -3864,7 +3880,9 @@
return (error);
}
- mtx_lock(&Giant); /* VFS */
+#if 0
+ mutex_lock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_USERSPACE, uap->path_p,
td);
@@ -3878,7 +3896,9 @@
}
NDFREE(&nd, 0);
- mtx_unlock(&Giant); /* VFS */
+#if 0
+ mutex_unlock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
mac_destroy_vnode_label(&intlabel);
return (error);
@@ -3920,7 +3940,9 @@
return (error);
}
- mtx_lock(&Giant); /* VFS */
+#if 0
+ mutex_lock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
NDINIT(&nd, LOOKUP, LOCKLEAF | NOFOLLOW, UIO_USERSPACE, uap->path_p,
td);
@@ -3934,7 +3956,9 @@
}
NDFREE(&nd, 0);
- mtx_unlock(&Giant); /* VFS */
+#if 0
+ mutex_unlock(&Giant); /* VFS */ /* XXX FUNNEL? */
+#endif
mac_destroy_vnode_label(&intlabel);
return (error);
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list