diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2011-03-08 02:08:11 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2011-03-14 19:38:44 -0400 |
commit | 5b94e23292dec213e5bb0240894b597d93744e2a (patch) | |
tree | 8c08c40fc80134c4d0f062739f8f601ddbafd2d0 /drivers/scsi/scsi_debug.c | |
parent | c98a0eb0e90d1caa8a92913cd45462102cbd5eaf (diff) |
[SCSI] scsi_debug: Logical Block Provisioning (SBC3r26)
Update scsi_debug to support the Logical Block Provisioning commands and
bits as defined in SBC3r26. The old tp* parameters have been
transitioned to the new lbp* scheme found in the draft standard.
The old tpu option to enable UNMAP is now called lbpu. tpws to signal
support for WRITE SAME(16) with the UNMAP bit set is now lbpws. Support
for WRITE SAME(10) with the UNMAP bit set is also available using the
lpuws10 parameter.
Limiting the maximum number of blocks per WRITE SAME command has been
implemented and is available via the write_same_length module parameter.
As part of the renaming process the parameter lists have been sorted
alphabetically (request from Doug).
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/scsi_debug.c')
-rw-r--r-- | drivers/scsi/scsi_debug.c | 183 |
1 files changed, 105 insertions, 78 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 7b310934efed..6ba5dbb91096 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
@@ -89,32 +89,34 @@ static const char * scsi_debug_version_date = "20100324"; | |||
89 | /* With these defaults, this driver will make 1 host with 1 target | 89 | /* With these defaults, this driver will make 1 host with 1 target |
90 | * (id 0) containing 1 logical unit (lun 0). That is 1 device. | 90 | * (id 0) containing 1 logical unit (lun 0). That is 1 device. |
91 | */ | 91 | */ |
92 | #define DEF_ATO 1 | ||
92 | #define DEF_DELAY 1 | 93 | #define DEF_DELAY 1 |
93 | #define DEF_DEV_SIZE_MB 8 | 94 | #define DEF_DEV_SIZE_MB 8 |
94 | #define DEF_EVERY_NTH 0 | 95 | #define DEF_DIF 0 |
95 | #define DEF_NUM_PARTS 0 | 96 | #define DEF_DIX 0 |
96 | #define DEF_OPTS 0 | ||
97 | #define DEF_SCSI_LEVEL 5 /* INQUIRY, byte2 [5->SPC-3] */ | ||
98 | #define DEF_PTYPE 0 | ||
99 | #define DEF_D_SENSE 0 | 97 | #define DEF_D_SENSE 0 |
100 | #define DEF_NO_LUN_0 0 | 98 | #define DEF_EVERY_NTH 0 |
101 | #define DEF_VIRTUAL_GB 0 | ||
102 | #define DEF_FAKE_RW 0 | 99 | #define DEF_FAKE_RW 0 |
103 | #define DEF_VPD_USE_HOSTNO 1 | ||
104 | #define DEF_SECTOR_SIZE 512 | ||
105 | #define DEF_DIX 0 | ||
106 | #define DEF_DIF 0 | ||
107 | #define DEF_GUARD 0 | 100 | #define DEF_GUARD 0 |
108 | #define DEF_ATO 1 | 101 | #define DEF_LBPU 0 |
109 | #define DEF_PHYSBLK_EXP 0 | 102 | #define DEF_LBPWS 0 |
103 | #define DEF_LBPWS10 0 | ||
110 | #define DEF_LOWEST_ALIGNED 0 | 104 | #define DEF_LOWEST_ALIGNED 0 |
105 | #define DEF_NO_LUN_0 0 | ||
106 | #define DEF_NUM_PARTS 0 | ||
107 | #define DEF_OPTS 0 | ||
111 | #define DEF_OPT_BLKS 64 | 108 | #define DEF_OPT_BLKS 64 |
109 | #define DEF_PHYSBLK_EXP 0 | ||
110 | #define DEF_PTYPE 0 | ||
111 | #define DEF_SCSI_LEVEL 5 /* INQUIRY, byte2 [5->SPC-3] */ | ||
112 | #define DEF_SECTOR_SIZE 512 | ||
113 | #define DEF_UNMAP_ALIGNMENT 0 | ||
114 | #define DEF_UNMAP_GRANULARITY 1 | ||
112 | #define DEF_UNMAP_MAX_BLOCKS 0xFFFFFFFF | 115 | #define DEF_UNMAP_MAX_BLOCKS 0xFFFFFFFF |
113 | #define DEF_UNMAP_MAX_DESC 256 | 116 | #define DEF_UNMAP_MAX_DESC 256 |
114 | #define DEF_UNMAP_GRANULARITY 1 | 117 | #define DEF_VIRTUAL_GB 0 |
115 | #define DEF_UNMAP_ALIGNMENT 0 | 118 | #define DEF_VPD_USE_HOSTNO 1 |
116 | #define DEF_TPWS 0 | 119 | #define DEF_WRITESAME_LENGTH 0xFFFF |
117 | #define DEF_TPU 0 | ||
118 | 120 | ||
119 | /* bit mask values for scsi_debug_opts */ | 121 | /* bit mask values for scsi_debug_opts */ |
120 | #define SCSI_DEBUG_OPT_NOISE 1 | 122 | #define SCSI_DEBUG_OPT_NOISE 1 |
@@ -155,36 +157,38 @@ static const char * scsi_debug_version_date = "20100324"; | |||
155 | #define SCSI_DEBUG_CANQUEUE 255 | 157 | #define SCSI_DEBUG_CANQUEUE 255 |
156 | 158 | ||
157 | static int scsi_debug_add_host = DEF_NUM_HOST; | 159 | static int scsi_debug_add_host = DEF_NUM_HOST; |
160 | static int scsi_debug_ato = DEF_ATO; | ||
158 | static int scsi_debug_delay = DEF_DELAY; | 161 | static int scsi_debug_delay = DEF_DELAY; |
159 | static int scsi_debug_dev_size_mb = DEF_DEV_SIZE_MB; | 162 | static int scsi_debug_dev_size_mb = DEF_DEV_SIZE_MB; |
163 | static int scsi_debug_dif = DEF_DIF; | ||
164 | static int scsi_debug_dix = DEF_DIX; | ||
165 | static int scsi_debug_dsense = DEF_D_SENSE; | ||
160 | static int scsi_debug_every_nth = DEF_EVERY_NTH; | 166 | static int scsi_debug_every_nth = DEF_EVERY_NTH; |
167 | static int scsi_debug_fake_rw = DEF_FAKE_RW; | ||
168 | static int scsi_debug_guard = DEF_GUARD; | ||
169 | static int scsi_debug_lowest_aligned = DEF_LOWEST_ALIGNED; | ||
161 | static int scsi_debug_max_luns = DEF_MAX_LUNS; | 170 | static int scsi_debug_max_luns = DEF_MAX_LUNS; |
162 | static int scsi_debug_max_queue = SCSI_DEBUG_CANQUEUE; | 171 | static int scsi_debug_max_queue = SCSI_DEBUG_CANQUEUE; |
163 | static int scsi_debug_num_parts = DEF_NUM_PARTS; | 172 | static int scsi_debug_no_lun_0 = DEF_NO_LUN_0; |
164 | static int scsi_debug_no_uld = 0; | 173 | static int scsi_debug_no_uld = 0; |
174 | static int scsi_debug_num_parts = DEF_NUM_PARTS; | ||
165 | static int scsi_debug_num_tgts = DEF_NUM_TGTS; /* targets per host */ | 175 | static int scsi_debug_num_tgts = DEF_NUM_TGTS; /* targets per host */ |
176 | static int scsi_debug_opt_blks = DEF_OPT_BLKS; | ||
166 | static int scsi_debug_opts = DEF_OPTS; | 177 | static int scsi_debug_opts = DEF_OPTS; |
167 | static int scsi_debug_scsi_level = DEF_SCSI_LEVEL; | 178 | static int scsi_debug_physblk_exp = DEF_PHYSBLK_EXP; |
168 | static int scsi_debug_ptype = DEF_PTYPE; /* SCSI peripheral type (0==disk) */ | 179 | static int scsi_debug_ptype = DEF_PTYPE; /* SCSI peripheral type (0==disk) */ |
169 | static int scsi_debug_dsense = DEF_D_SENSE; | 180 | static int scsi_debug_scsi_level = DEF_SCSI_LEVEL; |
170 | static int scsi_debug_no_lun_0 = DEF_NO_LUN_0; | 181 | static int scsi_debug_sector_size = DEF_SECTOR_SIZE; |
171 | static int scsi_debug_virtual_gb = DEF_VIRTUAL_GB; | 182 | static int scsi_debug_virtual_gb = DEF_VIRTUAL_GB; |
172 | static int scsi_debug_fake_rw = DEF_FAKE_RW; | ||
173 | static int scsi_debug_vpd_use_hostno = DEF_VPD_USE_HOSTNO; | 183 | static int scsi_debug_vpd_use_hostno = DEF_VPD_USE_HOSTNO; |
174 | static int scsi_debug_sector_size = DEF_SECTOR_SIZE; | 184 | static unsigned int scsi_debug_lbpu = DEF_LBPU; |
175 | static int scsi_debug_dix = DEF_DIX; | 185 | static unsigned int scsi_debug_lbpws = DEF_LBPWS; |
176 | static int scsi_debug_dif = DEF_DIF; | 186 | static unsigned int scsi_debug_lbpws10 = DEF_LBPWS10; |
177 | static int scsi_debug_guard = DEF_GUARD; | ||
178 | static int scsi_debug_ato = DEF_ATO; | ||
179 | static int scsi_debug_physblk_exp = DEF_PHYSBLK_EXP; | ||
180 | static int scsi_debug_lowest_aligned = DEF_LOWEST_ALIGNED; | ||
181 | static int scsi_debug_opt_blks = DEF_OPT_BLKS; | ||
182 | static unsigned int scsi_debug_unmap_max_desc = DEF_UNMAP_MAX_DESC; | ||
183 | static unsigned int scsi_debug_unmap_max_blocks = DEF_UNMAP_MAX_BLOCKS; | ||
184 | static unsigned int scsi_debug_unmap_granularity = DEF_UNMAP_GRANULARITY; | ||
185 | static unsigned int scsi_debug_unmap_alignment = DEF_UNMAP_ALIGNMENT; | 187 | static unsigned int scsi_debug_unmap_alignment = DEF_UNMAP_ALIGNMENT; |
186 | static unsigned int scsi_debug_tpws = DEF_TPWS; | 188 | static unsigned int scsi_debug_unmap_granularity = DEF_UNMAP_GRANULARITY; |
187 | static unsigned int scsi_debug_tpu = DEF_TPU; | 189 | static unsigned int scsi_debug_unmap_max_blocks = DEF_UNMAP_MAX_BLOCKS; |
190 | static unsigned int scsi_debug_unmap_max_desc = DEF_UNMAP_MAX_DESC; | ||
191 | static unsigned int scsi_debug_write_same_length = DEF_WRITESAME_LENGTH; | ||
188 | 192 | ||
189 | static int scsi_debug_cmnd_count = 0; | 193 | static int scsi_debug_cmnd_count = 0; |
190 | 194 | ||
@@ -206,6 +210,11 @@ static int sdebug_sectors_per; /* sectors per cylinder */ | |||
206 | 210 | ||
207 | #define SCSI_DEBUG_MAX_CMD_LEN 32 | 211 | #define SCSI_DEBUG_MAX_CMD_LEN 32 |
208 | 212 | ||
213 | static unsigned int scsi_debug_lbp(void) | ||
214 | { | ||
215 | return scsi_debug_lbpu | scsi_debug_lbpws | scsi_debug_lbpws10; | ||
216 | } | ||
217 | |||
209 | struct sdebug_dev_info { | 218 | struct sdebug_dev_info { |
210 | struct list_head dev_list; | 219 | struct list_head dev_list; |
211 | unsigned char sense_buff[SDEBUG_SENSE_LEN]; /* weak nexus */ | 220 | unsigned char sense_buff[SDEBUG_SENSE_LEN]; /* weak nexus */ |
@@ -727,7 +736,7 @@ static int inquiry_evpd_b0(unsigned char * arr) | |||
727 | /* Optimal Transfer Length */ | 736 | /* Optimal Transfer Length */ |
728 | put_unaligned_be32(scsi_debug_opt_blks, &arr[8]); | 737 | put_unaligned_be32(scsi_debug_opt_blks, &arr[8]); |
729 | 738 | ||
730 | if (scsi_debug_tpu) { | 739 | if (scsi_debug_lbpu) { |
731 | /* Maximum Unmap LBA Count */ | 740 | /* Maximum Unmap LBA Count */ |
732 | put_unaligned_be32(scsi_debug_unmap_max_blocks, &arr[16]); | 741 | put_unaligned_be32(scsi_debug_unmap_max_blocks, &arr[16]); |
733 | 742 | ||
@@ -744,7 +753,10 @@ static int inquiry_evpd_b0(unsigned char * arr) | |||
744 | /* Optimal Unmap Granularity */ | 753 | /* Optimal Unmap Granularity */ |
745 | put_unaligned_be32(scsi_debug_unmap_granularity, &arr[24]); | 754 | put_unaligned_be32(scsi_debug_unmap_granularity, &arr[24]); |
746 | 755 | ||
747 | return 0x3c; /* Mandatory page length for thin provisioning */ | 756 | /* Maximum WRITE SAME Length */ |
757 | put_unaligned_be64(scsi_debug_write_same_length, &arr[32]); | ||
758 | |||
759 | return 0x3c; /* Mandatory page length for Logical Block Provisioning */ | ||
748 | 760 | ||
749 | return sizeof(vpdb0_data); | 761 | return sizeof(vpdb0_data); |
750 | } | 762 | } |
@@ -767,12 +779,15 @@ static int inquiry_evpd_b2(unsigned char *arr) | |||
767 | memset(arr, 0, 0x8); | 779 | memset(arr, 0, 0x8); |
768 | arr[0] = 0; /* threshold exponent */ | 780 | arr[0] = 0; /* threshold exponent */ |
769 | 781 | ||
770 | if (scsi_debug_tpu) | 782 | if (scsi_debug_lbpu) |
771 | arr[1] = 1 << 7; | 783 | arr[1] = 1 << 7; |
772 | 784 | ||
773 | if (scsi_debug_tpws) | 785 | if (scsi_debug_lbpws) |
774 | arr[1] |= 1 << 6; | 786 | arr[1] |= 1 << 6; |
775 | 787 | ||
788 | if (scsi_debug_lbpws10) | ||
789 | arr[1] |= 1 << 5; | ||
790 | |||
776 | return 0x8; | 791 | return 0x8; |
777 | } | 792 | } |
778 | 793 | ||
@@ -831,7 +846,8 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target, | |||
831 | arr[n++] = 0x89; /* ATA information */ | 846 | arr[n++] = 0x89; /* ATA information */ |
832 | arr[n++] = 0xb0; /* Block limits (SBC) */ | 847 | arr[n++] = 0xb0; /* Block limits (SBC) */ |
833 | arr[n++] = 0xb1; /* Block characteristics (SBC) */ | 848 | arr[n++] = 0xb1; /* Block characteristics (SBC) */ |
834 | arr[n++] = 0xb2; /* Thin provisioning (SBC) */ | 849 | if (scsi_debug_lbp()) /* Logical Block Prov. (SBC) */ |
850 | arr[n++] = 0xb2; | ||
835 | arr[3] = n - 4; /* number of supported VPD pages */ | 851 | arr[3] = n - 4; /* number of supported VPD pages */ |
836 | } else if (0x80 == cmd[2]) { /* unit serial number */ | 852 | } else if (0x80 == cmd[2]) { /* unit serial number */ |
837 | arr[1] = cmd[2]; /*sanity */ | 853 | arr[1] = cmd[2]; /*sanity */ |
@@ -879,7 +895,7 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target, | |||
879 | } else if (0xb1 == cmd[2]) { /* Block characteristics (SBC) */ | 895 | } else if (0xb1 == cmd[2]) { /* Block characteristics (SBC) */ |
880 | arr[1] = cmd[2]; /*sanity */ | 896 | arr[1] = cmd[2]; /*sanity */ |
881 | arr[3] = inquiry_evpd_b1(&arr[4]); | 897 | arr[3] = inquiry_evpd_b1(&arr[4]); |
882 | } else if (0xb2 == cmd[2]) { /* Thin provisioning (SBC) */ | 898 | } else if (0xb2 == cmd[2]) { /* Logical Block Prov. (SBC) */ |
883 | arr[1] = cmd[2]; /*sanity */ | 899 | arr[1] = cmd[2]; /*sanity */ |
884 | arr[3] = inquiry_evpd_b2(&arr[4]); | 900 | arr[3] = inquiry_evpd_b2(&arr[4]); |
885 | } else { | 901 | } else { |
@@ -1053,8 +1069,8 @@ static int resp_readcap16(struct scsi_cmnd * scp, | |||
1053 | arr[13] = scsi_debug_physblk_exp & 0xf; | 1069 | arr[13] = scsi_debug_physblk_exp & 0xf; |
1054 | arr[14] = (scsi_debug_lowest_aligned >> 8) & 0x3f; | 1070 | arr[14] = (scsi_debug_lowest_aligned >> 8) & 0x3f; |
1055 | 1071 | ||
1056 | if (scsi_debug_tpu || scsi_debug_tpws) | 1072 | if (scsi_debug_lbp()) |
1057 | arr[14] |= 0x80; /* TPE */ | 1073 | arr[14] |= 0x80; /* LBPME */ |
1058 | 1074 | ||
1059 | arr[15] = scsi_debug_lowest_aligned & 0xff; | 1075 | arr[15] = scsi_debug_lowest_aligned & 0xff; |
1060 | 1076 | ||
@@ -2084,6 +2100,12 @@ static int resp_write_same(struct scsi_cmnd *scmd, unsigned long long lba, | |||
2084 | if (ret) | 2100 | if (ret) |
2085 | return ret; | 2101 | return ret; |
2086 | 2102 | ||
2103 | if (num > scsi_debug_write_same_length) { | ||
2104 | mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, | ||
2105 | 0); | ||
2106 | return check_condition_result; | ||
2107 | } | ||
2108 | |||
2087 | write_lock_irqsave(&atomic_rw, iflags); | 2109 | write_lock_irqsave(&atomic_rw, iflags); |
2088 | 2110 | ||
2089 | if (unmap && scsi_debug_unmap_granularity) { | 2111 | if (unmap && scsi_debug_unmap_granularity) { |
@@ -2695,37 +2717,40 @@ static int schedule_resp(struct scsi_cmnd * cmnd, | |||
2695 | /sys/bus/pseudo/drivers/scsi_debug directory is changed. | 2717 | /sys/bus/pseudo/drivers/scsi_debug directory is changed. |
2696 | */ | 2718 | */ |
2697 | module_param_named(add_host, scsi_debug_add_host, int, S_IRUGO | S_IWUSR); | 2719 | module_param_named(add_host, scsi_debug_add_host, int, S_IRUGO | S_IWUSR); |
2720 | module_param_named(ato, scsi_debug_ato, int, S_IRUGO); | ||
2698 | module_param_named(delay, scsi_debug_delay, int, S_IRUGO | S_IWUSR); | 2721 | module_param_named(delay, scsi_debug_delay, int, S_IRUGO | S_IWUSR); |
2699 | module_param_named(dev_size_mb, scsi_debug_dev_size_mb, int, S_IRUGO); | 2722 | module_param_named(dev_size_mb, scsi_debug_dev_size_mb, int, S_IRUGO); |
2723 | module_param_named(dif, scsi_debug_dif, int, S_IRUGO); | ||
2724 | module_param_named(dix, scsi_debug_dix, int, S_IRUGO); | ||
2700 | module_param_named(dsense, scsi_debug_dsense, int, S_IRUGO | S_IWUSR); | 2725 | module_param_named(dsense, scsi_debug_dsense, int, S_IRUGO | S_IWUSR); |
2701 | module_param_named(every_nth, scsi_debug_every_nth, int, S_IRUGO | S_IWUSR); | 2726 | module_param_named(every_nth, scsi_debug_every_nth, int, S_IRUGO | S_IWUSR); |
2702 | module_param_named(fake_rw, scsi_debug_fake_rw, int, S_IRUGO | S_IWUSR); | 2727 | module_param_named(fake_rw, scsi_debug_fake_rw, int, S_IRUGO | S_IWUSR); |
2728 | module_param_named(guard, scsi_debug_guard, int, S_IRUGO); | ||
2729 | module_param_named(lbpu, scsi_debug_lbpu, int, S_IRUGO); | ||
2730 | module_param_named(lbpws, scsi_debug_lbpws, int, S_IRUGO); | ||
2731 | module_param_named(lbpws10, scsi_debug_lbpws10, int, S_IRUGO); | ||
2732 | module_param_named(lowest_aligned, scsi_debug_lowest_aligned, int, S_IRUGO); | ||
2703 | module_param_named(max_luns, scsi_debug_max_luns, int, S_IRUGO | S_IWUSR); | 2733 | module_param_named(max_luns, scsi_debug_max_luns, int, S_IRUGO | S_IWUSR); |
2704 | module_param_named(max_queue, scsi_debug_max_queue, int, S_IRUGO | S_IWUSR); | 2734 | module_param_named(max_queue, scsi_debug_max_queue, int, S_IRUGO | S_IWUSR); |
2705 | module_param_named(no_lun_0, scsi_debug_no_lun_0, int, S_IRUGO | S_IWUSR); | 2735 | module_param_named(no_lun_0, scsi_debug_no_lun_0, int, S_IRUGO | S_IWUSR); |
2706 | module_param_named(no_uld, scsi_debug_no_uld, int, S_IRUGO); | 2736 | module_param_named(no_uld, scsi_debug_no_uld, int, S_IRUGO); |
2707 | module_param_named(num_parts, scsi_debug_num_parts, int, S_IRUGO); | 2737 | module_param_named(num_parts, scsi_debug_num_parts, int, S_IRUGO); |
2708 | module_param_named(num_tgts, scsi_debug_num_tgts, int, S_IRUGO | S_IWUSR); | 2738 | module_param_named(num_tgts, scsi_debug_num_tgts, int, S_IRUGO | S_IWUSR); |
2739 | module_param_named(opt_blks, scsi_debug_opt_blks, int, S_IRUGO); | ||
2709 | module_param_named(opts, scsi_debug_opts, int, S_IRUGO | S_IWUSR); | 2740 | module_param_named(opts, scsi_debug_opts, int, S_IRUGO | S_IWUSR); |
2741 | module_param_named(physblk_exp, scsi_debug_physblk_exp, int, S_IRUGO); | ||
2710 | module_param_named(ptype, scsi_debug_ptype, int, S_IRUGO | S_IWUSR); | 2742 | module_param_named(ptype, scsi_debug_ptype, int, S_IRUGO | S_IWUSR); |
2711 | module_param_named(scsi_level, scsi_debug_scsi_level, int, S_IRUGO); | 2743 | module_param_named(scsi_level, scsi_debug_scsi_level, int, S_IRUGO); |
2712 | module_param_named(virtual_gb, scsi_debug_virtual_gb, int, S_IRUGO | S_IWUSR); | ||
2713 | module_param_named(vpd_use_hostno, scsi_debug_vpd_use_hostno, int, | ||
2714 | S_IRUGO | S_IWUSR); | ||
2715 | module_param_named(sector_size, scsi_debug_sector_size, int, S_IRUGO); | 2744 | module_param_named(sector_size, scsi_debug_sector_size, int, S_IRUGO); |
2716 | module_param_named(dix, scsi_debug_dix, int, S_IRUGO); | 2745 | module_param_named(unmap_alignment, scsi_debug_unmap_alignment, int, S_IRUGO); |
2717 | module_param_named(dif, scsi_debug_dif, int, S_IRUGO); | 2746 | module_param_named(unmap_granularity, scsi_debug_unmap_granularity, int, S_IRUGO); |
2718 | module_param_named(guard, scsi_debug_guard, int, S_IRUGO); | ||
2719 | module_param_named(ato, scsi_debug_ato, int, S_IRUGO); | ||
2720 | module_param_named(physblk_exp, scsi_debug_physblk_exp, int, S_IRUGO); | ||
2721 | module_param_named(opt_blks, scsi_debug_opt_blks, int, S_IRUGO); | ||
2722 | module_param_named(lowest_aligned, scsi_debug_lowest_aligned, int, S_IRUGO); | ||
2723 | module_param_named(unmap_max_blocks, scsi_debug_unmap_max_blocks, int, S_IRUGO); | 2747 | module_param_named(unmap_max_blocks, scsi_debug_unmap_max_blocks, int, S_IRUGO); |
2724 | module_param_named(unmap_max_desc, scsi_debug_unmap_max_desc, int, S_IRUGO); | 2748 | module_param_named(unmap_max_desc, scsi_debug_unmap_max_desc, int, S_IRUGO); |
2725 | module_param_named(unmap_granularity, scsi_debug_unmap_granularity, int, S_IRUGO); | 2749 | module_param_named(virtual_gb, scsi_debug_virtual_gb, int, S_IRUGO | S_IWUSR); |
2726 | module_param_named(unmap_alignment, scsi_debug_unmap_alignment, int, S_IRUGO); | 2750 | module_param_named(vpd_use_hostno, scsi_debug_vpd_use_hostno, int, |
2727 | module_param_named(tpu, scsi_debug_tpu, int, S_IRUGO); | 2751 | S_IRUGO | S_IWUSR); |
2728 | module_param_named(tpws, scsi_debug_tpws, int, S_IRUGO); | 2752 | module_param_named(write_same_length, scsi_debug_write_same_length, int, |
2753 | S_IRUGO | S_IWUSR); | ||
2729 | 2754 | ||
2730 | MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); | 2755 | MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); |
2731 | MODULE_DESCRIPTION("SCSI debug adapter driver"); | 2756 | MODULE_DESCRIPTION("SCSI debug adapter driver"); |
@@ -2733,36 +2758,38 @@ MODULE_LICENSE("GPL"); | |||
2733 | MODULE_VERSION(SCSI_DEBUG_VERSION); | 2758 | MODULE_VERSION(SCSI_DEBUG_VERSION); |
2734 | 2759 | ||
2735 | MODULE_PARM_DESC(add_host, "0..127 hosts allowed(def=1)"); | 2760 | MODULE_PARM_DESC(add_host, "0..127 hosts allowed(def=1)"); |
2761 | MODULE_PARM_DESC(ato, "application tag ownership: 0=disk 1=host (def=1)"); | ||
2736 | MODULE_PARM_DESC(delay, "# of jiffies to delay response(def=1)"); | 2762 | MODULE_PARM_DESC(delay, "# of jiffies to delay response(def=1)"); |
2737 | MODULE_PARM_DESC(dev_size_mb, "size in MB of ram shared by devs(def=8)"); | 2763 | MODULE_PARM_DESC(dev_size_mb, "size in MB of ram shared by devs(def=8)"); |
2764 | MODULE_PARM_DESC(dif, "data integrity field type: 0-3 (def=0)"); | ||
2765 | MODULE_PARM_DESC(dix, "data integrity extensions mask (def=0)"); | ||
2738 | MODULE_PARM_DESC(dsense, "use descriptor sense format(def=0 -> fixed)"); | 2766 | MODULE_PARM_DESC(dsense, "use descriptor sense format(def=0 -> fixed)"); |
2739 | MODULE_PARM_DESC(every_nth, "timeout every nth command(def=0)"); | 2767 | MODULE_PARM_DESC(every_nth, "timeout every nth command(def=0)"); |
2740 | MODULE_PARM_DESC(fake_rw, "fake reads/writes instead of copying (def=0)"); | 2768 | MODULE_PARM_DESC(fake_rw, "fake reads/writes instead of copying (def=0)"); |
2769 | MODULE_PARM_DESC(guard, "protection checksum: 0=crc, 1=ip (def=0)"); | ||
2770 | MODULE_PARM_DESC(lbpu, "enable LBP, support UNMAP command (def=0)"); | ||
2771 | MODULE_PARM_DESC(lbpws, "enable LBP, support WRITE SAME(16) with UNMAP bit (def=0)"); | ||
2772 | MODULE_PARM_DESC(lbpws10, "enable LBP, support WRITE SAME(10) with UNMAP bit (def=0)"); | ||
2773 | MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)"); | ||
2741 | MODULE_PARM_DESC(max_luns, "number of LUNs per target to simulate(def=1)"); | 2774 | MODULE_PARM_DESC(max_luns, "number of LUNs per target to simulate(def=1)"); |
2742 | MODULE_PARM_DESC(max_queue, "max number of queued commands (1 to 255(def))"); | 2775 | MODULE_PARM_DESC(max_queue, "max number of queued commands (1 to 255(def))"); |
2743 | MODULE_PARM_DESC(no_lun_0, "no LU number 0 (def=0 -> have lun 0)"); | 2776 | MODULE_PARM_DESC(no_lun_0, "no LU number 0 (def=0 -> have lun 0)"); |
2744 | MODULE_PARM_DESC(no_uld, "stop ULD (e.g. sd driver) attaching (def=0))"); | 2777 | MODULE_PARM_DESC(no_uld, "stop ULD (e.g. sd driver) attaching (def=0))"); |
2745 | MODULE_PARM_DESC(num_parts, "number of partitions(def=0)"); | 2778 | MODULE_PARM_DESC(num_parts, "number of partitions(def=0)"); |
2746 | MODULE_PARM_DESC(num_tgts, "number of targets per host to simulate(def=1)"); | 2779 | MODULE_PARM_DESC(num_tgts, "number of targets per host to simulate(def=1)"); |
2780 | MODULE_PARM_DESC(opt_blks, "optimal transfer length in block (def=64)"); | ||
2747 | MODULE_PARM_DESC(opts, "1->noise, 2->medium_err, 4->timeout, 8->recovered_err... (def=0)"); | 2781 | MODULE_PARM_DESC(opts, "1->noise, 2->medium_err, 4->timeout, 8->recovered_err... (def=0)"); |
2782 | MODULE_PARM_DESC(physblk_exp, "physical block exponent (def=0)"); | ||
2748 | MODULE_PARM_DESC(ptype, "SCSI peripheral type(def=0[disk])"); | 2783 | MODULE_PARM_DESC(ptype, "SCSI peripheral type(def=0[disk])"); |
2749 | MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=5[SPC-3])"); | 2784 | MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=5[SPC-3])"); |
2750 | MODULE_PARM_DESC(virtual_gb, "virtual gigabyte size (def=0 -> use dev_size_mb)"); | ||
2751 | MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique dev ids)"); | ||
2752 | MODULE_PARM_DESC(sector_size, "logical block size in bytes (def=512)"); | 2785 | MODULE_PARM_DESC(sector_size, "logical block size in bytes (def=512)"); |
2753 | MODULE_PARM_DESC(physblk_exp, "physical block exponent (def=0)"); | 2786 | MODULE_PARM_DESC(unmap_alignment, "lowest aligned thin provisioning lba (def=0)"); |
2754 | MODULE_PARM_DESC(opt_blks, "optimal transfer length in block (def=64)"); | 2787 | MODULE_PARM_DESC(unmap_granularity, "thin provisioning granularity in blocks (def=1)"); |
2755 | MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)"); | ||
2756 | MODULE_PARM_DESC(dix, "data integrity extensions mask (def=0)"); | ||
2757 | MODULE_PARM_DESC(dif, "data integrity field type: 0-3 (def=0)"); | ||
2758 | MODULE_PARM_DESC(guard, "protection checksum: 0=crc, 1=ip (def=0)"); | ||
2759 | MODULE_PARM_DESC(ato, "application tag ownership: 0=disk 1=host (def=1)"); | ||
2760 | MODULE_PARM_DESC(unmap_max_blocks, "max # of blocks can be unmapped in one cmd (def=0xffffffff)"); | 2788 | MODULE_PARM_DESC(unmap_max_blocks, "max # of blocks can be unmapped in one cmd (def=0xffffffff)"); |
2761 | MODULE_PARM_DESC(unmap_max_desc, "max # of ranges that can be unmapped in one cmd (def=256)"); | 2789 | MODULE_PARM_DESC(unmap_max_desc, "max # of ranges that can be unmapped in one cmd (def=256)"); |
2762 | MODULE_PARM_DESC(unmap_granularity, "thin provisioning granularity in blocks (def=1)"); | 2790 | MODULE_PARM_DESC(virtual_gb, "virtual gigabyte size (def=0 -> use dev_size_mb)"); |
2763 | MODULE_PARM_DESC(unmap_alignment, "lowest aligned thin provisioning lba (def=0)"); | 2791 | MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique dev ids)"); |
2764 | MODULE_PARM_DESC(tpu, "enable TP, support UNMAP command (def=0)"); | 2792 | MODULE_PARM_DESC(write_same_length, "Maximum blocks per WRITE SAME cmd (def=0xffff)"); |
2765 | MODULE_PARM_DESC(tpws, "enable TP, support WRITE SAME(16) with UNMAP bit (def=0)"); | ||
2766 | 2793 | ||
2767 | static char sdebug_info[256]; | 2794 | static char sdebug_info[256]; |
2768 | 2795 | ||
@@ -3150,7 +3177,7 @@ static ssize_t sdebug_map_show(struct device_driver *ddp, char *buf) | |||
3150 | { | 3177 | { |
3151 | ssize_t count; | 3178 | ssize_t count; |
3152 | 3179 | ||
3153 | if (scsi_debug_tpu == 0 && scsi_debug_tpws == 0) | 3180 | if (!scsi_debug_lbp()) |
3154 | return scnprintf(buf, PAGE_SIZE, "0-%u\n", | 3181 | return scnprintf(buf, PAGE_SIZE, "0-%u\n", |
3155 | sdebug_store_sectors); | 3182 | sdebug_store_sectors); |
3156 | 3183 | ||
@@ -3333,8 +3360,8 @@ static int __init scsi_debug_init(void) | |||
3333 | memset(dif_storep, 0xff, dif_size); | 3360 | memset(dif_storep, 0xff, dif_size); |
3334 | } | 3361 | } |
3335 | 3362 | ||
3336 | /* Thin Provisioning */ | 3363 | /* Logical Block Provisioning */ |
3337 | if (scsi_debug_tpu || scsi_debug_tpws) { | 3364 | if (scsi_debug_lbp()) { |
3338 | unsigned int map_bytes; | 3365 | unsigned int map_bytes; |
3339 | 3366 | ||
3340 | scsi_debug_unmap_max_blocks = | 3367 | scsi_debug_unmap_max_blocks = |
@@ -3664,7 +3691,7 @@ int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done) | |||
3664 | errsts = resp_readcap16(SCpnt, devip); | 3691 | errsts = resp_readcap16(SCpnt, devip); |
3665 | else if (cmd[1] == SAI_GET_LBA_STATUS) { | 3692 | else if (cmd[1] == SAI_GET_LBA_STATUS) { |
3666 | 3693 | ||
3667 | if (scsi_debug_tpu == 0 && scsi_debug_tpws == 0) { | 3694 | if (scsi_debug_lbp() == 0) { |
3668 | mk_sense_buffer(devip, ILLEGAL_REQUEST, | 3695 | mk_sense_buffer(devip, ILLEGAL_REQUEST, |
3669 | INVALID_COMMAND_OPCODE, 0); | 3696 | INVALID_COMMAND_OPCODE, 0); |
3670 | errsts = check_condition_result; | 3697 | errsts = check_condition_result; |
@@ -3775,8 +3802,10 @@ write: | |||
3775 | } | 3802 | } |
3776 | break; | 3803 | break; |
3777 | case WRITE_SAME_16: | 3804 | case WRITE_SAME_16: |
3805 | case WRITE_SAME: | ||
3778 | if (cmd[1] & 0x8) { | 3806 | if (cmd[1] & 0x8) { |
3779 | if (scsi_debug_tpws == 0) { | 3807 | if ((*cmd == WRITE_SAME_16 && scsi_debug_lbpws == 0) || |
3808 | (*cmd == WRITE_SAME && scsi_debug_lbpws10 == 0)) { | ||
3780 | mk_sense_buffer(devip, ILLEGAL_REQUEST, | 3809 | mk_sense_buffer(devip, ILLEGAL_REQUEST, |
3781 | INVALID_FIELD_IN_CDB, 0); | 3810 | INVALID_FIELD_IN_CDB, 0); |
3782 | errsts = check_condition_result; | 3811 | errsts = check_condition_result; |
@@ -3785,8 +3814,6 @@ write: | |||
3785 | } | 3814 | } |
3786 | if (errsts) | 3815 | if (errsts) |
3787 | break; | 3816 | break; |
3788 | /* fall through */ | ||
3789 | case WRITE_SAME: | ||
3790 | errsts = check_readiness(SCpnt, 0, devip); | 3817 | errsts = check_readiness(SCpnt, 0, devip); |
3791 | if (errsts) | 3818 | if (errsts) |
3792 | break; | 3819 | break; |
@@ -3798,7 +3825,7 @@ write: | |||
3798 | if (errsts) | 3825 | if (errsts) |
3799 | break; | 3826 | break; |
3800 | 3827 | ||
3801 | if (scsi_debug_unmap_max_desc == 0 || scsi_debug_tpu == 0) { | 3828 | if (scsi_debug_unmap_max_desc == 0 || scsi_debug_lbpu == 0) { |
3802 | mk_sense_buffer(devip, ILLEGAL_REQUEST, | 3829 | mk_sense_buffer(devip, ILLEGAL_REQUEST, |
3803 | INVALID_COMMAND_OPCODE, 0); | 3830 | INVALID_COMMAND_OPCODE, 0); |
3804 | errsts = check_condition_result; | 3831 | errsts = check_condition_result; |