[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1812041135300.1537-100000@iolanthe.rowland.org>
Date: Tue, 4 Dec 2018 11:36:51 -0500 (EST)
From: Alan Stern <stern@...land.harvard.edu>
To: "Zengtao (B)" <prime.zeng@...ilicon.com>
cc: Martin Petersen <martin.petersen@...cle.com>,
"jejb@...ux.vnet.ibm.com" <jejb@...ux.vnet.ibm.com>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"usb-storage@...ts.one-eyed-alien.net"
<usb-storage@...ts.one-eyed-alien.net>
Subject: RE: scsi_set_medium_removal timeout issue
On Thu, 29 Nov 2018, Zengtao (B) wrote:
> Ping?
>
> >-----Original Message-----
> >From: Alan Stern [mailto:stern@...land.harvard.edu]
> >Sent: Wednesday, November 14, 2018 11:35 PM
> >To: Martin Petersen <martin.petersen@...cle.com>; Zengtao (B)
> ><prime.zeng@...ilicon.com>
> >Cc: jejb@...ux.vnet.ibm.com; gregkh@...uxfoundation.org;
> >linux-scsi@...r.kernel.org; linux-kernel@...r.kernel.org;
> >linux-usb@...r.kernel.org; usb-storage@...ts.one-eyed-alien.net
> >Subject: RE: scsi_set_medium_removal timeout issue
> >
> >On Wed, 14 Nov 2018, Zengtao (B) wrote:
> >
> >> I just enabled the scsi log in the middle of the umount operation,
> >> otherwise I can't reproduce the issue when the scsi log is enabled.
> >>
> >> >from the beginning. In any case, it wasn't what I wanted. I asked
> >> >you to post the dmesg log, not the SCSI log.
> >>
> >> Please refer to the new attachment for dmesg log.
> >
> >Heh, yes, I see now.
> >
> >Martin, shouldn't sd_release() call sd_sync_cache() in the same way that
> >sd_shutdown() does, before it calls scsi_set_medium_removal()?
> >
> >Alan Stern
I don't know if this is the right thing to do, but you can try out the
following patch to see if it helps.
Alan Stern
Index: usb-4.x/drivers/scsi/sd.c
===================================================================
--- usb-4.x.orig/drivers/scsi/sd.c
+++ usb-4.x/drivers/scsi/sd.c
@@ -113,6 +113,7 @@ static void sd_shutdown(struct device *)
static int sd_suspend_system(struct device *);
static int sd_suspend_runtime(struct device *);
static int sd_resume(struct device *);
+static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr);
static void sd_rescan(struct device *);
static int sd_init_command(struct scsi_cmnd *SCpnt);
static void sd_uninit_command(struct scsi_cmnd *SCpnt);
@@ -1393,8 +1394,14 @@ static void sd_release(struct gendisk *d
SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_release\n"));
if (atomic_dec_return(&sdkp->openers) == 0 && sdev->removable) {
- if (scsi_block_when_processing_errors(sdev))
+ if (scsi_block_when_processing_errors(sdev)) {
+ if (sdkp->WCE && sdkp->media_present) {
+ sd_printk(KERN_NOTICE, sdkp,
+ "Synchronizing SCSI cache\n");
+ sd_sync_cache(sdkp, NULL);
+ }
scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
+ }
}
/*
Powered by blists - more mailing lists