*     Zero.
  */
 int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
-                      unsigned int id, unsigned int lun)
+                      unsigned int id, u64 lun)
 {
        struct ata_port *ap = ata_shost_to_port(shost);
        unsigned long flags;
 
 extern void ata_scsi_dev_rescan(struct work_struct *work);
 extern int ata_bus_probe(struct ata_port *ap);
 extern int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
-                             unsigned int id, unsigned int lun);
+                             unsigned int id, u64 lun);
 
 
 /* libata-eh.c */
 
 typedef struct _VirtDevice {
        VirtTarget              *vtarget;
        u8                       configured_lun;
-       int                      lun;
+       u64                      lun;
 } VirtDevice;
 
 /*
 
         || (loops > 0 && ioc->active == 0)) {
                spin_unlock_irqrestore(shost->host_lock, flags);
                dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
-                       "mptfc_block_error_handler.%d: %d:%d, port status is "
+                       "mptfc_block_error_handler.%d: %d:%llu, port status is "
                        "%x, active flag %d, deferring %s recovery.\n",
                        ioc->name, ioc->sh->host_no,
                        SCpnt->device->id, SCpnt->device->lun,
        if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata
         || ioc->active == 0) {
                dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
-                       "%s.%d: %d:%d, failing recovery, "
+                       "%s.%d: %d:%llu, failing recovery, "
                        "port state %x, active %d, vdevice %p.\n", caller,
                        ioc->name, ioc->sh->host_no,
                        SCpnt->device->id, SCpnt->device->lun, ready,
                return FAILED;
        }
        dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
-               "%s.%d: %d:%d, executing recovery.\n", caller,
+               "%s.%d: %d:%llu, executing recovery.\n", caller,
                ioc->name, ioc->sh->host_no,
                SCpnt->device->id, SCpnt->device->lun));
        return (*func)(SCpnt);
 
 static void    mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply);
 
 int    mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id,
-               int lun, int ctx2abort, ulong timeout);
+               u64 lun, int ctx2abort, ulong timeout);
 
 int            mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
 int            mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
        }
 
        scsi_print_command(sc);
-       printk(MYIOC_s_DEBUG_FMT "\tfw_channel = %d, fw_id = %d, lun = %d\n",
+       printk(MYIOC_s_DEBUG_FMT "\tfw_channel = %d, fw_id = %d, lun = %llu\n",
            ioc->name, pScsiReply->Bus, pScsiReply->TargetID, sc->device->lun);
        printk(MYIOC_s_DEBUG_FMT "\trequest_len = %d, underflow = %d, "
            "resid = %d\n", ioc->name, scsi_bufflen(sc), sc->underflow,
                 */
                if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID &&
                    pScsiReply->ResponseInfo) {
-                       printk(MYIOC_s_NOTE_FMT "[%d:%d:%d:%d] "
+                       printk(MYIOC_s_NOTE_FMT "[%d:%d:%d:%llu] "
                        "FCP_ResponseInfo=%08xh\n", ioc->name,
                        sc->device->host->host_no, sc->device->channel,
                        sc->device->id, sc->device->lun,
                return;
        ioc = hd->ioc;
        if (time - hd->last_queue_full > 10 * HZ) {
-               dprintk(ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n",
+               dprintk(ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%llu) reported QUEUE_FULL!\n",
                                ioc->name, 0, sc->device->id, sc->device->lun));
                hd->last_queue_full = time;
        }
  *
  **/
 int
-mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun,
+mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, u64 lun,
        int ctx2abort, ulong timeout)
 {
        MPT_FRAME_HDR   *mf;
        vdevice = sdev->hostdata;
 
        dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
-               "device @ %p, channel=%d, id=%d, lun=%d\n",
+               "device @ %p, channel=%d, id=%d, lun=%llu\n",
                ioc->name, sdev, sdev->channel, sdev->id, sdev->lun));
        if (ioc->bus_type == SPI)
                dsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
                                           + (my_idx * MPT_SENSE_BUFFER_ALLOC));
 
        devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
-           "%s: Sending Command 0x%02x for fw_channel=%d fw_id=%d lun=%d\n",
+           "%s: Sending Command 0x%02x for fw_channel=%d fw_id=%d lun=%llu\n",
            ioc->name, __func__, cmd, io->channel, io->id, io->lun));
 
        if (dir == MPI_SCSIIO_CONTROL_READ)
 
        u8              cmd;            /* SCSI Op Code */
        u8              channel;        /* bus number */
        u8              id;             /* SCSI ID (virtual) */
-       int             lun;
+       u64             lun;
        u8              flags;          /* Bit Field - See above */
        u8              physDiskNum;    /* Phys disk number, -1 else */
        u8              rsvd2;
 extern const char * mptscsih_info(struct Scsi_Host *SChost);
 extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt);
 extern int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel,
-       u8 id, int lun, int ctx2abort, ulong timeout);
+       u8 id, u64 lun, int ctx2abort, ulong timeout);
 extern void mptscsih_slave_destroy(struct scsi_device *device);
 extern int mptscsih_slave_configure(struct scsi_device *device);
 extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
 
 struct i2o_scsi_host {
        struct Scsi_Host *scsi_host;    /* pointer to the SCSI host */
        struct i2o_controller *iop;     /* pointer to the I2O controller */
-       unsigned int lun;       /* lun's used for block devices */
+       u64 lun;        /* lun's used for block devices */
        struct i2o_device *channel[0];  /* channel->i2o_dev mapping table */
 };
 
        }
 
        if (le64_to_cpu(lun) >= scsi_host->max_lun) {
-               osm_warn("SCSI device lun (%lu) >= max_lun of I2O host (%d)",
-                        (long unsigned int)le64_to_cpu(lun),
-                        scsi_host->max_lun);
+               osm_warn("SCSI device lun (%llu) >= max_lun of I2O host (%d)",
+                        le64_to_cpu(lun), scsi_host->max_lun);
                return -EFAULT;
        }
 
        if (rc)
                goto err;
 
-       osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n",
+       osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %llu\n",
                 i2o_dev->lct_data.tid, channel, le32_to_cpu(id),
-                (long unsigned int)le64_to_cpu(lun));
+                le64_to_cpu(lun));
 
        return 0;
 
 
        rec->scsi_retries = sc->retries;
        rec->scsi_allowed = sc->allowed;
        rec->scsi_id = sc->device->id;
-       rec->scsi_lun = sc->device->lun;
+       /* struct zfcp_dbf_scsi needs to be updated to handle 64bit LUNs */
+       rec->scsi_lun = (u32)sc->device->lun;
        rec->host_scribble = (unsigned long)sc->host_scribble;
 
        memcpy(rec->scsi_opcode, sc->cmnd,
 
 void zfcp_unit_scsi_scan(struct zfcp_unit *unit)
 {
        struct fc_rport *rport = unit->port->rport;
-       unsigned int lun;
+       u64 lun;
 
        lun = scsilun_to_int((struct scsi_lun *) &unit->fcp_lun);
 
 {
        struct Scsi_Host *shost;
        struct zfcp_port *port;
-       unsigned int lun;
+       u64 lun;
 
        lun = scsilun_to_int((struct scsi_lun *) &unit->fcp_lun);
        port = unit->port;
 
                                                 DMA_TO_DEVICE);
 
                                cmnd[0] = REQUEST_SENSE;
-                               cmnd[1] = (SCp->device->lun & 0x7) << 5;
+                               cmnd[1] = (lun & 0x7) << 5;
                                cmnd[2] = 0;
                                cmnd[3] = 0;
                                cmnd[4] = SCSI_SENSE_BUFFERSIZE;
        struct NCR_700_Host_Parameters *hostdata =
                (struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0];
        __u16 count = 1;        /* for IDENTIFY message */
-       
+       u8 lun = SCp->device->lun;
+
        if(hostdata->state != NCR_700_HOST_FREE) {
                /* keep this inside the lock to close the race window where
                 * the running command finishes on another CPU while we don't
 
        hostdata->msgout[0] = NCR_700_identify((SCp->cmnd[0] != REQUEST_SENSE &&
                                                slot->flags != NCR_700_FLAG_AUTOSENSE),
-                                              SCp->device->lun);
+                                              lun);
        /* for INQUIRY or REQUEST_SENSE commands, we cannot be sure
         * if the negotiated transfer parameters still hold, so
         * always renegotiate them */
 
 
 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, cmd->device->lun);
+       SPRINTF("scsi%d : destination target %d, lun %llu\n", cmd->device->host->host_no, cmd->device->id, cmd->device->lun);
        SPRINTF("        command = ");
        lprint_command(cmd->cmnd, m);
 }
                        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], tmp->device->lun);
+                                   dprintk(NDEBUG_LISTS, "MAIN tmp=%p   target=%d   busy=%d lun=%llu\n", tmp, tmp->device->id, hostdata->busy[tmp->device->id], tmp->device->lun);
                                /*  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 << (u8)(tmp->device->lun & 0xff)))) {
                                        if (prev) {
                                                REMOVE(prev, prev->host_scribble, tmp, tmp->host_scribble);
                                                prev->host_scribble = tmp->host_scribble;
                                         * 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, tmp->device->lun);
+                                       dprintk(NDEBUG_MAIN|NDEBUG_QUEUES, "scsi%d : main() : command for target %d lun %llu removed from issue_queue\n", instance->host_no, tmp->device->id, tmp->device->lun);
        
                                        /*
                                         * A successful selection is defined as one that 
        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);
+       hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF));
 
        initialize_SCp(cmd);
 
                                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, cmd->device->lun);
+                                       dprintk(NDEBUG_LINKED, "scsi%d : target %d lun %llu linked command complete.\n", instance->host_no, cmd->device->id, cmd->device->lun);
                                        /* 
                                         * 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, cmd->device->lun);
+                                           printk("scsi%d : target %d lun %llu linked command complete, no next_link\n" instance->host_no, cmd->device->id, cmd->device->lun);
                                                sink = 1;
                                                do_abort(instance);
                                                return;
                                        /* 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, cmd->device->lun);
+                                       dprintk(NDEBUG_LINKED, "scsi%d : target %d lun %llu linked request done, calling scsi_done().\n", instance->host_no, cmd->device->id, cmd->device->lun);
                                        collect_stats(hostdata, cmd);
                                        cmd->scsi_done(cmd);
                                        cmd = hostdata->connected;
                                        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, cmd->device->lun);
-                                       hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+                                       dprintk(NDEBUG_QUEUES, "scsi%d : command for target %d, lun %llu completed\n", instance->host_no, cmd->device->id, cmd->device->lun);
+                                       hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xFF));
 
                                        /* 
                                         * I'm not sure what the correct thing to do here is : 
                                        case ORDERED_QUEUE_TAG:
                                        case SIMPLE_QUEUE_TAG:
                                                cmd->device->simple_tags = 0;
-                                               hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
+                                               hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF));
                                                break;
                                        default:
                                                break;
                                                    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, cmd->device->lun);
+                                               dprintk(NDEBUG_QUEUES, "scsi%d : command for target %d lun %llu was moved from connected to" "  the disconnected_queue\n", instance->host_no, cmd->device->id, cmd->device->lun);
                                                /* 
                                                 * Restore phase bits to 0 so an interrupted selection, 
                                                 * arbitration can resume.
                                hostdata->last_message = msgout;
                                NCR5380_transfer_pio(instance, &phase, &len, &data);
                                if (msgout == ABORT) {
-                                       hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+                                       hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xFF));
                                        hostdata->connected = NULL;
                                        cmd->result = DID_ERROR << 16;
                                        collect_stats(hostdata, cmd);
 
 
                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 == tmp->device->lun)
+                       if ((target_mask == (1 << tmp->device->id)) && (lun == (u8)tmp->device->lun)
                            ) {
                                if (prev) {
                                        REMOVE(prev, prev->host_scribble, tmp, tmp->host_scribble);
                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, tmp->device->lun, tmp->tag);
+               dprintk(NDEBUG_RESELECTION, "scsi%d : nexus established, target = %d, lun = %llu, tag = %d\n", instance->host_no, tmp->device->id, tmp->device->lun, tmp->tag);
        }
 }
 
 
        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, (u8)SCpnt->device->lun, scsi_bufflen(SCpnt)));
 
 #if 0
        VDEB(for (i = 0; i < SCpnt->cmd_len; i++)
 
                printk("max cdb length= %x\b", cmd->cmd_len);
                scb->cdb_len = IMAX_CDB;
        }
-       scb->ident = cmd->device->lun | DISC_ALLOW;
+       scb->ident = (u8)(cmd->device->lun & 0xff) | DISC_ALLOW;
        if (cmd->device->tagged_supported) {    /* Tag Support                  */
                scb->tag_msg = SIMPLE_QUEUE_TAG;        /* Do simple tag only   */
        } else {
 
        int count;
        int ret = FAILED;
 
-       printk(KERN_ERR "%s: Host adapter abort request (%d,%d,%d,%d)\n",
+       printk(KERN_ERR "%s: Host adapter abort request (%d,%d,%d,%llu)\n",
                AAC_DRIVERNAME,
                host->host_no, sdev_channel(dev), sdev_id(dev), dev->lun);
        switch (cmd->cmnd[0]) {
 
 #define CMDINFO(cmd) \
                        (cmd) ? ((cmd)->device->host->host_no) : -1, \
                         (cmd) ? ((cmd)->device->id & 0x0f) : -1, \
-                       (cmd) ? ((cmd)->device->lun & 0x07) : -1
+                       (cmd) ? ((u8)(cmd)->device->lun & 0x07) : -1
 
 static inline void
 CMD_INC_RESID(struct scsi_cmnd *cmd, int inc)
 #if defined(AHA152X_DEBUG)
                        int hostno=DONE_SC->device->host->host_no;
                        int id=DONE_SC->device->id & 0xf;
-                       int lun=DONE_SC->device->lun & 0x7;
+                       int lun=((u8)DONE_SC->device->lun) & 0x7;
 #endif
                        Scsi_Cmnd *ptr = DONE_SC;
                        DONE_SC=NULL;
        int i;
 
        SPRINTF("%p: target=%d; lun=%d; cmnd=( ",
-               ptr, ptr->device->id, ptr->device->lun);
+               ptr, ptr->device->id, (u8)ptr->device->lun);
 
        for (i = 0; i < COMMAND_SIZE(ptr->cmnd[0]); i++)
                SPRINTF("0x%02x ", ptr->cmnd[i]);
 
 #endif
 
 #define AHD_BUILD_COL_IDX(target, lun)                         \
-       (((lun) << 4) | target)
+       ((((u8)lun) << 4) | target)
 
 #define AHD_GET_SCB_COL_IDX(ahd, scb)                          \
        ((SCB_GET_LUN(scb) << 4) | SCB_GET_TARGET(ahd, scb))
 
        if (do_fallback) {
                printk("%s: device overrun (status %x) on %d:%d:%d\n",
                       ahd_name(ahd), status, cmd->device->channel,
-                      cmd->device->id, cmd->device->lun);
+                      cmd->device->id, (u8)cmd->device->lun);
        }
 
        ahd_cmd_set_transaction_status(cmd, new_status);
        disconnected = TRUE;
        if (ahd_search_qinfifo(ahd, cmd->device->id, 
                               cmd->device->channel + 'A',
-                              cmd->device->lun, 
+                              cmd->device->lun,
                               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, cmd->device->lun);
+                      cmd->device->id, (u8)cmd->device->lun);
                retval = SUCCESS;
                goto done;
        }
 
 
        seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n",
                  sdev->sdev_target->channel + 'A',
-                 sdev->sdev_target->id, sdev->lun);
+                  sdev->sdev_target->id, (u8)sdev->lun);
 
        seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued);
        seq_printf(m, "\t\tCommands Active %d\n", dev->active);
 
                 */
                printk("%s:%d:%d:%d: Is not an active device\n",
                       ahc_name(ahc), cmd->device->channel, cmd->device->id,
-                      cmd->device->lun);
+                      (u8)cmd->device->lun);
                retval = SUCCESS;
                goto no_cmd;
        }
        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',
-                                      cmd->device->lun,
+                                      (u8)cmd->device->lun,
                                       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,
