Skip to contentSkip to conversation

Fixed for 64bit LUNs

PATCH In review Hannes Reinecke 5 participants 22 messages Jul 4, 2014 – Jul 7, 2014

Subsystems (22)
SCSI PowerPC Staging InfiniBand +18 more subsystems
lore
Share & tools
lore
#0 lore raw

cover Fixed for 64bit LUNs

Hi Christoph,

here are some more fixes for 64bit LUNs, which should fix the latest built issues from Fengguang.
Most notably I've introduced a new accessor 'sdev_scsi2lun' for those devices which are not capable of handling LUNs higher than 255. And I've removed the custom LUN handling code from ib_srp.

Hannes Reinecke (2):
Use sdev_scsi2lun for SCSI parallel drivers
ib_srp: 64bit LUN fixes

 arch/ia64/hp/sim/simscsi.c            |  2 +-
 drivers/infiniband/ulp/srp/ib_srp.c   |  9 ++--
 drivers/infiniband/ulp/srpt/ib_srpt.c | 81 +--------------------------------
 drivers/scsi/53c700.c                 | 12 ++---
 drivers/scsi/BusLogic.c               |  2 +-
 drivers/scsi/NCR5380.c                | 32 ++++++-------
 drivers/scsi/NCR53c406a.c             |  2 +-
 drivers/scsi/a100u2w.c                |  4 +-
 drivers/scsi/advansys.c               | 16 +++----
 drivers/scsi/aha152x.c                | 13 +++---
 drivers/scsi/aha1542.c                |  4 +-
 drivers/scsi/aha1740.c                |  2 +-
 drivers/scsi/aic7xxx/aic79xx_osm.c    | 19 ++++----
 drivers/scsi/aic7xxx/aic79xx_proc.c   |  2 +-
 drivers/scsi/aic7xxx/aic7xxx_osm.c    | 23 +++++-----
 drivers/scsi/aic7xxx/aic7xxx_proc.c   |  2 +-
 drivers/scsi/arm/acornscsi.c          | 20 ++++----
 drivers/scsi/arm/fas216.c             | 15 +++---
 drivers/scsi/arm/queue.c              |  8 ++--
 drivers/scsi/atari_NCR5380.c          | 81 +++++++++++++++++----------------
 drivers/scsi/atp870u.c                |  2 +-
 drivers/scsi/bnx2fc/bnx2fc_io.c       |  4 +-
 drivers/scsi/ch.c                     | 16 +++----
 drivers/scsi/dc395x.c                 | 73 ++++++++++++++---------------
 drivers/scsi/eata.c                   |  4 +-
 drivers/scsi/eata_pio.c               |  2 +-
 drivers/scsi/esp_scsi.c               |  6 +--
 drivers/scsi/g_NCR5380.c              |  2 +-
 drivers/scsi/gdth.c                   |  4 +-
 drivers/scsi/hptiop.c                 |  6 +--
 drivers/scsi/in2000.c                 | 36 ++++++++-------
 drivers/scsi/initio.c                 |  4 +-
 drivers/scsi/megaraid.c               | 10 ++--
 drivers/scsi/mesh.c                   |  6 +--
 drivers/scsi/mvumi.c                  |  2 +-
 drivers/scsi/ncr53c8xx.c              | 33 +++++++-------
 drivers/scsi/nsp32.c                  | 14 +++---
 drivers/scsi/ps3rom.c                 |  2 +-
 drivers/scsi/qlogicpti.c              |  6 +--
 drivers/scsi/scsi.c                   |  2 +-
 drivers/scsi/stex.c                   |  2 +-
 drivers/scsi/sun3_NCR5380.c           | 86 +++++++++++++++++++----------------
 drivers/scsi/sym53c8xx_2/sym_glue.c   | 19 ++++----
 drivers/scsi/sym53c8xx_2/sym_hipd.c   | 10 ++--
 drivers/scsi/tmscsim.c                | 12 +++--
 drivers/scsi/u14-34f.c                |  6 +--
 drivers/scsi/ufs/ufshcd.c             |  4 +-
 drivers/scsi/ultrastor.c              |  2 +-
 drivers/scsi/wd33c93.c                | 35 ++++++++------
 drivers/scsi/wd7000.c                 |  3 +-
 drivers/staging/rts5208/rtsx.c        |  4 +-
 include/scsi/scsi_device.h            |  5 ++
 52 files changed, 373 insertions(+), 398 deletions(-)
Signature · 1 line
1.7.12.4
#1 lore raw

PATCH 1/2 Use sdev_scsi2lun for SCSI parallel drivers

SCSI-2 defines only up to 256 LUNs with a flat namespace. This patch introduces an accessor 'sdev_scsi2lun' which should be used for these drivers to avoid problems when using 64-bit LUNs internally.

---
 arch/ia64/hp/sim/simscsi.c          |  2 +-
 drivers/scsi/53c700.c               | 12 +++---
 drivers/scsi/BusLogic.c             |  2 +-
 drivers/scsi/NCR5380.c              | 32 +++++++-------
 drivers/scsi/NCR53c406a.c           |  2 +-
 drivers/scsi/a100u2w.c              |  4 +-
 drivers/scsi/advansys.c             | 16 +++----
 drivers/scsi/aha152x.c              | 13 +++---
 drivers/scsi/aha1542.c              |  4 +-
 drivers/scsi/aha1740.c              |  2 +-
 drivers/scsi/aic7xxx/aic79xx_osm.c  | 19 ++++----
 drivers/scsi/aic7xxx/aic79xx_proc.c |  2 +-
 drivers/scsi/aic7xxx/aic7xxx_osm.c  | 23 +++++-----
 drivers/scsi/aic7xxx/aic7xxx_proc.c |  2 +-
 drivers/scsi/arm/acornscsi.c        | 20 +++++----
 drivers/scsi/arm/fas216.c           | 15 ++++---
 drivers/scsi/arm/queue.c            |  8 ++--
 drivers/scsi/atari_NCR5380.c        | 81 ++++++++++++++++++----------------
 drivers/scsi/atp870u.c              |  2 +-
 drivers/scsi/bnx2fc/bnx2fc_io.c     |  4 +-
 drivers/scsi/ch.c                   | 16 +++----
 drivers/scsi/dc395x.c               | 73 +++++++++++++++----------------
 drivers/scsi/eata.c                 |  4 +-
 drivers/scsi/eata_pio.c             |  2 +-
 drivers/scsi/esp_scsi.c             |  6 +--
 drivers/scsi/g_NCR5380.c            |  2 +-
 drivers/scsi/gdth.c                 |  4 +-
 drivers/scsi/hptiop.c               |  6 +--
 drivers/scsi/in2000.c               | 36 +++++++++-------
 drivers/scsi/initio.c               |  4 +-
 drivers/scsi/megaraid.c             | 10 ++---
 drivers/scsi/mesh.c                 |  6 +--
 drivers/scsi/mvumi.c                |  2 +-
 drivers/scsi/ncr53c8xx.c            | 33 +++++++-------
 drivers/scsi/nsp32.c                | 14 +++---
 drivers/scsi/ps3rom.c               |  2 +-
 drivers/scsi/qlogicpti.c            |  6 +--
 drivers/scsi/scsi.c                 |  2 +-
 drivers/scsi/stex.c                 |  2 +-
 drivers/scsi/sun3_NCR5380.c         | 86 +++++++++++++++++++++----------------
 drivers/scsi/sym53c8xx_2/sym_glue.c | 19 ++++----
 drivers/scsi/sym53c8xx_2/sym_hipd.c | 10 ++---
 drivers/scsi/tmscsim.c              | 12 ++++--
 drivers/scsi/u14-34f.c              |  6 +--
 drivers/scsi/ufs/ufshcd.c           |  4 +-
 drivers/scsi/ultrastor.c            |  2 +-
 drivers/scsi/wd33c93.c              | 35 ++++++++-------
 drivers/scsi/wd7000.c               |  3 +-
 drivers/staging/rts5208/rtsx.c      |  4 +-
 include/scsi/scsi_device.h          |  5 +++
 50 files changed, 366 insertions(+), 315 deletions(-)
arch/ia64/hp/sim/simscsi.c +1 -1
index 3a428f1..3abd6fa 100644
@@ -219,7 +219,7 @@ simscsi_queuecommand_lck (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)
 
 	sc->result = DID_BAD_TARGET << 16;
 	sc->scsi_done = done;
