st: Fixup -ENOMEDIUM
Subsystems (2)
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
Signature · 4 lines
Dr. Hannes Reinecke [email protected] SuSE Linux Products GmbH S390 & zSeries Maxfeldstraße 5 +49 911 74053 688 90409 Nürnberg http://www.suse.de
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.
drivers/scsi/st.c +13 -9
@@ -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 ;
Quoted 7 lines · Hannes Reinecke
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.
The driver implements (up to a point) the Single Unix Specification: if O_NONBLOCK is clear, open() shall wait until the device is ready or available. It does not wait indefinitely but implements a timeout. This is the behaviour I found experimentally in some other Unices.
Quoted 3 lines
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.
It is true that st_open() does not currently return ENOMEDIUM and your fix for this is correct.
Quoted 2 lines
Please apply.
I don't think that the first and second parts should be applied. The third part fixes a bug and it should be applied. I include at the end a diff containing only that part.
Thanks,
Kai
-----------8<--------------------
Fix st_open() to return -ENOMEDIUM instead of -EIO if no medium is found.
drivers/scsi/st.c renamed from drivers/scsi/st.c.org +4 -1
@@ -1177,7 +1177,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 ==NO_TAPE ) + retval = (-ENOMEDIUM ); +else + retval = (-EIO ); goto err_out; }return 0 ;
Quoted 11 lines · Kai Makisara
Quoted 7 lines · Hannes Reinecke
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.
The driver implements (up to a point) the Single Unix Specification: if
O_NONBLOCKis clear,open()shall wait until the device is ready or available. It does not wait indefinitely but implements a timeout. This is the behaviour I found experimentally in some other Unices.
Ah. Ok; you're the maintainer, you get to decide.
Quoted 9 lines
Quoted 3 lines
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.
It is true that
st_open()does not currently return ENOMEDIUM and your fix for this is correct.Quoted 2 lines
Please apply.
I don't think that the first and second parts should be applied. The third part fixes a bug and it should be applied. I include at the end a diff containing only that part.
Right. Thanks.
Quoted 6 lines
-----------8<--------------------
Fix
st_open()to return-ENOMEDIUMinstead of-EIOif no medium is found.Signed-off-by Kai Makisara <[email protected]>
Cheers,
Hannes
Signature · 8 lines
Dr. Hannes Reinecke [email protected] SuSE Linux Products GmbH S390 & zSeries Maxfeldstraße 5 +49 911 74053 688 90409 Nürnberg http://www.suse.de - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html