-                      cmd->device->lun);
+                      (u8)cmd->device->lun);
                retval = SUCCESS;
                goto done;
        }
                                       SEARCH_COMPLETE) > 0) {
                        printk("%s:%d:%d:%d: Cmd aborted from QINFIFO\n",
                               ahc_name(ahc), cmd->device->channel,
-                                       cmd->device->id, cmd->device->lun);
+                              cmd->device->id, (u8)cmd->device->lun);
                        retval = SUCCESS;
                        goto done;
                }
        } else if (ahc_search_qinfifo(ahc, cmd->device->id,
                                      cmd->device->channel + 'A',
-                                     cmd->device->lun, pending_scb->hscb->tag,
+                                     cmd->device->lun,
+                                     pending_scb->hscb->tag,
                                      ROLE_INITIATOR, /*status*/0,
                                      SEARCH_COUNT) > 0) {
                disconnected = FALSE;
 
 
        seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n",
                  sdev->sdev_target->channel + 'A',
-                 sdev->sdev_target->id, sdev->lun);
+                  sdev->sdev_target->id, (u8)sdev->lun);
 
        seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued);
        seq_printf(m, "\t\tCommands Active %d\n", dev->active);
 
                                        " poll command abort successfully \n"
                                        , acb->host->host_no
                                        , ccb->pcmd->device->id
-                                       , ccb->pcmd->device->lun
+                                       , (u32)ccb->pcmd->device->lun
                                        , ccb);
                                ccb->pcmd->result = DID_ABORT << 16;
                                arcmsr_ccb_complete(ccb);
                                        " poll command abort successfully \n"
                                        ,acb->host->host_no
                                        ,ccb->pcmd->device->id
-                                       ,ccb->pcmd->device->lun
+                                       ,(u32)ccb->pcmd->device->lun
                                        ,ccb);
                                ccb->pcmd->result = DID_ABORT << 16;
                                arcmsr_ccb_complete(ccb);
                                        " poll command abort successfully \n"
                                        , acb->host->host_no
                                        , pCCB->pcmd->device->id
-                                       , pCCB->pcmd->device->lun
+                                       , (u32)pCCB->pcmd->device->lun
                                        , pCCB);
                                        pCCB->pcmd->result = DID_ABORT << 16;
                                        arcmsr_ccb_complete(pCCB);
        int rtn = FAILED;
        printk(KERN_NOTICE
                "arcmsr%d: abort device command of scsi id = %d lun = %d \n",
-               acb->host->host_no, cmd->device->id, cmd->device->lun);
+               acb->host->host_no, cmd->device->id, (u32)cmd->device->lun);
        acb->acb_flags |= ACB_F_ABORT;
        acb->num_aborts++;
        /*
 
            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 +
+                   (u8)(SCpnt->device->lun & 0x07), host->busyluns);
 
        host->stats.removes += 1;
 
        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 +
+                 (u8)(SCpnt->device->lun & 0x7), host->busyluns);
 
        SCpnt->scsi_done(SCpnt);
     } else
            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 +
+                   (u8)(host->SCpnt->device->lun & 0x7), host->busyluns);
            break;
 #endif
        case EXTENDED_MESSAGE | (EXTENDED_SDTR << 8):
 //#if (DEBUG & DEBUG_ABORT)
                printk("clear ");
 //#endif
-               clear_bit(SCpnt->device->id * 8 + SCpnt->device->lun, host->busyluns);
+               clear_bit(SCpnt->device->id * 8 +
+                         (u8)(SCpnt->device->lun & 0x7), host->busyluns);
 
        /*
         * We found the command, and cleared it out.  Either
 
     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/%llu   ", scd->id, scd->lun);
        if (scd->tagged_supported)
                seq_printf(m, "%3sabled(%3d) ",
                             scd->simple_tags ? "en" : "dis",
 
                        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 +
+                       (u8)(SCpnt->device->lun & 0x7), info->busyluns);
 
        info->stats.removes += 1;
        switch (SCpnt->cmnd[0]) {
         * 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 +
+                 (u8)(SCpnt->device->lun & 0x7), info->busyluns);
 
        fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned int))SCpnt->host_scribble;
        fn(info, SCpnt, result);
                 * been set.
                 */
                info->origSCpnt = NULL;
-               clear_bit(SCpnt->device->id * 8 + SCpnt->device->lun, info->busyluns);
+               clear_bit(SCpnt->device->id * 8 +
+                         (u8)(SCpnt->device->lun & 0x7), info->busyluns);
                printk("waiting for execution ");
                res = res_success;
        } else
 
        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/%llu   ", scd->id, scd->lun);
                if (scd->tagged_supported)
                        seq_printf(m, "%3sabled(%3d) ",
                                     scd->simple_tags ? "en" : "dis",
 
        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 +
+                             (u8)(q->SCpnt->device->lun & 0x7), exclude)) {
                        SCpnt = __queue_remove(queue, l);
                        break;
                }
 
 
 static int is_lun_busy(Scsi_Cmnd *cmd, int should_be_tagged)
 {
+       u8 lun = cmd->device->lun;
        SETUP_HOSTDATA(cmd->device->host);
 
-       if (hostdata->busy[cmd->device->id] & (1 << cmd->device->lun))
+       if (hostdata->busy[cmd->device->id] & (1 << lun))
                return 1;
        if (!should_be_tagged ||
            !setup_use_tagged_queuing || !cmd->device->tagged_supported)
                return 0;
-       if (TagAlloc[cmd->device->id][cmd->device->lun].nr_allocated >=
-           TagAlloc[cmd->device->id][cmd->device->lun].queue_size) {
+       if (TagAlloc[cmd->device->id][lun].nr_allocated >=
+           TagAlloc[cmd->device->id][lun].queue_size) {
                dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d: no free tags\n",
-                          H_NO(cmd), cmd->device->id, cmd->device->lun);
+                          H_NO(cmd), cmd->device->id, lun);
                return 1;
        }
        return 0;
 
 static void cmd_get_tag(Scsi_Cmnd *cmd, int should_be_tagged)
 {
+       u8 lun = cmd->device->lun;
        SETUP_HOSTDATA(cmd->device->host);
 
        /* If we or the target don't support tagged queuing, allocate the LUN for
        if (!should_be_tagged ||
            !setup_use_tagged_queuing || !cmd->device->tagged_supported) {
                cmd->tag = TAG_NONE;
-               hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
+               hostdata->busy[cmd->device->id] |= (1 << lun);
                dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d now allocated by untagged "
-                          "command\n", H_NO(cmd), cmd->device->id, cmd->device->lun);
+                          "command\n", H_NO(cmd), cmd->device->id, lun);
        } else {
-               TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
+               TAG_ALLOC *ta = &TagAlloc[cmd->device->id][lun];
 
                cmd->tag = find_first_zero_bit(ta->allocated, MAX_TAGS);
                set_bit(cmd->tag, ta->allocated);
                dprintk(NDEBUG_TAGS, "scsi%d: using tag %d for target %d lun %d "
                           "(now %d tags in use)\n",
                           H_NO(cmd), cmd->tag, cmd->device->id,
-                          cmd->device->lun, ta->nr_allocated);
+                          lun, ta->nr_allocated);
        }
 }
 
 
 static void cmd_free_tag(Scsi_Cmnd *cmd)
 {
+       u8 lun = cmd->device->lun;
        SETUP_HOSTDATA(cmd->device->host);
 
        if (cmd->tag == TAG_NONE) {
-               hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+               hostdata->busy[cmd->device->id] &= ~(1 << lun);
                dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d untagged cmd finished\n",
-                          H_NO(cmd), cmd->device->id, cmd->device->lun);
+                          H_NO(cmd), cmd->device->id, lun);
        } else if (cmd->tag >= MAX_TAGS) {
                printk(KERN_NOTICE "scsi%d: trying to free bad tag %d!\n",
                       H_NO(cmd), cmd->tag);
        } else {
-               TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
+               TAG_ALLOC *ta = &TagAlloc[cmd->device->id][lun];
                clear_bit(cmd->tag, ta->allocated);
                ta->nr_allocated--;
                dprintk(NDEBUG_TAGS, "scsi%d: freed tag %d for target %d lun %d\n",
-                          H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun);
+                          H_NO(cmd), cmd->tag, cmd->device->id, lun);
        }
 }
 
 {
        int i, s;
        unsigned char *command;
-       printk("scsi%d: destination target %d, lun %d\n",
+       printk("scsi%d: destination target %d, lun %llu\n",
                H_NO(cmd), cmd->device->id, cmd->device->lun);
        printk(KERN_CONT "        command = ");
        command = cmd->cmnd;
 {
        int i, s;
        unsigned char *command;
-       seq_printf(m, "scsi%d: destination target %d, lun %d\n",
+       seq_printf(m, "scsi%d: destination target %d, lun %llu\n",
                H_NO(cmd), cmd->device->id, cmd->device->lun);
        seq_printf(m, "        command = ");
        command = cmd->cmnd;
 #endif
                        for (tmp = (Scsi_Cmnd *) hostdata->issue_queue,
                             prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp)) {
+                               u8 lun = tmp->device->lun;
 
 #if (NDEBUG & NDEBUG_LISTS)
                                if (prev != tmp)
-                                       printk("MAIN tmp=%p   target=%d   busy=%d lun=%d\n",
+                                       printk("MAIN tmp=%p   target=%d   busy=%d lun=%llu\n",
                                               tmp, tmp->device->id, hostdata->busy[tmp->device->id],
-                                              tmp->device->lun);
+                                              lun);
 #endif
                                /*  When we find one, remove it from the issue queue. */
                                /* ++guenther: possible race with Falcon locking */
 #ifdef SUPPORT_TAGS
                                    !is_lun_busy( tmp, tmp->cmnd[0] != REQUEST_SENSE)
 #else
-                                   !(hostdata->busy[tmp->device->id] & (1 << tmp->device->lun))
+                                   !(hostdata->busy[tmp->device->id] & (1 << lun))
 #endif
                                    ) {
                                        /* ++guenther: just to be sure, this must be atomic */
                                         */
                                        dprintk(NDEBUG_MAIN, "scsi%d: main(): command for target %d "
                                                    "lun %d removed from issue_queue\n",
-                                                   HOSTNO, tmp->device->id, tmp->device->lun);
+                                                   HOSTNO, tmp->device->id, lun);
                                        /*
                                         * REQUEST SENSE commands are issued without tagged
                                         * queueing, even on SCSI-II devices because the
                                                 * accesses to this device will use the
                                                 * polled-IO. */
                                                printk(KERN_NOTICE "scsi%d: switching target %d "
-                                                          "lun %d to slow handshake\n", HOSTNO,
+                                                          "lun %llu to slow handshake\n", HOSTNO,
                                                           cmd->device->id, cmd->device->lun);
                                                cmd->device->borken = 1;
                                                NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE |
                                        /* Accept message by clearing ACK */
                                        NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 
-                                       dprintk(NDEBUG_LINKED, "scsi%d: target %d lun %d linked command "
+                                       dprintk(NDEBUG_LINKED, "scsi%d: target %d lun %llu linked command "
                                                   "complete.\n", HOSTNO, cmd->device->id, cmd->device->lun);
 
                                        /* Enable reselect interrupts */
                                         */
 
                                        if (!cmd->next_link) {
-                                                printk(KERN_NOTICE "scsi%d: target %d lun %d "
+                                                printk(KERN_NOTICE "scsi%d: target %d lun %llu "
                                                        "linked command complete, no next_link\n",
                                                        HOSTNO, cmd->device->id, cmd->device->lun);
                                                sink = 1;
                                         * and don't free it! */
                                        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 "
+                                       dprintk(NDEBUG_LINKED, "scsi%d: target %d lun %llu linked request "
                                                   "done, calling scsi_done().\n",
                                                   HOSTNO, cmd->device->id, cmd->device->lun);
 #ifdef NCR5380_STATS
                                        /* ++guenther: possible race with Falcon locking */
                                        falcon_dont_release++;
                                        hostdata->connected = NULL;
-                                       dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d, lun %d "
+                                       dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d, lun %llu "
                                                  "completed\n", HOSTNO, cmd->device->id, cmd->device->lun);
 #ifdef SUPPORT_TAGS
                                        cmd_free_tag(cmd);
                                                /* ++Andreas: the mid level code knows about
                                                   QUEUE_FULL now. */
                                                TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
-                                               dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d returned "
+                                               dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %llu returned "
                                                           "QUEUE_FULL after %d commands\n",
                                                           HOSTNO, cmd->device->id, cmd->device->lun,
                                                           ta->nr_allocated);
                                                cmd->device->tagged_supported = 0;
                                                hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
                                                cmd->tag = TAG_NONE;
-                                               dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d rejected "
+                                               dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %llu rejected "
                                                           "QUEUE_TAG message; tagged queuing "
                                                           "disabled\n",
                                                           HOSTNO, cmd->device->id, cmd->device->lun);
                                        hostdata->connected = NULL;
                                        hostdata->disconnected_queue = cmd;
                                        local_irq_restore(flags);
-                                       dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d lun %d was "
+                                       dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d lun %llu was "
                                                  "moved from connected to the "
                                                  "disconnected_queue\n", HOSTNO,
                                                  cmd->device->id, cmd->device->lun);
                                                printk("\n");
                                        } else if (tmp != EXTENDED_MESSAGE)
                                                printk(KERN_DEBUG "scsi%d: rejecting unknown "
-                                                      "message %02x from target %d, lun %d\n",
+                                                      "message %02x from target %d, lun %llu\n",
                                                       HOSTNO, tmp, cmd->device->id, cmd->device->lun);
                                        else
                                                printk(KERN_DEBUG "scsi%d: rejecting unknown "
                                                       "extended message "
-                                                      "code %02x, length %d from target %d, lun %d\n",
+                                                      "code %02x, length %d from target %d, lun %llu\n",
                                                       HOSTNO, extended_msg[1], extended_msg[0],
                                                       cmd->device->id, cmd->device->lun);
 
        NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 
        hostdata->connected = tmp;
-       dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %d, tag = %d\n",
+       dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %llu, tag = %d\n",
                   HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag);
        falcon_dont_release--;
 }
 
        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");
 
  retry:
        memset(cmd,0,sizeof(cmd));
        cmd[0] = READ_ELEMENT_STATUS;
-       cmd[1] = (ch->device->lun << 5) |
+       cmd[1] = ((ch->device->lun & 0x7) << 5) |
                (ch->voltags ? 0x10 : 0) |
                ch_elem_to_typecode(ch,elem);
        cmd[2] = (elem >> 8) & 0xff;
        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] = (ch->device->lun & 0x7) << 5;
        err = ch_do_scsi(ch, cmd, NULL, 0, DMA_NONE);
        VPRINTK(KERN_INFO, "... finished\n");
        return err;
 
        memset(cmd,0,sizeof(cmd));
        cmd[0] = MODE_SENSE;
-       cmd[1] = ch->device->lun << 5;
+       cmd[1] = (ch->device->lun & 0x7) << 5;
        cmd[2] = 0x1d;
        cmd[4] = 255;
        result = ch_do_scsi(ch, cmd, buffer, 255, DMA_FROM_DEVICE);
                trans = ch->firsts[CHET_MT];
        memset(cmd,0,sizeof(cmd));
        cmd[0]  = POSITION_TO_ELEMENT;
-       cmd[1]  = ch->device->lun << 5;
+       cmd[1]  = (ch->device->lun & 0x7) << 5;
        cmd[2]  = (trans >> 8) & 0xff;
        cmd[3]  =  trans       & 0xff;
        cmd[4]  = (elem  >> 8) & 0xff;
                trans = ch->firsts[CHET_MT];
        memset(cmd,0,sizeof(cmd));
        cmd[0]  = MOVE_MEDIUM;
-       cmd[1]  = ch->device->lun << 5;
+       cmd[1]  = (ch->device->lun & 0x7) << 5;
        cmd[2]  = (trans >> 8) & 0xff;
        cmd[3]  =  trans       & 0xff;
        cmd[4]  = (src   >> 8) & 0xff;
                trans = ch->firsts[CHET_MT];
        memset(cmd,0,sizeof(cmd));
        cmd[0]  = EXCHANGE_MEDIUM;
-       cmd[1]  = ch->device->lun << 5;
+       cmd[1]  = (ch->device->lun & 0x7) << 5;
        cmd[2]  = (trans >> 8) & 0xff;
        cmd[3]  =  trans       & 0xff;
        cmd[4]  = (src   >> 8) & 0xff;
                elem, tag);
        memset(cmd,0,sizeof(cmd));
        cmd[0]  = SEND_VOLUME_TAG;
