From: Mike Anderson <andmike@us.ibm.com>
To: linux-scsi@vger.kernel.org
Subject: [PATCH 5/5] scsi host / scsi target state model update
Date: Thu, 16 Jun 2005 11:16:11 -0700 [thread overview]
Message-ID: <20050616181611.GF20923@us.ibm.com> (raw)
In-Reply-To: <20050616181518.GE20923@us.ibm.com>
Use new SCSI target state model in scsi_forget_host to help with list
traversal and deletion of devices.
Signed-off-by: Mike Anderson <andmike@us.ibm.com>
---
linux-2.6.12-rc6-mm1-andmike/drivers/scsi/scsi_scan.c | 32 +++++++++--------
linux-2.6.12-rc6-mm1-andmike/drivers/scsi/scsi_sysfs.c | 1
2 files changed, 18 insertions(+), 15 deletions(-)
diff -puN drivers/scsi/scsi_scan.c~tgt_remove drivers/scsi/scsi_scan.c
--- linux-2.6.12-rc6-mm1/drivers/scsi/scsi_scan.c~tgt_remove 2005-06-16 10:48:38.000000000 -0700
+++ linux-2.6.12-rc6-mm1-andmike/drivers/scsi/scsi_scan.c 2005-06-16 10:48:38.000000000 -0700
@@ -1414,25 +1414,27 @@ EXPORT_SYMBOL(scsi_scan_single_target);
void scsi_forget_host(struct Scsi_Host *shost)
{
- struct scsi_target *starget, *tmp;
+ struct scsi_target *starget;
unsigned long flags;
- /*
- * Ok, this look a bit strange. We always look for the first device
- * on the list as scsi_remove_device removes them from it - thus we
- * also have to release the lock.
- * We don't need to get another reference to the device before
- * releasing the lock as we already own the reference from
- * scsi_register_device that's release in scsi_remove_device. And
- * after that we don't look at sdev anymore.
- */
- spin_lock_irqsave(shost->host_lock, flags);
- list_for_each_entry_safe(starget, tmp, &shost->__targets, siblings) {
- spin_unlock_irqrestore(shost->host_lock, flags);
- scsi_remove_target(&starget->dev);
+ while (1) {
+ starget = NULL;
spin_lock_irqsave(shost->host_lock, flags);
+ list_for_each_entry(starget, &shost->__targets, siblings) {
+ if (starget->stgt_state == STGT_DEL)
+ continue;
+ if (starget->stgt_state != STGT_CANCEL) {
+ scsi_target_set_state(starget, STGT_CANCEL);
+ break;
+ }
+ }
+ spin_unlock_irqrestore(shost->host_lock, flags);
+
+ if (starget && starget->stgt_state != STGT_DEL)
+ scsi_remove_target(&starget->dev);
+ else
+ return;
}
- spin_unlock_irqrestore(shost->host_lock, flags);
}
/*
diff -puN drivers/scsi/scsi_sysfs.c~tgt_remove drivers/scsi/scsi_sysfs.c
--- linux-2.6.12-rc6-mm1/drivers/scsi/scsi_sysfs.c~tgt_remove 2005-06-16 10:48:38.000000000 -0700
+++ linux-2.6.12-rc6-mm1-andmike/drivers/scsi/scsi_sysfs.c 2005-06-16 10:48:38.000000000 -0700
@@ -750,6 +750,7 @@ void __scsi_remove_target(struct scsi_ta
scsi_remove_device(sdev);
spin_lock_irqsave(shost->host_lock, flags);
}
+ scsi_target_set_state(starget, STGT_DEL);
spin_unlock_irqrestore(shost->host_lock, flags);
scsi_target_reap(starget);
}
_
next prev parent reply other threads:[~2005-06-16 18:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-16 18:10 [PATCH 0/5] scsi host / scsi target state model update Mike Anderson
2005-06-16 18:12 ` [PATCH 1/5] " Mike Anderson
2005-06-16 18:13 ` [PATCH 2/5] " Mike Anderson
2005-06-16 18:14 ` [PATCH 3/5] " Mike Anderson
2005-06-16 18:15 ` [PATCH 4/5] " Mike Anderson
2005-06-16 18:16 ` Mike Anderson [this message]
2005-07-12 16:44 ` 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=20050616181611.GF20923@us.ibm.com \
--to=andmike@us.ibm.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.