All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk, axboe@suse.de,
	albertcc@tw.ibm.com, forrest.zhao@intel.com, efalk@google.com,
	linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 07/14] libata-hp-prep: store attached SCSI device
Date: Fri, 12 May 2006 00:02:35 +0900	[thread overview]
Message-ID: <11473597553604-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11473597542442-git-send-email-htejun@gmail.com>

Add device persistent field dev->sdev and store the attached SCSI
device.  With hotplug, libata needs to know the attached SCSI device
to offline and detach it, but scsi_device_lookup() cannot be used
because libata will reuse SCSI ID numbers - dead but not gone devices
(due to zombie opens, etc...) interfere with the lookup.

dev->sdev doesn't hold reference to the SCSI device.  It's cleared
when the SCSI device goes away.

---

 drivers/scsi/libata-scsi.c |   14 ++++++++++----
 include/linux/libata.h     |    1 +
 2 files changed, 11 insertions(+), 4 deletions(-)

e04f46cf173e4b7f837ac75400eac20e2dd0d057
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 0316bc1..7827844 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -2738,17 +2738,23 @@ void ata_scsi_simulate(struct ata_device
 
 void ata_scsi_scan_host(struct ata_port *ap)
 {
-	struct ata_device *dev;
 	unsigned int i;
 
 	if (ap->flags & ATA_FLAG_DISABLED)
 		return;
 
 	for (i = 0; i < ATA_MAX_DEVICES; i++) {
-		dev = &ap->device[i];
+		struct ata_device *dev = &ap->device[i];
+		struct scsi_device *sdev;
 
-		if (ata_dev_enabled(dev))
-			scsi_scan_target(&ap->host->shost_gendev, 0, i, 0, 0);
+		if (!ata_dev_enabled(dev) || dev->sdev)
+			continue;
+
+		sdev = __scsi_add_device(ap->host, 0, i, 0, NULL);
+		if (!IS_ERR(sdev)) {
+			dev->sdev = sdev;
+			scsi_device_put(sdev);
+		}
 	}
 }
 
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 6ab988a..f4a544e 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -411,6 +411,7 @@ struct ata_device {
 	struct ata_port		*ap;
 	unsigned int		devno;		/* 0 or 1 */
 	unsigned long		flags;		/* ATA_DFLAG_xxx */
+	struct scsi_device	*sdev;		/* attached SCSI device */
 	/* fields above n_sectors are not cleared across device init */
 	u64			n_sectors;	/* size of device, if ATA */
 	unsigned int		class;		/* ATA_DEV_xxx */
-- 
1.2.4



  parent reply	other threads:[~2006-05-11 15:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-11 15:02 [PATCHSET 06/11] prep for hotplug support, take 2 Tejun Heo
2006-05-11 15:02 ` [PATCH 01/14] libata-hp-prep: add flags and eh_info/context fields for hotplug Tejun Heo
2006-05-11 15:02 ` [PATCH 02/14] libata-hp-prep: implement ata_dev_init() Tejun Heo
2006-05-11 15:02 ` [PATCH 03/14] libata-hp-prep: make some ata_device fields persistent Tejun Heo
2006-05-11 15:02 ` [PATCH 04/14] libata-hp-prep: update ata_scsi_find_dev() and friends Tejun Heo
2006-05-11 15:02 ` [PATCH 06/14] libata-hp-prep: implement ap->hw_sata_spd_limit Tejun Heo
2006-05-11 15:02 ` [PATCH 12/14] libata-hp-prep: implement ata_noop_check_status() Tejun Heo
2006-05-11 15:02 ` Tejun Heo [this message]
2006-05-11 15:02 ` [PATCH 13/14] libata-hp-prep: add prereset() method and implement ata_std_prereset() Tejun Heo
2006-05-11 15:02 ` [PATCH 10/14] libata-hp-prep: implement sata_phy_debounce() Tejun Heo
2006-05-11 15:02 ` [PATCH 14/14] libata-hp-prep: implement followup softreset handling Tejun Heo
2006-05-11 15:02 ` [PATCH 08/14] libata-hp-prep: add ata_hotplug_wq Tejun Heo
2006-05-11 15:02 ` [PATCH 11/14] libata-hp-prep: make ops->tf_read() optional Tejun Heo
2006-05-11 15:02 ` [PATCH 05/14] libata-hp-prep: use __ata_scsi_find_dev() Tejun Heo
2006-05-11 15:02 ` [PATCH 09/14] libata-hp-prep: make probing related functions global Tejun Heo
2006-05-13 23:01 ` [PATCHSET 06/11] prep for hotplug support, take 2 Jeff Garzik
2006-05-14  0:07   ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2006-05-11 15:11 [PATCHSET 07/11] prep LLDDs for hotplug support, take 1 Tejun Heo
2006-05-11 15:11 ` [PATCH 07/14] libata-hp-prep: store attached SCSI device Tejun Heo
2006-05-19 13:06 [PATCH 06/14] libata-hp-prep: implement ap->hw_sata_spd_limit Tejun Heo
2006-05-19 13:06 ` [PATCH 07/14] libata-hp-prep: store attached SCSI device Tejun Heo
2006-05-19 13:16 [PATCHSET 01/03] prep for hotplug support, take 3 Tejun Heo
2006-05-19 13:16 ` [PATCH 07/14] libata-hp-prep: store attached SCSI device Tejun Heo
2006-05-19 15:04   ` Jeff Garzik

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=11473597553604-git-send-email-htejun@gmail.com \
    --to=htejun@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=albertcc@tw.ibm.com \
    --cc=axboe@suse.de \
    --cc=efalk@google.com \
    --cc=forrest.zhao@intel.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@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.