-       cmd[1] = (ch->device->lun << 5) |
+       cmd[1] = ((ch->device->lun & 0x7) << 5) |
                ch_elem_to_typecode(ch,elem);
        cmd[2] = (elem >> 8) & 0xff;
        cmd[3] = elem        & 0xff;
        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] = ((ch->device->lun & 0x7) << 5) |
                        (ch->voltags ? 0x10 : 0) |
                        ch_elem_to_typecode(ch,elem);
                ch_cmd[2] = (elem >> 8) & 0xff;
 
        case FW_SCSI_UNDER_FLOW_ERR:
                csio_warn(hw,
                          "Under-flow error,cmnd:0x%x expected"
-                         " len:0x%x resid:0x%x lun:0x%x ssn:0x%x\n",
+                         " len:0x%x resid:0x%x lun:0x%llx ssn:0x%x\n",
                          cmnd->cmnd[0], scsi_bufflen(cmnd),
                          scsi_get_resid(cmnd), cmnd->device->lun,
                          rn->flowid);
 
        csio_dbg(hw,
                 "Request to abort ioreq:%p cmd:%p cdb:%08llx"
-                " ssni:0x%x lun:%d iq:0x%x\n",
+                " ssni:0x%x lun:%llu iq:0x%x\n",
                ioreq, cmnd, *((uint64_t *)cmnd->cmnd), rn->flowid,
                cmnd->device->lun, csio_q_physiqid(hw, ioreq->iq_idx));
 
        /* FW successfully aborted the request */
        if (host_byte(cmnd->result) == DID_REQUEUE) {
                csio_info(hw,
-                       "Aborted SCSI command to (%d:%d) serial#:0x%lx\n",
+                       "Aborted SCSI command to (%d:%llu) serial#:0x%lx\n",
                        cmnd->device->id, cmnd->device->lun,
                        cmnd->serial_number);
                return SUCCESS;
        } else {
                csio_info(hw,
-                       "Failed to abort SCSI command, (%d:%d) serial#:0x%lx\n",
+                       "Failed to abort SCSI command, (%d:%llu) serial#:0x%lx\n",
                        cmnd->device->id, cmnd->device->lun,
                        cmnd->serial_number);
                return FAILED;
        if (!rn)
                goto fail;
 
-       csio_dbg(hw, "Request to reset LUN:%d (ssni:0x%x tgtid:%d)\n",
+       csio_dbg(hw, "Request to reset LUN:%llu (ssni:0x%x tgtid:%d)\n",
                      cmnd->device->lun, rn->flowid, rn->scsi_id);
 
        if (!csio_is_lnode_ready(ln)) {
                csio_err(hw,
                         "LUN reset cannot be issued on non-ready"
-                        " local node vnpi:0x%x (LUN:%d)\n",
+                        " local node vnpi:0x%x (LUN:%llu)\n",
                         ln->vnp_flowid, cmnd->device->lun);
                goto fail;
        }
        if (fc_remote_port_chkready(rn->rport)) {
                csio_err(hw,
                         "LUN reset cannot be issued on non-ready"
-                        " remote node ssni:0x%x (LUN:%d)\n",
+                        " remote node ssni:0x%x (LUN:%llu)\n",
                         rn->flowid, cmnd->device->lun);
                goto fail;
        }
        sld.level = CSIO_LEV_LUN;
        sld.lnode = ioreq->lnode;
        sld.rnode = ioreq->rnode;
-       sld.oslun = (uint64_t)cmnd->device->lun;
+       sld.oslun = cmnd->device->lun;
 
        spin_lock_irqsave(&hw->lock, flags);
        /* Kick off TM SM on the ioreq */
 
        /* LUN reset timed-out */
        if (((struct scsi_cmnd *)csio_scsi_cmnd(ioreq)) == cmnd) {
-               csio_err(hw, "LUN reset (%d:%d) timed out\n",
+               csio_err(hw, "LUN reset (%d:%llu) timed out\n",
                         cmnd->device->id, cmnd->device->lun);
 
                spin_lock_irq(&hw->lock);
 
        /* LUN reset returned, check cached status */
        if (cmnd->SCp.Status != FW_SUCCESS) {
-               csio_err(hw, "LUN reset failed (%d:%d), status: %d\n",
+               csio_err(hw, "LUN reset failed (%d:%llu), status: %d\n",
                         cmnd->device->id, cmnd->device->lun, cmnd->SCp.Status);
                goto fail;
        }
        /* Aborts may have timed out */
        if (retval != 0) {
                csio_err(hw,
-                        "Attempt to abort I/Os during LUN reset of %d"
+                        "Attempt to abort I/Os during LUN reset of %llu"
                         " returned %d\n", cmnd->device->lun, retval);
                /* Return I/Os back to active_q */
                spin_lock_irq(&hw->lock);
 
        CSIO_INC_STATS(rn, n_lun_rst);
 
-       csio_info(hw, "LUN reset occurred (%d:%d)\n",
+       csio_info(hw, "LUN reset occurred (%d:%llu)\n",
                  cmnd->device->id, cmnd->device->lun);
 
        return SUCCESS;
 
        struct AdapterCtlBlk *acb =
            (struct AdapterCtlBlk *)cmd->device->host->hostdata;
        dprintkdbg(DBG_0, "queue_command: (0x%p) <%02i-%i> cmnd=0x%02x\n",
-               cmd, cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
+               cmd, cmd->device->id, (u8)cmd->device->lun, cmd->cmnd[0]);
 
        /* Assume BAD_TARGET; will be cleared later */
        cmd->result = DID_BAD_TARGET << 16;
        /* does the specified lun on the specified device exist */
        if (!(acb->dcb_map[cmd->device->id] & (1 << cmd->device->lun))) {
                dprintkl(KERN_INFO, "queue_command: Ignore target <%02i-%i>\n",
-                       cmd->device->id, cmd->device->lun);
+                       cmd->device->id, (u8)cmd->device->lun);
                goto complete;
        }
 
        if (!dcb) {
                /* should never happen */
                dprintkl(KERN_ERR, "queue_command: No such device <%02i-%i>",
-                       cmd->device->id, cmd->device->lun);
+                       cmd->device->id, (u8)cmd->device->lun);
                goto complete;
        }
 
                                 "cmnd=0x%02x <%02i-%i>\n",
                                srb, srb->cmd,
                                srb->cmd->cmnd[0], srb->cmd->device->id,
-                               srb->cmd->device->lun);
+                               (u8)srb->cmd->device->lun);
                printk("  sglist=%p cnt=%i idx=%i len=%zu\n",
                       srb->segment_x, srb->sg_count, srb->sg_index,
                       srb->total_xfer_length);
                (struct AdapterCtlBlk *)cmd->device->host->hostdata;
        dprintkl(KERN_INFO,
                "eh_bus_reset: (0%p) target=<%02i-%i> cmd=%p\n",
-               cmd, cmd->device->id, cmd->device->lun, cmd);
+               cmd, cmd->device->id, (u8)cmd->device->lun, cmd);
 
        if (timer_pending(&acb->waiting_timer))
                del_timer(&acb->waiting_timer);
        struct DeviceCtlBlk *dcb;
        struct ScsiReqBlk *srb;
        dprintkl(KERN_INFO, "eh_abort: (0x%p) target=<%02i-%i> cmd=%p\n",
-               cmd, cmd->device->id, cmd->device->lun, cmd);
+               cmd, cmd->device->id, (u8)cmd->device->lun, cmd);
 
        dcb = find_dcb(acb, cmd->device->id, cmd->device->lun);
        if (!dcb) {
                        dprintkl(KERN_WARNING, "start_scsi: (0x%p) "
                                "Out of tags target=<%02i-%i>)\n",
                                srb->cmd, srb->cmd->device->id,
-                               srb->cmd->device->lun);
+                               (u8)srb->cmd->device->lun);
                        srb->state = SRB_READY;
                        DC395x_write16(acb, TRM_S1040_SCSI_CONTROL,
                                       DO_HWRESELECT);
 /*polling:*/
        /* Send CDB ..command block ......... */
        dprintkdbg(DBG_KG, "start_scsi: (0x%p) <%02i-%i> cmnd=0x%02x tag=%i\n",
-               srb->cmd, srb->cmd->device->id, srb->cmd->device->lun,
+               srb->cmd, srb->cmd->device->id, (u8)srb->cmd->device->lun,
                srb->cmd->cmnd[0], srb->tag_number);
        if (srb->flag & AUTO_REQSENSE) {
                DC395x_write8(acb, TRM_S1040_SCSI_FIFO, REQUEST_SENSE);
        u16 scsi_status = *pscsi_status;
        u32 d_left_counter = 0;
        dprintkdbg(DBG_0, "data_out_phase0: (0x%p) <%02i-%i>\n",
-               srb->cmd, srb->cmd->device->id, srb->cmd->device->lun);
+               srb->cmd, srb->cmd->device->id, (u8)srb->cmd->device->lun);
 
        /*
         * KG: We need to drain the buffers before we draw any conclusions!
                u16 *pscsi_status)
 {
        dprintkdbg(DBG_0, "data_out_phase1: (0x%p) <%02i-%i>\n",
-               srb->cmd, srb->cmd->device->id, srb->cmd->device->lun);
+               srb->cmd, srb->cmd->device->id, (u8)srb->cmd->device->lun);
        clear_fifo(acb, "data_out_phase1");
        /* do prepare before transfer when data out phase */
        data_io_transfer(acb, srb, XFERDATAOUT);
        u16 scsi_status = *pscsi_status;
 
        dprintkdbg(DBG_0, "data_in_phase0: (0x%p) <%02i-%i>\n",
-               srb->cmd, srb->cmd->device->id, srb->cmd->device->lun);
+               srb->cmd, srb->cmd->device->id, (u8)srb->cmd->device->lun);
 
        /*
         * KG: DataIn is much more tricky than DataOut. When the device is finished
                u16 *pscsi_status)
 {
        dprintkdbg(DBG_0, "data_in_phase1: (0x%p) <%02i-%i>\n",
-               srb->cmd, srb->cmd->device->id, srb->cmd->device->lun);
+               srb->cmd, srb->cmd->device->id, (u8)srb->cmd->device->lun);
        data_io_transfer(acb, srb, XFERDATAIN);
 }
 
        u8 bval;
        dprintkdbg(DBG_0,
                "data_io_transfer: (0x%p) <%02i-%i> %c len=%i, sg=(%i/%i)\n",
-               srb->cmd, srb->cmd->device->id, srb->cmd->device->lun,
+               srb->cmd, srb->cmd->device->id, (u8)srb->cmd->device->lun,
                ((io_dir & DMACMD_DIR) ? 'r' : 'w'),
                srb->total_xfer_length, srb->sg_index, srb->sg_count);
        if (srb == acb->tmp_srb)
                u16 *pscsi_status)
 {
        dprintkdbg(DBG_0, "status_phase0: (0x%p) <%02i-%i>\n",
-               srb->cmd, srb->cmd->device->id, srb->cmd->device->lun);
+               srb->cmd, srb->cmd->device->id, (u8)srb->cmd->device->lun);
        srb->target_status = DC395x_read8(acb, TRM_S1040_SCSI_FIFO);
        srb->end_message = DC395x_read8(acb, TRM_S1040_SCSI_FIFO);      /* get message */
        srb->state = SRB_COMPLETED;
                u16 *pscsi_status)
 {
        dprintkdbg(DBG_0, "status_phase1: (0x%p) <%02i-%i>\n",
-               srb->cmd, srb->cmd->device->id, srb->cmd->device->lun);
+               srb->cmd, srb->cmd->device->id, (u8)srb->cmd->device->lun);
        srb->state = SRB_STATUS;
        DC395x_write16(acb, TRM_S1040_SCSI_CONTROL, DO_DATALATCH);      /* it's important for atn stop */
        DC395x_write8(acb, TRM_S1040_SCSI_COMMAND, SCMD_COMP);
        int ckc_only = 1;
 
        dprintkdbg(DBG_1, "srb_done: (0x%p) <%02i-%i>\n", srb->cmd,
-               srb->cmd->device->id, srb->cmd->device->lun);
+               srb->cmd->device->id, (u8)srb->cmd->device->lun);
        dprintkdbg(DBG_SG, "srb_done: srb=%p sg=%i(%i/%i) buf=%p\n",
                   srb, scsi_sg_count(cmd), srb->sg_index, srb->sg_count,
                   scsi_sgtalbe(cmd));
                if (srb->total_xfer_length)
                        dprintkdbg(DBG_KG, "srb_done: (0x%p) <%02i-%i> "
                                "cmnd=0x%02x Missed %i bytes\n",
-                               cmd, cmd->device->id, cmd->device->lun,
+                               cmd, cmd->device->id, (u8)cmd->device->lun,
                                cmd->cmnd[0], srb->total_xfer_length);
        }
 
                        dir = p->sc_data_direction;
                        result = MK_RES(0, did_flag, 0, 0);
                        printk("G:%p(%02i-%i) ", p,
-                              p->device->id, p->device->lun);
+                              p->device->id, (u8)p->device->lun);
                        srb_going_remove(dcb, srb);
                        free_tag(dcb, srb);
                        srb_free_insert(acb, srb);
 
                        result = MK_RES(0, did_flag, 0, 0);
                        printk("W:%p<%02i-%i>", p, p->device->id,
-                              p->device->lun);
+                              (u8)p->device->lun);
                        srb_waiting_remove(dcb, srb);
                        srb_free_insert(acb, srb);
                        p->result = result;
 {
        struct scsi_cmnd *cmd = srb->cmd;
        dprintkdbg(DBG_1, "request_sense: (0x%p) <%02i-%i>\n",
-               cmd, cmd->device->id, cmd->device->lun);
+               cmd, cmd->device->id, (u8)cmd->device->lun);
 
        srb->flag |= AUTO_REQSENSE;
        srb->adapter_status = 0;
 
                 * to the device structure.  This should be a TEST_UNIT_READY
                 * command from scan_scsis_single.
                 */
-               if ((pDev = adpt_find_device(pHba, (u32)cmd->device->channel, (u32)cmd->device->id, (u32)cmd->device->lun)) == NULL) {
+               if ((pDev = adpt_find_device(pHba, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun)) == NULL) {
                        // TODO: if any luns are at this bus, scsi id then fake a TEST_UNIT_READY and INQUIRY response 
                        // with type 7F (for all luns less than the max for this bus,id) so the lun scan will continue.
                        cmd->result = (DID_NO_CONNECT << 16);
                                seq_printf(m," Rev: %-8.8s\n", d->pScsi_dev->rev);
 
                                unit = d->pI2o_dev->lct_data.tid;
-                               seq_printf(m, "\tTID=%d, (Channel=%d, Target=%d, Lun=%d)  (%s)\n\n",
-                                              unit, (int)d->scsi_channel, (int)d->scsi_id, (int)d->scsi_lun,
+                               seq_printf(m, "\tTID=%d, (Channel=%d, Target=%d, Lun=%llu)  (%s)\n\n",
+                                              unit, (int)d->scsi_channel, (int)d->scsi_id, d->scsi_lun,
                                               scsi_device_online(d->pScsi_dev)? "online":"offline"); 
                                d = d->next_lun;
                        }
        }
 }
 
-static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun)
+static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u64 lun)
 {
        struct adpt_device* d;
 
        i2o_lct *lct = pHba->lct;
        u8 bus_no = 0;
        s16 scsi_id;
-       s16 scsi_lun;
+       u64 scsi_lun;
        u32 buf[10]; // larger than 7, or 8 ...
        struct adpt_device* pDev; 
        
                        }
                        bus_no = buf[0]>>16;
                        scsi_id = buf[1];
