aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_scan.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2014-06-25 09:27:39 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-17 16:07:39 -0400
commitd9e5d6183715e691b37afd3785c311d05cd1338d (patch)
treeb7b85fb5f76d647fe128972dadfe0157c8703478 /drivers/scsi/scsi_scan.c
parent1abf635d2f3332641570e1913e317073834a055f (diff)
scsi_scan: Fixup scsilun_to_int()
scsilun_to_int() has an error which prevents it from generating correct LUN numbers for 64bit values. Also we should remove the misleading comment about portions of the LUN being ignored; the initiator should treat the LUN as an opaque value. And, finally, the example given should use the correct prefix (here: extended flat space addressing scheme). This patch includes the modifications suggested by Bart van Assche. Cc: Bart van Assche <bvanassche@acm.org> Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Hannes Reinecke <hare@suse.de> Reviewed-by: James Bottomley <jbottomley@parallels.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/scsi_scan.c')
-rw-r--r--drivers/scsi/scsi_scan.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index fa57a046f025..784d4e648cf5 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1263,14 +1263,15 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget,
1263 * truncation before using this function. 1263 * truncation before using this function.
1264 * 1264 *
1265 * Notes: 1265 * Notes:
1266 * The struct scsi_lun is assumed to be four levels, with each level
1267 * effectively containing a SCSI byte-ordered (big endian) short; the
1268 * addressing bits of each level are ignored (the highest two bits).
1269 * For a description of the LUN format, post SCSI-3 see the SCSI 1266 * For a description of the LUN format, post SCSI-3 see the SCSI
1270 * Architecture Model, for SCSI-3 see the SCSI Controller Commands. 1267 * Architecture Model, for SCSI-3 see the SCSI Controller Commands.
1271 * 1268 *
1272 * Given a struct scsi_lun of: 0a 04 0b 03 00 00 00 00, this function returns 1269 * Given a struct scsi_lun of: d2 04 0b 03 00 00 00 00, this function
1273 * the integer: 0x0b030a04 1270 * returns the integer: 0x0b03d204
1271 *
1272 * This encoding will return a standard integer LUN for LUNs smaller
1273 * than 256, which typically use a single level LUN structure with
1274 * addressing method 0.
1274 **/ 1275 **/
1275u64 scsilun_to_int(struct scsi_lun *scsilun) 1276u64 scsilun_to_int(struct scsi_lun *scsilun)
1276{ 1277{
@@ -1279,8 +1280,8 @@ u64 scsilun_to_int(struct scsi_lun *scsilun)
1279 1280
1280 lun = 0; 1281 lun = 0;
1281 for (i = 0; i < sizeof(lun); i += 2) 1282 for (i = 0; i < sizeof(lun); i += 2)
1282 lun = lun | (((scsilun->scsi_lun[i] << 8) | 1283 lun = lun | (((u64)scsilun->scsi_lun[i] << ((i + 1) * 8)) |
1283 scsilun->scsi_lun[i + 1]) << (i * 8)); 1284 ((u64)scsilun->scsi_lun[i + 1] << (i * 8)));
1284 return lun; 1285 return lun;
1285} 1286}
1286EXPORT_SYMBOL(scsilun_to_int); 1287EXPORT_SYMBOL(scsilun_to_int);
@@ -1294,13 +1295,10 @@ EXPORT_SYMBOL(scsilun_to_int);
1294 * Reverts the functionality of the scsilun_to_int, which packed 1295 * Reverts the functionality of the scsilun_to_int, which packed
1295 * an 8-byte lun value into an int. This routine unpacks the int 1296 * an 8-byte lun value into an int. This routine unpacks the int
1296 * back into the lun value. 1297 * back into the lun value.
1297 * Note: the scsilun_to_int() routine does not truly handle all
1298 * 8bytes of the lun value. This functions restores only as much
1299 * as was set by the routine.
1300 * 1298 *
1301 * Notes: 1299 * Notes:
1302 * Given an integer : 0x0b030a04, this function returns a 1300 * Given an integer : 0x0b03d204, this function returns a
1303 * scsi_lun of : struct scsi_lun of: 0a 04 0b 03 00 00 00 00 1301 * struct scsi_lun of: d2 04 0b 03 00 00 00 00
1304 * 1302 *
1305 **/ 1303 **/
1306void int_to_scsilun(u64 lun, struct scsi_lun *scsilun) 1304void int_to_scsilun(u64 lun, struct scsi_lun *scsilun)