Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern vfs(9): For MP-safe mounts, don't kernel lock in mo...
details: https://anonhg.NetBSD.org/src/rev/11f6ceaf4f76
branches: trunk
changeset: 370034:11f6ceaf4f76
user: riastradh <riastradh%NetBSD.org@localhost>
date: Tue Sep 13 09:13:19 2022 +0000
description:
vfs(9): For MP-safe mounts, don't kernel lock in mount/unmount.
diffstat:
sys/kern/vfs_subr.c | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
diffs (61 lines):
diff -r fce45747918f -r 11f6ceaf4f76 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Tue Sep 13 08:48:20 2022 +0000
+++ b/sys/kern/vfs_subr.c Tue Sep 13 09:13:19 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.494 2022/09/13 08:48:20 riastradh Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.495 2022/09/13 09:13:19 riastradh Exp $ */
/*-
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008, 2019, 2020
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.494 2022/09/13 08:48:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.495 2022/09/13 09:13:19 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1385,11 +1385,24 @@
int
VFS_MOUNT(struct mount *mp, const char *a, void *b, size_t *c)
{
+ int mpsafe = mp->mnt_iflag & IMNT_MPSAFE;
int error;
- KERNEL_LOCK(1, NULL);
+ /*
+ * Note: The first time through, the vfs_mount function may set
+ * IMNT_MPSAFE, so we have to cache it on entry in order to
+ * avoid leaking a kernel lock.
+ *
+ * XXX Maybe the MPSAFE bit should be set in struct vfsops and
+ * not in struct mount.
+ */
+ if (mpsafe) {
+ KERNEL_LOCK(1, NULL);
+ }
error = (*(mp->mnt_op->vfs_mount))(mp, a, b, c);
- KERNEL_UNLOCK_ONE(NULL);
+ if (mpsafe) {
+ KERNEL_UNLOCK_ONE(NULL);
+ }
return error;
}
@@ -1415,9 +1428,13 @@
{
int error;
- KERNEL_LOCK(1, NULL);
+ if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
+ KERNEL_LOCK(1, NULL);
+ }
error = (*(mp->mnt_op->vfs_unmount))(mp, a);
- KERNEL_UNLOCK_ONE(NULL);
+ if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
+ KERNEL_UNLOCK_ONE(NULL);
+ }
return error;
}
Home |
Main Index |
Thread Index |
Old Index