Re: Merge I2O patches from -mm

From: Christoph Hellwig
Date: Tue Aug 17 2004 - 11:59:28 EST



The patch below adds a __scsi_add_device that can "preload" sdev->hostdata.


--- 1.127/drivers/scsi/scsi_scan.c 2004-06-25 13:56:28 +02:00
+++ edited/drivers/scsi/scsi_scan.c 2004-08-17 20:41:07 +02:00
@@ -200,7 +200,7 @@
* scsi_Device pointer, or NULL on failure.
**/
static struct scsi_device *scsi_alloc_sdev(struct Scsi_Host *shost,
- uint channel, uint id, uint lun)
+ uint channel, uint id, uint lun, void *hostdata)
{
struct scsi_device *sdev, *device;
unsigned long flags;
@@ -224,6 +224,8 @@
INIT_LIST_HEAD(&sdev->starved_entry);
spin_lock_init(&sdev->list_lock);

+ /* usually NULL and set by ->slave_alloc instead */
+ sdev->hostdata = hostdata;

/* if the device needs this changing, it may do so in the
* slave_configure function */
@@ -697,7 +699,7 @@
**/
static int scsi_probe_and_add_lun(struct Scsi_Host *host,
uint channel, uint id, uint lun, int *bflagsp,
- struct scsi_device **sdevp, int rescan)
+ struct scsi_device **sdevp, int rescan, void *hostdata)
{
struct scsi_device *sdev;
struct scsi_request *sreq;
@@ -726,7 +728,7 @@
}
}

- sdev = scsi_alloc_sdev(host, channel, id, lun);
+ sdev = scsi_alloc_sdev(host, channel, id, lun, hostdata);
if (!sdev)
goto out;
sreq = scsi_allocate_request(sdev, GFP_ATOMIC);
@@ -874,7 +876,7 @@
*/
for (lun = 1; lun < max_dev_lun; ++lun)
if ((scsi_probe_and_add_lun(shost, channel, id, lun,
- NULL, NULL, rescan) != SCSI_SCAN_LUN_PRESENT) &&
+ NULL, NULL, rescan, NULL) != SCSI_SCAN_LUN_PRESENT) &&
!sparse_lun)
return;
}
@@ -1085,7 +1087,7 @@
int res;

res = scsi_probe_and_add_lun(sdev->host, sdev->channel,
- sdev->id, lun, NULL, NULL, rescan);
+ sdev->id, lun, NULL, NULL, rescan, NULL);
if (res == SCSI_SCAN_NO_RESPONSE) {
/*
* Got some results, but now none, abort.
@@ -1111,14 +1113,15 @@
return 0;
}

-struct scsi_device *scsi_add_device(struct Scsi_Host *shost,
- uint channel, uint id, uint lun)
+struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
+ uint id, uint lun, void *hostdata)
{
struct scsi_device *sdev;
int res;

down(&shost->scan_mutex);
- res = scsi_probe_and_add_lun(shost, channel, id, lun, NULL, &sdev, 1);
+ res = scsi_probe_and_add_lun(shost, channel, id, lun, NULL,
+ &sdev, 1, hostdata);
if (res != SCSI_SCAN_LUN_PRESENT)
sdev = ERR_PTR(-ENODEV);
up(&shost->scan_mutex);
@@ -1178,7 +1181,7 @@
* Scan for a specific host/chan/id/lun.
*/
scsi_probe_and_add_lun(shost, channel, id, lun, NULL, NULL,
- rescan);
+ rescan, NULL);
return;
}

@@ -1187,7 +1190,7 @@
* would not configure LUN 0 until all LUNs are scanned.
*/
res = scsi_probe_and_add_lun(shost, channel, id, 0, &bflags, &sdev,
- rescan);
+ rescan, NULL);
if (res == SCSI_SCAN_LUN_PRESENT) {
if (scsi_report_lun_scan(sdev, bflags, rescan) != 0)
/*
@@ -1316,7 +1319,7 @@
{
struct scsi_device *sdev;

- sdev = scsi_alloc_sdev(shost, 0, shost->this_id, 0);
+ sdev = scsi_alloc_sdev(shost, 0, shost->this_id, 0, NULL);
if (sdev) {
sdev->borken = 0;
}
===== drivers/scsi/scsi_syms.c 1.49 vs edited =====
--- 1.49/drivers/scsi/scsi_syms.c 2004-06-27 00:40:24 +02:00
+++ edited/drivers/scsi/scsi_syms.c 2004-08-17 20:50:22 +02:00
@@ -73,7 +73,7 @@

EXPORT_SYMBOL(scsi_io_completion);

-EXPORT_SYMBOL(scsi_add_device);
+EXPORT_SYMBOL(__scsi_add_device);
EXPORT_SYMBOL(scsi_remove_device);
EXPORT_SYMBOL(scsi_device_cancel);

--- 1.19/include/scsi/scsi_device.h 2004-07-07 18:24:13 +02:00
+++ edited/include/scsi/scsi_device.h 2004-08-17 20:42:18 +02:00
@@ -129,8 +129,10 @@
#define transport_class_to_sdev(class_dev) \
container_of(class_dev, struct scsi_device, transport_classdev)

-extern struct scsi_device *scsi_add_device(struct Scsi_Host *,
- uint, uint, uint);
+extern struct scsi_device *__scsi_add_device(struct Scsi_Host *,
+ uint, uint, uint, void *hostdata);
+#define scsi_add_device(host, channel, target, lun) \
+ __scsi_add_device(host, channel, target, lun, NULL)
extern void scsi_remove_device(struct scsi_device *);
extern int scsi_device_cancel(struct scsi_device *, int);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/