-                       scsi_lun = (buf[2]>>8 )&0xff;
+                       scsi_lun = scsilun_to_int((struct scsi_lun *)&buf[2]);
                        if(bus_no >= MAX_CHANNEL) {     // Something wrong skip it
                                printk(KERN_WARNING"%s: Channel number %d out of range \n", pHba->name, bus_no);
                                continue;
                        if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)>=0) {
                                bus_no = buf[0]>>16;
                                scsi_id = buf[1];
-                               scsi_lun = (buf[2]>>8 )&0xff;
+                               scsi_lun = scsilun_to_int((struct scsi_lun *)&buf[2]);
                                if(bus_no >= MAX_CHANNEL) {     // Something wrong skip it
                                        continue;
                                }
                case I2O_SCSI_DSC_COMMAND_TIMEOUT:
                case I2O_SCSI_DSC_NO_ADAPTER:
                case I2O_SCSI_DSC_RESOURCE_UNAVAILABLE:
-                       printk(KERN_WARNING"%s: SCSI Timeout-Device (%d,%d,%d) hba status=0x%x, dev status=0x%x, cmd=0x%x\n",
-                               pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, (u32)cmd->device->lun, hba_status, dev_status, cmd->cmnd[0]);
+                       printk(KERN_WARNING"%s: SCSI Timeout-Device (%d,%d,%llu) hba status=0x%x, dev status=0x%x, cmd=0x%x\n",
+                               pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun, hba_status, dev_status, cmd->cmnd[0]);
                        cmd->result = (DID_TIME_OUT << 16);
                        break;
                case I2O_SCSI_DSC_ADAPTER_BUSY:
                case I2O_SCSI_DSC_QUEUE_FROZEN:
                case I2O_SCSI_DSC_REQUEST_INVALID:
                default:
-                       printk(KERN_WARNING"%s: SCSI error %0x-Device(%d,%d,%d) hba_status=0x%x, dev_status=0x%x, cmd=0x%x\n",
-                               pHba->name, detailed_status & I2O_SCSI_DSC_MASK, (u32)cmd->device->channel, (u32)cmd->device->id, (u32)cmd->device->lun,
+                       printk(KERN_WARNING"%s: SCSI error %0x-Device(%d,%d,%llu) hba_status=0x%x, dev_status=0x%x, cmd=0x%x\n",
+                               pHba->name, detailed_status & I2O_SCSI_DSC_MASK, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun,
                               hba_status, dev_status, cmd->cmnd[0]);
                        cmd->result = (DID_ERROR << 16);
                        break;
                           cmd->sense_buffer[2] == DATA_PROTECT ){
                                /* This is to handle an array failed */
                                cmd->result = (DID_TIME_OUT << 16);
-                               printk(KERN_WARNING"%s: SCSI Data Protect-Device (%d,%d,%d) hba_status=0x%x, dev_status=0x%x, cmd=0x%x\n",
-                                       pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, (u32)cmd->device->lun, 
+                               printk(KERN_WARNING"%s: SCSI Data Protect-Device (%d,%d,%llu) hba_status=0x%x, dev_status=0x%x, cmd=0x%x\n",
+                                       pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun,
                                        hba_status, dev_status, cmd->cmnd[0]);
 
                        }
                 * for a limitted number of retries.
                 */
                cmd->result = (DID_TIME_OUT << 16);
-               printk(KERN_WARNING"%s: I2O MSG_FAIL - Device (%d,%d,%d) tid=%d, cmd=0x%x\n",
-                       pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, (u32)cmd->device->lun,
+               printk(KERN_WARNING"%s: I2O MSG_FAIL - Device (%d,%d,%llu) tid=%d, cmd=0x%x\n",
+                       pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, cmd->device->lun,
                        ((struct adpt_device*)(cmd->device->hostdata))->tid, cmd->cmnd[0]);
        }
 
        i2o_lct *lct = pHba->lct;
        u8 bus_no = 0;
        s16 scsi_id;
-       s16 scsi_lun;
+       u64 scsi_lun;
        u32 buf[10]; // at least 8 u32's
        struct adpt_device* pDev = NULL;
        struct i2o_device* pI2o_dev = NULL;
                        }
 
                        scsi_id = buf[1];
-                       scsi_lun = (buf[2]>>8 )&0xff;
+                       scsi_lun = scsilun_to_int((struct scsi_lun *)&buf[2]);
                        pDev = pHba->channel[bus_no].device[scsi_id];
                        /* da lun */
                        while(pDev) {
                        while(pDev) {
                                if(pDev->scsi_lun == scsi_lun) {
                                        if(!scsi_device_online(pDev->pScsi_dev)) {
-                                               printk(KERN_WARNING"%s: Setting device (%d,%d,%d) back online\n",
+                                               printk(KERN_WARNING"%s: Setting device (%d,%d,%llu) back online\n",
                                                                pHba->name,bus_no,scsi_id,scsi_lun);
                                                if (pDev->pScsi_dev) {
                                                        scsi_device_set_state(pDev->pScsi_dev, SDEV_RUNNING);
                // in the LCT table
                if (pDev->state & DPTI_DEV_UNSCANNED){
                        pDev->state = DPTI_DEV_OFFLINE;
-                       printk(KERN_WARNING"%s: Device (%d,%d,%d) offline\n",pHba->name,pDev->scsi_channel,pDev->scsi_id,pDev->scsi_lun);
+                       printk(KERN_WARNING"%s: Device (%d,%d,%llu) offline\n",pHba->name,pDev->scsi_channel,pDev->scsi_id,pDev->scsi_lun);
                        if (pDev->pScsi_dev) {
                                scsi_device_set_state(pDev->pScsi_dev, SDEV_OFFLINE);
                        }
 
        u32     block_size;
        u8      scsi_channel;
        u8      scsi_id;
-       u8      scsi_lun;
+       u64     scsi_lun;
        u8      state;
        u16     tid;
        struct i2o_device* pI2o_dev;
        u32  sg_tablesize;      // Scatter/Gather List Size.       
        u8  top_scsi_channel;
        u8  top_scsi_id;
-       u8  top_scsi_lun;
+       u64  top_scsi_lun;
        u8  dma64;
 
        i2o_status_block* status_block;
 static void adpt_i2o_delete_hba(adpt_hba* pHba);
 static void adpt_inquiry(adpt_hba* pHba);
 static void adpt_fail_posted_scbs(adpt_hba* pHba);
-static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun);
+static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u64 lun);
 static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) ;
 static int adpt_i2o_online_hba(adpt_hba* pHba);
 static void adpt_i2o_post_wait_complete(u32, int);
 
                               "target_status 0x%x, sense key 0x%x.\n",
                               ha->board_name,
                               SCpnt->device->channel, SCpnt->device->id,
-                              SCpnt->device->lun,
+                              (u8)SCpnt->device->lun,
                               spp->target_status, SCpnt->sense_buffer[2]);
 
                ha->target_to[SCpnt->device->id][SCpnt->device->channel] = 0;
 
        tag = sc->request->tag;
        FNIC_SCSI_DBG(KERN_DEBUG,
                fnic->lport->host,
-               "Abort Cmd called FCID 0x%x, LUN 0x%x TAG %x flags %x\n",
+               "Abort Cmd called FCID 0x%x, LUN 0x%llx TAG %x flags %x\n",
                rport->port_id, sc->device->lun, tag, CMD_FLAGS(sc));
 
        CMD_FLAGS(sc) = FNIC_NO_FLAGS;
 
        rport = starget_to_rport(scsi_target(sc->device));
        FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
-                     "Device reset called FCID 0x%x, LUN 0x%x sc 0x%p\n",
+                     "Device reset called FCID 0x%x, LUN 0x%llx sc 0x%p\n",
                      rport->port_id, sc->device->lun, sc);
 
        if (lp->state != LPORT_ST_READY || !(lp->link_up))
 
 
 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 %llu\n" ANDP cmd->device->host->host_no ANDP cmd->device->id ANDP cmd->device->lun);
        PRINTP("        command = ");
        sprint_command(m, cmd->cmnd);
 }
 
                return FAILED;
 
        memset(msg, 0, sizeof(msg));
-       ml += sprintf(msg+ml, "ABORT REQUEST on C%d:B%d:T%d:L%d ",
+       ml += sprintf(msg+ml, "ABORT REQUEST on C%d:B%d:T%d:L%llu ",
                h->scsi_host->host_no, sc->device->channel,
                sc->device->id, sc->device->lun);
 
 
 
        _req->scp = scp;
 
-       dprintk("hptiop_queuecmd(scp=%p) %d/%d/%d/%d cdb=(%08x-%08x-%08x-%08x) "
+       dprintk("hptiop_queuecmd(scp=%p) %d/%d/%d/%llu cdb=(%08x-%08x-%08x-%08x) "
                        "req_index=%d, req=%p\n",
                        scp,
                        host->host_no, scp->device->channel,
 
                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:%llu(%02x)", cmd->device->id, cmd->device->lun, 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:%llu(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
                        cmd = (Scsi_Cmnd *) cmd->host_scribble;
                }
        }
                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:%llu(%02x)", cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
                        cmd = (Scsi_Cmnd *) cmd->host_scribble;
                }
        }
 
 {
        struct iscsi_conn *conn = task->conn;
        struct iscsi_tm *tmf = &conn->tmhdr;
-       unsigned int hdr_lun;
+       u64 hdr_lun;
 
        if (conn->tmf_state == TMF_INITIAL)
                return 0;
  * Fail commands. session lock held and recv side suspended and xmit
  * thread flushed
  */
-static void fail_scsi_tasks(struct iscsi_conn *conn, unsigned lun,
-                           int error)
+static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
 {
        struct iscsi_task *task;
        int i;
        cls_session = starget_to_session(scsi_target(sc->device));
        session = cls_session->dd_data;
 
-       ISCSI_DBG_EH(session, "LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
+       ISCSI_DBG_EH(session, "LU Reset [sc %p lun %llu]\n", sc,
+                    sc->device->lun);
 
        mutex_lock(&session->eh_mutex);
        spin_lock_bh(&session->frwd_lock);
 
 
        int_to_scsilun(cmd->device->lun, &lun);
 
-       SAS_DPRINTK("eh: device %llx LUN %x has the task\n",
+       SAS_DPRINTK("eh: device %llx LUN %llx has the task\n",
                    SAS_ADDR(dev->sas_addr),
                    cmd->device->lun);
 
 }
 EXPORT_SYMBOL(sas_wait_eh);
 
-static int sas_queue_reset(struct domain_device *dev, int reset_type, int lun, int wait)
+static int sas_queue_reset(struct domain_device *dev, int reset_type,
+                          u64 lun, int wait)
 {
        struct sas_ha_struct *ha = dev->port->ha;
        int scheduled = 0, tries = 100;
  reset:
                        tmf_resp = sas_recover_lu(task->dev, cmd);
                        if (tmf_resp == TMF_RESP_FUNC_COMPLETE) {
-                               SAS_DPRINTK("dev %016llx LU %x is "
+                               SAS_DPRINTK("dev %016llx LU %llx is "
                                            "recovered\n",
                                            SAS_ADDR(task->dev),
                                            cmd->device->lun);
                         * of effort could recover from errors.  Quite
                         * possibly the HA just disappeared.
                         */
-                       SAS_DPRINTK("error from  device %llx, LUN %x "
+                       SAS_DPRINTK("error from  device %llx, LUN %llx "
                                    "couldn't be recovered in any way\n",
                                    SAS_ADDR(task->dev->sas_addr),
                                    cmd->device->lun);
                scsi_set_tag_type(scsi_dev, MSG_SIMPLE_TAG);
                scsi_activate_tcq(scsi_dev, SAS_DEF_QD);
        } else {
-               SAS_DPRINTK("device %llx, LUN %x doesn't support "
+               SAS_DPRINTK("device %llx, LUN %llx doesn't support "
                            "TCQ\n", SAS_ADDR(dev->sas_addr),
                            scsi_dev->lun);
                scsi_dev->tagged_supported = 0;
 
 lpfc_send_sdev_queuedepth_change_event(struct lpfc_hba *phba,
                struct lpfc_vport  *vport,
                struct lpfc_nodelist *ndlp,
-               uint32_t lun,
+               uint64_t lun,
                uint32_t old_val,
                uint32_t new_val)
 {
                if (rsplen != 0 && rsplen != 4 && rsplen != 8) {
                        lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
                                 "2719 Invalid response length: "
-                                "tgt x%x lun x%x cmnd x%x rsplen x%x\n",
+                                "tgt x%x lun x%llx cmnd x%x rsplen x%x\n",
                                 cmnd->device->id,
                                 cmnd->device->lun, cmnd->cmnd[0],
                                 rsplen);
                        lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
                                 "2757 Protocol failure detected during "
                                 "processing of FCP I/O op: "
-                                "tgt x%x lun x%x cmnd x%x rspInfo3 x%x\n",
+                                "tgt x%x lun x%llx cmnd x%x rspInfo3 x%x\n",
                                 cmnd->device->id,
                                 cmnd->device->lun, cmnd->cmnd[0],
                                 fcprsp->rspInfo3);
                else
                        logit = LOG_FCP | LOG_FCP_UNDER;
                lpfc_printf_vlog(vport, KERN_WARNING, logit,
-                        "9030 FCP cmd x%x failed <%d/%d> "
+                        "9030 FCP cmd x%x failed <%d/%lld> "
                         "status: x%x result: x%x "
                         "sid: x%x did: x%x oxid: x%x "
                         "Data: x%x x%x\n",
                uint32_t *lp = (uint32_t *)cmd->sense_buffer;
 
                lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
-                                "0710 Iodone <%d/%d> cmd %p, error "
+                                "0710 Iodone <%d/%llu> cmd %p, error "
                                 "x%x SNS x%x x%x Data: x%x x%x\n",
                                 cmd->device->id, cmd->device->lun, cmd,
                                 cmd->result, *lp, *(lp + 3), cmd->retries,
 static int
 lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport,
                             struct lpfc_scsi_buf *lpfc_cmd,
-                            unsigned int lun,
+                            uint64_t lun,
                             uint8_t task_mgmt_cmd)
 {
        struct lpfc_iocbq *piocbq;
                atomic_dec(&ndlp->cmd_pending);
                lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
                                 "3376 FCP could not issue IOCB err %x"
-                                "FCP cmd x%x <%d/%d> "
+                                "FCP cmd x%x <%d/%llu> "
                                 "sid: x%x did: x%x oxid: x%x "
                                 "Data: x%x x%x x%x x%x\n",
                                 err, cmnd->cmnd[0],
                                 cmnd->device ? cmnd->device->id : 0xffff,
-                                cmnd->device ? cmnd->device->lun : 0xffff,
+                                cmnd->device ? cmnd->device->lun : (u64) -1,
                                 vport->fc_myDID, ndlp->nlp_DID,
                                 phba->sli_rev == LPFC_SLI_REV4 ?
                                 lpfc_cmd->cur_iocbq.sli4_xritag : 0xffff,
                spin_unlock_irqrestore(&phba->hbalock, flags);
                lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
                         "2873 SCSI Layer I/O Abort Request IO CMPL Status "
-                        "x%x ID %d LUN %d\n",
+                        "x%x ID %d LUN %llu\n",
                         SUCCESS, cmnd->device->id, cmnd->device->lun);
                return SUCCESS;
        }
                lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
                                 "0748 abort handler timed out waiting "
                                 "for abortng I/O (xri:x%x) to complete: "
-                                "ret %#x, ID %d, LUN %d\n",
+                                "ret %#x, ID %d, LUN %llu\n",
                                 iocb->sli4_xritag, ret,
                                 cmnd->device->id, cmnd->device->lun);
        }
 out:
        lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
                         "0749 SCSI Layer I/O Abort Request Status x%x ID %d "
-                        "LUN %d\n", ret, cmnd->device->id,
+                        "LUN %llu\n", ret, cmnd->device->id,
                         cmnd->device->lun);
        return ret;
 }
  **/
 static int
 lpfc_send_taskmgmt(struct lpfc_vport *vport, struct lpfc_rport_data *rdata,
-                   unsigned  tgt_id, unsigned int lun_id,
+                   unsigned  tgt_id, uint64_t lun_id,
                    uint8_t task_mgmt_cmd)
 {
        struct lpfc_hba   *phba = vport->phba;
        iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl;
 
        lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
-                        "0702 Issue %s to TGT %d LUN %d "
+                        "0702 Issue %s to TGT %d LUN %llu "
                         "rpi x%x nlp_flag x%x Data: x%x x%x\n",
                         lpfc_taskmgmt_name(task_mgmt_cmd), tgt_id, lun_id,
                         pnode->nlp_rpi, pnode->nlp_flag, iocbq->sli4_xritag,
        if ((status != IOCB_SUCCESS) ||
            (iocbqrsp->iocb.ulpStatus != IOSTAT_SUCCESS)) {
                lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
-                        "0727 TMF %s to TGT %d LUN %d failed (%d, %d) "
+                        "0727 TMF %s to TGT %d LUN %llu failed (%d, %d) "
                         "iocb_flag x%x\n",
                         lpfc_taskmgmt_name(task_mgmt_cmd),
                         tgt_id, lun_id, iocbqrsp->iocb.ulpStatus,
        struct lpfc_rport_data *rdata;
        struct lpfc_nodelist *pnode;
        unsigned tgt_id = cmnd->device->id;
-       unsigned int lun_id = cmnd->device->lun;
+       uint64_t lun_id = cmnd->device->lun;
        struct lpfc_scsi_event_header scsi_event;
        int status;
 
                                                FCP_LUN_RESET);
 
        lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
-                        "0713 SCSI layer issued Device Reset (%d, %d) "
+                        "0713 SCSI layer issued Device Reset (%d, %llu) "
                         "return x%x\n", tgt_id, lun_id, status);
 
        /*
        struct lpfc_rport_data *rdata;
        struct lpfc_nodelist *pnode;
        unsigned tgt_id = cmnd->device->id;
-       unsigned int lun_id = cmnd->device->lun;
+       uint64_t lun_id = cmnd->device->lun;
        struct lpfc_scsi_event_header scsi_event;
        int status;
 
                                        FCP_TARGET_RESET);
 
        lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
-                        "0723 SCSI layer issued Target Reset (%d, %d) "
+                        "0723 SCSI layer issued Target Reset (%d, %llu) "
                         "return x%x\n", tgt_id, lun_id, status);
 
        /*
 
 
        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, cmd->device->lun);
+            cmd->cmnd[0], cmd->device->channel,
+            cmd->device->id, (u32)cmd->device->lun);
 
        if(list_empty(&adapter->pending_list))
                return FALSE;
 
 #define SCP2HOSTDATA(scp)              SCP2HOST(scp)->hostdata // to soft state
 #define SCP2CHANNEL(scp)               (scp)->device->channel  // to channel
 #define SCP2TARGET(scp)                        (scp)->device->id       // to target
-#define SCP2LUN(scp)                   (scp)->device->lun      // to LUN
+#define SCP2LUN(scp)                   (u32)(scp)->device->lun // to LUN
 
 // generic macro to convert scsi command and host to controller's soft state
 #define SCSIHOST2ADAP(host)    (((caddr_t *)(host->hostdata))[0])
 
                         MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
        }
        io_request->RaidContext.VirtualDiskTgtId = cpu_to_le16(device_id);
-       io_request->LUN[1] = scmd->device->lun;
+       int_to_scsilun(scmd->device->lun, (struct scsi_lun *)io_request->LUN);
 }
 
 /**
        device_id = MEGASAS_DEV_INDEX(instance, scp);
 
        /* Zero out some fields so they don't get reused */
-       io_request->LUN[1] = 0;
+       memset(io_request->LUN, 0x0, 8);
        io_request->CDB.EEDP32.PrimaryReferenceTag = 0;
        io_request->CDB.EEDP32.PrimaryApplicationTagMask = 0;
        io_request->EEDPFlags = 0;
 
                                ms->msgphase = msg_out;
                        } else if (code != cmd->device->lun + IDENTIFY_BASE) {
                                printk(KERN_WARNING "mesh: lun mismatch "
-                                      "(%d != %d) on reselection from "
+                                      "(%d != %llu) on reselection from "
                                       "target %d\n", code - IDENTIFY_BASE,
                                       cmd->device->lun, ms->conn_tgt);
                        }
 
                **      patch requested size into sense command
                */
                cp->sensecmd[0]         = 0x03;
-               cp->sensecmd[1]         = cmd->device->lun << 5;
+               cp->sensecmd[1]         = (cmd->device->lun & 0x7) << 5;
                cp->sensecmd[4]         = sizeof(cp->sense_buf);
 
                /*
 
        int ret;
 
        nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND,
-                 "enter. target: 0x%x LUN: 0x%x cmnd: 0x%x cmndlen: 0x%x "
+                 "enter. target: 0x%x LUN: 0x%llu 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));
 
        nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
 
        nsp_dbg(NSP_DEBUG_QUEUECOMMAND,
-               "SCpnt=0x%p target=%d lun=%d sglist=0x%p bufflen=%d sg_count=%d",
+               "SCpnt=0x%p target=%d lun=%llu sglist=0x%p bufflen=%d sg_count=%d",
                SCpnt, target, SCpnt->device->lun, scsi_sglist(SCpnt),
                scsi_bufflen(SCpnt), scsi_sg_count(SCpnt));
        //nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "before CurrentSC=0x%p", data->CurrentSC);
 
 
        DEB(printk("cmd=%02x, cmd_len=%02x, target=%02x, lun=%02x, bufflen=%d\n", 
            SCpnt->cmnd[0], SCpnt->cmd_len, SCpnt->device->id, 
-           SCpnt->device->lun,  scsi_bufflen(SCpnt)));
+                  (u8)SCpnt->device->lun,  scsi_bufflen(SCpnt)));
 
        VDEB(for (i = 0; i < SCpnt->cmd_len; i++)
            printk("cmd[%d]=%02x  ", i, SCpnt->cmnd[i]));
 
                     scsi_dev->host->unique_id,
                     scsi_dev->channel,
                     scsi_dev->id,
-                    scsi_dev->lun);
+                    (u8)scsi_dev->lun);
 
        if (RES_IS_GSCSI(res->cfg_entry)) {
                scsi_dev->allow_restart = 1;
 
        struct ps3rom_private *priv = shost_priv(scsi_dev->host);
        struct ps3_storage_device *dev = priv->dev;
 
-       dev_dbg(&dev->sbd.core, "%s:%u: id %u, lun %u, channel %u\n", __func__,
+       dev_dbg(&dev->sbd.core, "%s:%u: id %u, lun %llu, channel %u\n", __func__,
                __LINE__, scsi_dev->id, scsi_dev->lun, scsi_dev->channel);
 
        /*
 
                         * defined in tsk_mgmt_entry struct
                         * for control_flags field in qla_fw.h.
                         */
+                       uint64_t lun;
                        uint32_t flags;
-                       uint32_t lun;
                        uint32_t data;
                        struct completion comp;
                        __le16 comp_status;
        void (*disable_intrs) (struct qla_hw_data *);
 
        int (*abort_command) (srb_t *);
-       int (*target_reset) (struct fc_port *, unsigned int, int);
-       int (*lun_reset) (struct fc_port *, unsigned int, int);
+       int (*target_reset) (struct fc_port *, uint64_t, int);
+       int (*lun_reset) (struct fc_port *, uint64_t, int);
        int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
                uint8_t, uint8_t, uint16_t *, uint8_t);
        int (*fabric_logout) (struct scsi_qla_host *, uint16_t, uint8_t,
 
 extern int qla2x00_start_scsi(srb_t *sp);
 extern int qla24xx_start_scsi(srb_t *sp);
 int qla2x00_marker(struct scsi_qla_host *, struct req_que *, struct rsp_que *,
-                                               uint16_t, uint16_t, uint8_t);
+                                               uint16_t, uint64_t, uint8_t);
 extern int qla2x00_start_sp(srb_t *);
 extern int qla24xx_dif_start_scsi(srb_t *);
 extern int qla2x00_start_bidir(srb_t *, struct scsi_qla_host *, uint32_t);
 qla2x00_abort_command(srb_t *);
 
 extern int
-qla2x00_abort_target(struct fc_port *, unsigned int, int);
+qla2x00_abort_target(struct fc_port *, uint64_t, int);
 
 extern int
-qla2x00_lun_reset(struct fc_port *, unsigned int, int);
+qla2x00_lun_reset(struct fc_port *, uint64_t, int);
 
 extern int
 qla2x00_get_adapter_id(scsi_qla_host_t *, uint16_t *, uint8_t *, uint8_t *,
 extern int qla24xx_abort_command(srb_t *);
 extern int qla24xx_async_abort_command(srb_t *);
 extern int
-qla24xx_abort_target(struct fc_port *, unsigned int, int);
+qla24xx_abort_target(struct fc_port *, uint64_t, int);
 extern int
-qla24xx_lun_reset(struct fc_port *, unsigned int, int);
+qla24xx_lun_reset(struct fc_port *, uint64_t, int);
 extern int
 qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *, unsigned int,
-       unsigned int, enum nexus_wait_type);
+       uint64_t, enum nexus_wait_type);
 extern int
 qla2x00_system_error(scsi_qla_host_t *);
 
 extern irqreturn_t qlafx00_intr_handler(int, void *);
 extern void qlafx00_enable_intrs(struct qla_hw_data *);
 extern void qlafx00_disable_intrs(struct qla_hw_data *);
-extern int qlafx00_abort_target(fc_port_t *, unsigned int, int);
-extern int qlafx00_lun_reset(fc_port_t *, unsigned int, int);
+extern int qlafx00_abort_target(fc_port_t *, uint64_t, int);
+extern int qlafx00_lun_reset(fc_port_t *, uint64_t, int);
 extern int qlafx00_start_scsi(srb_t *);
 extern int qlafx00_abort_isp(scsi_qla_host_t *);
 extern int qlafx00_iospace_config(struct qla_hw_data *);
 
 static int
 __qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req,
                        struct rsp_que *rsp, uint16_t loop_id,
-                       uint16_t lun, uint8_t type)
+                       uint64_t lun, uint8_t type)
 {
        mrk_entry_t *mrk;
        struct mrk_entry_24xx *mrk24 = NULL;
                if (IS_FWI2_CAPABLE(ha)) {
                        mrk24 = (struct mrk_entry_24xx *) mrk;
                        mrk24->nport_handle = cpu_to_le16(loop_id);
-                       mrk24->lun[1] = LSB(lun);
-                       mrk24->lun[2] = MSB(lun);
+                       int_to_scsilun(lun, (struct scsi_lun *)&mrk24->lun);
                        host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun));
                        mrk24->vp_index = vha->vp_idx;
                        mrk24->handle = MAKE_HANDLE(req->id, mrk24->handle);
                } else {
                        SET_TARGET_ID(ha, mrk->target, loop_id);
-                       mrk->lun = cpu_to_le16(lun);
+                       mrk->lun = cpu_to_le16((uint16_t)lun);
                }
        }
        wmb();
 
 int
 qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req,
