]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/scsi/scsi_debug.c
[SCSI] Handle disk devices which can not process medium access commands
[mirror_ubuntu-zesty-kernel.git] / drivers / scsi / scsi_debug.c
index 6888b2ca5bfcdaa470dd7c44219f2507247f46f9..8917154d96c7b39f447077f938b358eb075afcf3 100644 (file)
@@ -126,6 +126,7 @@ static const char * scsi_debug_version_date = "20100324";
 #define SCSI_DEBUG_OPT_TRANSPORT_ERR   16
 #define SCSI_DEBUG_OPT_DIF_ERR   32
 #define SCSI_DEBUG_OPT_DIX_ERR   64
+#define SCSI_DEBUG_OPT_MAC_TIMEOUT  128
 /* 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
@@ -2220,7 +2221,7 @@ static int resp_get_lba_status(struct scsi_cmnd * scmd,
        mapped = map_state(lba, &num);
 
        memset(arr, 0, SDEBUG_GET_LBA_STATUS_LEN);
-       put_unaligned_be32(16, &arr[0]);        /* Parameter Data Length */
+       put_unaligned_be32(20, &arr[0]);        /* Parameter Data Length */
        put_unaligned_be64(lba, &arr[8]);       /* LBA */
        put_unaligned_be32(num, &arr[16]);      /* Number of blocks */
        arr[20] = !mapped;                      /* mapped = 0, unmapped = 1 */
@@ -3615,6 +3616,9 @@ int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done)
                        scsi_debug_every_nth = -1;
                if (SCSI_DEBUG_OPT_TIMEOUT & scsi_debug_opts)
                        return 0; /* ignore command causing timeout */
+               else if (SCSI_DEBUG_OPT_MAC_TIMEOUT & scsi_debug_opts &&
+                        scsi_medium_access_command(SCpnt))
+                       return 0; /* time out reads and writes */
                else if (SCSI_DEBUG_OPT_RECOVERED_ERR & scsi_debug_opts)
                        inj_recovered = 1; /* to reads and writes below */
                else if (SCSI_DEBUG_OPT_TRANSPORT_ERR & scsi_debug_opts)