* [PATCH] split busy check out of scsi_remove_host
@ 2002-11-20 23:39 Christoph Hellwig
0 siblings, 0 replies; only message in thread
From: Christoph Hellwig @ 2002-11-20 23:39 UTC (permalink / raw)
To: James.Bottomley; +Cc: linux-scsi
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-11-20 23:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-20 23:39 [PATCH] split busy check out of scsi_remove_host 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.