summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2020-08-29 18:43:26 +0000
committerBrian Behlendorf <[email protected]>2020-08-31 19:43:08 -0700
commiteff621071ffd33764b833ea16894bee47d6ffb34 (patch)
treed1b7165fe0b8d69c3ce97c4ed0163d8205225821
parent2f65c7a608520f5907eddca0a732b0a995cb0a86 (diff)
FreeBSD: Simplify INGLOBALZONE
FreeBSD's previous ZFS implemented INGLOBALZONE(thread) as (!jailed((thread)->td_ucred)) and passed curthread to INGLOBALZONE. We pass curproc instead of curthread, so we can achieve the same effect with (!jailed((proc)->p_ucred)). The implementation is trivial enough to fit on a single line in a define. We don't really need a whole separate function for something that's already macros all the way down. Eliminate in_globalzone. Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #10851
-rw-r--r--include/os/freebsd/spl/sys/zone.h9
-rw-r--r--module/os/freebsd/spl/spl_zone.c6
2 files changed, 4 insertions, 11 deletions
diff --git a/include/os/freebsd/spl/sys/zone.h b/include/os/freebsd/spl/sys/zone.h
index 71a28adaf..dd088de83 100644
--- a/include/os/freebsd/spl/sys/zone.h
+++ b/include/os/freebsd/spl/sys/zone.h
@@ -29,6 +29,8 @@
#ifndef _OPENSOLARIS_SYS_ZONE_H_
#define _OPENSOLARIS_SYS_ZONE_H_
+#include <sys/jail.h>
+
/*
* Macros to help with zone visibility restrictions.
*/
@@ -36,12 +38,9 @@
#define GLOBAL_ZONEID 0
/*
- * Is thread in the global zone?
+ * Is proc in the global zone?
*/
-#define INGLOBALZONE(p) in_globalzone((p))
-
-
-extern boolean_t in_globalzone(struct proc *);
+#define INGLOBALZONE(proc) (!jailed((proc)->p_ucred))
/*
* Attach the given dataset to the given jail.
diff --git a/module/os/freebsd/spl/spl_zone.c b/module/os/freebsd/spl/spl_zone.c
index 0b3b04d2a..bd3f019b2 100644
--- a/module/os/freebsd/spl/spl_zone.c
+++ b/module/os/freebsd/spl/spl_zone.c
@@ -242,12 +242,6 @@ zone_get_hostid(void *ptr)
return ((uint32_t)curthread->td_ucred->cr_prison->pr_hostid);
}
-boolean_t
-in_globalzone(struct proc *p)
-{
- return (!jailed(FIRST_THREAD_IN_PROC((p))->td_ucred));
-}
-
static void
zone_sysinit(void *arg __unused)
{