From: Christoph Hellwig <hch@lst.de>
To: James.Bottomley@steeleye.com
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH] split busy check out of scsi_remove_host
Date: Thu, 21 Nov 2002 00:39:56 +0100 [thread overview]
Message-ID: <20021121003956.B8517@lst.de> (raw)
just a simple code cleanup
--- 1.31/drivers/scsi/hosts.c Sun Nov 17 16:47:02 2002
+++ edited/drivers/scsi/hosts.c Wed Nov 20 02:20:15 2002
@@ -208,6 +208,48 @@
return 0;
}
+static int scsi_check_device_busy(struct scsi_device *sdev)
+{
+ struct Scsi_Host *shost = sdev->host;
+ struct scsi_cmnd *scmd;
+
+ /*
+ * Loop over all of the commands associated with the
+ * device. If any of them are busy, then set the state
+ * back to inactive and bail.
+ */
+ for (scmd = sdev->device_queue; scmd; scmd = scmd->next) {
+ if (scmd->request && scmd->request->rq_status != RQ_INACTIVE)
+ goto active;
+
+ /*
+ * No, this device is really free. Mark it as such, and
+ * continue on.
+ */
+ scmd->state = SCSI_STATE_DISCONNECTING;
+ if (scmd->request)
+ scmd->request->rq_status = RQ_SCSI_DISCONNECTING;
+ }
+
+ return 0;
+
+active:
+ printk(KERN_ERR "SCSI device not inactive - rq_status=%d, target=%d, "
+ "pid=%ld, state=%d, owner=%d.\n",
+ scmd->request->rq_status, scmd->target,
+ scmd->pid, scmd->state, scmd->owner);
+
+ for (sdev = shost->host_queue; sdev; sdev = sdev->next) {
+ for (scmd = sdev->device_queue; scmd; scmd = scmd->next) {
+ if (scmd->request->rq_status == RQ_SCSI_DISCONNECTING)
+ scmd->request->rq_status = RQ_INACTIVE;
+ }
+ }
+
+ printk(KERN_ERR "Device busy???\n");
+ return 1;
+}
+
/**
* scsi_remove_host - check a scsi host for release and release
* @shost: a pointer to a scsi host to release
@@ -218,7 +260,6 @@
int scsi_remove_host(struct Scsi_Host *shost)
{
struct scsi_device *sdev;
- struct scsi_cmnd *scmd;
/*
* FIXME Do ref counting. We force all of the devices offline to
@@ -228,43 +269,9 @@
for (sdev = shost->host_queue; sdev; sdev = sdev->next)
sdev->online = FALSE;
- for (sdev = shost->host_queue; sdev; sdev = sdev->next) {
- /*
- * Loop over all of the commands associated with the
- * device. If any of them are busy, then set the state
- * back to inactive and bail.
- */
- for (scmd = sdev->device_queue; scmd; scmd = scmd->next) {
- if (scmd->request && scmd->request->rq_status !=
- RQ_INACTIVE) {
- printk(KERN_ERR "SCSI device not inactive"
- "- rq_status=%d, target=%d, pid=%ld,"
- "state=%d, owner=%d.\n",
- scmd->request->rq_status,
- scmd->target, scmd->pid,
- scmd->state, scmd->owner);
- for (sdev = shost->host_queue; sdev;
- sdev = sdev->next) {
- for (scmd = sdev->device_queue; scmd;
- scmd = scmd->next)
- if (scmd->request->rq_status ==
- RQ_SCSI_DISCONNECTING)
- scmd->request->rq_status = RQ_INACTIVE;
- }
- printk(KERN_ERR "Device busy???\n");
- return 1;
- }
- /*
- * No, this device is really free. Mark it as such, and
- * continue on.
- */
- scmd->state = SCSI_STATE_DISCONNECTING;
- if (scmd->request)
- scmd->request->rq_status =
- RQ_SCSI_DISCONNECTING; /* Mark as
- busy */
- }
- }
+ for (sdev = shost->host_queue; sdev; sdev = sdev->next)
+ if (scsi_check_device_busy(sdev))
+ return 1;
/*
* Next we detach the high level drivers from the Scsi_Device
reply other threads:[~2002-11-20 23:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20021121003956.B8517@lst.de \
--to=hch@lst.de \
--cc=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 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.