-               struct rsp_que *rsp, uint16_t loop_id, uint16_t lun,
+               struct rsp_que *rsp, uint16_t loop_id, uint64_t lun,
                uint8_t type)
 {
        int ret;
 qla24xx_tm_iocb(srb_t *sp, struct tsk_mgmt_entry *tsk)
 {
        uint32_t flags;
-       unsigned int lun;
+       uint64_t lun;
        struct fc_port *fcport = sp->fcport;
        scsi_qla_host_t *vha = fcport->vha;
        struct qla_hw_data *ha = vha->hw;
 
 
        if (sense_len) {
                ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x301c,
-                   "Check condition Sense data, nexus%ld:%d:%d cmd=%p.\n",
+                   "Check condition Sense data, nexus%ld:%d:%llu cmd=%p.\n",
                    sp->fcport->vha->host_no, cp->device->id, cp->device->lun,
                    cp);
                ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x302b,
 out:
        if (logit)
                ql_dbg(ql_dbg_io, fcport->vha, 0x3022,
-                   "FCP command status: 0x%x-0x%x (0x%x) nexus=%ld:%d:%d "
+                   "FCP command status: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu "
                    "portid=%02x%02x%02x oxid=0x%x cdb=%10phN len=0x%x "
                    "rsp_info=0x%x resid=0x%x fw_resid=0x%x.\n",
                    comp_status, scsi_status, res, vha->host_no,
 
 }
 
 int
-qla2x00_abort_target(struct fc_port *fcport, unsigned int l, int tag)
+qla2x00_abort_target(struct fc_port *fcport, uint64_t l, int tag)
 {
        int rval, rval2;
        mbx_cmd_t  mc;
 }
 
 int
-qla2x00_lun_reset(struct fc_port *fcport, unsigned int l, int tag)
+qla2x00_lun_reset(struct fc_port *fcport, uint64_t l, int tag)
 {
        int rval, rval2;
        mbx_cmd_t  mc;
                mcp->mb[1] = fcport->loop_id;
        else
                mcp->mb[1] = fcport->loop_id << 8;
-       mcp->mb[2] = l;
+       mcp->mb[2] = (u32)l;
        mcp->mb[3] = 0;
        mcp->mb[9] = vha->vp_idx;
 
 
 static int
 __qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport,
-    unsigned int l, int tag)
+    uint64_t l, int tag)
 {
        int             rval, rval2;
        struct tsk_mgmt_cmd *tsk;
 }
 
 int
-qla24xx_abort_target(struct fc_port *fcport, unsigned int l, int tag)
+qla24xx_abort_target(struct fc_port *fcport, uint64_t l, int tag)
 {
        struct qla_hw_data *ha = fcport->vha->hw;
 
 }
 
 int
-qla24xx_lun_reset(struct fc_port *fcport, unsigned int l, int tag)
+qla24xx_lun_reset(struct fc_port *fcport, uint64_t l, int tag)
 {
        struct qla_hw_data *ha = fcport->vha->hw;
 
 
 }
 
 int
-qlafx00_abort_target(fc_port_t *fcport, unsigned int l, int tag)
+qlafx00_abort_target(fc_port_t *fcport, uint64_t l, int tag)
 {
        return qla2x00_async_tm_cmd(fcport, TCF_TARGET_RESET, l, tag);
 }
 
 int
-qlafx00_lun_reset(fc_port_t *fcport, unsigned int l, int tag)
+qlafx00_lun_reset(fc_port_t *fcport, uint64_t l, int tag)
 {
        return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag);
 }
 
        if (sense_len) {
                ql_dbg(ql_dbg_io + ql_dbg_buffer, vha, 0x3039,
-                   "Check condition Sense data, nexus%ld:%d:%d cmd=%p.\n",
+                   "Check condition Sense data, nexus%ld:%d:%llu cmd=%p.\n",
                    sp->fcport->vha->host_no, cp->device->id, cp->device->lun,
                    cp);
                ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x3049,
 
        if (logit)
                ql_dbg(ql_dbg_io, fcport->vha, 0x3058,
-                   "FCP command status: 0x%x-0x%x (0x%x) nexus=%ld:%d:%d "
+                   "FCP command status: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu "
                    "tgt_id: 0x%x lscsi_status: 0x%x cdb=%10phN len=0x%x "
                    "rsp_info=0x%x resid=0x%x fw_resid=0x%x sense_len=0x%x, "
                    "par_sense_len=0x%x, rsp_info_len=0x%x\n",
 
        scsi_qla_host_t *vha = shost_priv(cmd->device->host);
        srb_t *sp;
        int ret;
-       unsigned int id, lun;
+       unsigned int id;
+       uint64_t lun;
        unsigned long flags;
        int rval, wait = 0;
        struct qla_hw_data *ha = vha->hw;
        }
 
        ql_dbg(ql_dbg_taskm, vha, 0x8002,
-           "Aborting from RISC nexus=%ld:%d:%d sp=%p cmd=%p\n",
+           "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p\n",
            vha->host_no, id, lun, sp, cmd);
 
        /* Get a reference to the sp and drop the lock.*/
        }
 
        ql_log(ql_log_info, vha, 0x801c,
-           "Abort command issued nexus=%ld:%d:%d --  %d %x.\n",
+           "Abort command issued nexus=%ld:%d:%llu --  %d %x.\n",
            vha->host_no, id, lun, wait, ret);
 
        return ret;
 
 int
 qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
