All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: Allow retry on UNIT_ATTENTION media changed if not CDROM drive
@ 2015-01-08 22:33 Al Cooper
  2015-01-12  9:44 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Al Cooper @ 2015-01-08 22:33 UTC (permalink / raw)
  To: JBottomley, axboe, linux-scsi; +Cc: Al Cooper

Previous commit dfcf7775815504d13a1d273073810058caf84b9d added
a workaround for CD-ROM drives that were out of spec. This is causing
scsi_check_sense() to return an error instead of NEEDS_RETRY on
some USB thumb drives that return UNIT_ATTENTION Media Changed
(ASC/ASCQ 28/00) after resuming from S3. This can cause mounted
thumb drives to fail on the next access to the filesystem after
S3 resume. This is masked on many systems because udev/dbus event
handlers open the /dev/sd* device before filesystem access and the
open always retries the UNIT_ATTENTION. The fix is to limit the
original workaround to CDROM drives.

Signed-off-by: Al Cooper <alcooperx@gmail.com>
---
 drivers/scsi/scsi_error.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 8afb016..eee95d2 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -525,12 +525,13 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		 */
 		if (scmd->device->expecting_cc_ua) {
 			/*
-			 * Because some device does not queue unit
+			 * Because some CDROM drives do not queue unit
 			 * attentions correctly, we carefully check
 			 * additional sense code and qualifier so as
 			 * not to squash media change unit attention.
 			 */
-			if (sshdr.asc != 0x28 || sshdr.ascq != 0x00) {
+			if ((sdev->type != TYPE_ROM) ||
+				(sshdr.asc != 0x28 || sshdr.ascq != 0x00)) {
 				scmd->device->expecting_cc_ua = 0;
 				return NEEDS_RETRY;
 			}
-- 
1.9.0.138.g2de3478


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: Allow retry on UNIT_ATTENTION media changed if not CDROM drive
  2015-01-08 22:33 [PATCH] scsi: Allow retry on UNIT_ATTENTION media changed if not CDROM drive Al Cooper
@ 2015-01-12  9:44 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2015-01-12  9:44 UTC (permalink / raw)
  To: Al Cooper; +Cc: JBottomley, axboe, linux-scsi, TARUISI Hiroaki

On Thu, Jan 08, 2015 at 05:33:53PM -0500, Al Cooper wrote:
> Previous commit dfcf7775815504d13a1d273073810058caf84b9d added
> a workaround for CD-ROM drives that were out of spec. This is causing
> scsi_check_sense() to return an error instead of NEEDS_RETRY on
> some USB thumb drives that return UNIT_ATTENTION Media Changed
> (ASC/ASCQ 28/00) after resuming from S3. This can cause mounted
> thumb drives to fail on the next access to the filesystem after
> S3 resume. This is masked on many systems because udev/dbus event
> handlers open the /dev/sd* device before filesystem access and the
> open always retries the UNIT_ATTENTION. The fix is to limit the
> original workaround to CDROM drives.

Even better would be quirk for the deice mishandlign the UAs, but I
suspect that's too late now..


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-12  9:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-08 22:33 [PATCH] scsi: Allow retry on UNIT_ATTENTION media changed if not CDROM drive Al Cooper
2015-01-12  9:44 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.