-	if (target_id <= 15 && sc->device->lun == 0) {
+	if (target_id <= 15 && sdev_scsi2lun(sc->device) == 0) {
 		switch (sc->cmnd[0]) {
 		      case INQUIRY:
 			if (scsi_bufflen(sc) < 35) {
drivers/scsi/53c700.c +6 -6
index a3adfb4..d91811d 100644
@@ -792,7 +792,7 @@ process_extended_message(struct Scsi_Host *host,
 
 	if(SCp != NULL) {
 		pun = SCp->device->id;
-		lun = SCp->device->lun;
+		lun = sdev_scsi2lun(SCp->device);
 	}
 
 	switch(hostdata->msgin[2]) {
@@ -875,7 +875,7 @@ process_message(struct Scsi_Host *host,	struct NCR_700_Host_Parameters *hostdata
 
 	if(SCp != NULL) {
 		pun = SCp->device->id;
-		lun = SCp->device->lun;
+		lun = sdev_scsi2lun(SCp->device);
 	}
 
 #ifdef NCR_700_DEBUG
@@ -962,7 +962,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
 
 	if(SCp != NULL) {
 		pun = SCp->device->id;
-		lun = SCp->device->lun;
+		lun = sdev_scsi2lun(SCp->device);
 	}
 
 	if(dsps == A_GOOD_STATUS_AFTER_STATUS) {
@@ -1005,7 +1005,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
 						 DMA_TO_DEVICE);
 
 				cmnd[0] = REQUEST_SENSE;
-				cmnd[1] = (SCp->device->lun & 0x7) << 5;
+				cmnd[1] = sdev_scsi2lun(SCp->device) << 5;
 				cmnd[2] = 0;
 				cmnd[3] = 0;
 				cmnd[4] = SCSI_SENSE_BUFFERSIZE;
@@ -1415,7 +1415,7 @@ NCR_700_start_command(struct scsi_cmnd *SCp)
 
 	hostdata->msgout[0] = NCR_700_identify((SCp->cmnd[0] != REQUEST_SENSE &&
 						slot->flags != NCR_700_FLAG_AUTOSENSE),
-					       SCp->device->lun);
+					       sdev_scsi2lun(SCp->device));
 	/* for INQUIRY or REQUEST_SENSE commands, we cannot be sure
 	 * if the negotiated transfer parameters still hold, so
 	 * always renegotiate them */
@@ -1528,7 +1528,7 @@ NCR_700_intr(int irq, void *dev_id)
 
 		if(SCp != NULL) {
 			pun = SCp->device->id;
-			lun = SCp->device->lun;
+			lun = sdev_scsi2lun(SCp->device);
 		}
 
 		if(sstat0 & SCSI_RESET_DETECTED) {
drivers/scsi/BusLogic.c +1 -1
index 972f817..6dd99b6 100644
@@ -3032,7 +3032,7 @@ static int blogic_qcmd_lck(struct scsi_cmnd *command,
 	unsigned char *cdb = command->cmnd;
 	int cdblen = command->cmd_len;
 	int tgt_id = command->device->id;
-	int lun = command->device->lun;
+	int lun = sdev_scsi2lun(command->device);
 	int buflen = scsi_bufflen(command);
 	int count;
 	struct blogic_ccb *ccb;
drivers/scsi/NCR5380.c +16 -16
index 2893d6a..4e5440d 100644
@@ -762,7 +762,7 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m,
 
 static void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m)
 {
-	SPRINTF("scsi%d : destination target %d, lun %d\n", cmd->device->host->host_no, cmd->device->id, (u8)cmd->device->lun);
+	SPRINTF("scsi%d : destination target %d, lun %d\n", cmd->device->host->host_no, cmd->device->id, sdev_scsi2lun(cmd->device));
 	SPRINTF("        command = ");
 	lprint_command(cmd->cmnd, m);
 }
@@ -1039,9 +1039,9 @@ static void NCR5380_main(struct work_struct *work)
 			for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble) 
 			{
 				if (prev != tmp)
-				    dprintk(NDEBUG_LISTS, "MAIN tmp=%p   target=%d   busy=%d lun=%d\n", tmp, tmp->device->id, hostdata->busy[tmp->device->id], (u8)tmp->device->lun);
+					dprintk(NDEBUG_LISTS, "MAIN tmp=%p   target=%d   busy=%d lun=%d\n", tmp, tmp->device->id, hostdata->busy[tmp->device->id], sdev_scsi2lun(tmp->device));
 				/*  When we find one, remove it from the issue queue. */
-				if (!(hostdata->busy[tmp->device->id] & (1 << tmp->device->lun))) {
+				if (!(hostdata->busy[tmp->device->id] & (1 << sdev_scsi2lun(tmp->device)))) {
 					if (prev) {
 						REMOVE(prev, prev->host_scribble, tmp, tmp->host_scribble);
 						prev->host_scribble = tmp->host_scribble;
@@ -1057,7 +1057,7 @@ static void NCR5380_main(struct work_struct *work)
 					 * On failure, we must add the command back to the
 					 *   issue queue so we can keep trying. 
 					 */
-					dprintk(NDEBUG_MAIN|NDEBUG_QUEUES, "scsi%d : main() : command for target %d lun %d removed from issue_queue\n", instance->host_no, tmp->device->id, (u8)tmp->device->lun);
+					dprintk(NDEBUG_MAIN|NDEBUG_QUEUES, "scsi%d : main() : command for target %d lun %d removed from issue_queue\n", instance->host_no, tmp->device->id, sdev_scsi2lun(tmp->device));
 	
 					/*
 					 * A successful selection is defined as one that 
@@ -1512,7 +1512,7 @@ part2:
 	}
 
 	dprintk(NDEBUG_SELECTION, "scsi%d : target %d selected, going into MESSAGE OUT phase.\n", instance->host_no, cmd->device->id);
-	tmp[0] = IDENTIFY(((instance->irq == SCSI_IRQ_NONE) ? 0 : 1), cmd->device->lun);
+	tmp[0] = IDENTIFY(((instance->irq == SCSI_IRQ_NONE) ? 0 : 1), sdev_scsi2lun(cmd->device));
 
 	len = 1;
 	cmd->tag = 0;
@@ -1524,7 +1524,7 @@ part2:
 	dprintk(NDEBUG_SELECTION, "scsi%d : nexus established.\n", instance->host_no);
 	/* XXX need to handle errors here */
 	hostdata->connected = cmd;
-	hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF));
+	hostdata->busy[cmd->device->id] |= (1 << sdev_scsi2lun(cmd->device));
 
 	initialize_SCp(cmd);
 
@@ -2210,14 +2210,14 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
 				case LINKED_FLG_CMD_COMPLETE:
 					/* Accept message by clearing ACK */
 					NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-					dprintk(NDEBUG_LINKED, "scsi%d : target %d lun %d linked command complete.\n", instance->host_no, cmd->device->id, (u8)cmd->device->lun);
+					dprintk(NDEBUG_LINKED, "scsi%d : target %d lun %d linked command complete.\n", instance->host_no, cmd->device->id, sdev_scsi2lun(cmd->device));
 					/* 
 					 * Sanity check : A linked command should only terminate with
 					 * one of these messages if there are more linked commands
 					 * available.
 					 */
 					if (!cmd->next_link) {
-					    printk("scsi%d : target %d lun %d linked command complete, no next_link\n" instance->host_no, cmd->device->id, (u8)cmd->device->lun);
+						printk("scsi%d : target %d lun %d linked command complete, no next_link\n" instance->host_no, cmd->device->id, sdev_scsi2lun(cmd->device));
 						sink = 1;
 						do_abort(instance);
 						return;
@@ -2226,7 +2226,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
 					/* The next command is still part of this process */
 					cmd->next_link->tag = cmd->tag;
 					cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
-					dprintk(NDEBUG_LINKED, "scsi%d : target %d lun %d linked request done, calling scsi_done().\n", instance->host_no, cmd->device->id, (u8)cmd->device->lun);
+					dprintk(NDEBUG_LINKED, "scsi%d : target %d lun %d linked request done, calling scsi_done().\n", instance->host_no, cmd->device->id, sdev_scsi2lun(cmd->device));
 					collect_stats(hostdata, cmd);
 					cmd->scsi_done(cmd);
 					cmd = hostdata->connected;
@@ -2238,8 +2238,8 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
 					sink = 1;
 					NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 					hostdata->connected = NULL;
-					dprintk(NDEBUG_QUEUES, "scsi%d : command for target %d, lun %d completed\n", instance->host_no, cmd->device->id, (u8)cmd->device->lun);
-					hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xFF));
+					dprintk(NDEBUG_QUEUES, "scsi%d : command for target %d, lun %d completed\n", instance->host_no, cmd->device->id, sdev_scsi2lun(cmd->device));
+					hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 
 					/* 
 					 * I'm not sure what the correct thing to do here is : 
@@ -2304,7 +2304,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
 					case ORDERED_QUEUE_TAG:
 					case SIMPLE_QUEUE_TAG:
 						cmd->device->simple_tags = 0;
-						hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF));
+						hostdata->busy[cmd->device->id] |= (1 << sdev_scsi2lun(cmd->device));
 						break;
 					default:
 						break;
@@ -2318,7 +2318,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
 						    hostdata->disconnected_queue;
 						hostdata->connected = NULL;
 						hostdata->disconnected_queue = cmd;
-						dprintk(NDEBUG_QUEUES, "scsi%d : command for target %d lun %d was moved from connected to" "  the disconnected_queue\n", instance->host_no, cmd->device->id, (u8)cmd->device->lun);
+						dprintk(NDEBUG_QUEUES, "scsi%d : command for target %d lun %d was moved from connected to" "  the disconnected_queue\n", instance->host_no, cmd->device->id, sdev_scsi2lun(cmd->device));
 						/* 
 						 * Restore phase bits to 0 so an interrupted selection, 
 						 * arbitration can resume.
@@ -2426,7 +2426,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
 				hostdata->last_message = msgout;
 				NCR5380_transfer_pio(instance, &phase, &len, &data);
 				if (msgout == ABORT) {
-					hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xFF));
+					hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 					hostdata->connected = NULL;
 					cmd->result = DID_ERROR << 16;
 					collect_stats(hostdata, cmd);
@@ -2562,7 +2562,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) {
 
 
 		for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble)
-			if ((target_mask == (1 << tmp->device->id)) && (lun == (u8)tmp->device->lun)
+			if ((target_mask == (1 << tmp->device->id)) && (lun == sdev_scsi2lun(tmp->device))
 			    ) {
 				if (prev) {
 					REMOVE(prev, prev->host_scribble, tmp, tmp->host_scribble);
@@ -2588,7 +2588,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) {
 		do_abort(instance);
 	} else {
 		hostdata->connected = tmp;
-		dprintk(NDEBUG_RESELECTION, "scsi%d : nexus established, target = %d, lun = %d, tag = %d\n", instance->host_no, tmp->device->id, (u8)tmp->device->lun, tmp->tag);
+		dprintk(NDEBUG_RESELECTION, "scsi%d : nexus established, target = %d, lun = %d, tag = %d\n", instance->host_no, tmp->device->id, sdev_scsi2lun(tmp->device), tmp->tag);
 	}
 }
 
drivers/scsi/NCR53c406a.c +1 -1
index c91888a..1e44137 100644
@@ -698,7 +698,7 @@ static int NCR53c406a_queue_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
 	int i;
 
 	VDEB(printk("NCR53c406a_queue called\n"));
-	DEB(printk("cmd=%02x, cmd_len=%02x, target=%02x, lun=%02x, bufflen=%d\n", SCpnt->cmnd[0], SCpnt->cmd_len, SCpnt->target, SCpnt->lun, scsi_bufflen(SCpnt)));
+	DEB(printk("cmd=%02x, cmd_len=%02x, target=%02x, lun=%02x, bufflen=%d\n", SCpnt->cmnd[0], SCpnt->cmd_len, SCpnt->device->target, sdev_scsi2lun(SCpnt->device), scsi_bufflen(SCpnt)));
 
 #if 0
 	VDEB(for (i = 0; i < SCpnt->cmd_len; i++)
drivers/scsi/a100u2w.c +2 -2
index 0163457..fe0596b 100644
@@ -855,7 +855,7 @@ static int inia100_build_scb(struct orc_host * host, struct orc_scb * scb, struc
 	scb->opcode = ORC_EXECSCSI;
 	scb->flags = SCF_NO_DCHK;	/* Clear done bit               */
 	scb->target = cmd->device->id;
-	scb->lun = cmd->device->lun;
+	scb->lun = sdev_scsi2lun(cmd->device);
 	scb->reserved0 = 0;
 	scb->reserved1 = 0;
 	scb->sg_len = cpu_to_le32(0);
@@ -891,7 +891,7 @@ static int inia100_build_scb(struct orc_host * host, struct orc_scb * scb, struc
 		printk("max cdb length= %x\b", cmd->cmd_len);
 		scb->cdb_len = IMAX_CDB;
 	}
-	scb->ident = cmd->device->lun | DISC_ALLOW;
+	scb->ident = sdev_scsi2lun(cmd->device) | DISC_ALLOW;
 	if (cmd->device->tagged_supported) {	/* Tag Support                  */
 		scb->tag_msg = SIMPLE_QUEUE_TAG;	/* Do simple tag only   */
 	} else {
drivers/scsi/advansys.c +8 -8
index e716d0a..11a8ec5 100644
@@ -7688,7 +7688,7 @@ advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
 	ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
 	ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
 
-	if (sdev->lun == 0) {
+	if (sdev_scsi2lun(sdev) == 0) {
 		ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
 		if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
 			asc_dvc->init_sdtr |= tid_bit;
@@ -7702,7 +7702,7 @@ advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
 
 	if (sdev->tagged_supported) {
 		if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
-			if (sdev->lun == 0) {
+			if (sdev_scsi2lun(sdev) == 0) {
 				asc_dvc->cfg->can_tagged_qng |= tid_bit;
 				asc_dvc->use_tagged_qng |= tid_bit;
 			}
@@ -7710,14 +7710,14 @@ advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
 						asc_dvc->max_dvc_qng[sdev->id]);
 		}
 	} else {
-		if (sdev->lun == 0) {
+		if (sdev_scsi2lun(sdev) == 0) {
 			asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
 			asc_dvc->use_tagged_qng &= ~tid_bit;
 		}
 		scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
 	}
 
-	if ((sdev->lun == 0) &&
+	if ((sdev_scsi2lun(sdev) == 0) &&
 	    (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
 		AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
 				 asc_dvc->cfg->disc_enable);
@@ -7815,7 +7815,7 @@ advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
 	AdvPortAddr iop_base = adv_dvc->iop_base;
 	unsigned short tidmask = 1 << sdev->id;
 
-	if (sdev->lun == 0) {
+	if (sdev_scsi2lun(sdev) == 0) {
 		/*
 		 * Handle WDTR, SDTR, and Tag Queuing. If the feature
 		 * is enabled in the EEPROM and the device supports the
@@ -7907,9 +7907,9 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	asc_scsi_q->cdbptr = &scp->cmnd[0];
 	asc_scsi_q->q2.cdb_len = scp->cmd_len;
 	asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
-	asc_scsi_q->q1.target_lun = scp->device->lun;
+	asc_scsi_q->q1.target_lun = sdev_scsi2lun(scp->device);
 	asc_scsi_q->q2.target_ix =
-	    ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
+		ASC_TIDLUN_TO_IX(scp->device->id, sdev_scsi2lun(scp->device));
 	asc_scsi_q->q1.sense_addr = advansys_get_sense_buffer_dma(scp);
 	asc_scsi_q->q1.sense_len = SCSI_SENSE_BUFFERSIZE;
 
@@ -8167,7 +8167,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 	}
 
 	scsiqp->target_id = scp->device->id;
-	scsiqp->target_lun = scp->device->lun;
+	scsiqp->target_lun = sdev_scsi2lun(scp->device);
 
 	scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
 	scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
drivers/scsi/aha152x.c +7 -6
index e77b72f..b08fa37 100644
@@ -321,7 +321,7 @@ static LIST_HEAD(aha152x_host_list);
 #define CMDINFO(cmd) \
 			(cmd) ? ((cmd)->device->host->host_no) : -1, \
                         (cmd) ? ((cmd)->device->id & 0x0f) : -1, \
-			(cmd) ? ((u8)(cmd)->device->lun & 0x07) : -1
+			(cmd) ? (sdev_scsi2lun((cmd)->device)) : -1
 
 static inline void
 CMD_INC_RESID(struct scsi_cmnd *cmd, int inc)
@@ -730,7 +730,8 @@ static inline Scsi_Cmnd *remove_lun_SC(Scsi_Cmnd ** SC, int target, int lun)
 	Scsi_Cmnd *ptr, *prev;
 
 	for (ptr = *SC, prev = NULL;
-	     ptr && ((ptr->device->id != target) || (ptr->device->lun != lun));
+	     ptr && ((ptr->device->id != target) ||
+		     sdev_scsi2lun(ptr->device) != lun));
 	     prev = ptr, ptr = SCNEXT(ptr))
 	     ;
 
@@ -1602,7 +1603,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
 #if defined(AHA152X_DEBUG)
 			int hostno=DONE_SC->device->host->host_no;
 			int id=DONE_SC->device->id & 0xf;
-			int lun=((u8)DONE_SC->device->lun) & 0x7;
+			int lun=(sdev_scsi2lun(DONE_SC->device)) & 0x7;
 #endif
 			Scsi_Cmnd *ptr = DONE_SC;
 			DONE_SC=NULL;
@@ -1686,7 +1687,7 @@ static void seldo_run(struct Scsi_Host *shpnt)
 
 	SETPORT(SSTAT0, CLRSELDO);
 	
-	ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun));
+	ADDMSGO(IDENTIFY(RECONNECT, sdev_scsi2lun(CURRENT_SC->device)));
 
 	if (CURRENT_SC->SCp.phase & aborting) {
 		ADDMSGO(ABORT);
@@ -2001,7 +2002,7 @@ static void msgo_init(struct Scsi_Host *shpnt)
 {
 	if(MSGOLEN==0) {
 		if((CURRENT_SC->SCp.phase & syncneg) && SYNCNEG==2 && SYNCRATE==0) {
-			ADDMSGO(IDENTIFY(RECONNECT, CURRENT_SC->device->lun));
+			ADDMSGO(IDENTIFY(RECONNECT, sdev_scsi2lun(CURRENT_SC->device)));
 		} else {
 			printk(INFO_LEAD "unexpected MESSAGE OUT phase; rejecting\n", CMDINFO(CURRENT_SC));
 			ADDMSGO(MESSAGE_REJECT);
@@ -2984,7 +2985,7 @@ static void get_command(struct seq_file *m, Scsi_Cmnd * ptr)
 	int i;
 
 	SPRINTF("%p: target=%d; lun=%d; cmnd=( ",
-		ptr, ptr->device->id, (u8)ptr->device->lun);
+		ptr, ptr->device->id, sdev_scsi2lun(ptr->device));
 
 	for (i = 0; i < COMMAND_SIZE(ptr->cmnd[0]); i++)
 		SPRINTF("0x%02x ", ptr->cmnd[i]);
drivers/scsi/aha1542.c +2 -2
index 770c48d..ae2bf2b 100644
@@ -561,7 +561,7 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *
 	unchar direction;
 	unchar *cmd = (unchar *) SCpnt->cmnd;
 	unchar target = SCpnt->device->id;
-	unchar lun = SCpnt->device->lun;
+	unchar lun = sdev_scsi2lun(SCpnt->device);
 	unsigned long flags;
 	int bufflen = scsi_bufflen(SCpnt);
 	int mbo;
@@ -1228,7 +1228,7 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)
 	unsigned long flags;
 	struct mailbox *mb;
 	unchar target = SCpnt->device->id;
-	unchar lun = SCpnt->device->lun;
+	unchar lun = sdev_scsi2lun(SCpnt->device);
 	int mbo;
 	struct ccb *ccb;
 	unchar ahacmd = CMD_START_SCSI;
drivers/scsi/aha1740.c +1 -1
index 5f31017..a1646b4 100644
@@ -417,7 +417,7 @@ static int aha1740_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done)(Scsi_Cmnd *)
 		host->ecb[ecbno].datalen = 0;
 		host->ecb[ecbno].dataptr = 0;
 	}
-	host->ecb[ecbno].lun = SCpnt->device->lun;
+	host->ecb[ecbno].lun = sdev_scsi2lun(SCpnt->device);
 	host->ecb[ecbno].ses = 1; /* Suppress underrun errors */
 	host->ecb[ecbno].dir = direction;
 	host->ecb[ecbno].ars = 1; /* Yes, get the sense on an error */
drivers/scsi/aic7xxx/aic79xx_osm.c +10 -9
index ed333669..5611d4d 100644
@@ -838,7 +838,7 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd)
 	reset_scb->platform_data->xfer_len = 0;
 	reset_scb->hscb->control = 0;
 	reset_scb->hscb->scsiid = BUILD_SCSIID(ahd,cmd);
-	reset_scb->hscb->lun = cmd->device->lun;
+	reset_scb->hscb->lun = sdev_scsi2lun(cmd->device);
 	reset_scb->hscb->cdb_len = 0;
 	reset_scb->hscb->task_management = SIU_TASKMGMT_LUN_RESET;
 	reset_scb->flags |= SCB_DEVICE_RESET|SCB_RECOVERY_SCB|SCB_ACTIVE;
@@ -1537,7 +1537,7 @@ ahd_linux_device_queue_depth(struct scsi_device *sdev)
 
 	ahd_compile_devinfo(&devinfo,
 			    ahd->our_id,
-			    sdev->sdev_target->id, sdev->lun,
+			    sdev->sdev_target->id, sdev_scsi2lun(sdev),
 			    sdev->sdev_target->channel == 0 ? 'A' : 'B',
 			    ROLE_INITIATOR);
 	tags = ahd_linux_user_tagdepth(ahd, &devinfo);
@@ -1584,7 +1584,7 @@ ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev,
 		col_idx = AHD_NEVER_COL_IDX;
 	} else {
 		col_idx = AHD_BUILD_COL_IDX(cmd->device->id,
-					    cmd->device->lun);
+					    sdev_scsi2lun(cmd->device));
 	}
 	if ((scb = ahd_get_scb(ahd, col_idx)) == NULL) {
 		ahd->flags |= AHD_RESOURCE_SHORTAGE;
@@ -1603,7 +1603,7 @@ ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev,
 	 */
 	hscb->control = 0;
 	hscb->scsiid = BUILD_SCSIID(ahd, cmd);
-	hscb->lun = cmd->device->lun;
+	hscb->lun = sdev_scsi2lun(cmd->device);
 	scb->hscb->task_management = 0;
 	mask = SCB_GET_TARGET_MASK(ahd, scb);
 
@@ -1900,7 +1900,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
 
 	ahd_compile_devinfo(&devinfo,
 			    ahd->our_id,
-			    sdev->sdev_target->id, sdev->lun,
+			    sdev->sdev_target->id, sdev_scsi2lun(sdev),
 			    sdev->sdev_target->channel == 0 ? 'A' : 'B',
 			    ROLE_INITIATOR);
 	
@@ -2137,7 +2137,7 @@ ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, struct scsi_cmnd *cmd)
 	if (do_fallback) {
 		printk("%s: device overrun (status %x) on %d:%d:%d\n",
 		       ahd_name(ahd), status, cmd->device->channel,
-		       cmd->device->id, (u8)cmd->device->lun);
+		       cmd->device->id, sdev_scsi2lun(cmd->device));
 	}
 
 	ahd_cmd_set_transaction_status(cmd, new_status);
@@ -2253,13 +2253,13 @@ ahd_linux_queue_abort_cmd(struct scsi_cmnd *cmd)
 	disconnected = TRUE;
 	if (ahd_search_qinfifo(ahd, cmd->device->id, 
 			       cmd->device->channel + 'A',
-			       cmd->device->lun,
+			       sdev_scsi2lun(cmd->device),
 			       pending_scb->hscb->tag,
 			       ROLE_INITIATOR, CAM_REQ_ABORTED,
 			       SEARCH_COMPLETE) > 0) {
 		printk("%s:%d:%d:%d: Cmd aborted from QINFIFO\n",
 		       ahd_name(ahd), cmd->device->channel, 
-		       cmd->device->id, (u8)cmd->device->lun);
+		       cmd->device->id, sdev_scsi2lun(cmd->device));
 		retval = SUCCESS;
 		goto done;
 	}
@@ -2346,7 +2346,8 @@ ahd_linux_queue_abort_cmd(struct scsi_cmnd *cmd)
 		 * to run.
 		 */
 		ahd_search_qinfifo(ahd, cmd->device->id,
-				   cmd->device->channel + 'A', cmd->device->lun,
+				   cmd->device->channel + 'A',
+				   sdev_scsi2lun(cmd->device),
 				   SCB_LIST_NULL, ROLE_INITIATOR,
 				   CAM_REQUEUE_REQ, SEARCH_COMPLETE);
 		ahd_qinfifo_requeue_tail(ahd, pending_scb);
drivers/scsi/aic7xxx/aic79xx_proc.c +1 -1
index 27dbfcc..2e1f92e 100644
@@ -197,7 +197,7 @@ ahd_dump_device_state(struct seq_file *m, struct scsi_device *sdev)
 
 	seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n",
 		  sdev->sdev_target->channel + 'A',
-		   sdev->sdev_target->id, (u8)sdev->lun);
+		   sdev->sdev_target->id, sdev_scsi2lun(sdev));
 
 	seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued);
 	seq_printf(m, "\t\tCommands Active %d\n", dev->active);
drivers/scsi/aic7xxx/aic7xxx_osm.c +12 -11
index d2c9bf3..1232e69 100644
@@ -1404,7 +1404,7 @@ ahc_linux_device_queue_depth(struct scsi_device *sdev)
 	ahc_compile_devinfo(&devinfo,
 			    sdev->sdev_target->channel == 0
 			  ? ahc->our_id : ahc->our_id_b,
-			    sdev->sdev_target->id, sdev->lun,
+			    sdev->sdev_target->id, sdev_scsi2lun(sdev),
 			    sdev->sdev_target->channel == 0 ? 'A' : 'B',
 			    ROLE_INITIATOR);
 	tags = ahc_linux_user_tagdepth(ahc, &devinfo);
@@ -1482,7 +1482,7 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
 	 */
 	hscb->control = 0;
 	hscb->scsiid = BUILD_SCSIID(ahc, cmd);
-	hscb->lun = cmd->device->lun;
+	hscb->lun = sdev_scsi2lun(cmd->device);
 	mask = SCB_GET_TARGET_MASK(ahc, scb);
 	tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb),
 				    SCB_GET_OUR_ID(scb),
@@ -1830,7 +1830,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
 
 	ahc_compile_devinfo(&devinfo,
 			    ahc->our_id,
-			    sdev->sdev_target->id, sdev->lun,
+			    sdev->sdev_target->id, sdev_scsi2lun(sdev),
 			    sdev->sdev_target->channel == 0 ? 'A' : 'B',
 			    ROLE_INITIATOR);
 	
@@ -2110,7 +2110,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
 		 */
 		printk("%s:%d:%d:%d: Is not an active device\n",
 		       ahc_name(ahc), cmd->device->channel, cmd->device->id,
-		       (u8)cmd->device->lun);
+		       sdev_scsi2lun(cmd->device));
 		retval = SUCCESS;
 		goto no_cmd;
 	}
@@ -2118,11 +2118,11 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
 	if ((dev->flags & (AHC_DEV_Q_BASIC|AHC_DEV_Q_TAGGED)) == 0
 	 && ahc_search_untagged_queues(ahc, cmd, cmd->device->id,
 				       cmd->device->channel + 'A',
-				       (u8)cmd->device->lun,
+				       sdev_scsi2lun(cmd->device),
 				       CAM_REQ_ABORTED, SEARCH_COMPLETE) != 0) {
 		printk("%s:%d:%d:%d: Command found on untagged queue\n",
 		       ahc_name(ahc), cmd->device->channel, cmd->device->id,
-		       (u8)cmd->device->lun);
+		       sdev_scsi2lun(cmd->device));
 		retval = SUCCESS;
 		goto done;
 	}
@@ -2182,19 +2182,19 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
 	if (flag == SCB_ABORT) {
 		if (ahc_search_qinfifo(ahc, cmd->device->id,
 				       cmd->device->channel + 'A',
-				       cmd->device->lun,
+				       sdev_scsi2lun(cmd->device),
 				       pending_scb->hscb->tag,
 				       ROLE_INITIATOR, CAM_REQ_ABORTED,
 				       SEARCH_COMPLETE) > 0) {
 			printk("%s:%d:%d:%d: Cmd aborted from QINFIFO\n",
 			       ahc_name(ahc), cmd->device->channel,
-			       cmd->device->id, (u8)cmd->device->lun);
+			       cmd->device->id, sdev_scsi2lun(cmd->device));
 			retval = SUCCESS;
 			goto done;
 		}
 	} else if (ahc_search_qinfifo(ahc, cmd->device->id,
 				      cmd->device->channel + 'A',
-				      cmd->device->lun,
+				      sdev_scsi2lun(cmd->device),
 				      pending_scb->hscb->tag,
 				      ROLE_INITIATOR, /*status*/0,
 				      SEARCH_COUNT) > 0) {
@@ -2270,7 +2270,8 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
 		 */
 		ahc_search_disc_list(ahc, cmd->device->id,
 				     cmd->device->channel + 'A',
-				     cmd->device->lun, pending_scb->hscb->tag,
+				     sdev_scsi2lun(cmd->device),
+				     pending_scb->hscb->tag,
 				     /*stop_on_first*/TRUE,
 				     /*remove*/TRUE,
 				     /*save_state*/FALSE);
@@ -2295,7 +2296,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
 		 */
 		ahc_search_qinfifo(ahc, cmd->device->id,
 				   cmd->device->channel + 'A',
-				   cmd->device->lun, SCB_LIST_NULL,
+				   sdev_scsi2lun(cmd->device), SCB_LIST_NULL,
 				   ROLE_INITIATOR, CAM_REQUEUE_REQ,
 				   SEARCH_COMPLETE);
 		ahc_qinfifo_requeue_tail(ahc, pending_scb);
drivers/scsi/aic7xxx/aic7xxx_proc.c +1 -1
index 64eec6c..e7787c6 100644
@@ -175,7 +175,7 @@ ahc_dump_device_state(struct seq_file *m, struct scsi_device *sdev)
 
 	seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n",
 		  sdev->sdev_target->channel + 'A',
-		   sdev->sdev_target->id, (u8)sdev->lun);
+		   sdev->sdev_target->id, sdev_scsi2lun(sdev));
 
 	seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued);
 	seq_printf(m, "\t\tCommands Active %d\n", dev->active);