-       unsigned int l, enum nexus_wait_type type)
+       uint64_t l, enum nexus_wait_type type)
 {
        int cnt, match, status;
        unsigned long flags;
 
 static int
 __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type,
-    struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, unsigned int, int))
+    struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, uint64_t, int))
 {
        scsi_qla_host_t *vha = shost_priv(cmd->device->host);
        fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
                return err;
 
        ql_log(ql_log_info, vha, 0x8009,
-           "%s RESET ISSUED nexus=%ld:%d:%d cmd=%p.\n", name, vha->host_no,
+           "%s RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", name, vha->host_no,
            cmd->device->id, cmd->device->lun, cmd);
 
        err = 0;
        }
 
        ql_log(ql_log_info, vha, 0x800e,
-           "%s RESET SUCCEEDED nexus:%ld:%d:%d cmd=%p.\n", name,
+           "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name,
            vha->host_no, cmd->device->id, cmd->device->lun, cmd);
 
        return SUCCESS;
 
 eh_reset_failed:
        ql_log(ql_log_info, vha, 0x800f,
-           "%s RESET FAILED: %s nexus=%ld:%d:%d cmd=%p.\n", name,
+           "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name,
            reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun,
            cmd);
        return FAILED;
        scsi_qla_host_t *vha = shost_priv(cmd->device->host);
        fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
        int ret = FAILED;
