Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/miscfs/specfs Pull up following revision(s) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/c9f494004ce4
branches:  netbsd-8
changeset: 850777:c9f494004ce4
user:      snj <snj%NetBSD.org@localhost>
date:      Sat Jul 01 08:54:08 2017 +0000

description:
Pull up following revision(s) (requested by hannken in ticket #76):
        sys/miscfs/specfs/spec_vnops.c: revision 1.174
Refuse to open a block device with zero open count when it has
a mountpoint set.  This may happen after forced detach or unplug
of a mounted block device.

diffstat:

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

diffs (36 lines):

diff -r e78cbaf73a86 -r c9f494004ce4 sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c    Sat Jul 01 08:53:06 2017 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c    Sat Jul 01 08:54:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spec_vnops.c,v 1.173 2017/06/01 02:45:14 chs Exp $     */
+/*     $NetBSD: spec_vnops.c,v 1.173.2.1 2017/07/01 08:54:08 snj 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.173 2017/06/01 02:45:14 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.173.2.1 2017/07/01 08:54:08 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -580,13 +580,16 @@
                 * For block devices, permit only one open.  The buffer
                 * cache cannot remain self-consistent with multiple
                 * vnodes holding a block device open.
+                *
+                * Treat zero opencnt with non-NULL mountpoint as open.
+                * This may happen after forced detach of a mounted device.
                 */
                mutex_enter(&device_lock);
                if (sn->sn_gone) {
                        mutex_exit(&device_lock);
                        return (EBADF);
                }
-               if (sd->sd_opencnt != 0) {
+               if (sd->sd_opencnt != 0 || sd->sd_mountpoint != NULL) {
                        mutex_exit(&device_lock);
                        return EBUSY;
                }



Home | Main Index | Thread Index | Old Index