drivers/scsi/arm/acornscsi.c +12 -8
index 2e797a3..e0336e7 100644
@@ -760,7 +760,8 @@ intr_ret_t acornscsi_kick(AS_Host *host)
 	    SCpnt->tag = SCpnt->device->current_tag;
 	} else
 #endif
-	    set_bit(SCpnt->device->id * 8 + SCpnt->device->lun, host->busyluns);
+		set_bit(SCpnt->device->id * 8 + sdev_scsi2lun(SCpnt->device),
+			host->busyluns);
 
 	host->stats.removes += 1;
 
@@ -863,7 +864,8 @@ static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp,
 	if (!SCpnt->scsi_done)
 	    panic("scsi%d.H: null scsi_done function in acornscsi_done", host->host->host_no);
 
-	clear_bit(SCpnt->device->id * 8 + SCpnt->device->lun, host->busyluns);
+	clear_bit(SCpnt->device->id * 8 + sdev_scsi2lun(SCpnt->device),
+		  host->busyluns);
 
 	SCpnt->scsi_done(SCpnt);
     } else
@@ -1576,7 +1578,7 @@ void acornscsi_message(AS_Host *host)
 	    printk(KERN_NOTICE "scsi%d.%c: disabling tagged queueing\n",
 		    host->host->host_no, acornscsi_target(host));
 	    host->SCpnt->device->simple_tags = 0;
-	    set_bit(host->SCpnt->device->id * 8 + host->SCpnt->device->lun, host->busyluns);
+	    set_bit(host->SCpnt->device->id * 8 + sdev_scsi2lun(host->SCpnt->device), host->busyluns);
 	    break;
 #endif
 	case EXTENDED_MESSAGE | (EXTENDED_SDTR << 8):
@@ -1688,7 +1690,7 @@ void acornscsi_buildmessages(AS_Host *host)
 
     msgqueue_addmsg(&host->scsi.msgs, 1,
 		     IDENTIFY(host->device[host->SCpnt->device->id].disconnect_ok,
-			     host->SCpnt->device->lun));
+			      sdev_scsi2lun(host->SCpnt->device)));
 
 #if 0
     /* does the device need the current command aborted */
@@ -1788,7 +1790,8 @@ int acornscsi_reconnect(AS_Host *host)
     host->scsi.reconnected.tag = 0;
 
     if (host->scsi.disconnectable && host->SCpnt &&
-	host->SCpnt->device->id == target && host->SCpnt->device->lun == lun)
+	host->SCpnt->device->id == target &&
+	sdev_scsi2lun(host->SCpnt->device) == lun)
 	ok = 1;
 
     if (!ok && queue_probetgtlun(&host->queues.disconnected, target, lun))
