summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-04-01 23:34:40 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-04-01 23:34:40 +0000
commit52e849154e76bf130b289d2e0a27b7c93ff2d932 (patch)
tree17bd65d6ca7dab91ae8c96cd640de163662748ec
parent43d47078afe78091fb9c219fc2a6728d1f8dcacc (diff)
Cleanup SKEY_NOT_READY logic. Only retry command if it's likely the
condition is going to clear up, which speeds up boot by avoiding delays in disk matching. Return ENODEV if media is not present, which avoids trying to spin up disks that are not present. Use ENODEV in amd64/i386 dkcsum.c to filter failure reports. Mostly from NetBSD. ok marco@
-rw-r--r--sys/arch/amd64/amd64/dkcsum.c4
-rw-r--r--sys/arch/i386/i386/dkcsum.c4
-rw-r--r--sys/scsi/scsi_base.c36
3 files changed, 27 insertions, 17 deletions
diff --git a/sys/arch/amd64/amd64/dkcsum.c b/sys/arch/amd64/amd64/dkcsum.c
index 0c060144d74..8817d7cb58d 100644
--- a/sys/arch/amd64/amd64/dkcsum.c
+++ b/sys/arch/amd64/amd64/dkcsum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkcsum.c,v 1.4 2005/01/01 03:07:08 millert Exp $ */
+/* $OpenBSD: dkcsum.c,v 1.5 2005/04/01 23:34:38 krw Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
@@ -95,7 +95,7 @@ dkcsumattach(void)
error = (*bdsw->d_open)(dev, FREAD, S_IFCHR, curproc);
if (error) {
/* XXX What to do here? */
- if (error != EIO)
+ if (error != ENODEV)
printf("dkcsum: open of %s failed (%d)\n",
dv->dv_xname, error);
continue;
diff --git a/sys/arch/i386/i386/dkcsum.c b/sys/arch/i386/i386/dkcsum.c
index 691f53407cb..da3a9bd67e4 100644
--- a/sys/arch/i386/i386/dkcsum.c
+++ b/sys/arch/i386/i386/dkcsum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkcsum.c,v 1.15 2005/01/01 03:07:08 millert Exp $ */
+/* $OpenBSD: dkcsum.c,v 1.16 2005/04/01 23:34:39 krw Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
@@ -94,7 +94,7 @@ dkcsumattach()
error = (*bdsw->d_open)(dev, FREAD, S_IFCHR, curproc);
if (error) {
/* XXX What to do here? */
- if (error != EIO)
+ if (error != ENODEV)
printf("dkcsum: open of %s failed (%d)\n",
dv->dv_xname, error);
continue;
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index d8e4cbb7380..734303ac95d 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.63 2005/03/24 12:52:01 krw Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.64 2005/04/01 23:34:39 krw Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -720,20 +720,30 @@ scsi_interpret_sense(xs)
case SKEY_EQUAL:
break;
case SKEY_NOT_READY:
- if ((sc_link->flags & SDEV_REMOVABLE) != 0)
- sc_link->flags &= ~SDEV_MEDIA_LOADED;
if ((xs->flags & SCSI_IGNORE_NOT_READY) != 0)
- return 0;
- if (xs->retries && sense->add_sense_code == 0x04 &&
- sense->add_sense_code_qual == 0x01) {
- xs->error = XS_BUSY; /* ie. sense_retry */
- return ERESTART;
- }
- if (xs->retries && !(sc_link->flags & SDEV_REMOVABLE)) {
- delay(1000000);
- return ERESTART;
- }
+ return (0);
error = EIO;
+ if (xs->retries) {
+ switch (sense->add_sense_code) {
+ case 0x04: /* LUN not ready */
+ switch (sense->add_sense_code_qual) {
+ case 0x01: /* Becoming Ready */
+ case 0x04: /* Format In Progress */
+ case 0x05: /* Rebuild In Progress */
+ case 0x06: /* Recalculation In Progress */
+ case 0x07: /* Operation In Progress */
+ case 0x08: /* Long Write In Progress */
+ case 0x09: /* Self-Test In Progress */
+ xs->error = XS_BUSY; /* wait & retry */
+ return (ERESTART);
+ }
+ break;
+ case 0x3a: /* Medium not present */
+ sc_link->flags &= ~SDEV_MEDIA_LOADED;
+ error = ENODEV;
+ break;
+ }
+ }
break;
case SKEY_ILLEGAL_REQUEST:
if ((xs->flags & SCSI_IGNORE_ILLEGAL_REQUEST) != 0)