-       unsigned int id, lun;
+       unsigned int id;
+       uint64_t lun;
 
        id = cmd->device->id;
        lun = cmd->device->lun;
        ret = FAILED;
 
        ql_log(ql_log_info, vha, 0x8012,
-           "BUS RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun);
+           "BUS RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
 
        if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
                ql_log(ql_log_fatal, vha, 0x8013,
 
 eh_bus_reset_done:
        ql_log(ql_log_warn, vha, 0x802b,
-           "BUS RESET %s nexus=%ld:%d:%d.\n",
+           "BUS RESET %s nexus=%ld:%d:%llu.\n",
            (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
 
        return ret;
        scsi_qla_host_t *vha = shost_priv(cmd->device->host);
        struct qla_hw_data *ha = vha->hw;
        int ret = FAILED;
-       unsigned int id, lun;
+       unsigned int id;
+       uint64_t lun;
        scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
 
        id = cmd->device->id;
        lun = cmd->device->lun;
 
        ql_log(ql_log_info, vha, 0x8018,
-           "ADAPTER RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun);
+           "ADAPTER RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
 
        /*
         * No point in issuing another reset if one is active.  Also do not
 
 eh_host_reset_lock:
        ql_log(ql_log_info, vha, 0x8017,
-           "ADAPTER RESET %s nexus=%ld:%d:%d.\n",
+           "ADAPTER RESET %s nexus=%ld:%d:%llu.\n",
            (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
 
        return ret;
                return;
 
        ql_dbg(ql_dbg_io, fcport->vha, 0x3029,
-           "Queue depth adjusted-down to %d for nexus=%ld:%d:%d.\n",
+           "Queue depth adjusted-down to %d for nexus=%ld:%d:%llu.\n",
            sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun);
 }
 
                scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth);
 
        ql_dbg(ql_dbg_io, vha, 0x302a,
-           "Queue depth adjusted-up to %d for nexus=%ld:%d:%d.\n",
+           "Queue depth adjusted-up to %d for nexus=%ld:%d:%llu.\n",
            sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun);
 }
 
 
 int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host *ha);
 int qla4xxx_abort_task(struct scsi_qla_host *ha, struct srb *srb);
 int qla4xxx_reset_lun(struct scsi_qla_host *ha, struct ddb_entry *ddb_entry,
-                     int lun);
+                     uint64_t lun);
 int qla4xxx_reset_target(struct scsi_qla_host *ha,
                         struct ddb_entry *ddb_entry);
 int qla4xxx_get_flash(struct scsi_qla_host *ha, dma_addr_t dma_addr,
                uint32_t state, uint32_t conn_error);
 void qla4xxx_dump_buffer(void *b, uint32_t size);
 int qla4xxx_send_marker_iocb(struct scsi_qla_host *ha,
-       struct ddb_entry *ddb_entry, int lun, uint16_t mrkr_mod);
+       struct ddb_entry *ddb_entry, uint64_t lun, uint16_t mrkr_mod);
 int qla4xxx_set_flash(struct scsi_qla_host *ha, dma_addr_t dma_addr,
                      uint32_t offset, uint32_t length, uint32_t options);
 int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
 
  * This routine issues a marker IOCB.
  **/
 int qla4xxx_send_marker_iocb(struct scsi_qla_host *ha,
-       struct ddb_entry *ddb_entry, int lun, uint16_t mrkr_mod)
+       struct ddb_entry *ddb_entry, uint64_t lun, uint16_t mrkr_mod)
 {
        struct qla4_marker_entry *marker_entry;
        unsigned long flags = 0;
 
        memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
        sense_len = le16_to_cpu(sts_entry->senseDataByteCnt);
        if (sense_len == 0) {
-               DEBUG2(ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%d:%d: %s:"
+               DEBUG2(ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%d:%llu: %s:"
                                  " sense len 0\n", ha->host_no,
                                  cmd->device->channel, cmd->device->id,
                                  cmd->device->lun, __func__));
        sense_len = min_t(uint16_t, sense_len, IOCB_MAX_SENSEDATA_LEN);
        memcpy(cmd->sense_buffer, sts_entry->senseData, sense_len);
 
-       DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: %s: sense key = %x, "
+       DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%llu: %s: sense key = %x, "
                "ASL= %02x, ASC/ASCQ = %02x/%02x\n", ha->host_no,
                cmd->device->channel, cmd->device->id,
                cmd->device->lun, __func__,
 
                                cmd->result = DID_ERROR << 16;
 
-                               DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
+                               DEBUG2(printk("scsi%ld:%d:%d:%llu: %s: "
                                        "Mid-layer Data underrun0, "
                                        "xferlen = 0x%x, "
                                        "residual = 0x%x\n", ha->host_no,
                break;
 
        case SCS_RESET_OCCURRED:
-               DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Device RESET occurred\n",
+               DEBUG2(printk("scsi%ld:%d:%d:%llu: %s: Device RESET occurred\n",
                              ha->host_no, cmd->device->channel,
                              cmd->device->id, cmd->device->lun, __func__));
 
                break;
 
        case SCS_ABORTED:
-               DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Abort occurred\n",
+               DEBUG2(printk("scsi%ld:%d:%d:%llu: %s: Abort occurred\n",
                              ha->host_no, cmd->device->channel,
                              cmd->device->id, cmd->device->lun, __func__));
 
                break;
 
        case SCS_TIMEOUT:
-               DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: Timeout\n",
+               DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%llu: Timeout\n",
                              ha->host_no, cmd->device->channel,
                              cmd->device->id, cmd->device->lun));
 
        case SCS_DATA_OVERRUN:
                if ((sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) ||
                     (sts_entry->completionStatus == SCS_DATA_OVERRUN)) {
-                       DEBUG2(printk("scsi%ld:%d:%d:%d: %s: " "Data overrun\n",
+                       DEBUG2(printk("scsi%ld:%d:%d:%llu: %s: " "Data overrun\n",
                                      ha->host_no,
                                      cmd->device->channel, cmd->device->id,
                                      cmd->device->lun, __func__));
                        if (!scsi_status && (scsi_bufflen(cmd) - residual) <
                            cmd->underflow) {
                                DEBUG2(ql4_printk(KERN_INFO, ha,
-                                                 "scsi%ld:%d:%d:%d: %s: Mid-layer Data underrun, xferlen = 0x%x,residual = 0x%x\n",
+                                                 "scsi%ld:%d:%d:%llu: %s: Mid-layer Data underrun, xferlen = 0x%x,residual = 0x%x\n",
                                                   ha->host_no,
                                                   cmd->device->channel,
                                                   cmd->device->id,
                         */
 
                        DEBUG2(ql4_printk(KERN_INFO, ha,
-                                         "scsi%ld:%d:%d:%d: %s: Dropped frame(s) detected (0x%x of 0x%x bytes).\n",
+                                         "scsi%ld:%d:%d:%llu: %s: Dropped frame(s) detected (0x%x of 0x%x bytes).\n",
                                          ha->host_no,
                                          cmd->device->channel,
                                          cmd->device->id,
 
        case SCS_DEVICE_LOGGED_OUT:
        case SCS_DEVICE_UNAVAILABLE:
-               DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: SCS_DEVICE "
+               DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%llu: SCS_DEVICE "
                    "state: 0x%x\n", ha->host_no,
                    cmd->device->channel, cmd->device->id,
                    cmd->device->lun, sts_entry->completionStatus));
                 * SCSI Mid-Layer handles device queue full
                 */
                cmd->result = DID_OK << 16 | sts_entry->scsiStatus;
-               DEBUG2(printk("scsi%ld:%d:%d: %s: QUEUE FULL detected "
+               DEBUG2(printk("scsi%ld:%d:%llu: %s: QUEUE FULL detected "
                              "compl=%02x, scsi=%02x, state=%02x, iFlags=%02x,"
                              " iResp=%02x\n", ha->host_no, cmd->device->id,
                              cmd->device->lun, __func__,
 
        if (mbox_sts[0] != MBOX_STS_COMMAND_COMPLETE) {
                status = QLA_ERROR;
 
-               DEBUG2(printk(KERN_WARNING "scsi%ld:%d:%d: abort task FAILED: "
+               DEBUG2(printk(KERN_WARNING "scsi%ld:%d:%llu: abort task FAILED: "
                    "mbx0=%04X, mb1=%04X, mb2=%04X, mb3=%04X, mb4=%04X\n",
                    ha->host_no, cmd->device->id, cmd->device->lun, mbox_sts[0],
                    mbox_sts[1], mbox_sts[2], mbox_sts[3], mbox_sts[4]));
  * are valid before calling this routine.
  **/
 int qla4xxx_reset_lun(struct scsi_qla_host * ha, struct ddb_entry * ddb_entry,
-                     int lun)
+                     uint64_t lun)
 {
        uint32_t mbox_cmd[MBOX_REG_COUNT];
        uint32_t mbox_sts[MBOX_REG_COUNT];
        uint32_t scsi_lun[2];
        int status = QLA_SUCCESS;
 
-       DEBUG2(printk("scsi%ld:%d:%d: lun reset issued\n", ha->host_no,
+       DEBUG2(printk("scsi%ld:%d:%llu: lun reset issued\n", ha->host_no,
                      ddb_entry->fw_ddb_index, lun));
 
        /*
 
 {
        struct scsi_qla_host *ha = to_qla_host(cmd->device->host);
        unsigned int id = cmd->device->id;
-       unsigned int lun = cmd->device->lun;
+       uint64_t lun = cmd->device->lun;
        unsigned long flags;
        struct srb *srb = NULL;
        int ret = SUCCESS;
        int wait = 0;
 
-       ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%d: Abort command issued cmd=%p, cdb=0x%x\n",
+       ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Abort command issued cmd=%p, cdb=0x%x\n",
                   ha->host_no, id, lun, cmd, cmd->cmnd[0]);
 
        spin_lock_irqsave(&ha->hardware_lock, flags);
        srb = (struct srb *) CMD_SP(cmd);
        if (!srb) {
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
-               ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%d: Specified command has already completed.\n",
+               ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Specified command has already completed.\n",
                           ha->host_no, id, lun);
                return SUCCESS;
        }
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
        if (qla4xxx_abort_task(ha, srb) != QLA_SUCCESS) {
-               DEBUG3(printk("scsi%ld:%d:%d: Abort_task mbx failed.\n",
+               DEBUG3(printk("scsi%ld:%d:%llu: Abort_task mbx failed.\n",
                    ha->host_no, id, lun));
                ret = FAILED;
        } else {
-               DEBUG3(printk("scsi%ld:%d:%d: Abort_task mbx success.\n",
+               DEBUG3(printk("scsi%ld:%d:%llu: Abort_task mbx success.\n",
                    ha->host_no, id, lun));
                wait = 1;
        }
        /* Wait for command to complete */
        if (wait) {
                if (!qla4xxx_eh_wait_on_command(ha, cmd)) {
-                       DEBUG2(printk("scsi%ld:%d:%d: Abort handler timed out\n",
+                       DEBUG2(printk("scsi%ld:%d:%llu: Abort handler timed out\n",
                            ha->host_no, id, lun));
                        ret = FAILED;
                }
        }
 
        ql4_printk(KERN_INFO, ha,
-           "scsi%ld:%d:%d: Abort command - %s\n",
+           "scsi%ld:%d:%llu: Abort command - %s\n",
            ha->host_no, id, lun, (ret == SUCCESS) ? "succeeded" : "failed");
 
        return ret;
        ret = FAILED;
 
        ql4_printk(KERN_INFO, ha,
-                  "scsi%ld:%d:%d:%d: DEVICE RESET ISSUED.\n", ha->host_no,
+                  "scsi%ld:%d:%d:%llu: DEVICE RESET ISSUED.\n", ha->host_no,
                   cmd->device->channel, cmd->device->id, cmd->device->lun);
 
        DEBUG2(printk(KERN_INFO
                goto eh_dev_reset_done;
 
        ql4_printk(KERN_INFO, ha,
-                  "scsi(%ld:%d:%d:%d): DEVICE RESET SUCCEEDED.\n",
+                  "scsi(%ld:%d:%d:%llu): DEVICE RESET SUCCEEDED.\n",
                   ha->host_no, cmd->device->channel, cmd->device->id,
                   cmd->device->lun);
 
        }
 
        ql4_printk(KERN_INFO, ha,
-                  "scsi(%ld:%d:%d:%d): HOST RESET ISSUED.\n", ha->host_no,
+                  "scsi(%ld:%d:%d:%llu): HOST RESET ISSUED.\n", ha->host_no,
                   cmd->device->channel, cmd->device->id, cmd->device->lun);
 
        if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) {
 
  * really want to use scsi_device_lookup_by_target instead.
  **/
 struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *starget,
-                                                  uint lun)
+                                                  u64 lun)
 {
        struct scsi_device *sdev;
 
  * needs to be released with scsi_device_put once you're done with it.
  **/
 struct scsi_device *scsi_device_lookup_by_target(struct scsi_target *starget,
-                                                uint lun)
+                                                u64 lun)
 {
        struct scsi_device *sdev;
        struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
  * really want to use scsi_device_lookup instead.
  **/
 struct scsi_device *__scsi_device_lookup(struct Scsi_Host *shost,
-               uint channel, uint id, uint lun)
+               uint channel, uint id, u64 lun)
 {
        struct scsi_device *sdev;
 
  * needs to be released with scsi_device_put once you're done with it.
  **/
 struct scsi_device *scsi_device_lookup(struct Scsi_Host *shost,
-               uint channel, uint id, uint lun)
+               uint channel, uint id, u64 lun)
 {
        struct scsi_device *sdev;
        unsigned long flags;
 
        unsigned char sense_buff[SDEBUG_SENSE_LEN];     /* weak nexus */
        unsigned int channel;
        unsigned int target;
-       unsigned int lun;
+       u64 lun;
        struct sdebug_host_info *sdbg_host;
-       unsigned int wlun;
+       u64 wlun;
        char reset;
        char stopped;
        char used;
                            struct sdebug_dev_info * devip)
 {
        unsigned int alloc_len;
-       int lun_cnt, i, upper, num, n, wlun, lun;
+       int lun_cnt, i, upper, num, n;
+       u64 wlun, lun;
        unsigned char *cmd = (unsigned char *)scp->cmnd;
        int select_report = (int)cmd[2];
        struct scsi_lun *one_lun;
 static int scsi_debug_slave_alloc(struct scsi_device *sdp)
 {
        if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)
-               printk(KERN_INFO "scsi_debug: slave_alloc <%u %u %u %u>\n",
+               printk(KERN_INFO "scsi_debug: slave_alloc <%u %u %u %llu>\n",
                       sdp->host->host_no, sdp->channel, sdp->id, sdp->lun);
        queue_flag_set_unlocked(QUEUE_FLAG_BIDI, sdp->request_queue);
        return 0;
        struct sdebug_dev_info *devip;
 
        if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)
-               printk(KERN_INFO "scsi_debug: slave_configure <%u %u %u %u>\n",
+               printk(KERN_INFO "scsi_debug: slave_configure <%u %u %u %llu>\n",
                       sdp->host->host_no, sdp->channel, sdp->id, sdp->lun);
        if (sdp->host->max_cmd_len != SCSI_DEBUG_MAX_CMD_LEN)
                sdp->host->max_cmd_len = SCSI_DEBUG_MAX_CMD_LEN;
                (struct sdebug_dev_info *)sdp->hostdata;
 
        if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)
-               printk(KERN_INFO "scsi_debug: slave_destroy <%u %u %u %u>\n",
+               printk(KERN_INFO "scsi_debug: slave_destroy <%u %u %u %llu>\n",
                       sdp->host->host_no, sdp->channel, sdp->id, sdp->lun);
        if (devip) {
                /* make this slot available for re-use */
                if (scsi_result) {
                        struct scsi_device * sdp = cmnd->device;
 
-                       printk(KERN_INFO "scsi_debug:    <%u %u %u %u> "
+                       printk(KERN_INFO "scsi_debug:    <%u %u %u %llu> "
                               "non-zero result=0x%x\n", sdp->host->host_no,
                               sdp->channel, sdp->id, sdp->lun, scsi_result);
                }
 
 extern char scsi_scan_type[];
 extern int scsi_complete_async_scans(void);
 extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
-                                  unsigned int, unsigned int, int);
+                                  unsigned int, u64, int);
 extern void scsi_forget_host(struct Scsi_Host *);
 extern void scsi_rescan_device(struct device *);
 
 
 
        sdev = to_scsi_device(dev);
        seq_printf(s,
-               "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n  Vendor: ",
+               "Host: scsi%d Channel: %02d Id: %02d Lun: %02llu\n  Vendor: ",
                sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
        for (i = 0; i < 8; i++) {
                if (sdev->vendor[i] >= 0x20)
 
  *     scsi_Device pointer, or NULL on failure.
  **/
 static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
-                                          unsigned int lun, void *hostdata)
+                                          u64 lun, void *hostdata)
 {
        struct scsi_device *sdev;
        int display_failure_msg = 1, ret;
  *     SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized
  **/
 static int scsi_probe_and_add_lun(struct scsi_target *starget,
-                                 uint lun, int *bflagsp,
+                                 u64 lun, int *bflagsp,
                                  struct scsi_device **sdevp, int rescan,
                                  void *hostdata)
 {
 static void scsi_sequential_lun_scan(struct scsi_target *starget,
                                     int bflags, int scsi_level, int rescan)
 {
-       unsigned int sparse_lun, lun, max_dev_lun;
+       uint max_dev_lun;
+       u64 sparse_lun, lun;
        struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
 
        SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: Sequential scan of"
  *     Given a struct scsi_lun of: 0a 04 0b 03 00 00 00 00, this function returns
  *     the integer: 0x0b030a04
  **/
-int scsilun_to_int(struct scsi_lun *scsilun)
+u64 scsilun_to_int(struct scsi_lun *scsilun)
 {
        int i;
-       unsigned int lun;
+       u64 lun;
 
        lun = 0;
        for (i = 0; i < sizeof(lun); i += 2)
  *     scsi_lun of : struct scsi_lun of: 0a 04 0b 03 00 00 00 00
  *
  **/
-void int_to_scsilun(unsigned int lun, struct scsi_lun *scsilun)
+void int_to_scsilun(u64 lun, struct scsi_lun *scsilun)
 {
        int i;
 
        char devname[64];
        unsigned char scsi_cmd[MAX_COMMAND_SIZE];
        unsigned int length;
-       unsigned int lun;
+       u64 lun;
        unsigned int num_luns;
        unsigned int retries;
        int result;
        for (lunp = &lun_data[1]; lunp <= &lun_data[num_luns]; lunp++) {
                lun = scsilun_to_int(lunp);
 
-               /*
-                * Check if the unused part of lunp is non-zero, and so
-                * does not fit in lun.
-                */
-               if (memcmp(&lunp->scsi_lun[sizeof(lun)], "\0\0\0\0", 4)) {
-                       int i;
-
-                       /*
-                        * Output an error displaying the LUN in byte order,
-                        * this differs from what linux would print for the
-                        * integer LUN value.
-                        */
-                       printk(KERN_WARNING "scsi: %s lun 0x", devname);
-                       data = (char *)lunp->scsi_lun;
-                       for (i = 0; i < sizeof(struct scsi_lun); i++)
-                               printk("%02x", data[i]);
-                       printk(" has a LUN larger than currently supported.\n");
-               } else if (lun > sdev->host->max_lun) {
-                       printk(KERN_WARNING "scsi: %s lun%d has a LUN larger"
+               if (lun > sdev->host->max_lun) {
+                       printk(KERN_WARNING "scsi: %s lun%llu has a LUN larger"
                               " than allowed by the host adapter\n",
                               devname, lun);
                } else {
                                 */
                                sdev_printk(KERN_ERR, sdev,
                                        "Unexpected response"
-                                       " from lun %d while scanning, scan"
-                                       " aborted\n", lun);
+                                       " from lun %llu while scanning, scan"
+                                       " aborted\n", (unsigned long long)lun);
                                break;
                        }
                }
 }
 
 struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
-                                     uint id, uint lun, void *hostdata)
+                                     uint id, u64 lun, void *hostdata)
 {
        struct scsi_device *sdev = ERR_PTR(-ENODEV);
        struct device *parent = &shost->shost_gendev;
 EXPORT_SYMBOL(__scsi_add_device);
 
 int scsi_add_device(struct Scsi_Host *host, uint channel,
-                   uint target, uint lun)
+                   uint target, u64 lun)
 {
        struct scsi_device *sdev = 
                __scsi_add_device(host, channel, target, lun, NULL);
 EXPORT_SYMBOL(scsi_rescan_device);
 
 static void __scsi_scan_target(struct device *parent, unsigned int channel,
-               unsigned int id, unsigned int lun, int rescan)
+               unsigned int id, u64 lun, int rescan)
 {
        struct Scsi_Host *shost = dev_to_shost(parent);
        int bflags = 0;
  *     sequential scan of LUNs on the target id.
  **/
 void scsi_scan_target(struct device *parent, unsigned int channel,
-                     unsigned int id, unsigned int lun, int rescan)
+                     unsigned int id, u64 lun, int rescan)
 {
        struct Scsi_Host *shost = dev_to_shost(parent);
 
 EXPORT_SYMBOL(scsi_scan_target);
 
 static void scsi_scan_channel(struct Scsi_Host *shost, unsigned int channel,
-                             unsigned int id, unsigned int lun, int rescan)
+                             unsigned int id, u64 lun, int rescan)
 {
        uint order_id;
 
 }
 
 int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
-                           unsigned int id, unsigned int lun, int rescan)
+                           unsigned int id, u64 lun, int rescan)
 {
        SCSI_LOG_SCAN_BUS(3, shost_printk (KERN_INFO, shost,
-               "%s: <%u:%u:%u>\n",
+               "%s: <%u:%u:%llu>\n",
                __func__, channel, id, lun));
 
        if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
 
        return name;
 }
 
-static int check_set(unsigned int *val, char *src)
+static int check_set(unsigned long long *val, char *src)
 {
        char *last;
 
                /*
                 * Doesn't check for int overflow
                 */
-               *val = simple_strtoul(src, &last, 0);
+               *val = simple_strtoull(src, &last, 0);
                if (*last != '\0')
                        return 1;
        }
 
 static int scsi_scan(struct Scsi_Host *shost, const char *str)
 {
-       char s1[15], s2[15], s3[15], junk;
-       unsigned int channel, id, lun;
+       char s1[15], s2[15], s3[17], junk;
+       unsigned long long channel, id, lun;
        int res;
 
-       res = sscanf(str, "%10s %10s %10s %c", s1, s2, s3, &junk);
+       res = sscanf(str, "%10s %10s %16s %c", s1, s2, s3, &junk);
        if (res != 3)
                return -EINVAL;
        if (check_set(&channel, s1))
        device_initialize(&sdev->sdev_gendev);
        sdev->sdev_gendev.bus = &scsi_bus_type;
        sdev->sdev_gendev.type = &scsi_dev_type;
-       dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%d",
+       dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu",
                     sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
 
        device_initialize(&sdev->sdev_dev);
        sdev->sdev_dev.parent = get_device(&sdev->sdev_gendev);
        sdev->sdev_dev.class = &sdev_class;
-       dev_set_name(&sdev->sdev_dev, "%d:%d:%d:%d",
+       dev_set_name(&sdev->sdev_dev, "%d:%d:%d:%llu",
                     sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
        sdev->scsi_level = starget->scsi_level;
        transport_setup_device(&sdev->sdev_gendev);
 
  * on the rport.
  */
 static void
-fc_user_scan_tgt(struct Scsi_Host *shost, uint channel, uint id, uint lun)
+fc_user_scan_tgt(struct Scsi_Host *shost, uint channel, uint id, u64 lun)
 {
        struct fc_rport *rport;
        unsigned long flags;
  * object as the parent.
  */
 static int
-fc_user_scan(struct Scsi_Host *shost, uint channel, uint id, uint lun)
+fc_user_scan(struct Scsi_Host *shost, uint channel, uint id, u64 lun)
 {
        uint chlo, chhi;
        uint tgtlo, tgthi;
 
 struct iscsi_scan_data {
        unsigned int channel;
        unsigned int id;
-       unsigned int lun;
+       u64 lun;
 };
 
 static int iscsi_user_scan_session(struct device *dev, void *data)
 }
 
 static int iscsi_user_scan(struct Scsi_Host *shost, uint channel,
-                          uint id, uint lun)
+                          uint id, u64 lun)
 {
        struct iscsi_scan_data scan_data;
 
 
  */
 
 static int sas_user_scan(struct Scsi_Host *shost, uint channel,
-               uint id, uint lun)
+               uint id, u64 lun)
 {
        struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
        struct sas_rphy *rphy;
 
                seq_puts(s, "-1\t-1\t-1\t-1\t-1\t-1\t-1\t-1\t-1\n");
        else {
                scsidp = sdp->device;
-               seq_printf(s, "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
+               seq_printf(s, "%d\t%d\t%d\t%llu\t%d\t%d\t%d\t%d\t%d\n",
                              scsidp->host->host_no, scsidp->channel,
                              scsidp->id, scsidp->lun, (int) scsidp->type,
                              1,
                else if (sdp->device) {
                        struct scsi_device *scsidp = sdp->device;
 
-                       seq_printf(s, "%d:%d:%d:%d   em=%d",
+                       seq_printf(s, "%d:%d:%d:%llu   em=%d",
                                   scsidp->host->host_no,
                                   scsidp->channel, scsidp->id,
                                   scsidp->lun,
 
 
 static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged)
 {
+    u8 lun = cmd->device->lun;
     SETUP_HOSTDATA(cmd->device->host);
 
-    if (hostdata->busy[cmd->device->id] & (1 << cmd->device->lun))
+    if (hostdata->busy[cmd->device->id] & (1 << lun))
        return( 1 );
     if (!should_be_tagged ||
        !setup_use_tagged_queuing || !cmd->device->tagged_supported)
        return( 0 );
-    if (TagAlloc[cmd->device->id][cmd->device->lun].nr_allocated >=
-       TagAlloc[cmd->device->id][cmd->device->lun].queue_size ) {
+    if (TagAlloc[cmd->device->id][lun].nr_allocated >=
+       TagAlloc[cmd->device->id][lun].queue_size ) {
        dprintk(NDEBUG_TAGS,  "scsi%d: target %d lun %d: no free tags\n",
-                   H_NO(cmd), cmd->device->id, cmd->device->lun );
+                   H_NO(cmd), cmd->device->id, lun );
        return( 1 );
     }
     return( 0 );
 
 static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged)
 {
+    u8 lun = cmd->device->lun;
     SETUP_HOSTDATA(cmd->device->host);
 
     /* If we or the target don't support tagged queuing, allocate the LUN for
     if (!should_be_tagged ||
        !setup_use_tagged_queuing || !cmd->device->tagged_supported) {
        cmd->tag = TAG_NONE;
-       hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
+       hostdata->busy[cmd->device->id] |= (1 << lun);
        dprintk(NDEBUG_TAGS,  "scsi%d: target %d lun %d now allocated by untagged "
-                   "command\n", H_NO(cmd), cmd->device->id, cmd->device->lun );
+                   "command\n", H_NO(cmd), cmd->device->id, lun );
     }
     else {
-       TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
+       TAG_ALLOC *ta = &TagAlloc[cmd->device->id][lun];
 
        cmd->tag = find_first_zero_bit( &ta->allocated, MAX_TAGS );
        set_bit( cmd->tag, &ta->allocated );
        ta->nr_allocated++;
        dprintk(NDEBUG_TAGS,  "scsi%d: using tag %d for target %d lun %d "
                    "(now %d tags in use)\n",
-                   H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun,
+                   H_NO(cmd), cmd->tag, cmd->device->id, lun,
                    ta->nr_allocated );
     }
 }
 
 static void cmd_free_tag(struct scsi_cmnd *cmd)
 {
+    u8 lun = cmd->device->lun;
     SETUP_HOSTDATA(cmd->device->host);
 
     if (cmd->tag == TAG_NONE) {
-       hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+       hostdata->busy[cmd->device->id] &= ~(1 << lun);
        dprintk(NDEBUG_TAGS,  "scsi%d: target %d lun %d untagged cmd finished\n",
-                   H_NO(cmd), cmd->device->id, cmd->device->lun );
+                   H_NO(cmd), cmd->device->id, lun );
     }
     else if (cmd->tag >= MAX_TAGS) {
        printk(KERN_NOTICE "scsi%d: trying to free bad tag %d!\n",
                H_NO(cmd), cmd->tag );
     }
     else {
-       TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
+       TAG_ALLOC *ta = &TagAlloc[cmd->device->id][lun];
        clear_bit( cmd->tag, &ta->allocated );
        ta->nr_allocated--;
        dprintk(NDEBUG_TAGS,  "scsi%d: freed tag %d for target %d lun %d\n",
-                   H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun );
+                   H_NO(cmd), cmd->tag, cmd->device->id, lun );
     }
 }
 
 {
        int i, s;
        unsigned char *command;
-       printk("scsi%d: destination target %d, lun %d\n",
+       printk("scsi%d: destination target %d, lun %llu\n",
                H_NO(cmd), cmd->device->id, cmd->device->lun);
        printk(KERN_CONT "        command = ");
        command = cmd->cmnd;
 {
        int i, s;
        unsigned char *command;
-       seq_printf(m, "scsi%d: destination target %d, lun %d\n",
+       seq_printf(m, "scsi%d: destination target %d, lun %llu\n",
                H_NO(cmd), cmd->device->id, cmd->device->lun);
        seq_printf(m, "        command = ");
        command = cmd->cmnd;
                 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) {
 
                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], tmp->device->lun);
+                       dprintk(NDEBUG_LISTS, "MAIN tmp=%p   target=%d   busy=%d lun=%llu\n", tmp, tmp->device->id, hostdata->busy[tmp->device->id], tmp->device->lun);
                /*  When we find one, remove it from the issue queue. */
                /* ++guenther: possible race with Falcon locking */
                if (
                     *   issue queue so we can keep trying.     
                     */
                    dprintk(NDEBUG_MAIN, "scsi%d: main(): command for target %d "
-                               "lun %d removed from issue_queue\n",
+                               "lun %llu removed from issue_queue\n",
                                HOSTNO, tmp->device->id, tmp->device->lun);
                    /* 
                     * REQUEST SENSE commands are issued without tagged
                         * accesses to this device will use the
                         * polled-IO. */ 
                        printk(KERN_NOTICE "scsi%d: switching target %d "
-                              "lun %d to slow handshake\n", HOSTNO,
+                              "lun %llu to slow handshake\n", HOSTNO,
                               cmd->device->id, cmd->device->lun);
                        cmd->device->borken = 1;
                        NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
                    /* Accept message by clearing ACK */
                    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
                    
-                   dprintk(NDEBUG_LINKED, "scsi%d: target %d lun %d linked command "
+                   dprintk(NDEBUG_LINKED, "scsi%d: target %d lun %llu linked command "
                               "complete.\n", HOSTNO, cmd->device->id, cmd->device->lun);
 
                    /* Enable reselect interrupts */
                     */
 
                    if (!cmd->next_link) {
-                        printk(KERN_NOTICE "scsi%d: target %d lun %d "
+                        printk(KERN_NOTICE "scsi%d: target %d lun %llu "
                                "linked command complete, no next_link\n",
                                HOSTNO, cmd->device->id, cmd->device->lun);
                            sink = 1;
                     * and don't free it! */
                    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 "
+                   dprintk(NDEBUG_LINKED, "scsi%d: target %d lun %llu linked request "
                               "done, calling scsi_done().\n",
                               HOSTNO, cmd->device->id, cmd->device->lun);
 #ifdef NCR5380_STATS
                    /* Accept message by clearing ACK */
                    NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
                    hostdata->connected = NULL;
-                   dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d, lun %d "
+                   dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d, lun %llu "
                              "completed\n", HOSTNO, cmd->device->id, cmd->device->lun);
 #ifdef SUPPORT_TAGS
                    cmd_free_tag( cmd );
                        /* ++Andreas: the mid level code knows about
                           QUEUE_FULL now. */
                        TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
-                       dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d returned "
+                       dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %llu returned "
                                   "QUEUE_FULL after %d commands\n",
                                   HOSTNO, cmd->device->id, cmd->device->lun,
                                   ta->nr_allocated);
                        cmd->device->tagged_supported = 0;
                        hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
                        cmd->tag = TAG_NONE;
-                       dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d rejected "
+                       dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %llu rejected "
                                   "QUEUE_TAG message; tagged queuing "
                                   "disabled\n",
                                   HOSTNO, cmd->device->id, cmd->device->lun);
                    hostdata->connected = NULL;
                    hostdata->disconnected_queue = cmd;
                    local_irq_restore(flags);
-                   dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d lun %d was "
+                   dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d lun %llu was "
                              "moved from connected to the "
                              "disconnected_queue\n", HOSTNO, 
                              cmd->device->id, cmd->device->lun);
                        printk("\n");
                    } else if (tmp != EXTENDED_MESSAGE)
                        printk(KERN_DEBUG "scsi%d: rejecting unknown "
-                              "message %02x from target %d, lun %d\n",
+                              "message %02x from target %d, lun %llu\n",
                               HOSTNO, tmp, cmd->device->id, cmd->device->lun);
                    else
                        printk(KERN_DEBUG "scsi%d: rejecting unknown "
                               "extended message "
-                              "code %02x, length %d from target %d, lun %d\n",
+                              "code %02x, length %d from target %d, lun %llu\n",
                               HOSTNO, extended_msg[1], extended_msg[0],
                               cmd->device->id, cmd->device->lun);
    
 #endif
     
     hostdata->connected = tmp;
-    dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %d, tag = %d\n",
+    dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %llu, tag = %d\n",
               HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag);
 }
 
 
                 * so let's try to stop all on-going I/O.
                 */
                starget_printk(KERN_WARNING, tp->starget,
-                              "Removing busy LCB (%d)\n", sdev->lun);
+                              "Removing busy LCB (%d)\n", (u8)sdev->lun);
                sym_reset_scsi_bus(np, 1);
        }
 
 
 #define sym_lp(tp, lun) (!lun) ? (tp)->lun0p : NULL
 #else
 #define sym_lp(tp, lun) \
-       (!lun) ? (tp)->lun0p : (tp)->lunmp ? (tp)->lunmp[(lun)] : NULL
+       (!lun) ? (tp)->lun0p : (tp)->lunmp ? (tp)->lunmp[((u8)lun)] : NULL
 #endif
 
 /*
 
     {
        dc390_freetag (pDCB, pSRB);
        DEBUG0(printk ("DC390: Interrupt during Start SCSI (target %02i-%02i)\n",
-               scmd->device->id, scmd->device->lun));
+                      scmd->device->id, (u8)scmd->device->lun));
        pSRB->SRBState = SRB_READY;
        //DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
        pACB->SelLost++;
            } 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, (u8)pcmd->device->lun));
                pSRB->TotalXferredLen = 0;
                SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
            }
        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, (u8)pcmd->device->lun));
            pSRB->TotalXferredLen = 0;
            SET_RES_DID(pcmd->result, DID_SOFT_ERROR);
        }
 
    cpp->cpp_index = i;
    SCpnt->host_scribble = (unsigned char *) &cpp->cpp_index;
 
-   if (do_trace) printk("%s: qcomm, mbox %d, target %d.%d:%d.\n",
+   if (do_trace) printk("%s: qcomm, mbox %d, target %d.%d:%llu.\n",
                         BN(j), i, SCpnt->device->channel, SCpnt->device->id,
-                        SCpnt->device->lun);
+                        (u8)SCpnt->device->lun);
 
    cpp->opcode = OP_SCSI;
    cpp->channel = SCpnt->device->channel;
    cpp->target = SCpnt->device->id;
-   cpp->lun = SCpnt->device->lun;
+   cpp->lun = (u8)SCpnt->device->lun;
    cpp->SCpnt = SCpnt;
    cpp->cdb_len = SCpnt->cmd_len;
    memcpy(cpp->cdb, SCpnt->cmnd, SCpnt->cmd_len);
    if (link_statistics && (overlap || !(flushcount % link_statistics)))
       for (n = 0; n < n_ready; n++) {
          k = il[n]; cpp = &HD(j)->cp[k]; SCpnt = cpp->SCpnt;
-         printk("%s %d.%d:%d mb %d fc %d nr %d sec %ld ns %u"\
+         printk("%s %d.%d:%llu 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,
+                (u8)SCpnt->lun, 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);
 
        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 << (cmd->device->lun & 0xff))))
                        break;
                prev = cmd;
                cmd = (struct scsi_cmnd *) cmd->host_scribble;
 
        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, (u8)cmd->device->lun);
        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 << (cmd->device->lun & 0xFF));
 
        if ((hostdata->level2 == L2_NONE) ||
            (hostdata->sync_stat[cmd->device->id] == SS_UNSET)) {
                }
 
                cmd->result = DID_NO_CONNECT << 16;
-               hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+               hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
                hostdata->state = S_UNCONNECTED;
                cmd->scsi_done(cmd);
 
 
                /* construct an IDENTIFY message with correct disconnect bit */
 
-               hostdata->outgoing_msg[0] = (0x80 | 0x00 | cmd->device->lun);
+               hostdata->outgoing_msg[0] = IDENTIFY(0, cmd->device->lun);
                if (cmd->SCp.phase)
                        hostdata->outgoing_msg[0] |= 0x40;
 
                        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 << (cmd->device->lun & 0xff));
                        hostdata->state = S_UNCONNECTED;
                        if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE)
                                cmd->SCp.Status = lun;
                }
                DB(DB_INTR, printk("UNEXP_DISC"))
                    hostdata->connected = NULL;
-               hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
+               hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
                hostdata->state = S_UNCONNECTED;
                if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != GOOD)
                        cmd->result =
                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 << (cmd->device->lun & 0xff));
                        hostdata->state = S_UNCONNECTED;
                        DB(DB_INTR, printk(":%d", cmd->SCp.Status))
                            if (cmd->cmnd[0] == REQUEST_SENSE
                        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 << (cmd->device->lun & 0xff));
                                cmd->host_scribble =
                                    (uchar *) hostdata->input_Q;
                                hostdata->input_Q = cmd;
                        if (cmd) {
                                if (phs == 0x00) {
                                        hostdata->busy[cmd->device->id] &=
-                                           ~(1 << cmd->device->lun);
+                                               ~(1 << (cmd->device->lun & 0xff));
                                        cmd->host_scribble =
                                            (uchar *) hostdata->input_Q;
                                        hostdata->input_Q = cmd;
                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 == (u8)cmd->device->lun)
                                break;
                        patch = cmd;
                        cmd = (struct scsi_cmnd *) cmd->host_scribble;
                if (!cmd) {
                        printk
                            ("---TROUBLE: target %d.%d not in disconnect queue---",
-                            id, lun);
+                            id, (u8)lun);
                        spin_unlock_irqrestore(&hostdata->lock, flags);
                        return;
                }
                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 << (cmd->device->lun & 0xff));
                hostdata->connected = NULL;
                hostdata->state = S_UNCONNECTED;
                cmd->result = DID_ABORT << 16;
                seq_printf(m, "\nconnected:     ");
                if (hd->connected) {
                        cmd = (struct scsi_cmnd *) hd->connected;
-                       seq_printf(m, " %d:%d(%02x)",
+                       seq_printf(m, " %d:%llu(%02x)",
                                cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
                }
        }
                seq_printf(m, "\ninput_Q:       ");
                cmd = (struct scsi_cmnd *) hd->input_Q;
                while (cmd) {
-                       seq_printf(m, " %d:%d(%02x)",
+                       seq_printf(m, " %d:%llu(%02x)",
                                cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
                        cmd = (struct scsi_cmnd *) cmd->host_scribble;
                }
                seq_printf(m, "\ndisconnected_Q:");
                cmd = (struct scsi_cmnd *) hd->disconnected_Q;
                while (cmd) {
-                       seq_printf(m, " %d:%d(%02x)",
+                       seq_printf(m, " %d:%llu(%02x)",
                                cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
                        cmd = (struct scsi_cmnd *) cmd->host_scribble;
                }
 
                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);
+                               (u8)chip->srb->device->lun);
                        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);
+                               (u8)chip->srb->device->lun);
                        chip->srb->result = DID_BAD_TARGET << 16;
                }
 
 
 {
        struct tcm_loop_cmd *tl_cmd;
 
-       pr_debug("tcm_loop_queuecommand() %d:%d:%d:%d got CDB: 0x%02x"
+       pr_debug("tcm_loop_queuecommand() %d:%d:%d:%llu got CDB: 0x%02x"
                " scsi_buf_len: %u\n", sc->device->host->host_no,
                sc->device->id, sc->device->channel, sc->device->lun,
                sc->cmnd[0], scsi_bufflen(sc));
 
        if (!sd->queue_depth) {
                sd->queue_depth = PSCSI_DEFAULT_QUEUEDEPTH;
 
-               pr_err("Set broken SCSI Device %d:%d:%d"
+               pr_err("Set broken SCSI Device %d:%d:%llu"
                        " queue_depth to %d\n", sd->channel, sd->id,
                                sd->lun, sd->queue_depth);
        }
        int ret;
 
        if (scsi_device_get(sd)) {
-               pr_err("scsi_device_get() failed for %d:%d:%d:%d\n",
+               pr_err("scsi_device_get() failed for %d:%d:%d:%llu\n",
                        sh->host_no, sd->channel, sd->id, sd->lun);
                spin_unlock_irq(sh->host_lock);
                return -EIO;
                return ret;
        }
 
-       pr_debug("CORE_PSCSI[%d] - Added TYPE_DISK for %d:%d:%d:%d\n",
+       pr_debug("CORE_PSCSI[%d] - Added TYPE_DISK for %d:%d:%d:%llu\n",
                phv->phv_host_id, sh->host_no, sd->channel, sd->id, sd->lun);
        return 0;
 }
        int ret;
 
        if (scsi_device_get(sd)) {
-               pr_err("scsi_device_get() failed for %d:%d:%d:%d\n",
+               pr_err("scsi_device_get() failed for %d:%d:%d:%llu\n",
                        sh->host_no, sd->channel, sd->id, sd->lun);
                spin_unlock_irq(sh->host_lock);
                return -EIO;
                scsi_device_put(sd);
                return ret;
        }
-       pr_debug("CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%d\n",
+       pr_debug("CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%llu\n",
                phv->phv_host_id, scsi_device_type(sd->type), sh->host_no,
                sd->channel, sd->id, sd->lun);
 
        if (ret)
                return ret;
 
-       pr_debug("CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%d\n",
+       pr_debug("CORE_PSCSI[%d] - Added Type: %s for %d:%d:%d:%llu\n",
                phv->phv_host_id, scsi_device_type(sd->type), sh->host_no,
                sd->channel, sd->id, sd->lun);
        return 0;
 
 {
        int ret;
 
-       usb_stor_dbg(us, "LUN=%d\n", srb->device->lun);
+       usb_stor_dbg(us, "LUN=%d\n", (u8)srb->device->lun);
 
        switch (srb->device->lun) {
        case 0:
                break;
 
        default:
-               usb_stor_dbg(us, "Invalid LUN %d\n", srb->device->lun);
+           usb_stor_dbg(us, "Invalid LUN %d\n", (u8)srb->device->lun);
                ret = USB_STOR_TRANSPORT_ERROR;
                break;
        }
 
                 */
                else if (us->srb->device->id &&
                                !(us->fflags & US_FL_SCM_MULT_TARG)) {
-                       usb_stor_dbg(us, "Bad target number (%d:%d)\n",
-                                    us->srb->device->id, us->srb->device->lun);
+                       usb_stor_dbg(us, "Bad target number (%d:%llu)\n",
+                                    us->srb->device->id,
+                                    us->srb->device->lun);
                        us->srb->result = DID_BAD_TARGET << 16;
                }
 
                else if (us->srb->device->lun > us->max_lun) {
-                       usb_stor_dbg(us, "Bad LUN (%d:%d)\n",
-                                    us->srb->device->id, us->srb->device->lun);
+                       usb_stor_dbg(us, "Bad LUN (%d:%llu)\n",
+                                    us->srb->device->id,
+                                    us->srb->device->lun);
                        us->srb->result = DID_BAD_TARGET << 16;
                }
 
 
 #define SCSI_W_LUN_ACCESS_CONTROL (SCSI_W_LUN_BASE + 2)
 #define SCSI_W_LUN_TARGET_LOG_PAGE (SCSI_W_LUN_BASE + 3)
 
-static inline int scsi_is_wlun(unsigned int lun)
+static inline int scsi_is_wlun(u64 lun)
 {
        return (lun & 0xff00) == SCSI_W_LUN_BASE;
 }
 
 
        unsigned long last_queue_ramp_up;       /* last queue ramp up time */
 
-       unsigned int id, lun, channel;
-
+       unsigned int id, channel;
+       u64 lun;
        unsigned int manufacturer;      /* Manufacturer of device, for using 
                                         * vendor-specific cmd's */
        unsigned sector_size;   /* size in bytes */
        dev_printk(prefix, &(starget)->dev, fmt, ##a)
 
 extern struct scsi_device *__scsi_add_device(struct Scsi_Host *,
-               uint, uint, uint, void *hostdata);
+               uint, uint, u64, void *hostdata);
 extern int scsi_add_device(struct Scsi_Host *host, uint channel,
-                          uint target, uint lun);
+                          uint target, u64 lun);
 extern int scsi_register_device_handler(struct scsi_device_handler *scsi_dh);
 extern void scsi_remove_device(struct scsi_device *);
 extern int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh);
 extern int scsi_device_get(struct scsi_device *);
 extern void scsi_device_put(struct scsi_device *);
 extern struct scsi_device *scsi_device_lookup(struct Scsi_Host *,
-                                             uint, uint, uint);
+                                             uint, uint, u64);
 extern struct scsi_device *__scsi_device_lookup(struct Scsi_Host *,
-                                               uint, uint, uint);
+                                               uint, uint, u64);
 extern struct scsi_device *scsi_device_lookup_by_target(struct scsi_target *,
-                                                       uint);
+                                                       u64);
 extern struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *,
-                                                         uint);
+                                                         u64);
 extern void starget_for_each_device(struct scsi_target *, void *,
                     void (*fn)(struct scsi_device *, void *));
 extern void __starget_for_each_device(struct scsi_target *, void *,
 extern void scsi_target_quiesce(struct scsi_target *);
 extern void scsi_target_resume(struct scsi_target *);
 extern void scsi_scan_target(struct device *parent, unsigned int channel,
-                            unsigned int id, unsigned int lun, int rescan);
+                            unsigned int id, u64 lun, int rescan);
 extern void scsi_target_reap(struct scsi_target *);
 extern void scsi_target_block(struct device *);
 extern void scsi_target_unblock(struct device *, enum scsi_device_state);
 extern void scsi_remove_target(struct device *);
-extern void int_to_scsilun(unsigned int, struct scsi_lun *);
-extern int scsilun_to_int(struct scsi_lun *);
+extern void int_to_scsilun(u64, struct scsi_lun *);
+extern u64 scsilun_to_int(struct scsi_lun *);
 extern const char *scsi_device_state_name(enum scsi_device_state);
 extern int scsi_is_sdev_device(const struct device *);
 extern int scsi_is_target_device(const struct device *);
 
        /*
         * If set, called from sysfs and legacy procfs rescanning code.
         */
-       int (*user_scan)(struct Scsi_Host *, uint, uint, uint);
+       int (*user_scan)(struct Scsi_Host *, uint, uint, u64);
 
        /* The size of the specific transport attribute structure (a
         * space of this size will be left at the end of the