Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/dkwedge dk(4): Restore assertions in dklastclose.



details:   https://anonhg.NetBSD.org/src/rev/1617c1360537
branches:  trunk
changeset: 374371:1617c1360537
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Apr 21 18:09:38 2023 +0000

description:
dk(4): Restore assertions in dklastclose.

We only enter dklastclose if the wedge is open (sc->sc_dk.dk_openmask
!= 0), which can happen only if dkfirstopen has succeeded, in which
case we hold a dk_rawopens reference to the parent that prevents
anyone else from closing it.  Hence sc->sc_parent->dk_rawopens > 0.

On open, sc->sc_parent->dk_rawvp is set to nonnull, and it is only
reset to null on close.  Hence if the parent is still open, as it
must be here, sc->sc_parent->dk_rawvp must be nonnull.

diffstat:

 sys/dev/dkwedge/dk.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r c15e2de12082 -r 1617c1360537 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Fri Apr 21 17:48:06 2023 +0000
+++ b/sys/dev/dkwedge/dk.c      Fri Apr 21 18:09:38 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.125 2023/04/13 08:30:40 riastradh Exp $       */
+/*     $NetBSD: dk.c,v 1.126 2023/04/21 18:09:38 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.125 2023/04/13 08:30:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.126 2023/04/21 18:09:38 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1227,6 +1227,8 @@ dklastclose(struct dkwedge_softc *sc)
 
        KASSERT(mutex_owned(&sc->sc_dk.dk_openlock));
        KASSERT(mutex_owned(&sc->sc_parent->dk_rawlock));
+       KASSERT(sc->sc_parent->dk_rawopens > 0);
+       KASSERT(sc->sc_parent->dk_rawvp != NULL);
 
        if (--sc->sc_parent->dk_rawopens == 0) {
                struct vnode *const vp = sc->sc_parent->dk_rawvp;



Home | Main Index | Thread Index | Old Index