From: Mike Christie <michaelc@cs.wisc.edu>
To: Bart Van Assche <bvanassche@acm.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
James Bottomley <jbottomley@parallels.com>,
Jun'ichi Nomura <j-nomura@ce.jp.nec.com>,
Stefan Richter <stefanr@s5r6.in-berlin.de>,
Tomas Henzl <thenzl@redhat.com>,
Mike Snitzer <snitzer@redhat.com>
Subject: Re: [PATCH 2/3] Stop accepting SCSI requests before removing a device
Date: Fri, 04 May 2012 15:30:42 -0500 [thread overview]
Message-ID: <4FA43C72.3000108@cs.wisc.edu> (raw)
In-Reply-To: <4FA43912.2060706@cs.wisc.edu>
[-- Attachment #1: Type: text/plain, Size: 1781 bytes --]
On 05/04/2012 03:16 PM, Mike Christie wrote:
> On 05/04/2012 10:06 AM, Bart Van Assche wrote:
>> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
>> index 42c35ff..f8fc240 100644
>> --- a/drivers/scsi/scsi_sysfs.c
>> +++ b/drivers/scsi/scsi_sysfs.c
>> @@ -955,12 +955,20 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
>> void __scsi_remove_device(struct scsi_device *sdev)
>> {
>> struct device *dev = &sdev->sdev_gendev;
>> + struct request_queue *q = sdev->request_queue;
>> +
>> + /*
>> + * Stop accepting new requests before tearing down the
>> + * device. Note: the actual queue deallocation happens in
>> + * scsi_device_dev_release_usercontext().
>> + */
>> + blk_cleanup_queue(q);
>>
>> if (sdev->is_visible) {
>> if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
>> return;
>>
>> - bsg_unregister_queue(sdev->request_queue);
>> + bsg_unregister_queue(q);
>> device_unregister(&sdev->sdev_dev);
>> transport_remove_device(dev);
>> device_del(dev);
>> @@ -971,8 +979,6 @@ void __scsi_remove_device(struct scsi_device *sdev)
>
> My fault. The blk_cleanup_queue call should be right before the
> scsi_device_set_state(sdev, SDEV_DEL); call in this function.
>
> It needs to be after the device_del call, because that triggers the SCSI
> ULD removal which can send IO.
>
I made the attached patch. It allows the scsi ULD removal IO to execute
ok. I tested with iscsi devices that have write caches.
With your patch I get:
Apr 27 19:09:51 noisyr6 kernel: sd 11:0:0:1: [sdc] Synchronizing SCSI cache
Apr 27 19:09:51 noisyr6 kernel: sd 11:0:0:1: [sdc] Result:
hostbyte=DID_TRANSPORT_FAILFAST driverbyte=DRIVER_OK
With my patch I just get:
May 4 16:29:27 noisyr6 kernel: sd 8:0:0:1: [sdc] Synchronizing SCSI cache
[-- Attachment #2: scsi-clean-queue-after-del.patch --]
[-- Type: text/x-patch, Size: 1165 bytes --]
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 42c35ff..11dc3ff 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -955,24 +955,30 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
void __scsi_remove_device(struct scsi_device *sdev)
{
struct device *dev = &sdev->sdev_gendev;
+ struct request_queue *q = sdev->request_queue;
if (sdev->is_visible) {
if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
return;
- bsg_unregister_queue(sdev->request_queue);
+ bsg_unregister_queue(q);
device_unregister(&sdev->sdev_dev);
transport_remove_device(dev);
device_del(dev);
} else
put_device(&sdev->sdev_dev);
+ /*
+ * Stop accepting new requests before tearing down the
+ * queue. Note: the actual queue deallocation happens in
+ * scsi_device_dev_release_usercontext().
+ */
+ blk_cleanup_queue(q);
+
scsi_device_set_state(sdev, SDEV_DEL);
if (sdev->host->hostt->slave_destroy)
sdev->host->hostt->slave_destroy(sdev);
transport_destroy_device(dev);
- /* Freeing the queue signals to block that we're done */
- blk_cleanup_queue(sdev->request_queue);
put_device(dev);
}
next prev parent reply other threads:[~2012-05-04 20:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-04 15:00 [PATCH 0/3 v6] Fixes for SCSI device removal Bart Van Assche
2012-05-04 15:03 ` [PATCH 1/3] sd: Fix device removal NULL pointer dereference Bart Van Assche
2012-05-04 15:06 ` [PATCH 2/3] Stop accepting SCSI requests before removing a device Bart Van Assche
2012-05-04 20:16 ` Mike Christie
2012-05-04 20:30 ` Mike Christie [this message]
2012-05-05 13:04 ` Bart Van Assche
2012-05-29 15:00 ` Bart Van Assche
2012-05-29 17:35 ` Mike Christie
2012-05-30 6:56 ` Bart Van Assche
2012-05-30 17:27 ` Mike Christie
2012-05-30 20:00 ` Bart Van Assche
2012-06-01 3:13 ` Mike Christie
2012-05-04 15:07 ` [PATCH 3/3] Make scsi_free_queue() abort pending requests Bart Van Assche
2012-05-04 20:25 ` Mike Christie
2012-05-04 20:32 ` Mike Christie
2012-05-05 6:07 ` Bart Van Assche
2012-05-07 0:44 ` Mike Christie
2012-05-07 1:15 ` Mike Christie
2012-05-14 18:43 ` Bart Van Assche
2012-05-29 14:56 ` Bart Van Assche
2012-05-05 13:41 ` Bart Van Assche
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=4FA43C72.3000108@cs.wisc.edu \
--to=michaelc@cs.wisc.edu \
--cc=bvanassche@acm.org \
--cc=j-nomura@ce.jp.nec.com \
--cc=jbottomley@parallels.com \
--cc=linux-scsi@vger.kernel.org \
--cc=snitzer@redhat.com \
--cc=stefanr@s5r6.in-berlin.de \
--cc=thenzl@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).