From 462b7859a07c9c2b060fa2b5b1d49f8b33706d4e Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Tue, 19 Jun 2007 10:25:30 +0200 Subject: [SCSI] zfcp: Report FCP LUN to SCSI midlayer When reporting SCSI devices to the SCSI midlayer, use the FCP LUN as LUN reported to the SCSI layer. With this approach, zfcp does not have to create unique LUNS, and this code can be removed. Signed-off-by: Christof Schmitt Signed-off-by: Swen Schillig Signed-off-by: James Bottomley --- drivers/scsi/scsi_scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/scsi_scan.c') diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index a67f315244d..5df28e2fd3b 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1204,7 +1204,7 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget, * Given a struct scsi_lun of: 0a 04 0b 03 00 00 00 00, this function returns * the integer: 0x0b030a04 **/ -static int scsilun_to_int(struct scsi_lun *scsilun) +int scsilun_to_int(struct scsi_lun *scsilun) { int i; unsigned int lun; @@ -1215,6 +1215,7 @@ static int scsilun_to_int(struct scsi_lun *scsilun) scsilun->scsi_lun[i + 1]) << (i * 8)); return lun; } +EXPORT_SYMBOL(scsilun_to_int); /** * int_to_scsilun: reverts an int into a scsi_lun -- cgit v1.2.3 From 6d877688ef411313c94aa3c83c7473fbec6db32c Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Wed, 11 Jul 2007 12:54:55 -0600 Subject: [SCSI] Clean up scsi_add_lun a bit This patch tidies up scsi_add_lun a bit. I rewrote the kerneldoc to match the actual parameters, moved the check for RBC and MMC REPORT_LUN devices away from the switch(), changed the setup of sdev->type to account for BLIST_ISROM, moved the check for BLIST_NO_ULD_ATTACH further down in the function, removed a bogus comment and fixed some whitespace issues. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/scsi_scan.c | 64 ++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 38 deletions(-) (limited to 'drivers/scsi/scsi_scan.c') diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 5df28e2fd3b..0827df2ebb6 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -694,16 +694,14 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, /** * scsi_add_lun - allocate and fully initialze a scsi_device - * @sdevscan: holds information to be stored in the new scsi_device - * @sdevnew: store the address of the newly allocated scsi_device + * @sdev: holds information to be stored in the new scsi_device * @inq_result: holds the result of a previous INQUIRY to the LUN * @bflags: black/white list flag + * @async: 1 if this device is being scanned asynchronously * * Description: - * Allocate and initialize a scsi_device matching sdevscan. Optionally - * set fields based on values in *@bflags. If @sdevnew is not - * NULL, store the address of the new scsi_device in *@sdevnew (needed - * when scanning a particular LUN). + * Initialize the scsi_device @sdev. Optionally set fields based + * on values in *@bflags. * * Return: * SCSI_SCAN_NO_RESPONSE: could not allocate or setup a scsi_device @@ -743,25 +741,15 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, sdev->rev = (char *) (sdev->inquiry + 32); if (*bflags & BLIST_ISROM) { - /* - * It would be better to modify sdev->type, and set - * sdev->removable; this can now be done since - * print_inquiry has gone away. - */ - inq_result[0] = TYPE_ROM; - inq_result[1] |= 0x80; /* removable */ - } else if (*bflags & BLIST_NO_ULD_ATTACH) - sdev->no_uld_attach = 1; + sdev->type = TYPE_ROM; + sdev->removable = 1; + } else { + sdev->type = (inq_result[0] & 0x1f); + sdev->removable = (inq_result[1] & 0x80) >> 7; + } - switch (sdev->type = (inq_result[0] & 0x1f)) { + switch (sdev->type) { case TYPE_RBC: - /* RBC devices can return SCSI-3 compliance and yet - * still not support REPORT LUNS, so make them act as - * BLIST_NOREPORTLUN unless BLIST_REPORTLUN2 is - * specifically set */ - if ((*bflags & BLIST_REPORTLUN2) == 0) - *bflags |= BLIST_NOREPORTLUN; - /* fall through */ case TYPE_TAPE: case TYPE_DISK: case TYPE_PRINTER: @@ -775,13 +763,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, sdev->writeable = 1; break; case TYPE_ROM: - /* MMC devices can return SCSI-3 compliance and yet - * still not support REPORT LUNS, so make them act as - * BLIST_NOREPORTLUN unless BLIST_REPORTLUN2 is - * specifically set */ - if ((*bflags & BLIST_REPORTLUN2) == 0) - *bflags |= BLIST_NOREPORTLUN; - /* fall through */ case TYPE_WORM: sdev->writeable = 0; break; @@ -789,6 +770,15 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, printk(KERN_INFO "scsi: unknown device type %d\n", sdev->type); } + if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) { + /* RBC and MMC devices can return SCSI-3 compliance and yet + * still not support REPORT LUNS, so make them act as + * BLIST_NOREPORTLUN unless BLIST_REPORTLUN2 is + * specifically set */ + if ((*bflags & BLIST_REPORTLUN2) == 0) + *bflags |= BLIST_NOREPORTLUN; + } + /* * For a peripheral qualifier (PQ) value of 1 (001b), the SCSI * spec says: The device server is capable of supporting the @@ -806,12 +796,11 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, */ sdev->inq_periph_qual = (inq_result[0] >> 5) & 7; - sdev->removable = (0x80 & inq_result[1]) >> 7; sdev->lockable = sdev->removable; sdev->soft_reset = (inq_result[7] & 1) && ((inq_result[3] & 7) == 2); - if (sdev->scsi_level >= SCSI_3 || (sdev->inquiry_len > 56 && - inq_result[56] & 0x04)) + if (sdev->scsi_level >= SCSI_3 || + (sdev->inquiry_len > 56 && inq_result[56] & 0x04)) sdev->ppr = 1; if (inq_result[7] & 0x60) sdev->wdtr = 1; @@ -824,13 +813,10 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, sdev->inq_periph_qual, inq_result[2] & 0x07, (inq_result[3] & 0x0f) == 1 ? " CCS" : ""); - /* - * End sysfs code. - */ - if ((sdev->scsi_level >= SCSI_2) && (inq_result[7] & 2) && !(*bflags & BLIST_NOTQ)) sdev->tagged_supported = 1; + /* * Some devices (Texel CD ROM drives) have handshaking problems * when used with the Seagate controllers. borken is initialized @@ -839,6 +825,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, if ((*bflags & BLIST_BORKEN) == 0) sdev->borken = 0; + if (*bflags & BLIST_NO_ULD_ATTACH) + sdev->no_uld_attach = 1; + /* * Apparently some really broken devices (contrary to the SCSI * standards) need to be selected without asserting ATN @@ -863,7 +852,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, if (*bflags & BLIST_SINGLELUN) sdev->single_lun = 1; - sdev->use_10_for_rw = 1; if (*bflags & BLIST_MS_SKIP_PAGE_08) -- cgit v1.2.3