Module Name:    src
Committed By:   dyoung
Date:           Tue May 19 19:56:11 UTC 2009

Modified Files:
        src/sys/dev/ata: wd.c
        src/sys/dev/scsipi: sd.c

Log Message:
Delete wdactivate() and sdactivate().  They were no-ops, but as a
side-effect of registering them, config_detach(9) cleared DVF_ACTIVE
before it called wddetach() or sddetach().  Even though sd(4)'s
detachment may have subsequently failed with EBUSY, we could not
begin new disk I/O on sd(4) because the device had been deactivated.

By analogy to sdstrategy(), test device_is_active() in wdstrategy()
and if it is false set b_errno to EIO instead of initiating new
disk I/O.

XXX We should decline more politely to start new I/O, since
XXX !device_is_active() may mean simply that the device is suspended.
XXX I suppose that EIO is safe as long as system suspension is
XXX all-or-nothing.


To generate a diff of this commit:
cvs rdiff -u -r1.374 -r1.375 src/sys/dev/ata/wd.c
cvs rdiff -u -r1.283 -r1.284 src/sys/dev/scsipi/sd.c

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/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.374 src/sys/dev/ata/wd.c:1.375
--- src/sys/dev/ata/wd.c:1.374	Fri May 15 23:49:28 2009
+++ src/sys/dev/ata/wd.c	Tue May 19 19:56:10 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.374 2009/05/15 23:49:28 dyoung Exp $ */
+/*	$NetBSD: wd.c,v 1.375 2009/05/19 19:56:10 dyoung Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.374 2009/05/15 23:49:28 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.375 2009/05/19 19:56:10 dyoung Exp $");
 
 #include "opt_ata.h"
 
@@ -129,7 +129,6 @@
 int	wdprobe(device_t, cfdata_t, void *);
 void	wdattach(device_t, device_t, void *);
 int	wddetach(device_t, int);
-int	wdactivate(device_t, enum devact);
 int	wdprint(void *, char *);
 void	wdperror(const struct wd_softc *);
 
@@ -138,7 +137,7 @@
 static int	wd_standby(struct wd_softc *, int);
 
 CFATTACH_DECL3_NEW(wd, sizeof(struct wd_softc),
-    wdprobe, wdattach, wddetach, wdactivate, NULL, NULL, DVF_DETACH_SHUTDOWN);
+    wdprobe, wdattach, wddetach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
 
 extern struct cfdriver wd_cd;
 
@@ -435,25 +434,6 @@
 }
 
 int
-wdactivate(device_t self, enum devact act)
-{
-	int rv = 0;
-
-	switch (act) {
-	case DVACT_ACTIVATE:
-		rv = EOPNOTSUPP;
-		break;
-
-	case DVACT_DEACTIVATE:
-		/*
-		 * Nothing to do; we key off the device's DVF_ACTIVATE.
-		 */
-		break;
-	}
-	return (rv);
-}
-
-int
 wddetach(device_t self, int flags)
 {
 	struct wd_softc *sc = device_private(self);
@@ -548,8 +528,10 @@
 		goto done;
 	}
 
-	/* If device invalidated (e.g. media change, door open), error. */
-	if ((wd->sc_flags & WDF_LOADED) == 0) {
+	/* If device invalidated (e.g. media change, door open,
+	 * device suspension), then error.
+	 */
+	if ((wd->sc_flags & WDF_LOADED) == 0 || !device_is_active(wd->sc_dev)) {
 		bp->b_error = EIO;
 		goto done;
 	}

Index: src/sys/dev/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.283 src/sys/dev/scsipi/sd.c:1.284
--- src/sys/dev/scsipi/sd.c:1.283	Sun May 17 18:11:34 2009
+++ src/sys/dev/scsipi/sd.c	Tue May 19 19:56:11 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.283 2009/05/17 18:11:34 dyoung Exp $	*/
+/*	$NetBSD: sd.c,v 1.284 2009/05/19 19:56:11 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.283 2009/05/17 18:11:34 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.284 2009/05/19 19:56:11 dyoung Exp $");
 
 #include "opt_scsi.h"
 #include "rnd.h"
@@ -126,12 +126,11 @@
 
 static int	sdmatch(device_t, cfdata_t, void *);
 static void	sdattach(device_t, device_t, void *);
-static int	sdactivate(device_t, enum devact);
 static int	sddetach(device_t, int);
 static void	sd_set_properties(struct sd_softc *);
 
 CFATTACH_DECL3_NEW(sd, sizeof(struct sd_softc), sdmatch, sdattach, sddetach,
-    sdactivate, NULL, NULL, DVF_DETACH_SHUTDOWN);
+    NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
 
 extern struct cfdriver sd_cd;
 
@@ -328,25 +327,6 @@
 }
 
 static int
-sdactivate(device_t self, enum devact act)
-{
-	int rv = 0;
-
-	switch (act) {
-	case DVACT_ACTIVATE:
-		rv = EOPNOTSUPP;
-		break;
-
-	case DVACT_DEACTIVATE:
-		/*
-		 * Nothing to do; we key off the device's DVF_ACTIVE.
-		 */
-		break;
-	}
-	return (rv);
-}
-
-static int
 sddetach(device_t self, int flags)
 {
 	struct sd_softc *sd = device_private(self);

Reply via email to