From: James Bottomley <James.Bottomley@SteelEye.com>
To: linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] sd: fix cache flushing on module removal (and individual device removal)
Date: Thu, 31 Aug 2006 18:15:22 -0400 [thread overview]
Message-ID: <1157062522.3666.10.camel@mulgrave.il.steeleye.com> (raw)
In-Reply-To: <1157058484.3666.5.camel@mulgrave.il.steeleye.com>
On Thu, 2006-08-31 at 17:08 -0400, James Bottomley wrote:
> The fix isn't actually in sd: it's in scsi_device_get(). I modified it
> to allow devices to be returned in SDEV_CANCEL, but not SDEV_DEL. This
> means that the device_remove_driver, which occurs in device_del() in
> scsi_remove_device() after the device has gone into SDEV_CANCEL is now
> effective at flushing the cache.
Actually, lets try that again, but with the correct patch.
James
Index: linux-2.6/drivers/scsi/scsi.c
===================================================================
--- linux-2.6.orig/drivers/scsi/scsi.c
+++ linux-2.6/drivers/scsi/scsi.c
@@ -835,14 +835,14 @@ EXPORT_SYMBOL(scsi_track_queue_full);
*/
int scsi_device_get(struct scsi_device *sdev)
{
- if (sdev->sdev_state == SDEV_DEL || sdev->sdev_state == SDEV_CANCEL)
+ if (sdev->sdev_state == SDEV_DEL)
return -ENXIO;
if (!get_device(&sdev->sdev_gendev))
return -ENXIO;
- if (!try_module_get(sdev->host->hostt->module)) {
- put_device(&sdev->sdev_gendev);
- return -ENXIO;
- }
+ /* We can fail this if we're doing SCSI operations
+ * from module exit (like cache flush) */
+ try_module_get(sdev->host->hostt->module);
+
return 0;
}
EXPORT_SYMBOL(scsi_device_get);
@@ -857,7 +857,10 @@ EXPORT_SYMBOL(scsi_device_get);
*/
void scsi_device_put(struct scsi_device *sdev)
{
- module_put(sdev->host->hostt->module);
+ /* The module refcount will be zero if scsi_device_get()
+ * was called from a module removal routine */
+ if (likely(module_refcount(sdev->host->hostt->module) != 0))
+ module_put(sdev->host->hostt->module);
put_device(&sdev->sdev_gendev);
}
EXPORT_SYMBOL(scsi_device_put);
next prev parent reply other threads:[~2006-08-31 22:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-31 21:08 [PATCH] sd: fix cache flushing on module removal (and individual device removal) James Bottomley
2006-08-31 22:15 ` James Bottomley [this message]
2006-09-01 9:02 ` Stefan Richter
2006-09-01 13:54 ` James Bottomley
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=1157062522.3666.10.camel@mulgrave.il.steeleye.com \
--to=james.bottomley@steeleye.com \
--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