public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: SCSI Mailing List <linux-scsi@vger.kernel.org>
Cc: Kai.Makisara@kolumbus.fi
Subject: st: Fixup -ENOMEDIUM
Date: Thu, 05 Oct 2006 11:26:02 +0200	[thread overview]
Message-ID: <4524CFAA.3010309@suse.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 624 bytes --]

Hi all,

currently the tape driver doesn't believe in ENOMEDIUM. Even if the 
sense code from TUR indicates that no tape is present the command will 
be retried; maybe the user is fast enough to slip a medium in in the 
meantime ...
And even if not, it will return 'EIO' in any case.

This patch fixes the ENOMEDIUM handling: TUR will _not_ be retried if no 
medium is present and the correct error number ENOMEDIUM will be set on 
exit.

Please apply.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke			hare@suse.de
SuSE Linux Products GmbH		S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de

[-- Attachment #2: st-no-tape.diff --]
[-- Type: text/x-patch, Size: 1539 bytes --]

st: Fix no medium handling

Currently the 'st' driver doesn't believe in -ENOMEDIUM.
Whenever the sense code indicates 'No tape' we might as well
return that status instead of retrying for ages.
And even then we really should return that error code to userland.

Signed-off-by: Hannes Reinecke <hare@suse.de>

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 7f669b6..b77fd61 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -877,6 +877,12 @@ static int test_ready(struct scsi_tape *
 			}
 
 			if (scode == NOT_READY) {
+				if ((STp->device)->scsi_level >= SCSI_2 &&
+				    cmdstatp->sense_hdr.asc == 0x3a) {
+					/* Early exit if there is no tape */
+					retval = CHKRES_NO_TAPE;
+					break;
+				}
 				if (waits < max_wait) {
 					if (msleep_interruptible(1000)) {
 						retval = (-EINTR);
@@ -885,14 +891,9 @@ static int test_ready(struct scsi_tape *
 					waits++;
 					continue;
 				}
-				else {
-					if ((STp->device)->scsi_level >= SCSI_2 &&
-					    cmdstatp->sense_hdr.asc == 0x3a)	/* Check ASC */
-						retval = CHKRES_NO_TAPE;
-					else
-						retval = CHKRES_NOT_READY;
-					break;
-				}
+				/* Accept we won't be getting anywhere */
+				retval = CHKRES_NOT_READY;
+				break;
 			}
 		}
 
@@ -1177,7 +1178,10 @@ static int st_open(struct inode *inode, 
 		goto err_out;
 	if ((filp->f_flags & O_NONBLOCK) == 0 &&
 	    retval != CHKRES_READY) {
-		retval = (-EIO);
+		if (STp->ready == ST_NO_TAPE)
+			retval = (-ENOMEDIUM);
+		else
+			retval = (-EIO);
 		goto err_out;
 	}
 	return 0;

             reply	other threads:[~2006-10-05  9:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-05  9:26 Hannes Reinecke [this message]
2006-10-05 19:59 ` st: Fixup -ENOMEDIUM Kai Makisara
2006-10-06  9:19   ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4524CFAA.3010309@suse.de \
    --to=hare@suse.de \
    --cc=Kai.Makisara@kolumbus.fi \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox