summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2001-08-31 22:15:37 +0000
committerdillon <dillon@FreeBSD.org>2001-08-31 22:15:37 +0000
commit4609145389bf78da2e1e473b940bc5fd6e2860e3 (patch)
treefd069386de5468e4d53b53a688d465f943acc9cb /sys/vm
parentaf4e4157dfdcf08b1deac490ee93ae5c0c336ed7 (diff)
downloadFreeBSD-src-4609145389bf78da2e1e473b940bc5fd6e2860e3.zip
FreeBSD-src-4609145389bf78da2e1e473b940bc5fd6e2860e3.tar.gz
make swapon() MPSAFE (will adjust syscalls.master later)
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_swap.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c
index 6bde4b1..72f7b9c 100644
--- a/sys/vm/vm_swap.c
+++ b/sys/vm/vm_swap.c
@@ -183,6 +183,9 @@ struct swapon_args {
};
#endif
+/*
+ * MPSAFE
+ */
/* ARGSUSED */
int
swapon(p, uap)
@@ -194,21 +197,25 @@ swapon(p, uap)
struct nameidata nd;
int error;
+ mtx_lock(&Giant);
+
error = suser(p);
if (error)
- return (error);
+ goto done2;
/*
* Swap metadata may not fit in the KVM if we have physical
* memory of >1GB.
*/
- if (swap_zone == NULL)
- return (ENOMEM);
+ if (swap_zone == NULL) {
+ error = ENOMEM;
+ goto done2;
+ }
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->name, p);
error = namei(&nd);
if (error)
- return (error);
+ goto done2;
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
@@ -226,7 +233,8 @@ swapon(p, uap)
if (error)
vrele(vp);
-
+done2:
+ mtx_unlock(&Giant);
return (error);
}
OpenPOWER on IntegriCloud