@@ -1826,7 +1829,7 @@ int acornscsi_reconnect_finish(AS_Host *host)
     if (host->scsi.disconnectable && host->SCpnt) {
 	host->scsi.disconnectable = 0;
 	if (host->SCpnt->device->id  == host->scsi.reconnected.target &&
-	    host->SCpnt->device->lun == host->scsi.reconnected.lun &&
+	    sdev_scsi2lun(host->SCpnt->device) == host->scsi.reconnected.lun &&
 	    host->SCpnt->tag         == host->scsi.reconnected.tag) {
 #if (DEBUG & (DEBUG_QUEUES|DEBUG_DISCON))
 	    DBG(host->SCpnt, printk("scsi%d.%c: reconnected",
@@ -2671,7 +2674,8 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt)
 //#if (DEBUG & DEBUG_ABORT)
 		printk("clear ");
 //#endif
-		clear_bit(SCpnt->device->id * 8 + SCpnt->device->lun, host->busyluns);
+		clear_bit(SCpnt->device->id * 8 + sdev_scsi2lun(SCpnt->device),
+			  host->busyluns);
 
 	/*
 	 * We found the command, and cleared it out.  Either
@@ -2853,7 +2857,7 @@ static int acornscsi_show_info(struct seq_file *m, struct Scsi_Host *instance)
 
     shost_for_each_device(scd, instance) {
 	seq_printf(m, "Device/Lun TaggedQ      Sync\n");
-	seq_printf(m, "     %d/%d   ", scd->id, scd->lun);
+	seq_printf(m, "     %d/%d   ", scd->id, sdev_scsi2lun(scd));
 	if (scd->tagged_supported)
 		seq_printf(m, "%3sabled(%3d) ",
 			     scd->simple_tags ? "en" : "dis",
drivers/scsi/arm/fas216.c +9 -6
index b46a6f6..2dd52e7 100644
@@ -989,7 +989,7 @@ fas216_reselected_intr(FAS216_Info *info)
 	if (info->scsi.disconnectable && info->SCpnt) {
 		info->scsi.disconnectable = 0;
 		if (info->SCpnt->device->id  == target &&
-		    info->SCpnt->device->lun == lun &&
+		    sdev_scsi2lun(info->SCpnt->device) == lun &&
 		    info->SCpnt->tag         == tag) {
 			fas216_log(info, LOG_CONNECT, "reconnected previously executing command");
 		} else {
@@ -1780,7 +1780,8 @@ static void fas216_start_command(FAS216_Info *info, struct scsi_cmnd *SCpnt)
 	 * build outgoing message bytes
 	 */
 	msgqueue_flush(&info->scsi.msgs);
-	msgqueue_addmsg(&info->scsi.msgs, 1, IDENTIFY(disconnect_ok, SCpnt->device->lun));
+	msgqueue_addmsg(&info->scsi.msgs, 1,
+			IDENTIFY(disconnect_ok, sdev_scsi2lun(SCpnt->device)));
 
 	/*
 	 * add tag message if required
@@ -1821,7 +1822,8 @@ static void fas216_allocate_tag(FAS216_Info *info, struct scsi_cmnd *SCpnt)
 			SCpnt->tag = SCpnt->device->current_tag;
 	} else
 #endif
-		set_bit(SCpnt->device->id * 8 + SCpnt->device->lun, info->busyluns);
+		set_bit(SCpnt->device->id * 8 + sdev_scsi2lun(SCpnt->device),
+			info->busyluns);
 
 	info->stats.removes += 1;
 	switch (SCpnt->cmnd[0]) {
@@ -2171,7 +2173,7 @@ static void fas216_done(FAS216_Info *info, unsigned int result)
 	 * status.
 	 */
 	info->device[SCpnt->device->id].parity_check = 0;
-	clear_bit(SCpnt->device->id * 8 + SCpnt->device->lun, info->busyluns);
+	clear_bit(SCpnt->device->id * 8 + sdev_scsi2lun(SCpnt->device), info->busyluns);
 
 	fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned int))SCpnt->host_scribble;
 	fn(info, SCpnt, result);
@@ -2398,7 +2400,8 @@ static enum res_find fas216_find_command(FAS216_Info *info,
 		 * been set.
 		 */
 		info->origSCpnt = NULL;
-		clear_bit(SCpnt->device->id * 8 + SCpnt->device->lun, info->busyluns);
+		clear_bit(SCpnt->device->id * 8 + sdev_scsi2lun(SCpnt->device),
+			  info->busyluns);
 		printk("waiting for execution ");
 		res = res_success;
 	} else
@@ -3000,7 +3003,7 @@ void fas216_print_devices(FAS216_Info *info, struct seq_file *m)
 
 	shost_for_each_device(scd, info->host) {
 		dev = &info->device[scd->id];
-		seq_printf(m, "     %d/%d   ", scd->id, scd->lun);
+		seq_printf(m, "     %d/%d   ", scd->id, sdev_scsi2lun(scd));
 		if (scd->tagged_supported)
 			seq_printf(m, "%3sabled(%3d) ",
 				     scd->simple_tags ? "en" : "dis",
drivers/scsi/arm/queue.c +5 -3
index cb11cce..d62b48e 100644
@@ -167,7 +167,7 @@ struct scsi_cmnd *queue_remove_exclude(Queue_t *queue, unsigned long *exclude)
 	spin_lock_irqsave(&queue->queue_lock, flags);
 	list_for_each(l, &queue->head) {
 		QE_t *q = list_entry(l, QE_t, list);
-		if (!test_bit(q->SCpnt->device->id * 8 + q->SCpnt->device->lun, exclude)) {
+		if (!test_bit(q->SCpnt->device->id * 8 + sdev_scsi2lun(q->SCpnt->device), exclude)) {
 			SCpnt = __queue_remove(queue, l);
 			break;
 		}
@@ -215,7 +215,8 @@ struct scsi_cmnd *queue_remove_tgtluntag(Queue_t *queue, int target, int lun,
 	spin_lock_irqsave(&queue->queue_lock, flags);
 	list_for_each(l, &queue->head) {
 		QE_t *q = list_entry(l, QE_t, list);
-		if (q->SCpnt->device->id == target && q->SCpnt->device->lun == lun &&
+		if (q->SCpnt->device->id == target &&
+		    sdev_scsi2lun(q->SCpnt->device) == lun &&
 		    q->SCpnt->tag == tag) {
 			SCpnt = __queue_remove(queue, l);
 			break;
@@ -265,7 +266,8 @@ int queue_probetgtlun (Queue_t *queue, int target, int lun)
 	spin_lock_irqsave(&queue->queue_lock, flags);
 	list_for_each(l, &queue->head) {
 		QE_t *q = list_entry(l, QE_t, list);
-		if (q->SCpnt->device->id == target && q->SCpnt->device->lun == lun) {
+		if (q->SCpnt->device->id == target &&
+		    sdev_scsi2lun(q->SCpnt->device) == lun) {
 			found = 1;
 			break;
 		}
drivers/scsi/atari_NCR5380.c +43 -38

285 lines not on this page · raw message

drivers/scsi/atp870u.c +1 -1
index a795d81..59e2a69 100644
@@ -835,7 +835,7 @@ oktosend:
 		outb(workreq->cmnd[i], tmport++);
 	}
 	tmport = workport + 0x0f;
-	outb(workreq->device->lun, tmport);
+	outb(sdev_scsi2lun(workreq->device), tmport);
 	tmport += 0x02;
 	/*
 	 *	Write the target
drivers/scsi/bnx2fc/bnx2fc_io.c +2 -2
index 32a5e0a..00db81d 100644
@@ -1448,9 +1448,9 @@ static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req)
 	struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
 	struct bnx2fc_rport *tgt = io_req->tgt;
 	struct bnx2fc_cmd *cmd, *tmp;
-	int tm_lun = sc_cmd->device->lun;
+	u64 tm_lun = sc_cmd->device->lun;
+	u64 lun;
 	int rc = 0;
-	int lun;
 
 	/* called with tgt_lock held */
 	BNX2FC_IO_DBG(io_req, "Entered bnx2fc_lun_reset_cmpl\n");
drivers/scsi/ch.c +8 -8
index ba1c3bf..6738578 100644
@@ -251,7 +251,7 @@ ch_read_element_status(scsi_changer *ch, u_int elem, char *data)
  retry:
 	memset(cmd,0,sizeof(cmd));
 	cmd[0] = READ_ELEMENT_STATUS;
-	cmd[1] = (ch->device->lun << 5) |
+	cmd[1] = (sdev_scsi2lun(ch->device) << 5) |
 		(ch->voltags ? 0x10 : 0) |
 		ch_elem_to_typecode(ch,elem);
 	cmd[2] = (elem >> 8) & 0xff;
@@ -287,7 +287,7 @@ ch_init_elem(scsi_changer *ch)
 	VPRINTK(KERN_INFO, "INITIALIZE ELEMENT STATUS, may take some time ...\n");
 	memset(cmd,0,sizeof(cmd));
 	cmd[0] = INITIALIZE_ELEMENT_STATUS;
-	cmd[1] = ch->device->lun << 5;
+	cmd[1] = sdev_scsi2lun(ch->device) << 5;
 	err = ch_do_scsi(ch, cmd, NULL, 0, DMA_NONE);
 	VPRINTK(KERN_INFO, "... finished\n");
 	return err;
@@ -307,7 +307,7 @@ ch_readconfig(scsi_changer *ch)
 
 	memset(cmd,0,sizeof(cmd));
 	cmd[0] = MODE_SENSE;
-	cmd[1] = ch->device->lun << 5;
+	cmd[1] = sdev_scsi2lun(ch->device) << 5;
 	cmd[2] = 0x1d;
 	cmd[4] = 255;
 	result = ch_do_scsi(ch, cmd, buffer, 255, DMA_FROM_DEVICE);
@@ -432,7 +432,7 @@ ch_position(scsi_changer *ch, u_int trans, u_int elem, int rotate)
 		trans = ch->firsts[CHET_MT];
 	memset(cmd,0,sizeof(cmd));
 	cmd[0]  = POSITION_TO_ELEMENT;
-	cmd[1]  = ch->device->lun << 5;
+	cmd[1]  = sdev_scsi2lun(ch->device) << 5;
 	cmd[2]  = (trans >> 8) & 0xff;
 	cmd[3]  =  trans       & 0xff;
 	cmd[4]  = (elem  >> 8) & 0xff;
@@ -451,7 +451,7 @@ ch_move(scsi_changer *ch, u_int trans, u_int src, u_int dest, int rotate)
 		trans = ch->firsts[CHET_MT];
 	memset(cmd,0,sizeof(cmd));
 	cmd[0]  = MOVE_MEDIUM;
-	cmd[1]  = ch->device->lun << 5;
+	cmd[1]  = sdev_scsi2lun(ch->device) << 5;
 	cmd[2]  = (trans >> 8) & 0xff;
 	cmd[3]  =  trans       & 0xff;
 	cmd[4]  = (src   >> 8) & 0xff;
@@ -474,7 +474,7 @@ ch_exchange(scsi_changer *ch, u_int trans, u_int src,
 		trans = ch->firsts[CHET_MT];
 	memset(cmd,0,sizeof(cmd));
 	cmd[0]  = EXCHANGE_MEDIUM;
-	cmd[1]  = ch->device->lun << 5;
+	cmd[1]  = sdev_scsi2lun(ch->device) << 5;
 	cmd[2]  = (trans >> 8) & 0xff;
 	cmd[3]  =  trans       & 0xff;
 	cmd[4]  = (src   >> 8) & 0xff;
@@ -522,7 +522,7 @@ ch_set_voltag(scsi_changer *ch, u_int elem,
 		elem, tag);
 	memset(cmd,0,sizeof(cmd));
 	cmd[0]  = SEND_VOLUME_TAG;
-	cmd[1] = (ch->device->lun << 5) |
+	cmd[1] = (sdev_scsi2lun(ch->device) << 5) |
 		ch_elem_to_typecode(ch,elem);
 	cmd[2] = (elem >> 8) & 0xff;
 	cmd[3] = elem        & 0xff;
@@ -758,7 +758,7 @@ static long ch_ioctl(struct file *file,
 	voltag_retry:
 		memset(ch_cmd, 0, sizeof(ch_cmd));
 		ch_cmd[0] = READ_ELEMENT_STATUS;
-		ch_cmd[1] = (ch->device->lun << 5) |
+		ch_cmd[1] = (sdev_scsi2lun(ch->device) << 5) |
 			(ch->voltags ? 0x10 : 0) |
 			ch_elem_to_typecode(ch,elem);
 		ch_cmd[2] = (elem >> 8) & 0xff;
drivers/scsi/dc395x.c +37 -36

212 lines not on this page · raw message

drivers/scsi/eata.c +2 -2
index 03372cf..aeefa93 100644
@@ -1812,7 +1812,7 @@ static int eata2x_queuecommand_lck(struct scsi_cmnd *SCpnt,
 	cpp->one = 1;
 	cpp->channel = SCpnt->device->channel;
 	cpp->target = SCpnt->device->id;
-	cpp->lun = SCpnt->device->lun;
+	cpp->lun = sdev_scsi2lun(SCpnt->device);
 	cpp->SCpnt = SCpnt;
 	memcpy(cpp->cdb, SCpnt->cmnd, SCpnt->cmd_len);
 
@@ -2449,7 +2449,7 @@ static irqreturn_t ihdlr(struct Scsi_Host *shost)
 			       "target_status 0x%x, sense key 0x%x.\n",
 			       ha->board_name,
 			       SCpnt->device->channel, SCpnt->device->id,
-			       (u8)SCpnt->device->lun,
+			       sdev_scsi2lun(SCpnt->device),
 			       spp->target_status, SCpnt->sense_buffer[2]);
 
 		ha->target_to[SCpnt->device->id][SCpnt->device->channel] = 0;
drivers/scsi/eata_pio.c +1 -1
index 8319d2b..65c3a8a 100644
@@ -352,7 +352,7 @@ static int eata_pio_queue_lck(struct scsi_cmnd *cmd,
 	cp->reqlen = 0;
 
 	cp->cp_id = cmd->device->id;
-	cp->cp_lun = cmd->device->lun;
+	cp->cp_lun = sdev_scsi2lun(cmd->device);
 	cp->cp_dispri = 0;
 	cp->cp_identify = 1;
 	memcpy(cp->cp_cdb, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
drivers/scsi/esp_scsi.c +3 -3
index 55548dc..0f7ec18 100644
@@ -600,7 +600,7 @@ static void esp_autosense(struct esp *esp, struct esp_cmd_entry *ent)
 	u8 *p, val;
 
 	tgt = dev->id;
-	lun = dev->lun;
+	lun = sdev_scsi2lun(dev);
 
 
 	if (!ent->sense_ptr) {
@@ -706,7 +706,7 @@ static void esp_maybe_execute_command(struct esp *esp)
 	cmd = ent->cmd;
 	dev = cmd->device;
 	tgt = dev->id;
-	lun = dev->lun;
+	lun = sdev_scsi2lun(dev);
 	tp = &esp->target[tgt];
 	lp = dev->hostdata;
 
@@ -857,7 +857,7 @@ static void esp_cmd_is_done(struct esp *esp, struct esp_cmd_entry *ent,
 {
 	struct scsi_device *dev = cmd->device;
 	int tgt = dev->id;
-	int lun = dev->lun;
+	int lun = sdev_scsi2lun(dev);
 
 	esp->active_cmd = NULL;
 	esp_unmap_dma(esp, cmd);
drivers/scsi/g_NCR5380.c +1 -1
index a1bc8ca..e537ac3 100644
@@ -768,7 +768,7 @@ static void sprint_command(struct seq_file *m, unsigned char *command)
 
 static void sprint_Scsi_Cmnd(struct seq_file *m, Scsi_Cmnd * cmd)
 {
-	PRINTP("host number %d destination target %d, lun %d\n" ANDP cmd->device->host->host_no ANDP cmd->device->id ANDP cmd->device->lun);
+	PRINTP("host number %d destination target %d, lun %d\n" ANDP cmd->device->host->host_no ANDP cmd->device->id ANDP sdev_scsi2lun(cmd->device));
 	PRINTP("        command = ");
 	sprint_command(m, cmd->cmnd);
 }
drivers/scsi/gdth.c +2 -2
index 0f1ae13..c3438b0 100644
@@ -2047,7 +2047,7 @@ static void gdth_next(gdth_ha_str *ha)
         if (!nscp_cmndinfo->internal_command) {
             b = nscp->device->channel;
             t = nscp->device->id;
-            l = nscp->device->lun;
+            l = sdev_scsi2lun(nscp->device);
             if (nscp_cmndinfo->priority >= DEFAULT_PRI) {
                 if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) ||
                     (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock))
@@ -2606,7 +2606,7 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, u8 b)
     struct gdth_cmndinfo *cmndinfo;
 
     t = scp->device->id;
-    l = scp->device->lun;
+    l = sdev_scsi2lun(scp->device);
     cmdp = ha->pccb;
     TRACE(("gdth_fill_raw_cmd() cmd 0x%x bus %d ID %d LUN %d\n",
            scp->cmnd[0],b,t,l));
drivers/scsi/hptiop.c +3 -3
index ee196b3..b64b0e4 100644
@@ -1028,7 +1028,7 @@ static int hptiop_queuecommand_lck(struct scsi_cmnd *scp,
 			"req_index=%d, req=%p\n",
 			scp,
 			host->host_no, scp->device->channel,
-			scp->device->id, scp->device->lun,
+			scp->device->id, sdev_scsi2lun(scp->device),
 			cpu_to_be32(((u32 *)scp->cmnd)[0]),
 			cpu_to_be32(((u32 *)scp->cmnd)[1]),
 			cpu_to_be32(((u32 *)scp->cmnd)[2]),
@@ -1037,7 +1037,7 @@ static int hptiop_queuecommand_lck(struct scsi_cmnd *scp,
 
 	scp->result = 0;
 
-	if (scp->device->channel || scp->device->lun ||
+	if (scp->device->channel || sdev_scsi2lun(scp->device) ||
 			scp->device->id > hba->max_devices) {
 		scp->result = DID_BAD_TARGET << 16;
 		free_req(hba, _req);
@@ -1057,7 +1057,7 @@ static int hptiop_queuecommand_lck(struct scsi_cmnd *scp,
 	req->dataxfer_length = cpu_to_le32(scsi_bufflen(scp));
 	req->channel = scp->device->channel;
 	req->target = scp->device->id;
-	req->lun = scp->device->lun;
+	req->lun = sdev_scsi2lun(scp->device);
 	req->header.size = cpu_to_le32(
 				sizeof(struct hpt_iop_request_scsi_command)
 				 - sizeof(struct hpt_iopsg)
drivers/scsi/in2000.c +20 -16
index b1c4d83..83af7f9 100644
@@ -471,7 +471,7 @@ static void in2000_execute(struct Scsi_Host *instance)
 	cmd = (Scsi_Cmnd *) hostdata->input_Q;
 	prev = NULL;
 	while (cmd) {
-		if (!(hostdata->busy[cmd->device->id] & (1 << cmd->device->lun)))
+		if (!(hostdata->busy[cmd->device->id] & (1 << sdev_scsi2lun(cmd->device))))
 			break;
 		prev = cmd;
 		cmd = (Scsi_Cmnd *) cmd->host_scribble;
@@ -541,7 +541,7 @@ static void in2000_execute(struct Scsi_Host *instance)
 	if (!(hostdata->input_Q))	/* input_Q empty? */
 		goto no;
 	for (prev = (Scsi_Cmnd *) hostdata->input_Q; prev; prev = (Scsi_Cmnd *) prev->host_scribble) {
-		if ((prev->device->id != cmd->device->id) || (prev->device->lun != cmd->device->lun)) {
+		if ((prev->device->id != cmd->device->id) || prev->device->lun != cmd->device->lun)) {
 			for (prev = (Scsi_Cmnd *) hostdata->input_Q; prev; prev = (Scsi_Cmnd *) prev->host_scribble)
 				prev->SCp.phase = 1;
 			goto yes;
@@ -559,9 +559,9 @@ static void in2000_execute(struct Scsi_Host *instance)
       no:
 	write_3393(hostdata, WD_SOURCE_ID, ((cmd->SCp.phase) ? SRCID_ER : 0));
 
-	write_3393(hostdata, WD_TARGET_LUN, cmd->device->lun);
+	write_3393(hostdata, WD_TARGET_LUN, sdev_scsi2lun(cmd->device));
 	write_3393(hostdata, WD_SYNCHRONOUS_TRANSFER, hostdata->sync_xfer[cmd->device->id]);
-	hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
+	hostdata->busy[cmd->device->id] |= (1 << sdev_scsi2lun(cmd->device));
 
 	if ((hostdata->level2 <= L2_NONE) || (hostdata->sync_stat[cmd->device->id] == SS_UNSET)) {
 
@@ -1075,7 +1075,7 @@ static irqreturn_t in2000_intr(int irqnum, void *dev_id)
 		}
 
 		cmd->result = DID_NO_CONNECT << 16;
-		hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+		hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 		hostdata->state = S_UNCONNECTED;
 		cmd->scsi_done(cmd);
 
@@ -1097,7 +1097,7 @@ static irqreturn_t in2000_intr(int irqnum, void *dev_id)
 
 		/* construct an IDENTIFY message with correct disconnect bit */
 
-		hostdata->outgoing_msg[0] = (0x80 | 0x00 | cmd->device->lun);
+		hostdata->outgoing_msg[0] = (0x80 | 0x00 | sdev_scsi2lun(cmd->device));
 		if (cmd->SCp.phase)
 			hostdata->outgoing_msg[0] |= 0x40;
 
@@ -1333,7 +1333,7 @@ static irqreturn_t in2000_intr(int irqnum, void *dev_id)
 			lun = read_3393(hostdata, WD_TARGET_LUN);
 			DB(DB_INTR, printk(":%d.%d", cmd->SCp.Status, lun))
 			    hostdata->connected = NULL;
-			hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+			hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 			hostdata->state = S_UNCONNECTED;
 			if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE)
 				cmd->SCp.Status = lun;
@@ -1418,7 +1418,7 @@ static irqreturn_t in2000_intr(int irqnum, void *dev_id)
 		}
 		DB(DB_INTR, printk("UNEXP_DISC"))
 		    hostdata->connected = NULL;
-		hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+		hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 		hostdata->state = S_UNCONNECTED;
 		if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != GOOD)
 			cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
@@ -1449,7 +1449,7 @@ static irqreturn_t in2000_intr(int irqnum, void *dev_id)
 		switch (hostdata->state) {
 		case S_PRE_CMP_DISC:
 			hostdata->connected = NULL;
-			hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+			hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 			hostdata->state = S_UNCONNECTED;
 			DB(DB_INTR, printk(":%d", cmd->SCp.Status))
 			    if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != GOOD)
@@ -1494,7 +1494,7 @@ static irqreturn_t in2000_intr(int irqnum, void *dev_id)
 			if (hostdata->selecting) {
 				cmd = (Scsi_Cmnd *) hostdata->selecting;
 				hostdata->selecting = NULL;
-				hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+				hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 				cmd->host_scribble = (uchar *) hostdata->input_Q;
 				hostdata->input_Q = cmd;
 			}
@@ -1504,7 +1504,7 @@ static irqreturn_t in2000_intr(int irqnum, void *dev_id)
 
 			if (cmd) {
 				if (phs == 0x00) {
-					hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+					hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 					cmd->host_scribble = (uchar *) hostdata->input_Q;
 					hostdata->input_Q = cmd;
 				} else {
@@ -1536,7 +1536,8 @@ static irqreturn_t in2000_intr(int irqnum, void *dev_id)
 		cmd = (Scsi_Cmnd *) hostdata->disconnected_Q;
 		patch = NULL;
 		while (cmd) {
-			if (id == cmd->device->id && lun == cmd->device->lun)
+			if (id == cmd->device->id &&
+			    lun == sdev_scsi2lun(cmd->device))
 				break;
 			patch = cmd;
 			cmd = (Scsi_Cmnd *) cmd->host_scribble;
@@ -1757,7 +1758,7 @@ static int __in2000_abort(Scsi_Cmnd * cmd)
 		sr = read_3393(hostdata, WD_SCSI_STATUS);
 		printk("asr=%02x, sr=%02x.", asr, sr);
 
-		hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+		hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 		hostdata->connected = NULL;
 		hostdata->state = S_UNCONNECTED;
 		cmd->result = DID_ABORT << 16;
@@ -2251,14 +2252,16 @@ static int in2000_show_info(struct seq_file *m, struct Scsi_Host *instance)
 		seq_printf(m, "\nconnected:     ");
 		if (hd->connected) {
 			cmd = (Scsi_Cmnd *) hd->connected;
-			seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
+			seq_printf(m, " %d:%d(%02x)", cmd->device->id,
+				   sdev_scsi2lun(cmd->device), cmd->cmnd[0]);
 		}
 	}
 	if (hd->proc & PR_INPUTQ) {
 		seq_printf(m, "\ninput_Q:       ");
 		cmd = (Scsi_Cmnd *) hd->input_Q;
 		while (cmd) {
-			seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
+			seq_printf(m, " %d:%d(%02x)", cmd->device->id,
+				   sdev_scsi2lun(cmd->device), cmd->cmnd[0]);
 			cmd = (Scsi_Cmnd *) cmd->host_scribble;
 		}
 	}
@@ -2266,7 +2269,8 @@ static int in2000_show_info(struct seq_file *m, struct Scsi_Host *instance)
 		seq_printf(m, "\ndisconnected_Q:");
 		cmd = (Scsi_Cmnd *) hd->disconnected_Q;
 		while (cmd) {
-			seq_printf(m, " %d:%d(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
+			seq_printf(m, " %d:%d(%02x)", cmd->device->id,
+				   sdev_scsi2lun(cmd->device), cmd->cmnd[0]);
 			cmd = (Scsi_Cmnd *) cmd->host_scribble;
 		}
 	}
drivers/scsi/initio.c +2 -2
index e5dae7b..2ac878e 100644
@@ -2573,8 +2573,8 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c
 	cblk->opcode = ExecSCSI;
 	cblk->flags = SCF_POST;	/* After SCSI done, call post routine */
 	cblk->target = cmnd->device->id;
-	cblk->lun = cmnd->device->lun;
-	cblk->ident = cmnd->device->lun | DISC_ALLOW;
+	cblk->lun = sdev_scsi2lun(cmnd->device);
+	cblk->ident = sdev_scsi2lun(cmnd->device) | DISC_ALLOW;
 
 	cblk->flags |= SCF_SENSE;	/* Turn on auto request sense   */
 
drivers/scsi/megaraid.c +5 -5
index ac5d94c..eccbb75 100644
@@ -583,7 +583,7 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
 	if(islogical) {
 
 		/* have just LUN 0 for each target on virtual channels */
-		if (cmd->device->lun) {
+		if (sdev_scsi2lun(cmd->device)) {
 			cmd->result = (DID_BAD_TARGET << 16);
 			cmd->scsi_done(cmd);
 			return NULL;
@@ -610,7 +610,7 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
 
 	}
 	else {
-		if( cmd->device->lun > 7) {
+		if (sdev_scsi2lun(cmd->device) > 7) {
 			/*
 			 * Do not support lun >7 for physically accessed
 			 * devices
@@ -970,7 +970,7 @@ mega_prepare_passthru(adapter_t *adapter, scb_t *scb, Scsi_Cmnd *cmd,
 		(channel << 4) | target : target;
 
 	pthru->cdblen = cmd->cmd_len;
-	pthru->logdrv = cmd->device->lun;
+	pthru->logdrv = sdev_scsi2lun(cmd->device);
 
 	memcpy(pthru->cdb, cmd->cmnd, cmd->cmd_len);
 
@@ -1033,7 +1033,7 @@ mega_prepare_extpassthru(adapter_t *adapter, scb_t *scb, Scsi_Cmnd *cmd,
 		(channel << 4) | target : target;
 
 	epthru->cdblen = cmd->cmd_len;
-	epthru->logdrv = cmd->device->lun;
+	epthru->logdrv = sdev_scsi2lun(cmd->device);
 
 	memcpy(epthru->cdb, cmd->cmnd, cmd->cmd_len);
 
@@ -1942,7 +1942,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
 	printk(KERN_WARNING "megaraid: %s cmd=%x <c=%d t=%d l=%d>\n",
 	     (aor == SCB_ABORT)? "ABORTING":"RESET",
 	     cmd->cmnd[0], cmd->device->channel,
-	     cmd->device->id, (u32)cmd->device->lun);
+	     cmd->device->id, sdev_scsi2lun(cmd->device));
 
 	if(list_empty(&adapter->pending_list))
 		return FALSE;
drivers/scsi/mesh.c +3 -3
index e8a04ae..d69203a 100644
@@ -1228,11 +1228,11 @@ static void handle_msgin(struct mesh_state *ms)
 			if (cmd == NULL) {
 				do_abort(ms);
 				ms->msgphase = msg_out;
-			} else if (code != cmd->device->lun + IDENTIFY_BASE) {
+			} else if (code != sdev_scsi2lun(cmd->device) + IDENTIFY_BASE) {
 				printk(KERN_WARNING "mesh: lun mismatch "
 				       "(%d != %d) on reselection from "
 				       "target %d\n", code - IDENTIFY_BASE,
-				       cmd->device->lun, ms->conn_tgt);
+				       sdev_scsi2lun(cmd->device), ms->conn_tgt);
 			}
 			break;
 		}
@@ -1544,7 +1544,7 @@ static void cmd_complete(struct mesh_state *ms)
 		case selecting:
 			dlog(ms, "Selecting phase at command completion",0);
 			ms->msgout[0] = IDENTIFY(ALLOW_RESEL(ms->conn_tgt),
-						 (cmd? cmd->device->lun: 0));
+						 (cmd? sdev_scsi2lun(cmd->device): 0));
 			ms->n_msgout = 1;
 			ms->expect_reply = 0;
 			if (ms->aborting) {
drivers/scsi/mvumi.c +1 -1
index edbee8d..59f6f06 100644
@@ -2071,7 +2071,7 @@ static unsigned char mvumi_build_frame(struct mvumi_hba *mhba,
 	cmd->cmd_status = REQ_STATUS_PENDING;
 	pframe = cmd->frame;
 	pframe->device_id = ((unsigned short) scmd->device->id) |
-				(((unsigned short) scmd->device->lun) << 8);
+		(sdev_scsi2lun(scmd->device) << 8);
 	pframe->cmd_flag = 0;
 
 	switch (scmd->sc_data_direction) {
drivers/scsi/ncr53c8xx.c +17 -16
index 7d014b1..ba673a8 100644
@@ -4120,7 +4120,7 @@ static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd)
 {
 	struct scsi_device *sdev = cmd->device;
 	struct tcb *tp = &np->target[sdev->id];
-	struct lcb *lp = tp->lp[sdev->lun];
+	struct lcb *lp = tp->lp[sdev_scsi2lun(sdev)];
 	struct ccb *cp;
 
 	int	segments;
@@ -4135,9 +4135,9 @@ static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd)
 	**
 	**---------------------------------------------
 	*/
-	if ((sdev->id == np->myaddr	  ) ||
-		(sdev->id >= MAX_TARGET) ||
-		(sdev->lun    >= MAX_LUN   )) {
+	if ((sdev->id == np->myaddr) ||
+	    (sdev->id >= MAX_TARGET) ||
+	    (sdev_scsi2lun(sdev) >= MAX_LUN)) {
 		return(DID_BAD_TARGET);
 	}
 
@@ -4189,7 +4189,7 @@ static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd)
 	**----------------------------------------------------
 	*/
 
-	idmsg = IDENTIFY(0, sdev->lun);
+	idmsg = IDENTIFY(0, sdev_scsi2lun(sdev));
 
 	if (cp ->tag != NO_TAG ||
 		(cp != np->ccb && np->disc && !(tp->usrflag & UF_NODISC)))
@@ -4841,7 +4841,7 @@ void ncr_complete (struct ncb *np, struct ccb *cp)
 	cmd = cp->cmd;
 	cp->cmd = NULL;
 	tp = &np->target[cmd->device->id];
-	lp = tp->lp[cmd->device->lun];
+	lp = tp->lp[sdev_scsi2lun(cmd->device)];
 
 	/*
 	**	We donnot queue more than 1 ccb per target 
@@ -4935,7 +4935,8 @@ void ncr_complete (struct ncb *np, struct ccb *cp)
 		**	Allocate the lcb if not yet.
 		*/
 		if (!lp)
-			ncr_alloc_lcb (np, cmd->device->id, cmd->device->lun);
+			ncr_alloc_lcb (np, cmd->device->id,
+				       sdev_scsi2lun(cmd->device));
 
 		tp->bytes     += cp->data_len;
 		tp->transfers ++;
@@ -5631,7 +5632,7 @@ static void ncr_setwide (struct ncb *np, struct ccb *cp, u_char wide, u_char ack
 
 static void ncr_setup_tags (struct ncb *np, struct scsi_device *sdev)
 {
-	unsigned char tn = sdev->id, ln = sdev->lun;
+	unsigned char tn = sdev->id, ln = sdev_scsi2lun(sdev);
 	struct tcb *tp = &np->target[tn];
 	struct lcb *lp = tp->lp[ln];
 	u_char   reqtags, maxdepth;
@@ -6542,7 +6543,7 @@ static void ncr_sir_to_redo(struct ncb *np, int num, struct ccb *cp)
 {
 	struct scsi_cmnd *cmd	= cp->cmd;
 	struct tcb *tp	= &np->target[cmd->device->id];
-	struct lcb *lp	= tp->lp[cmd->device->lun];
+	struct lcb *lp	= tp->lp[sdev_scsi2lun(cmd->device)];
 	struct list_head *qp;
 	struct ccb *	cp2;
 	int		disc_cnt = 0;
@@ -6619,7 +6620,7 @@ static void ncr_sir_to_redo(struct ncb *np, int num, struct ccb *cp)
 		**
 		**	identify message
 		*/
-		cp->scsi_smsg2[0]	= IDENTIFY(0, cmd->device->lun);
+		cp->scsi_smsg2[0]	= IDENTIFY(0, sdev_scsi2lun(cmd->device));
 		cp->phys.smsg.addr	= cpu_to_scr(CCB_PHYS (cp, scsi_smsg2));
 		cp->phys.smsg.size	= cpu_to_scr(1);
 
@@ -6633,7 +6634,7 @@ static void ncr_sir_to_redo(struct ncb *np, int num, struct ccb *cp)
 		**	patch requested size into sense command
 		*/
 		cp->sensecmd[0]		= 0x03;
-		cp->sensecmd[1]		= cmd->device->lun << 5;
+		cp->sensecmd[1]		= (sdev_scsi2lun(cmd->device) & 0x7) << 5;
 		cp->sensecmd[4]		= sizeof(cp->sense_buf);
 
 		/*
@@ -7143,7 +7144,7 @@ out:
 static struct ccb *ncr_get_ccb(struct ncb *np, struct scsi_cmnd *cmd)
 {
 	u_char tn = cmd->device->id;
-	u_char ln = cmd->device->lun;
+	u_char ln = sdev_scsi2lun(cmd->device);
 	struct tcb *tp = &np->target[tn];
 	struct lcb *lp = tp->lp[ln];
 	u_char tag = NO_TAG;
@@ -7580,7 +7581,7 @@ fail:
 */
 static struct lcb *ncr_setup_lcb (struct ncb *np, struct scsi_device *sdev)
 {
-	unsigned char tn = sdev->id, ln = sdev->lun;
+	unsigned char tn = sdev->id, ln = sdev_scsi2lun(sdev);
 	struct tcb *tp = &np->target[tn];
 	struct lcb *lp = tp->lp[ln];
 
@@ -7975,7 +7976,7 @@ static int ncr53c8xx_slave_configure(struct scsi_device *device)
 	struct Scsi_Host *host = device->host;
 	struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
 	struct tcb *tp = &np->target[device->id];
-	struct lcb *lp = tp->lp[device->lun];
+	struct lcb *lp = tp->lp[sdev_scsi2lun(device)];
 	int numtags, depth_to_use;
 
 	ncr_setup_lcb(np, device);
@@ -7986,7 +7987,7 @@ static int ncr53c8xx_slave_configure(struct scsi_device *device)
 	**	Use at least 2.
 	**	Donnot use more than our maximum.
 	*/
-	numtags = device_queue_depth(np->unit, device->id, device->lun);
+	numtags = device_queue_depth(np->unit, device->id, sdev_scsi2lun(device));
 	if (numtags > tp->usrtags)
 		numtags = tp->usrtags;
 	if (!device->tagged_supported)
@@ -8019,7 +8020,7 @@ static int ncr53c8xx_slave_configure(struct scsi_device *device)
 
 #ifdef DEBUG_NCR53C8XX
 	printk("ncr53c8xx_select_queue_depth: host=%d, id=%d, lun=%d, depth=%d\n",
-	       np->unit, device->id, device->lun, depth_to_use);
+	       np->unit, device->id, sdev_scsi2lun(device), depth_to_use);
 #endif
 
 	if (spi_support_sync(device->sdev_target) &&
drivers/scsi/nsp32.c +8 -6
index 0665f9c..d6856c8 100644
@@ -376,7 +376,7 @@ static void nsp32_build_identify(struct scsi_cmnd *SCpnt)
 		/* mode = TRUE; */
 	}
 
-	data->msgoutbuf[pos] = IDENTIFY(mode, SCpnt->device->lun); pos++;
+	data->msgoutbuf[pos] = IDENTIFY(mode, sdev_scsi2lun(SCpnt->device)); pos++;
 
 	data->msgout_len = pos;
 }
@@ -917,8 +917,10 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct s
 	nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND,
 		  "enter. target: 0x%x LUN: 0x%x cmnd: 0x%x cmndlen: 0x%x "
 		  "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x",
-		  SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len,
-		  scsi_sg_count(SCpnt), scsi_sglist(SCpnt), scsi_bufflen(SCpnt));
+		  SCpnt->device->id, sdev_scsi2lun(SCpnt->device),
+		  SCpnt->cmnd[0], SCpnt->cmd_len,
+		  scsi_sg_count(SCpnt), scsi_sglist(SCpnt),
+		  scsi_bufflen(SCpnt));
 
 	if (data->CurrentSC != NULL) {
 		nsp32_msg(KERN_ERR, "Currentsc != NULL. Cancel this command request");
@@ -937,7 +939,7 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct s
 	}
 
 	/* check target LUN is allowable value */
-	if (SCpnt->device->lun >= MAX_LUN) {
+	if (sdev_scsi2lun(SCpnt->device) >= MAX_LUN) {
 		nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "no more lun");
 		SCpnt->result = DID_BAD_TARGET << 16;
 		done(SCpnt);
@@ -960,13 +962,13 @@ static int nsp32_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct s
 	/* initialize data */
 	data->msgout_len	= 0;
 	data->msgin_len		= 0;
-	cur_lunt		= &(data->lunt[SCpnt->device->id][SCpnt->device->lun]);
+	cur_lunt		= &(data->lunt[SCpnt->device->id][sdev_scsi2lun(SCpnt->device)]);
 	cur_lunt->SCpnt		= SCpnt;
 	cur_lunt->save_datp	= 0;
 	cur_lunt->msgin03	= FALSE;
 	data->cur_lunt		= cur_lunt;
 	data->cur_id		= SCpnt->device->id;
-	data->cur_lun		= SCpnt->device->lun;
+	data->cur_lun		= sdev_scsi2lun(SCpnt->device);
 
 	ret = nsp32_setup_sg_table(SCpnt);
 	if (ret == FALSE) {
drivers/scsi/ps3rom.c +1 -1
index e6e2a30..d790f4e 100644
@@ -79,7 +79,7 @@ static int ps3rom_slave_configure(struct scsi_device *scsi_dev)
 	struct ps3_storage_device *dev = priv->dev;
 
 	dev_dbg(&dev->sbd.core, "%s:%u: id %u, lun %u, channel %u\n", __func__,
-		__LINE__, scsi_dev->id, scsi_dev->lun, scsi_dev->channel);
+		__LINE__, scsi_dev->id, sdev_scsi2lun(scsi_dev), scsi_dev->channel);
 
 	/*
 	 * ATAPI SFF8020 devices use MODE_SENSE_10,
drivers/scsi/qlogicpti.c +3 -3
index 6d48d30..0422327 100644
@@ -861,7 +861,7 @@ static inline void cmd_frob(struct Command_Entry *cmd, struct scsi_cmnd *Cmnd,
 	cmd->hdr.entry_cnt = 1;
 	cmd->hdr.entry_type = ENTRY_COMMAND;
 	cmd->target_id = Cmnd->device->id;
-	cmd->target_lun = Cmnd->device->lun;
+	cmd->target_lun = sdev_scsi2lun(Cmnd->device);
 	cmd->cdb_length = Cmnd->cmd_len;
 	cmd->control_flags = 0;
 	if (Cmnd->device->tagged_supported) {
@@ -1222,7 +1222,7 @@ static int qlogicpti_abort(struct scsi_cmnd *Cmnd)
 	int i;
 
 	printk(KERN_WARNING "qlogicpti%d: Aborting cmd for tgt[%d] lun[%d]\n",
-	       qpti->qpti_id, (int)Cmnd->device->id, (int)Cmnd->device->lun);
+	       qpti->qpti_id, (int)Cmnd->device->id, sdev_scsi2lun(Cmnd->device));
 
 	qlogicpti_disable_irqs(qpti);
 
@@ -1235,7 +1235,7 @@ static int qlogicpti_abort(struct scsi_cmnd *Cmnd)
 	cmd_cookie = i;
 
 	param[0] = MBOX_ABORT;
-	param[1] = (((u_short) Cmnd->device->id) << 8) | Cmnd->device->lun;
+	param[1] = (((u_short) Cmnd->device->id) << 8) | sdev_scsi2lun(Cmnd->device);
 	param[2] = cmd_cookie >> 16;
 	param[3] = cmd_cookie & 0xffff;
 	if (qlogicpti_mbox_command(qpti, param, 0) ||
drivers/scsi/scsi.c +1 -1
index ce5b4e5..f56eb94 100644
@@ -681,7 +681,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 	if (cmd->device->scsi_level <= SCSI_2 &&
 	    cmd->device->scsi_level != SCSI_UNKNOWN) {
 		cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) |
-			       (cmd->device->lun << 5 & 0xe0);
+			(sdev_scsi2lun(cmd->device) << 5 & 0xe0);
 	}
 
 	scsi_log_send(cmd);
drivers/scsi/stex.c +1 -1
index 1aa4bef..d7fcbdb 100644
@@ -582,7 +582,7 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
 
 	host = cmd->device->host;
 	id = cmd->device->id;
-	lun = cmd->device->lun;
+	lun = sdev_scsi2lun(cmd->device);
 	hba = (struct st_hba *) &host->hostdata[0];
 
 	if (unlikely(hba->mu_status == MU_STATE_RESETTING))
drivers/scsi/sun3_NCR5380.c +48 -38

293 lines not on this page · raw message

drivers/scsi/sym53c8xx_2/sym_glue.c +10 -9
index e59e6f9..2220684 100644
@@ -313,7 +313,7 @@ static int sym_queue_command(struct sym_hcb *np, struct scsi_cmnd *cmd)
 	/*
 	 *  Select tagged/untagged.
 	 */
-	lp = sym_lp(tp, sdev->lun);
+	lp = sym_lp(tp, sdev_scsi2lun(sdev));
 	order = (lp && lp->s.reqtags) ? M_SIMPLE_TAG : 0;
 
 	/*
@@ -742,7 +742,8 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
 	unsigned long flags;
 	int error;
 
-	if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN)
+	if (sdev->id >= SYM_CONF_MAX_TARGET ||
+	    sdev_scsi2lun(sdev) >= SYM_CONF_MAX_LUN)
 		return -ENXIO;
 
 	spin_lock_irqsave(np->s.host->host_lock, flags);
@@ -765,7 +766,7 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
 	}
 
 	if (tp->usrflags & SYM_SCAN_LUNS_DISABLED) {
-		if (sdev->lun != 0) {
+		if (sdev_scsi2lun(sdev) != 0) {
 			error = -ENXIO;
 			goto out;
 		}
@@ -773,7 +774,7 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
 				"Multiple LUNs disabled in NVRAM\n");
 	}
 
-	lp = sym_alloc_lcb(np, sdev->id, sdev->lun);
+	lp = sym_alloc_lcb(np, sdev->id, sdev_scsi2lun(sdev));
 	if (!lp) {
 		error = -ENOMEM;
 		goto out;
@@ -798,7 +799,7 @@ static int sym53c8xx_slave_configure(struct scsi_device *sdev)
 {
 	struct sym_hcb *np = sym_get_hcb(sdev->host);
 	struct sym_tcb *tp = &np->target[sdev->id];
-	struct sym_lcb *lp = sym_lp(tp, sdev->lun);
+	struct sym_lcb *lp = sym_lp(tp, sdev_scsi2lun(sdev));
 	int reqtags, depth_to_use;
 
 	/*
@@ -824,7 +825,7 @@ static int sym53c8xx_slave_configure(struct scsi_device *sdev)
 				sdev->tagged_supported ? MSG_SIMPLE_TAG : 0,
 				depth_to_use);
 	lp->s.scdev_depth = depth_to_use;
-	sym_tune_dev_queuing(tp, sdev->lun, reqtags);
+	sym_tune_dev_queuing(tp, sdev_scsi2lun(sdev), reqtags);
 
 	if (!spi_initial_dv(sdev->sdev_target))
 		spi_dv_device(sdev);
@@ -836,7 +837,7 @@ static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
 {
 	struct sym_hcb *np = sym_get_hcb(sdev->host);
 	struct sym_tcb *tp = &np->target[sdev->id];
-	struct sym_lcb *lp = sym_lp(tp, sdev->lun);
+	struct sym_lcb *lp = sym_lp(tp, sdev_scsi2lun(sdev));
 	unsigned long flags;
 
 	/* if slave_alloc returned before allocating a sym_lcb, return */
@@ -851,11 +852,11 @@ static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
 		 * so let's try to stop all on-going I/O.
 		 */
 		starget_printk(KERN_WARNING, tp->starget,
-			       "Removing busy LCB (%d)\n", (u8)sdev->lun);
+			       "Removing busy LCB (%d)\n", sdev_scsi2lun(sdev));
 		sym_reset_scsi_bus(np, 1);
 	}
 
-	if (sym_free_lcb(np, sdev->id, sdev->lun) == 0) {
+	if (sym_free_lcb(np, sdev->id, sdev_scsi2lun(sdev)) == 0) {
 		/*
 		 * It was the last unit for this target.
 		 */
drivers/scsi/sym53c8xx_2/sym_hipd.c +5 -5
index 6b349e3..7204e51 100644
@@ -4650,7 +4650,7 @@ out_stuck:
 struct sym_ccb *sym_get_ccb (struct sym_hcb *np, struct scsi_cmnd *cmd, u_char tag_order)
 {
 	u_char tn = cmd->device->id;
-	u_char ln = cmd->device->lun;
+	u_char ln = sdev_scsi2lun(cmd->device);
 	struct sym_tcb *tp = &np->target[tn];
 	struct sym_lcb *lp = sym_lp(tp, ln);
 	u_short tag = NO_TAG;
@@ -5159,14 +5159,14 @@ int sym_queue_scsiio(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *
 	/*
 	 *  Retrieve the lun descriptor.
 	 */
-	lp = sym_lp(tp, sdev->lun);
+	lp = sym_lp(tp, sdev_scsi2lun(sdev));
 
 	can_disconnect = (cp->tag != NO_TAG) ||
 		(lp && (lp->curr_flags & SYM_DISC_ENABLED));
 
 	msgptr = cp->scsi_smsg;
 	msglen = 0;
-	msgptr[msglen++] = IDENTIFY(can_disconnect, sdev->lun);
+	msgptr[msglen++] = IDENTIFY(can_disconnect, sdev_scsi2lun(sdev));
 
 	/*
 	 *  Build the tag message if present.
@@ -5383,7 +5383,7 @@ void sym_complete_error(struct sym_hcb *np, struct sym_ccb *cp)
 	 *  Get target and lun pointers.
 	 */
 	tp = &np->target[cp->target];
-	lp = sym_lp(tp, sdev->lun);
+	lp = sym_lp(tp, sdev_scsi2lun(sdev));
 
 	/*
 	 *  Check for extended errors.
@@ -5414,7 +5414,7 @@ if (resid)
 	 *  not yet started by SCRIPTS.
 	 */
 	i = (INL(np, nc_scratcha) - np->squeue_ba) / 4;
-	i = sym_dequeue_from_squeue(np, i, cp->target, sdev->lun, -1);
+	i = sym_dequeue_from_squeue(np, i, cp->target, sdev_scsi2lun(sdev), -1);
 
 	/*
 	 *  Restart the SCRIPTS processor.
drivers/scsi/tmscsim.c +8 -4
index b006cf7..ea8b4c6 100644
@@ -621,7 +621,7 @@ dc390_StartSCSI( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_sr
     {
 	dc390_freetag (pDCB, pSRB);
 	DEBUG0(printk ("DC390: Interrupt during Start SCSI (target %02i-%02i)\n",
-		scmd->device->id, scmd->device->lun));
+		       scmd->device->id, sdev_scsi2lun(scmd->device)));
 	pSRB->SRBState = SRB_READY;
 	//DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
 	pACB->SelLost++;
@@ -1726,7 +1726,9 @@ dc390_SRBdone( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb*
 	    } else {
 		SET_RES_DRV(pcmd->result, DRIVER_SENSE);
 		//pSRB->ScsiCmdLen	 = (u8) (pSRB->Segment1[0] >> 8);
-		DEBUG0 (printk ("DC390: RETRY (%02x), target %02i-%02i\n", pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
+		DEBUG0 (printk ("DC390: RETRY (%02x), target %02i-%02i\n",
+				pcmd->cmnd[0], pcmd->device->id,
+				sdev_scsi2lun(pcmd->device)));
 		pSRB->TotalXferredLen = 0;
 		SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
 	    }
@@ -1746,7 +1748,9 @@ dc390_SRBdone( struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb*
 	else if (status == SAM_STAT_TASK_SET_FULL)
 	{
 	    scsi_track_queue_full(pcmd->device, pDCB->GoingSRBCnt - 1);
-	    DEBUG0 (printk ("DC390: RETRY (%02x), target %02i-%02i\n", pcmd->cmnd[0], pcmd->device->id, pcmd->device->lun));
+	    DEBUG0 (printk ("DC390: RETRY (%02x), target %02i-%02i\n",
+			    pcmd->cmnd[0], pcmd->device->id,
+			    sdev_scsi2lun(pcmd->device)));
 	    pSRB->TotalXferredLen = 0;
 	    SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
 	}
@@ -2078,7 +2082,7 @@ static int dc390_slave_alloc(struct scsi_device *scsi_device)
 	struct dc390_acb *pACB = (struct dc390_acb*) scsi_device->host->hostdata;
 	struct dc390_dcb *pDCB, *pDCB2 = NULL;
 	uint id = scsi_device->id;
-	uint lun = scsi_device->lun;
+	uint lun = sdev_scsi2lun(scsi_device);
 
 	pDCB = kzalloc(sizeof(struct dc390_dcb), GFP_KERNEL);
 	if (!pDCB)
drivers/scsi/u14-34f.c +3 -3
index 5a03bb3..1ffede5 100644
@@ -1287,12 +1287,12 @@ static int u14_34f_queuecommand_lck(struct scsi_cmnd *SCpnt, void (*done)(struct
 
    if (do_trace) printk("%s: qcomm, mbox %d, target %d.%d:%d.\n",
                         BN(j), i, SCpnt->device->channel, SCpnt->device->id,
-                        SCpnt->device->lun);
+                        sdev_scsi2lun(SCpnt->device));
 
    cpp->opcode = OP_SCSI;
    cpp->channel = SCpnt->device->channel;
    cpp->target = SCpnt->device->id;
-   cpp->lun = SCpnt->device->lun;
+   cpp->lun = sdev_scsi2lun(SCpnt->device);
    cpp->SCpnt = SCpnt;
    cpp->cdb_len = SCpnt->cmd_len;
    memcpy(cpp->cdb, SCpnt->cmnd, SCpnt->cmd_len);
@@ -1666,7 +1666,7 @@ static int reorder(unsigned int j, unsigned long cursec,
          printk("%s %d.%d:%d mb %d fc %d nr %d sec %ld ns %u"\
                 " cur %ld s:%c r:%c rev:%c in:%c ov:%c xd %d.\n",
                 (ihdlr ? "ihdlr" : "qcomm"), SCpnt->channel, SCpnt->target,
-                SCpnt->lun, k, flushcount, n_ready,
+                sdev_scsi2lun(SCpnt->device), k, flushcount, n_ready,
                 blk_rq_pos(SCpnt->request), blk_rq_sectors(SCpnt->request),
 		cursec, YESNO(s), YESNO(r), YESNO(rev), YESNO(input_only),
                 YESNO(overlap), cpp->xdir);
drivers/scsi/ufs/ufshcd.c +2 -2
index 0c28772..8a0e717 100644
@@ -920,7 +920,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 	lrbp->sense_bufflen = SCSI_SENSE_BUFFERSIZE;
 	lrbp->sense_buffer = cmd->sense_buffer;
 	lrbp->task_tag = tag;
-	lrbp->lun = cmd->device->lun;
+	lrbp->lun = sdev_scsi2lun(cmd->device);
 	lrbp->intr_cmd = false;
 	lrbp->command_type = UTP_CMD_TYPE_SCSI;
 
@@ -1976,7 +1976,7 @@ static void ufshcd_adjust_lun_qdepth(struct scsi_cmnd *cmd)
 			 * Check if the outstanding command belongs
 			 * to the LUN which reported SAM_STAT_TASK_SET_FULL.
 			 */
-			if (cmd->device->lun == hba->lrb[i].lun)
+			if (sdev_scsi2lun(cmd->device) == hba->lrb[i].lun)
 				lun_qdepth++;
 		}
 	}
drivers/scsi/ultrastor.c +1 -1
index 14e0c40..a34c297 100644
@@ -735,7 +735,7 @@ static int ultrastor_queuecommand_lck(struct scsi_cmnd *SCpnt,
     my_mscp->ca = SCpnt->device->type != TYPE_TAPE;
     my_mscp->target_id = SCpnt->device->id;
     my_mscp->ch_no = 0;
-    my_mscp->lun = SCpnt->device->lun;
+    my_mscp->lun = sdev_scsi2lun(SCpnt->device);
     if (scsi_sg_count(SCpnt)) {
 	/* Set scatter/gather flag in SCSI command packet */
 	my_mscp->sg = TRUE;
drivers/scsi/wd33c93.c +20 -15
index 41883a8..a9c2575 100644
@@ -502,7 +502,8 @@ wd33c93_execute(struct Scsi_Host *instance)
 	cmd = (struct scsi_cmnd *) hostdata->input_Q;
 	prev = NULL;
 	while (cmd) {
-		if (!(hostdata->busy[cmd->device->id] & (1 << cmd->device->lun)))
+		if (!(hostdata->busy[cmd->device->id] &
+		      (1 << sdev_scsi2lun(cmd->device))))
 			break;
 		prev = cmd;
 		cmd = (struct scsi_cmnd *) cmd->host_scribble;
@@ -593,10 +594,10 @@ wd33c93_execute(struct Scsi_Host *instance)
 
 	write_wd33c93(regs, WD_SOURCE_ID, ((cmd->SCp.phase) ? SRCID_ER : 0));
 
-	write_wd33c93(regs, WD_TARGET_LUN, cmd->device->lun);
+	write_wd33c93(regs, WD_TARGET_LUN, sdev_scsi2lun(cmd->device));
 	write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER,
 		      hostdata->sync_xfer[cmd->device->id]);
-	hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
+	hostdata->busy[cmd->device->id] |= (1 << sdev_scsi2lun(cmd->device));
 
 	if ((hostdata->level2 == L2_NONE) ||
 	    (hostdata->sync_stat[cmd->device->id] == SS_UNSET)) {
@@ -862,7 +863,7 @@ wd33c93_intr(struct Scsi_Host *instance)
 		}
 
 		cmd->result = DID_NO_CONNECT << 16;
-		hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+		hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 		hostdata->state = S_UNCONNECTED;
 		cmd->scsi_done(cmd);
 
@@ -895,7 +896,7 @@ wd33c93_intr(struct Scsi_Host *instance)
 
 		/* construct an IDENTIFY message with correct disconnect bit */
 
-		hostdata->outgoing_msg[0] = (0x80 | 0x00 | cmd->device->lun);
+		hostdata->outgoing_msg[0] = IDENTIFY(0, sdev_scsi2lun(cmd->device));
 		if (cmd->SCp.phase)
 			hostdata->outgoing_msg[0] |= 0x40;
 
@@ -1179,7 +1180,7 @@ wd33c93_intr(struct Scsi_Host *instance)
 			lun = read_wd33c93(regs, WD_TARGET_LUN);
 			DB(DB_INTR, printk(":%d.%d", cmd->SCp.Status, lun))
 			    hostdata->connected = NULL;
-			hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+			hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 			hostdata->state = S_UNCONNECTED;
 			if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE)
 				cmd->SCp.Status = lun;
@@ -1268,7 +1269,7 @@ wd33c93_intr(struct Scsi_Host *instance)
 		}
 		DB(DB_INTR, printk("UNEXP_DISC"))
 		    hostdata->connected = NULL;
-		hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+		hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 		hostdata->state = S_UNCONNECTED;
 		if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != GOOD)
 			cmd->result =
@@ -1300,7 +1301,7 @@ wd33c93_intr(struct Scsi_Host *instance)
 		switch (hostdata->state) {
 		case S_PRE_CMP_DISC:
 			hostdata->connected = NULL;
-			hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+			hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 			hostdata->state = S_UNCONNECTED;
 			DB(DB_INTR, printk(":%d", cmd->SCp.Status))
 			    if (cmd->cmnd[0] == REQUEST_SENSE
@@ -1353,7 +1354,7 @@ wd33c93_intr(struct Scsi_Host *instance)
 			if (hostdata->selecting) {
 				cmd = (struct scsi_cmnd *) hostdata->selecting;
 				hostdata->selecting = NULL;
-				hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+				hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 				cmd->host_scribble =
 				    (uchar *) hostdata->input_Q;
 				hostdata->input_Q = cmd;
@@ -1365,7 +1366,7 @@ wd33c93_intr(struct Scsi_Host *instance)
 			if (cmd) {
 				if (phs == 0x00) {
 					hostdata->busy[cmd->device->id] &=
-					    ~(1 << cmd->device->lun);
+						~(1 << sdev_scsi2lun(cmd->device));
 					cmd->host_scribble =
 					    (uchar *) hostdata->input_Q;
 					hostdata->input_Q = cmd;
@@ -1448,7 +1449,8 @@ wd33c93_intr(struct Scsi_Host *instance)
 		cmd = (struct scsi_cmnd *) hostdata->disconnected_Q;
 		patch = NULL;
 		while (cmd) {
-			if (id == cmd->device->id && lun == cmd->device->lun)
+			if (id == cmd->device->id &&
+			    lun == sdev_scsi2lun(cmd->device))
 				break;
 			patch = cmd;
 			cmd = (struct scsi_cmnd *) cmd->host_scribble;
@@ -1705,7 +1707,7 @@ wd33c93_abort(struct scsi_cmnd * cmd)
 		sr = read_wd33c93(regs, WD_SCSI_STATUS);
 		printk("asr=%02x, sr=%02x.", asr, sr);
 
-		hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+		hostdata->busy[cmd->device->id] &= ~(1 << sdev_scsi2lun(cmd->device));
 		hostdata->connected = NULL;
 		hostdata->state = S_UNCONNECTED;
 		cmd->result = DID_ABORT << 16;
@@ -2170,7 +2172,8 @@ wd33c93_show_info(struct seq_file *m, struct Scsi_Host *instance)
 		if (hd->connected) {
 			cmd = (struct scsi_cmnd *) hd->connected;
 			seq_printf(m, " %d:%d(%02x)",
-				cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
+				   cmd->device->id, sdev_scsi2lun(cmd->device),
+				   cmd->cmnd[0]);
 		}
 	}
 	if (hd->proc & PR_INPUTQ) {
@@ -2178,7 +2181,8 @@ wd33c93_show_info(struct seq_file *m, struct Scsi_Host *instance)
 		cmd = (struct scsi_cmnd *) hd->input_Q;
 		while (cmd) {
 			seq_printf(m, " %d:%d(%02x)",
-				cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
+				   cmd->device->id, sdev_scsi2lun(cmd->device),
+				   cmd->cmnd[0]);
 			cmd = (struct scsi_cmnd *) cmd->host_scribble;
 		}
 	}
@@ -2187,7 +2191,8 @@ wd33c93_show_info(struct seq_file *m, struct Scsi_Host *instance)
 		cmd = (struct scsi_cmnd *) hd->disconnected_Q;
 		while (cmd) {
 			seq_printf(m, " %d:%d(%02x)",
-				cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
+				   cmd->device->id, sdev_scsi2lun(cmd->device),
+				   cmd->cmnd[0]);
 			cmd = (struct scsi_cmnd *) cmd->host_scribble;
 		}
 	}
drivers/scsi/wd7000.c +2 -1
index 3267423..56bf3bf 100644
@@ -1093,7 +1093,8 @@ static int wd7000_queuecommand_lck(struct scsi_cmnd *SCpnt,
 	Adapter *host = (Adapter *) SCpnt->device->host->hostdata;
 
 	cdblen = SCpnt->cmd_len;
-	idlun = ((SCpnt->device->id << 5) & 0xe0) | (SCpnt->device->lun & 7);
+	idlun = ((SCpnt->device->id << 5) & 0xe0) |
+		(sdev_scsi2lun(SCpnt->device) & 7);
 	SCpnt->scsi_done = done;
 	SCpnt->SCp.phase = 1;
 	scb = alloc_scbs(SCpnt->device->host, 1);
drivers/staging/rts5208/rtsx.c +2 -2
index c0a0e60..be0f91b 100644
@@ -465,14 +465,14 @@ static int rtsx_control_thread(void *__dev)
 		else if (chip->srb->device->id) {
 			dev_err(&dev->pci->dev, "Bad target number (%d:%d)\n",
 				chip->srb->device->id,
-				chip->srb->device->lun);
+				sdev_scsi2lun(chip->srb->device));
 			chip->srb->result = DID_BAD_TARGET << 16;
 		}
 
 		else if (chip->srb->device->lun > chip->max_lun) {
 			dev_err(&dev->pci->dev, "Bad LUN (%d:%d)\n",
 				chip->srb->device->id,
-				chip->srb->device->lun);
+				sdev_scsi2lun(chip->srb->device));
 			chip->srb->result = DID_BAD_TARGET << 16;
 		}
 
include/scsi/scsi_device.h +5 -0
index 816e8a2..e48c60d 100644
@@ -462,6 +462,11 @@ static inline unsigned int sdev_id(struct scsi_device *sdev)
 	return sdev->id;
 }
 
+static inline u8 sdev_scsi2lun(struct scsi_device *sdev)
+{
+	return (u8)(sdev->lun & 0xff);
+}
+
 #define scmd_id(scmd) sdev_id((scmd)->device)
 #define scmd_channel(scmd) sdev_channel((scmd)->device)
 
Signature · 1 line
1.7.12.4
#2 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

Quoted 4 lines · Hannes Reinecke

SCSI-2 defines only up to 256 LUNs with a flat namespace. This patch introduces an accessor 'sdev_scsi2lun' which should be used for these drivers to avoid problems when using 64-bit LUNs internally.

So what would be set in the upper 48 bits for those drivers? We receive the LUN over the wire to start with.

#3 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Hannes Reinecke

SCSI-2 defines only up to 256 LUNs with a flat namespace. This patch introduces an accessor 'sdev_scsi2lun' which should be used for these drivers to avoid problems when using 64-bit LUNs internally.

So what would be set in the upper 48 bits for those drivers? We receive the LUN over the wire to start with.

None. All these devices are physically incapable of receiving or sending LUNs more that a byte wide.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

Quoted 5 lines · Hannes Reinecke
Quoted 3 lines

So what would be set in the upper 48 bits for those drivers? We receive the LUN over the wire to start with.

None. All these devices are physically incapable of receiving or sending LUNs more that a byte wide.

So what problems does this patch fix then?

#5 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Hannes Reinecke
Quoted 3 lines

So what would be set in the upper 48 bits for those drivers? We receive the LUN over the wire to start with.

None. All these devices are physically incapable of receiving or sending LUNs more that a byte wide.

So what problems does this patch fix then?

The intention is twofold:

1) Isolate from any fallout due to the 64bit LUN changes. By introducing accessors we are guaranteed that the drivers will only ever see LUN numbers they are expecting.
2) Using accessors allows us to eventually change the ->lun field to 'struct scsi_lun', and call 'scsilun_to_int' only for display purposes. This will address the objection by Bart for ib_srp, but applies to other drivers as well.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

Quoted 14 lines · Hannes Reinecke
Quoted 11 lines · Christoph Hellwig
Quoted 7 lines · Hannes Reinecke
Quoted 4 lines

So what would be set in the upper 48 bits for those drivers? We receive
the LUN over the wire to start with.

None. All these devices are physically incapable of receiving or sending
LUNs more that a byte wide.

So what problems does this patch fix then?

The intention is twofold:

Quoted 8 lines

1) Isolate from any fallout due to the 64bit LUN changes. By introducing accessors we are guaranteed that the drivers will only ever see LUN numbers they are expecting.
2) Using accessors allows us to eventually change the ->lun field to 'struct scsi_lun', and call 'scsilun_to_int' only for display purposes. This will address the objection by Bart for ib_srp, but applies to other drivers as well.

Oh. And it addresses the build issues Fengguang has been seen during automated kernel builds. Of course.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

In reply to Hannes Reinecke
Quoted 3 lines · Hannes Reinecke

1) Isolate from any fallout due to the 64bit LUN changes. By introducing accessors we are guaranteed that the drivers will only ever see LUN numbers they are expecting.

I really don't see the point. The LUNs have to be passed up from the driver anyway, so seeing anything unexpect just doesn't make sense. Furthermore if we really are worried about this we should have asserts that the higher bytes aren't set, and also take care of the even more limited LUN size for SCSI-2.

Quoted 4 lines

2) Using accessors allows us to eventually change the ->lun field to 'struct scsi_lun', and call 'scsilun_to_int' only for display purposes. This will address the objection by Bart for
ib_srp, but applies to other drivers as well.

So, for any SAM based drivers struct scsi_lun is the wire format anyway, so those are easy. For SCSI-2 and older we can just use scsilun_to_int and easily get the back the LUN that came over the wire. Is it worth to micro optimize by not looking at the other fields? I'd say no, but even if it is I'd rather see this as part of the series moving to embedding the scsi_lun.

FYI, I've merged your first set of fixes for the printk specifiers, but I've not merged anything fixing the other warnings that the build but sent reports for for now.

#8 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

Quoted 23 lines · Christoph Hellwig
Quoted 3 lines · Hannes Reinecke

1) Isolate from any fallout due to the 64bit LUN changes. By introducing accessors we are guaranteed that the drivers will only ever see LUN numbers they are expecting.

I really don't see the point. The LUNs have to be passed up from the driver anyway, so seeing anything unexpect just doesn't make sense. Furthermore if we really are worried about this we should have asserts that the higher bytes aren't set, and also take care of the even more limited LUN size for SCSI-2.

Quoted 4 lines

2) Using accessors allows us to eventually change the ->lun field to 'struct scsi_lun', and call 'scsilun_to_int' only for display purposes. This will address the objection by Bart for
ib_srp, but applies to other drivers as well.

So, for any SAM based drivers struct scsi_lun is the wire format anyway, so those are easy. For SCSI-2 and older we can just use scsilun_to_int and easily get the back the LUN that came over the wire. Is it worth to micro optimize by not looking at the other fields? I'd say no, but even if it is I'd rather see this as part of the series moving to embedding the scsi_lun.

Quoted 4 lines

FYI, I've merged your first set of fixes for the printk specifiers, but I've not merged anything fixing the other warnings that the build but sent reports for for now.

Ok, so I'll be sending a patchset for fixing up the build warnings
(and keeping the current accesses to ->lun), and prepare a different patchset moving everything onto accessors so that we can use struct scsi_lun directly. Agreed?

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

Quoted 5 lines · Hannes Reinecke

Ok, so I'll be sending a patchset for fixing up the build warnings (and keeping the current accesses to ->lun), and prepare a different patchset moving everything onto accessors so that we can use struct scsi_lun directly.
Agreed?

That would be my preference, yes.

Btw, re the build warnings: what's the reason you prefer casts to u8 over just using the %lld printk specifier? Avoiding casts generally seems to be the cleaner variant to me.

#10 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Hannes Reinecke

Ok, so I'll be sending a patchset for fixing up the build warnings (and keeping the current accesses to ->lun), and prepare a different patchset moving everything onto accessors so that we can use struct scsi_lun directly.
Agreed?

Quoted 6 lines

That would be my preference, yes.

Btw, re the build warnings: what's the reason you prefer casts to u8 over just using the %lld printk specifier? Avoiding casts generally seems to be the cleaner variant to me.

Yeah, I've been a bit inconsistent here.
In general I've been using 'u8' casts for the older SCSI parallel
drivers, on the grounds they'll never be seeing any LUN numbers higher than that and I don't have to modify the printk output here.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

In reply to Hannes Reinecke
Quoted 1 line · Hannes Reinecke

SCSI-2 defines only up to 256 LUNs with a flat namespace.

My SCSI-2 draft (revision 10b from August 1989) only has 3 bit LUNs placed in byte 1 of the command block, in the top 3 bits. There are also things called LUNTARs and LUNTRNs at the message level.

8 bit LUNs do ring a distant bell, perhaps after SCSI-2?

Doug Gilbert

#12 lore raw

RE: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

Quoted 13 lines

-----Original Message-----
From: [email protected] [mailto:linux-scsi- [email protected]] On Behalf Of Douglas Gilbert
Sent: Friday, 04 July, 2014 2:44 PM
To: Hannes Reinecke; James Bottomley
Cc: Christoph Hellwig; [email protected]
Subject: Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

Quoted 1 line · Hannes Reinecke

SCSI-2 defines only up to 256 LUNs with a flat namespace.

Quoted 8 lines

My SCSI-2 draft (revision 10b from August 1989) only has 3 bit LUNs placed in byte 1 of the command block, in the top 3 bits. There are also things called LUNTARs and LUNTRNs at the message level.

8 bit LUNs do ring a distant bell, perhaps after SCSI-2?

Doug Gilbert

The hierarchical LUN structures have some limited size LUN subfields:
* the peripheral device addressing method includes an 8-bit TARGET OR LUN subfield, which specifies an 8-bit LUN at the current level (if the BUS IDENTIFIER field is 0)
* the logical unit addressing method has a 5-bit LUN subfield

---
Rob Elliott HP Server Storage

#13 lore raw

Re: [PATCH 1/2] Use sdev_scsi2lun for SCSI parallel drivers

In reply to Douglas Gilbert
Quoted 10 lines · Douglas Gilbert
Quoted 1 line · Hannes Reinecke

SCSI-2 defines only up to 256 LUNs with a flat namespace.

My SCSI-2 draft (revision 10b from August 1989) only has 3 bit LUNs placed in byte 1 of the command block, in the top 3 bits. There are also things called LUNTARs and LUNTRNs at the message level.

8 bit LUNs do ring a distant bell, perhaps after SCSI-2?

Yeah, you're right. SCSI-2 defines a 3-byte LUN; starting with SCSI-3 it went to 64bit.

I'll be renaming them to 'sdev_lun8'.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#14 lore raw

PATCH 2/2 ib_srp: 64bit LUN fixes

In reply to Hannes Reinecke

SRP is capable of handling 64bit LUNs, so as we now have proper support for it we can modify the driver to use the standard functions.

---
 drivers/infiniband/ulp/srp/ib_srp.c   |  9 ++--
 drivers/infiniband/ulp/srpt/ib_srpt.c | 81 +----------------------------------
 2 files changed, 7 insertions(+), 83 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +5 -4
index e3c2c5b..eb55f25 100644
@@ -1713,7 +1713,8 @@ static void srp_process_aer_req(struct srp_target_port *target,
 	s32 delta = be32_to_cpu(req->req_lim_delta);
 
 	shost_printk(KERN_ERR, target->scsi_host, PFX
-		     "ignoring AER for LUN %llu\n", be64_to_cpu(req->lun));
+		     "ignoring AER for LUN %llu\n",
+		     scsilun_to_int((struct scsi_lun *)&req->lun));
 
 	if (srp_response_common(target, delta, &rsp, sizeof rsp))
 		shost_printk(KERN_ERR, target->scsi_host, PFX
@@ -1887,7 +1888,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 	memset(cmd, 0, sizeof *cmd);
 
 	cmd->opcode = SRP_CMD;
-	cmd->lun    = cpu_to_be64((u64) scmnd->device->lun << 48);
+	int_to_scsilun(scmnd->device->lun, (struct scsi_lun *)&cmd->lun);
 	cmd->tag    = req->index;
 	memcpy(cmd->cdb, scmnd->cmnd, scmnd->cmd_len);
 
@@ -2305,7 +2306,7 @@ srp_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
 }
 
 static int srp_send_tsk_mgmt(struct srp_target_port *target,
-			     u64 req_tag, unsigned int lun, u8 func)
+			     u64 req_tag, u64 lun, u8 func)
 {
 	struct srp_rport *rport = target->rport;
 	struct ib_device *dev = target->srp_host->srp_dev->dev;
@@ -2338,7 +2339,7 @@ static int srp_send_tsk_mgmt(struct srp_target_port *target,
 	memset(tsk_mgmt, 0, sizeof *tsk_mgmt);
 
 	tsk_mgmt->opcode 	= SRP_TSK_MGMT;
-	tsk_mgmt->lun		= cpu_to_be64((u64) lun << 48);
+	int_to_scsilun(lun, (struct scsi_lun *)&tsk_mgmt->lun);
 	tsk_mgmt->tag		= req_tag | SRP_TAG_TSK_MGMT;
 	tsk_mgmt->tsk_mgmt_func = func;
 	tsk_mgmt->task_tag	= req_tag;
drivers/infiniband/ulp/srpt/ib_srpt.c +2 -79

99 lines not on this page · raw message

Signature · 1 line
1.7.12.4
maintainer
#15 lore raw

Re: [PATCH 2/2] ib_srp: 64bit LUN fixes

Quoted 9 lines · Hannes Reinecke

SRP is capable of handling 64bit LUNs, so as we now have proper support for it we can modify the driver to use the standard functions.

---
 drivers/infiniband/ulp/srp/ib_srp.c   |  9 ++--
 drivers/infiniband/ulp/srpt/ib_srpt.c | 81 +----------------------------------
 2 files changed, 7 insertions(+), 83 deletions(-)

The SRP initiator and target drivers are independent drivers so this should be two patches instead of one. Furthermore, I do not agree with introducing a call to int_to_scsilun() in the hot path of the initiator driver since that causes a small but unnecessary additional overhead. Please keep in mind that there is no need to repeat the int_to_scsilun() conversion for every I/O request. Hence my earlier proposal to cache the int_to_scsilun() result.

Bart.

#16 lore raw

Re: [PATCH 2/2] ib_srp: 64bit LUN fixes

Quoted 11 lines · Bart Van Assche
Quoted 9 lines · Hannes Reinecke

SRP is capable of handling 64bit LUNs, so as we now have proper support for it we can modify the driver to use the standard functions.

---
  drivers/infiniband/ulp/srp/ib_srp.c   |  9 ++--
  drivers/infiniband/ulp/srpt/ib_srpt.c | 81 +----------------------------------
  2 files changed, 7 insertions(+), 83 deletions(-)
Quoted 8 lines

The SRP initiator and target drivers are independent drivers so this should be two patches instead of one. Furthermore, I do not agree with introducing a call to int_to_scsilun() in the hot path of the initiator driver since that causes a small but unnecessary additional overhead. Please keep in mind that there is no need to repeat the int_to_scsilun() conversion for every I/O request. Hence my earlier proposal to cache the int_to_scsilun() result.

What I would like to do is to provide accessor functions for the scsi lun; I've started this already for the older SCSI parallel drivers (see my earlier patch). Once everything is moved over to accessors it should be trivial to move from the current scsilun_to_int representation in struct scsi_device to the 'real' LUN.

Adding another field would be bit of an overkill IMO, seeing that we can achieve the very same thing with a bit of code reshuffling.

James, Christoph, what's your opinion on using accessors?
Would solve this issue nicely, and we can also use proper functions for HBAs only capable of handling 32bit LUNs. Drawback is that we would need accessors also for this capable of handling full 64bit LUNs, thus potentially incur some overhead there.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#17 lore raw

Re: [PATCH 2/2] ib_srp: 64bit LUN fixes

Quoted 7 lines · Hannes Reinecke

What I would like to do is to provide accessor functions for the scsi lun; I've started this already for the older SCSI parallel drivers (see my earlier patch).
Once everything is moved over to accessors it should be trivial to move from the current scsilun_to_int representation in struct scsi_device to the 'real' LUN.

Quoted 8 lines

Adding another field would be bit of an overkill IMO, seeing that we can achieve the very same thing with a bit of code reshuffling.

James, Christoph, what's your opinion on using accessors?
Would solve this issue nicely, and we can also use proper functions for HBAs only capable of handling 32bit LUNs.
Drawback is that we would need accessors also for this capable of handling full 64bit LUNs, thus potentially incur some overhead there.

I think storing the struct scsi_lun in the scsi_device is the right way to go ahead. Any "accessors" for 8 or 32-bit LUNs should be simply enough by just ignoring bits in the array, so there's very little performance overhead.

If we can get rid of the old scalar LUN field that would be great, and given that we know the printk format fallout already it doesn't look like too much work. Do you want to look into this?

#18 lore raw

Re: [PATCH 2/2] ib_srp: 64bit LUN fixes

Quoted 17 lines · Christoph Hellwig
Quoted 7 lines · Hannes Reinecke

What I would like to do is to provide accessor functions for the scsi lun; I've started this already for the older SCSI parallel drivers (see my earlier patch).
Once everything is moved over to accessors it should be trivial to move from the current scsilun_to_int representation in struct scsi_device to the 'real' LUN.

Quoted 8 lines

Adding another field would be bit of an overkill IMO, seeing that we can achieve the very same thing with a bit of code reshuffling.

James, Christoph, what's your opinion on using accessors?
Would solve this issue nicely, and we can also use proper functions for HBAs only capable of handling 32bit LUNs.
Drawback is that we would need accessors also for this capable of handling full 64bit LUNs, thus potentially incur some overhead there.

Quoted 9 lines

I think storing the struct scsi_lun in the scsi_device is the right way to go ahead. Any "accessors" for 8 or 32-bit LUNs should be simply enough by just ignoring bits in the array, so there's very little performance overhead.

If we can get rid of the old scalar LUN field that would be great, and given that we know the printk format fallout already it doesn't look like too much work. Do you want to look into this?

Already working on it.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#19 lore raw

Re: [PATCH 2/2] ib_srp: 64bit LUN fixes

Quoted 11 lines · Hannes Reinecke
Quoted 8 lines · Christoph Hellwig

I think storing the struct scsi_lun in the scsi_device is the right way to go ahead. Any "accessors" for 8 or 32-bit LUNs should be simply enough by just ignoring bits in the array, so there's very little performance overhead.

If we can get rid of the old scalar LUN field that would be great, and given that we know the printk format fallout already it doesn't look like too much work. Do you want to look into this?

Already working on it.

That sounds great. Regarding the SRP initiator driver: if the "__be64 lun" declarations in <scsi/srp.h> are changed into "struct scsi_lun lun" then that allows to encode / decode LUNs inside the SRP initiator without having to cast the address of these "lun" members into struct scsi_lun *. In case you would prefer me to have a look into this, please let me know.

Bart.

#20 lore raw

Re: [PATCH 2/2] ib_srp: 64bit LUN fixes

Quoted 11 lines · Bart Van Assche
Quoted 10 lines · Hannes Reinecke
Quoted 8 lines · Christoph Hellwig

I think storing the struct scsi_lun in the scsi_device is the right way to go ahead. Any "accessors" for 8 or 32-bit LUNs should be simply enough by just ignoring bits in the array, so there's very little performance overhead.

If we can get rid of the old scalar LUN field that would be great, and given that we know the printk format fallout already it doesn't look like too much work. Do you want to look into this?

Quoted 9 lines
Quoted 1 line

Already working on it.

That sounds great. Regarding the SRP initiator driver: if the "__be64 lun" declarations in <scsi/srp.h> are changed into "struct scsi_lun lun" then that allows to encode / decode LUNs inside the SRP initiator without having to cast the address of these "lun" members into struct scsi_lun *. In case you would prefer me to have a look into this, please let me know.

That would be perfect.
Most of the HBAs supporting 64bit LUNs internally are already doing this.

Cheers,

Hannes

Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#21 lore raw

Re: [PATCH 2/2] ib_srp: 64bit LUN fixes

Quoted 22 lines · Hannes Reinecke
Quoted 12 lines · Bart Van Assche
Quoted 11 lines · Hannes Reinecke
Quoted 9 lines · Christoph Hellwig

I think storing the struct scsi_lun in the scsi_device is the right way to go ahead. Any "accessors" for 8 or 32-bit LUNs should be simply enough by just ignoring bits in the array, so there's very little performance overhead.

If we can get rid of the old scalar LUN field that would be great, and given that we know the printk format fallout already it doesn't look
like too much work. Do you want to look into this?

Quoted 9 lines
Quoted 1 line

Already working on it.

That sounds great. Regarding the SRP initiator driver: if the "__be64 lun" declarations in <scsi/srp.h> are changed into "struct scsi_lun lun" then that allows to encode / decode LUNs inside the SRP initiator without having to cast the address of these "lun" members into struct scsi_lun *. In case you would prefer me to have a look into this, please let me know.

Quoted 2 lines

That would be perfect.
Most of the HBAs supporting 64bit LUNs internally are already doing this.

Here it is (compile tested only on x86 and ppc - will do more testing once the entire series is available). Please CC all maintainers and relevant mailing lists for the next version of the 64-bit LUN patch series. Several IB/SRP users are reading the linux-rdma mailing list but not the linux-scsi mailing list.

From: Bart Van Assche <[email protected]>
Date: Fri, 4 Jul 2014 17:11:31 +0200
Subject: [PATCH] SRP: Convert lun into struct scsi_lun

Checked the following structure sizes with gdb:
* sizeof(struct srp_cmd) = 48
* sizeof(struct srp_tsk_mgmt) = 48
* sizeof(struct srp_aer_req) = 36

The ibmvscsi changes have been compile tested only (on a PPC system).

---
 drivers/infiniband/ulp/srp/ib_srp.c   |  6 ++--
 drivers/infiniband/ulp/srpt/ib_srpt.c | 68 ++---------------------------------
 drivers/scsi/ibmvscsi/ibmvscsi.c      |  6 ++--
 drivers/scsi/libsrp.c                 |  7 ++--
 include/scsi/srp.h                    |  6 ++--
 5 files changed, 14 insertions(+), 79 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +3 -3
index b017a3a..a04f245 100644
@@ -1719,7 +1719,7 @@ static void srp_process_aer_req(struct srp_target_port *target,
 	s32 delta = be32_to_cpu(req->req_lim_delta);
 
 	shost_printk(KERN_ERR, target->scsi_host, PFX
-		     "ignoring AER for LUN %llu\n", be64_to_cpu(req->lun));
+		     "ignoring AER for LUN %u\n", scsilun_to_int(&req->lun));
 
 	if (srp_response_common(target, delta, &rsp, sizeof rsp))
 		shost_printk(KERN_ERR, target->scsi_host, PFX
@@ -1914,7 +1914,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd)
 	memset(cmd, 0, sizeof *cmd);
 
 	cmd->opcode = SRP_CMD;
-	cmd->lun    = cpu_to_be64((u64) scmnd->device->lun << 48);
+	int_to_scsilun(scmnd->device->lun, &cmd->lun);
 	cmd->tag    = req->index;
 	memcpy(cmd->cdb, scmnd->cmnd, scmnd->cmd_len);
 
@@ -2365,7 +2365,7 @@ static int srp_send_tsk_mgmt(struct srp_target_port *target,
 	memset(tsk_mgmt, 0, sizeof *tsk_mgmt);
 
 	tsk_mgmt->opcode 	= SRP_TSK_MGMT;
-	tsk_mgmt->lun		= cpu_to_be64((u64) lun << 48);
+	int_to_scsilun(lun, &tsk_mgmt->lun);
 	tsk_mgmt->tag		= req_tag | SRP_TAG_TSK_MGMT;
 	tsk_mgmt->tsk_mgmt_func = func;
 	tsk_mgmt->task_tag	= req_tag;
drivers/infiniband/ulp/srpt/ib_srpt.c +2 -66

86 lines not on this page · raw message

drivers/scsi/ibmvscsi/ibmvscsi.c +3 -3
index 2ebfb2b..34fcfc5 100644
@@ -1042,7 +1042,7 @@ static int ibmvscsi_queuecommand_lck(struct scsi_cmnd *cmnd,
 	memset(srp_cmd, 0x00, SRP_MAX_IU_LEN);
 	srp_cmd->opcode = SRP_CMD;
 	memcpy(srp_cmd->cdb, cmnd->cmnd, sizeof(srp_cmd->cdb));
-	srp_cmd->lun = cpu_to_be64(((u64)lun) << 48);
+	int_to_scsilun(lun, &srp_cmd->lun);
 
 	if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) {
 		if (!firmware_has_feature(FW_FEATURE_CMO))
@@ -1518,7 +1518,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
 		/* Set up an abort SRP command */
 		memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt));
 		tsk_mgmt->opcode = SRP_TSK_MGMT;
-		tsk_mgmt->lun = cpu_to_be64(((u64) lun) << 48);
+		int_to_scsilun(lun, &tsk_mgmt->lun);
 		tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK;
 		tsk_mgmt->task_tag = (u64) found_evt;
 
@@ -1641,7 +1641,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
 		/* Set up a lun reset SRP command */
 		memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt));
 		tsk_mgmt->opcode = SRP_TSK_MGMT;
-		tsk_mgmt->lun = cpu_to_be64(((u64) lun) << 48);
+		int_to_scsilun(lun, &tsk_mgmt->lun);
 		tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET;
 
 		evt->sync_srp = &srp_rsp;
drivers/scsi/libsrp.c +3 -4
index 0707ecd..0768051 100644
@@ -421,8 +421,8 @@ int srp_cmd_queue(struct Scsi_Host *shost, struct srp_cmd *cmd, void *info,
 	dir = srp_cmd_direction(cmd);
 	len = vscsis_data_length(cmd, dir);
 
-	dprintk("%p %x %lx %d %d %d %llx\n", info, cmd->cdb[0],
-		cmd->lun, dir, len, tag, (unsigned long long) cmd->tag);
+	dprintk("%p %x %u %d %d %d %llx\n", info, cmd->cdb[0],
+		scsilun_to_int(&cmd->lun), dir, len, tag, cmd->tag);
 
 	sc = scsi_host_get_command(shost, dir, GFP_KERNEL);
 	if (!sc)
@@ -433,8 +433,7 @@ int srp_cmd_queue(struct Scsi_Host *shost, struct srp_cmd *cmd, void *info,
 	sc->sdb.length = len;
 	sc->sdb.table.sgl = (void *) (unsigned long) addr;
 	sc->tag = tag;
-	err = scsi_tgt_queue_command(sc, itn_id, (struct scsi_lun *)&cmd->lun,
-				     cmd->tag);
+	err = scsi_tgt_queue_command(sc, itn_id, &cmd->lun, cmd->tag);
 	if (err)
 		scsi_host_put_command(shost, sc);
 
include/scsi/srp.h +3 -3
index 1ae84db..4844516 100644
@@ -179,7 +179,7 @@ struct srp_tsk_mgmt {
 	u8	reserved1[6];
 	u64	tag;
 	u8	reserved2[4];
-	__be64	lun __attribute__((packed));
+	struct scsi_lun	lun;
 	u8	reserved3[2];
 	u8	tsk_mgmt_func;
 	u8	reserved4;
@@ -200,7 +200,7 @@ struct srp_cmd {
 	u8	data_in_desc_cnt;
 	u64	tag;
 	u8	reserved2[4];
-	__be64	lun __attribute__((packed));
+	struct scsi_lun	lun;
 	u8	reserved3;
 	u8	task_attr;
 	u8	reserved4;
@@ -265,7 +265,7 @@ struct srp_aer_req {
 	__be32	req_lim_delta;
 	u64	tag;
 	u32	reserved2;
-	__be64	lun;
+	struct scsi_lun	lun;
 	__be32	sense_data_len;
 	u32	reserved3;
 	u8	sense_data[0];
Signature · 1 line
1.8.4.5