Module Name:    src
Committed By:   hannken
Date:           Wed Feb 20 10:03:25 UTC 2019

Modified Files:
        src/sys/dev: fss.c fssvar.h

Log Message:
Make FSS_ERROR a flag to prevent bogus fscow_disestablish() after error.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/fss.c
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/fssvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/fss.c
diff -u src/sys/dev/fss.c:1.106 src/sys/dev/fss.c:1.107
--- src/sys/dev/fss.c:1.106	Wed Aug 29 09:04:40 2018
+++ src/sys/dev/fss.c	Wed Feb 20 10:03:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: fss.c,v 1.106 2018/08/29 09:04:40 hannken Exp $	*/
+/*	$NetBSD: fss.c,v 1.107 2019/02/20 10:03:25 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.106 2018/08/29 09:04:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.107 2019/02/20 10:03:25 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -398,8 +398,7 @@ fss_ioctl(dev_t dev, u_long cmd, void *d
 		mutex_enter(&sc->sc_slock);
 		if ((flag & FWRITE) == 0) {
 			error = EPERM;
-		} else if (sc->sc_state != FSS_ACTIVE &&
-		    sc->sc_state != FSS_ERROR) {
+		} else if (sc->sc_state != FSS_ACTIVE) {
 			error = EBUSY;
 		} else {
 			sc->sc_state = FSS_DESTROYING;
@@ -509,7 +508,7 @@ fss_error(struct fss_softc *sc, const ch
 
 	KASSERT(mutex_owned(&sc->sc_slock));
 
-	if (sc->sc_state == FSS_ERROR)
+	if ((sc->sc_flags & FSS_ERROR))
 		return;
 
 	aprint_error_dev(sc->sc_dev, "snapshot invalid: %s\n", msg);
@@ -518,7 +517,7 @@ fss_error(struct fss_softc *sc, const ch
 		fscow_disestablish(sc->sc_mount, fss_copy_on_write, sc);
 		mutex_enter(&sc->sc_slock);
 	}
-	sc->sc_state = FSS_ERROR;
+	sc->sc_flags |= FSS_ERROR;
 }
 
 /*
@@ -944,7 +943,8 @@ fss_delete_snapshot(struct fss_softc *sc
 {
 
 	mutex_enter(&sc->sc_slock);
-	if ((sc->sc_flags & FSS_PERSISTENT) == 0 && sc->sc_state != FSS_ERROR) {
+	if ((sc->sc_flags & FSS_PERSISTENT) == 0 &&
+	    (sc->sc_flags & FSS_ERROR) == 0) {
 		mutex_exit(&sc->sc_slock);
 		fscow_disestablish(sc->sc_mount, fss_copy_on_write, sc);
 	} else {

Index: src/sys/dev/fssvar.h
diff -u src/sys/dev/fssvar.h:1.31 src/sys/dev/fssvar.h:1.32
--- src/sys/dev/fssvar.h:1.31	Wed Aug 29 09:04:40 2018
+++ src/sys/dev/fssvar.h	Wed Feb 20 10:03:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: fssvar.h,v 1.31 2018/08/29 09:04:40 hannken Exp $	*/
+/*	$NetBSD: fssvar.h,v 1.32 2019/02/20 10:03:25 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -137,8 +137,7 @@ typedef enum {
 	FSS_IDLE,			/* Device is unconfigured */
 	FSS_CREATING,			/* Device is currently configuring */
 	FSS_ACTIVE,			/* Device is configured */
-	FSS_DESTROYING,			/* Device is currently unconfiguring */
-	FSS_ERROR			/* Device had errors */
+	FSS_DESTROYING			/* Device is currently unconfiguring */
 } fss_state_t;
 
 struct fss_softc {
@@ -148,6 +147,7 @@ struct fss_softc {
 	kcondvar_t	sc_cache_cv;	/* Signals free cache slot */
 	fss_state_t	sc_state;	/* Current state */
 	volatile int	sc_flags;	/* Flags */
+#define FSS_ERROR	0x01		/* Device had errors. */
 #define FSS_BS_THREAD	0x04		/* Kernel thread is running */
 #define FSS_PERSISTENT	0x20		/* File system internal snapshot */
 #define FSS_CDEV_OPEN	0x40		/* character device open */

Reply via email to