]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/scsi/scsi_debug.c
scsi: use 64-bit value for 'max_luns'
[mirror_ubuntu-bionic-kernel.git] / drivers / scsi / scsi_debug.c
index f3e9cc038d1d9126dadddb686b356b43c43ba1c5..6ed43fd19a22a5f01e21996d02c2939ab737161e 100644 (file)
@@ -130,6 +130,7 @@ static const char * scsi_debug_version_date = "20100324";
 #define SCSI_DEBUG_OPT_DIF_ERR   32
 #define SCSI_DEBUG_OPT_DIX_ERR   64
 #define SCSI_DEBUG_OPT_MAC_TIMEOUT  128
+#define SCSI_DEBUG_OPT_SHORT_TRANSFER  256
 /* When "every_nth" > 0 then modulo "every_nth" commands:
  *   - a no response is simulated if SCSI_DEBUG_OPT_TIMEOUT is set
  *   - a RECOVERED_ERROR is simulated on successful read and write
@@ -227,9 +228,9 @@ struct sdebug_dev_info {
        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;
@@ -2277,7 +2278,8 @@ static int resp_report_luns(struct scsi_cmnd * scp,
                            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;
@@ -2461,7 +2463,7 @@ static struct sdebug_dev_info * devInfoReg(struct scsi_device * sdev)
 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;
@@ -2472,7 +2474,7 @@ static int scsi_debug_slave_configure(struct scsi_device *sdp)
        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;
@@ -2483,7 +2485,7 @@ static int scsi_debug_slave_configure(struct scsi_device *sdp)
        if (sdp->host->cmd_per_lun)
                scsi_adjust_queue_depth(sdp, SDEBUG_TAGGED_QUEUING,
                                        sdp->host->cmd_per_lun);
-       blk_queue_max_segment_size(sdp->request_queue, 256 * 1024);
+       blk_queue_max_segment_size(sdp->request_queue, -1U);
        if (scsi_debug_no_uld)
                sdp->no_uld_attach = 1;
        return 0;
@@ -2495,7 +2497,7 @@ static void scsi_debug_slave_destroy(struct scsi_device *sdp)
                (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 */
@@ -2707,7 +2709,7 @@ static int schedule_resp(struct scsi_cmnd * cmnd,
                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);
                }
@@ -3583,6 +3585,7 @@ int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done)
        int inj_transport = 0;
        int inj_dif = 0;
        int inj_dix = 0;
+       int inj_short = 0;
        int delay_override = 0;
        int unmap = 0;
 
@@ -3628,6 +3631,8 @@ int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done)
                        inj_dif = 1; /* to reads and writes below */
                else if (SCSI_DEBUG_OPT_DIX_ERR & scsi_debug_opts)
                        inj_dix = 1; /* to reads and writes below */
+               else if (SCSI_DEBUG_OPT_SHORT_TRANSFER & scsi_debug_opts)
+                       inj_short = 1;
        }
 
        if (devip->wlun) {
@@ -3744,6 +3749,10 @@ read:
                if (scsi_debug_fake_rw)
                        break;
                get_data_transfer_info(cmd, &lba, &num, &ei_lba);
+
+               if (inj_short)
+                       num /= 2;
+
                errsts = resp_read(SCpnt, lba, num, devip, ei_lba);
                if (inj_recovered && (0 == errsts)) {
                        mk_sense_buffer(devip, RECOVERED_ERROR,
@@ -3938,9 +3947,9 @@ static struct scsi_host_template sdebug_driver_template = {
        .bios_param =           scsi_debug_biosparam,
        .can_queue =            SCSI_DEBUG_CANQUEUE,
        .this_id =              7,
-       .sg_tablesize =         256,
+       .sg_tablesize =         SCSI_MAX_SG_CHAIN_SEGMENTS,
        .cmd_per_lun =          16,
-       .max_sectors =          0xffff,
+       .max_sectors =          -1U,
        .use_clustering =       DISABLE_CLUSTERING,
        .module =               THIS_MODULE,
 };