summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorhannken <hannken@NetBSD.org>2019-02-20 10:03:25 +0000
committerhannken <hannken@NetBSD.org>2019-02-20 10:03:25 +0000
commitd3d92310055584ce2ced1f2c54e944ca53a488dc (patch)
tree702ee35e61cd376edb6b71c0154670368f793dac /sys/dev
parent234ee9d38596b4e7cdcfc0f92fd3a457897df4d7 (diff)
Make FSS_ERROR a flag to prevent bogus fscow_disestablish() after error.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/fss.c14
-rw-r--r--sys/dev/fssvar.h6
2 files changed, 10 insertions, 10 deletions
diff --git a/sys/dev/fss.c b/sys/dev/fss.c
index 7912a9fa721..019d2c38190 100644
--- a/sys/dev/fss.c
+++ b/sys/dev/fss.c
@@ -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 *data, int flag, struct lwp *l)
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 char *msg)
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 char *msg)
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, struct lwp *l)
{
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 {
diff --git a/sys/dev/fssvar.h b/sys/dev/fssvar.h
index 618bf0bafdd..b2bc2b1103f 100644
--- a/sys/dev/fssvar.h
+++ b/sys/dev/fssvar.h
@@ -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 */