Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/miscfs/specfs specfs: Call bdev_open without the vnode l...



details:   https://anonhg.NetBSD.org/src/rev/6c03834cc916
branches:  trunk
changeset: 364497:6c03834cc916
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Mar 28 12:34:34 2022 +0000

description:
specfs: Call bdev_open without the vnode lock.

There is no need for it to serialize opens, because they are already
serialized by sd_opencnt which for block devices is always either 0
or 1.

There's not obviously any other reason why the vnode lock should be
held across bdev_open, other than that it might be nice to avoid
dropping it if not necessary.  For character devices we always have
to drop the vnode lock because open might hang indefinitely, when
opening a tty, which is not allowed while holding the vnode lock.

diffstat:

 sys/miscfs/specfs/spec_vnops.c |  10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diffs (41 lines):

diff -r 104ff5162444 -r 6c03834cc916 sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c    Mon Mar 28 12:34:25 2022 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c    Mon Mar 28 12:34:34 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spec_vnops.c,v 1.186 2022/03/28 12:34:25 riastradh Exp $       */
+/*     $NetBSD: spec_vnops.c,v 1.187 2022/03/28 12:34:34 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.186 2022/03/28 12:34:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.187 2022/03/28 12:34:34 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -617,6 +617,7 @@
                sd->sd_opencnt = 1;
                sd->sd_bdevvp = vp;
                mutex_exit(&device_lock);
+               VOP_UNLOCK(vp);
                do {
                        const struct bdevsw *bdev;
 
@@ -636,13 +637,10 @@
                        if ((name = bdevsw_getname(major(dev))) == NULL)
                                break;
 
-                       VOP_UNLOCK(vp);
-
                         /* Try to autoload device module */
                        (void) module_autoload(name, MODULE_CLASS_DRIVER);
-                       
-                       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
                } while (gen != module_gen);
+               vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 
                break;
 



Home | Main Index | Thread Index | Old Index