diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-17 20:54:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-17 20:54:40 -0400 |
commit | c55d267de274d308927b60c3e740c1a826832317 (patch) | |
tree | 21b53a8c725d9f9650f60d94b349459d5b8dae10 /drivers/scsi/scsi_debug.c | |
parent | 61ef46fd45c3c62dc7c880a45dd2aa841b9af8fb (diff) | |
parent | bc898c97f7ba24def788d9f80786cf028a197122 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (170 commits)
[SCSI] scsi_dh_rdac: Add MD36xxf into device list
[SCSI] scsi_debug: add consecutive medium errors
[SCSI] libsas: fix ata list corruption issue
[SCSI] hpsa: export resettable host attribute
[SCSI] hpsa: move device attributes to avoid forward declarations
[SCSI] scsi_debug: Logical Block Provisioning (SBC3r26)
[SCSI] sd: Logical Block Provisioning update
[SCSI] Include protection operation in SCSI command trace
[SCSI] hpsa: fix incorrect PCI IDs and add two new ones (2nd try)
[SCSI] target: Fix volume size misreporting for volumes > 2TB
[SCSI] bnx2fc: Broadcom FCoE offload driver
[SCSI] fcoe: fix broken fcoe interface reset
[SCSI] fcoe: precedence bug in fcoe_filter_frames()
[SCSI] libfcoe: Remove stale fcoe-netdev entries
[SCSI] libfcoe: Move FCOE_MTU definition from fcoe.h to libfcoe.h
[SCSI] libfc: introduce __fc_fill_fc_hdr that accepts fc_hdr as an argument
[SCSI] fcoe, libfc: initialize EM anchors list and then update npiv EMs
[SCSI] Revert "[SCSI] libfc: fix exchange being deleted when the abort itself is timed out"
[SCSI] libfc: Fixing a memory leak when destroying an interface
[SCSI] megaraid_sas: Version and Changelog update
...
Fix up trivial conflicts due to whitespace differences in
drivers/scsi/libsas/{sas_ata.c,sas_scsi_host.c}
Diffstat (limited to 'drivers/scsi/scsi_debug.c')
-rw-r--r-- | drivers/scsi/scsi_debug.c | 192 |
1 files changed, 110 insertions, 82 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index a6b2d72022fc..fa5758cbdedb 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 |
@@ -144,6 +146,7 @@ static const char * scsi_debug_version_date = "20100324"; | |||
144 | /* when 1==SCSI_DEBUG_OPT_MEDIUM_ERR, a medium error is simulated at this | 146 | /* when 1==SCSI_DEBUG_OPT_MEDIUM_ERR, a medium error is simulated at this |
145 | * sector on read commands: */ | 147 | * sector on read commands: */ |
146 | #define OPT_MEDIUM_ERR_ADDR 0x1234 /* that's sector 4660 in decimal */ | 148 | #define OPT_MEDIUM_ERR_ADDR 0x1234 /* that's sector 4660 in decimal */ |
149 | #define OPT_MEDIUM_ERR_NUM 10 /* number of consecutive medium errs */ | ||
147 | 150 | ||
148 | /* If REPORT LUNS has luns >= 256 it can choose "flat space" (value 1) | 151 | /* If REPORT LUNS has luns >= 256 it can choose "flat space" (value 1) |
149 | * or "peripheral device" addressing (value 0) */ | 152 | * or "peripheral device" addressing (value 0) */ |
@@ -155,36 +158,38 @@ static const char * scsi_debug_version_date = "20100324"; | |||
155 | #define SCSI_DEBUG_CANQUEUE 255 | 158 | #define SCSI_DEBUG_CANQUEUE 255 |
156 | 159 | ||
157 | static int scsi_debug_add_host = DEF_NUM_HOST; | 160 | static int scsi_debug_add_host = DEF_NUM_HOST; |
161 | static int scsi_debug_ato = DEF_ATO; | ||
158 | static int scsi_debug_delay = DEF_DELAY; | 162 | static int scsi_debug_delay = DEF_DELAY; |
159 | static int scsi_debug_dev_size_mb = DEF_DEV_SIZE_MB; | 163 | static int scsi_debug_dev_size_mb = DEF_DEV_SIZE_MB; |
164 | static int scsi_debug_dif = DEF_DIF; | ||
165 | static int scsi_debug_dix = DEF_DIX; | ||
166 | static int scsi_debug_dsense = DEF_D_SENSE; | ||
160 | static int scsi_debug_every_nth = DEF_EVERY_NTH; | 167 | static int scsi_debug_every_nth = DEF_EVERY_NTH; |
168 | static int scsi_debug_fake_rw = DEF_FAKE_RW; | ||
169 | static int scsi_debug_guard = DEF_GUARD; | ||
170 | static int scsi_debug_lowest_aligned = DEF_LOWEST_ALIGNED; | ||
161 | static int scsi_debug_max_luns = DEF_MAX_LUNS; | 171 | static int scsi_debug_max_luns = DEF_MAX_LUNS; |
162 | static int scsi_debug_max_queue = SCSI_DEBUG_CANQUEUE; | 172 | static int scsi_debug_max_queue = SCSI_DEBUG_CANQUEUE; |
163 | static int scsi_debug_num_parts = DEF_NUM_PARTS; | 173 | static int scsi_debug_no_lun_0 = DEF_NO_LUN_0; |
164 | static int scsi_debug_no_uld = 0; | 174 | static int scsi_debug_no_uld = 0; |
175 | static int scsi_debug_num_parts = DEF_NUM_PARTS; | ||
165 | static int scsi_debug_num_tgts = DEF_NUM_TGTS; /* targets per host */ | 176 | static int scsi_debug_num_tgts = DEF_NUM_TGTS; /* targets per host */ |
177 | static int scsi_debug_opt_blks = DEF_OPT_BLKS; | ||
166 | static int scsi_debug_opts = DEF_OPTS; | 178 | static int scsi_debug_opts = DEF_OPTS; |
167 | static int scsi_debug_scsi_level = DEF_SCSI_LEVEL; | 179 | static int scsi_debug_physblk_exp = DEF_PHYSBLK_EXP; |
168 | static int scsi_debug_ptype = DEF_PTYPE; /* SCSI peripheral type (0==disk) */ | 180 | static int scsi_debug_ptype = DEF_PTYPE; /* SCSI peripheral type (0==disk) */ |
169 | static int scsi_debug_dsense = DEF_D_SENSE; | 181 | static int scsi_debug_scsi_level = DEF_SCSI_LEVEL; |
170 | static int scsi_debug_no_lun_0 = DEF_NO_LUN_0; | 182 | static int scsi_debug_sector_size = DEF_SECTOR_SIZE; |
171 | static int scsi_debug_virtual_gb = DEF_VIRTUAL_GB; | 183 | 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; | 184 | static int scsi_debug_vpd_use_hostno = DEF_VPD_USE_HOSTNO; |
174 | static int scsi_debug_sector_size = DEF_SECTOR_SIZE; | 185 | static unsigned int scsi_debug_lbpu = DEF_LBPU; |
175 | static int scsi_debug_dix = DEF_DIX; | 186 | static unsigned int scsi_debug_lbpws = DEF_LBPWS; |
176 | static int scsi_debug_dif = DEF_DIF; | 187 | 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; | 188 | static unsigned int scsi_debug_unmap_alignment = DEF_UNMAP_ALIGNMENT; |
186 | static unsigned int scsi_debug_tpws = DEF_TPWS; | 189 | static unsigned int scsi_debug_unmap_granularity = DEF_UNMAP_GRANULARITY; |
187 | static unsigned int scsi_debug_tpu = DEF_TPU; | 190 | static unsigned int scsi_debug_unmap_max_blocks = DEF_UNMAP_MAX_BLOCKS; |
191 | static unsigned int scsi_debug_unmap_max_desc = DEF_UNMAP_MAX_DESC; | ||
192 | static unsigned int scsi_debug_write_same_length = DEF_WRITESAME_LENGTH; | ||
188 | 193 | ||
189 | static int scsi_debug_cmnd_count = 0; | 194 | static int scsi_debug_cmnd_count = 0; |
190 | 195 | ||
@@ -206,6 +211,11 @@ static int sdebug_sectors_per; /* sectors per cylinder */ | |||
206 | 211 | ||
207 | #define SCSI_DEBUG_MAX_CMD_LEN 32 | 212 | #define SCSI_DEBUG_MAX_CMD_LEN 32 |
208 | 213 | ||
214 | static unsigned int scsi_debug_lbp(void) | ||
215 | { | ||
216 | return scsi_debug_lbpu | scsi_debug_lbpws | scsi_debug_lbpws10; | ||
217 | } | ||
218 | |||
209 | struct sdebug_dev_info { | 219 | struct sdebug_dev_info { |
210 | struct list_head dev_list; | 220 | struct list_head dev_list; |
211 | unsigned char sense_buff[SDEBUG_SENSE_LEN]; /* weak nexus */ | 221 | unsigned char sense_buff[SDEBUG_SENSE_LEN]; /* weak nexus */ |
@@ -727,7 +737,7 @@ static int inquiry_evpd_b0(unsigned char * arr) | |||
727 | /* Optimal Transfer Length */ | 737 | /* Optimal Transfer Length */ |
728 | put_unaligned_be32(scsi_debug_opt_blks, &arr[8]); | 738 | put_unaligned_be32(scsi_debug_opt_blks, &arr[8]); |
729 | 739 | ||
730 | if (scsi_debug_tpu) { | 740 | if (scsi_debug_lbpu) { |
731 | /* Maximum Unmap LBA Count */ | 741 | /* Maximum Unmap LBA Count */ |
732 | put_unaligned_be32(scsi_debug_unmap_max_blocks, &arr[16]); | 742 | put_unaligned_be32(scsi_debug_unmap_max_blocks, &arr[16]); |
733 | 743 | ||
@@ -744,7 +754,10 @@ static int inquiry_evpd_b0(unsigned char * arr) | |||
744 | /* Optimal Unmap Granularity */ | 754 | /* Optimal Unmap Granularity */ |
745 | put_unaligned_be32(scsi_debug_unmap_granularity, &arr[24]); | 755 | put_unaligned_be32(scsi_debug_unmap_granularity, &arr[24]); |
746 | 756 | ||
747 | return 0x3c; /* Mandatory page length for thin provisioning */ | 757 | /* Maximum WRITE SAME Length */ |
758 | put_unaligned_be64(scsi_debug_write_same_length, &arr[32]); | ||
759 | |||
760 | return 0x3c; /* Mandatory page length for Logical Block Provisioning */ | ||
748 | 761 | ||
749 | return sizeof(vpdb0_data); | 762 | return sizeof(vpdb0_data); |
750 | } | 763 | } |
@@ -767,12 +780,15 @@ static int inquiry_evpd_b2(unsigned char *arr) | |||
767 | memset(arr, 0, 0x8); | 780 | memset(arr, 0, 0x8); |
768 | arr[0] = 0; /* threshold exponent */ | 781 | arr[0] = 0; /* threshold exponent */ |
769 | 782 | ||
770 | if (scsi_debug_tpu) | 783 | if (scsi_debug_lbpu) |
771 | arr[1] = 1 << 7; | 784 | arr[1] = 1 << 7; |
772 | 785 | ||
773 | if (scsi_debug_tpws) | 786 | if (scsi_debug_lbpws) |
774 | arr[1] |= 1 << 6; | 787 | arr[1] |= 1 << 6; |
775 | 788 | ||
789 | if (scsi_debug_lbpws10) | ||
790 | arr[1] |= 1 << 5; | ||
791 | |||
776 | return 0x8; | 792 | return 0x8; |
777 | } | 793 | } |
778 | 794 | ||
@@ -831,7 +847,8 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target, | |||
831 | arr[n++] = 0x89; /* ATA information */ | 847 | arr[n++] = 0x89; /* ATA information */ |
832 | arr[n++] = 0xb0; /* Block limits (SBC) */ | 848 | arr[n++] = 0xb0; /* Block limits (SBC) */ |
833 | arr[n++] = 0xb1; /* Block characteristics (SBC) */ | 849 | arr[n++] = 0xb1; /* Block characteristics (SBC) */ |
834 | arr[n++] = 0xb2; /* Thin provisioning (SBC) */ | 850 | if (scsi_debug_lbp()) /* Logical Block Prov. (SBC) */ |
851 | arr[n++] = 0xb2; | ||
835 | arr[3] = n - 4; /* number of supported VPD pages */ | 852 | arr[3] = n - 4; /* number of supported VPD pages */ |
836 | } else if (0x80 == cmd[2]) { /* unit serial number */ | 853 | } else if (0x80 == cmd[2]) { /* unit serial number */ |
837 | arr[1] = cmd[2]; /*sanity */ | 854 | arr[1] = cmd[2]; /*sanity */ |
@@ -879,7 +896,7 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target, | |||
879 | } else if (0xb1 == cmd[2]) { /* Block characteristics (SBC) */ | 896 | } else if (0xb1 == cmd[2]) { /* Block characteristics (SBC) */ |
880 | arr[1] = cmd[2]; /*sanity */ | 897 | arr[1] = cmd[2]; /*sanity */ |
881 | arr[3] = inquiry_evpd_b1(&arr[4]); | 898 | arr[3] = inquiry_evpd_b1(&arr[4]); |
882 | } else if (0xb2 == cmd[2]) { /* Thin provisioning (SBC) */ | 899 | } else if (0xb2 == cmd[2]) { /* Logical Block Prov. (SBC) */ |
883 | arr[1] = cmd[2]; /*sanity */ | 900 | arr[1] = cmd[2]; /*sanity */ |
884 | arr[3] = inquiry_evpd_b2(&arr[4]); | 901 | arr[3] = inquiry_evpd_b2(&arr[4]); |
885 | } else { | 902 | } else { |
@@ -1053,8 +1070,8 @@ static int resp_readcap16(struct scsi_cmnd * scp, | |||
1053 | arr[13] = scsi_debug_physblk_exp & 0xf; | 1070 | arr[13] = scsi_debug_physblk_exp & 0xf; |
1054 | arr[14] = (scsi_debug_lowest_aligned >> 8) & 0x3f; | 1071 | arr[14] = (scsi_debug_lowest_aligned >> 8) & 0x3f; |
1055 | 1072 | ||
1056 | if (scsi_debug_tpu || scsi_debug_tpws) | 1073 | if (scsi_debug_lbp()) |
1057 | arr[14] |= 0x80; /* TPE */ | 1074 | arr[14] |= 0x80; /* LBPME */ |
1058 | 1075 | ||
1059 | arr[15] = scsi_debug_lowest_aligned & 0xff; | 1076 | arr[15] = scsi_debug_lowest_aligned & 0xff; |
1060 | 1077 | ||
@@ -1791,15 +1808,15 @@ static int resp_read(struct scsi_cmnd *SCpnt, unsigned long long lba, | |||
1791 | return ret; | 1808 | return ret; |
1792 | 1809 | ||
1793 | if ((SCSI_DEBUG_OPT_MEDIUM_ERR & scsi_debug_opts) && | 1810 | if ((SCSI_DEBUG_OPT_MEDIUM_ERR & scsi_debug_opts) && |
1794 | (lba <= OPT_MEDIUM_ERR_ADDR) && | 1811 | (lba <= (OPT_MEDIUM_ERR_ADDR + OPT_MEDIUM_ERR_NUM - 1)) && |
1795 | ((lba + num) > OPT_MEDIUM_ERR_ADDR)) { | 1812 | ((lba + num) > OPT_MEDIUM_ERR_ADDR)) { |
1796 | /* claim unrecoverable read error */ | 1813 | /* claim unrecoverable read error */ |
1797 | mk_sense_buffer(devip, MEDIUM_ERROR, UNRECOVERED_READ_ERR, | 1814 | mk_sense_buffer(devip, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0); |
1798 | 0); | ||
1799 | /* set info field and valid bit for fixed descriptor */ | 1815 | /* set info field and valid bit for fixed descriptor */ |
1800 | if (0x70 == (devip->sense_buff[0] & 0x7f)) { | 1816 | if (0x70 == (devip->sense_buff[0] & 0x7f)) { |
1801 | devip->sense_buff[0] |= 0x80; /* Valid bit */ | 1817 | devip->sense_buff[0] |= 0x80; /* Valid bit */ |
1802 | ret = OPT_MEDIUM_ERR_ADDR; | 1818 | ret = (lba < OPT_MEDIUM_ERR_ADDR) |
1819 | ? OPT_MEDIUM_ERR_ADDR : (int)lba; | ||
1803 | devip->sense_buff[3] = (ret >> 24) & 0xff; | 1820 | devip->sense_buff[3] = (ret >> 24) & 0xff; |
1804 | devip->sense_buff[4] = (ret >> 16) & 0xff; | 1821 | devip->sense_buff[4] = (ret >> 16) & 0xff; |
1805 | devip->sense_buff[5] = (ret >> 8) & 0xff; | 1822 | devip->sense_buff[5] = (ret >> 8) & 0xff; |
@@ -2084,6 +2101,12 @@ static int resp_write_same(struct scsi_cmnd *scmd, unsigned long long lba, | |||
2084 | if (ret) | 2101 | if (ret) |
2085 | return ret; | 2102 | return ret; |
2086 | 2103 | ||
2104 | if (num > scsi_debug_write_same_length) { | ||
2105 | mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, | ||
2106 | 0); | ||
2107 | return check_condition_result; | ||
2108 | } | ||
2109 | |||
2087 | write_lock_irqsave(&atomic_rw, iflags); | 2110 | write_lock_irqsave(&atomic_rw, iflags); |
2088 | 2111 | ||
2089 | if (unmap && scsi_debug_unmap_granularity) { | 2112 | if (unmap && scsi_debug_unmap_granularity) { |
@@ -2695,37 +2718,40 @@ static int schedule_resp(struct scsi_cmnd * cmnd, | |||
2695 | /sys/bus/pseudo/drivers/scsi_debug directory is changed. | 2718 | /sys/bus/pseudo/drivers/scsi_debug directory is changed. |
2696 | */ | 2719 | */ |
2697 | module_param_named(add_host, scsi_debug_add_host, int, S_IRUGO | S_IWUSR); | 2720 | module_param_named(add_host, scsi_debug_add_host, int, S_IRUGO | S_IWUSR); |
2721 | module_param_named(ato, scsi_debug_ato, int, S_IRUGO); | ||
2698 | module_param_named(delay, scsi_debug_delay, int, S_IRUGO | S_IWUSR); | 2722 | 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); | 2723 | module_param_named(dev_size_mb, scsi_debug_dev_size_mb, int, S_IRUGO); |
2724 | module_param_named(dif, scsi_debug_dif, int, S_IRUGO); | ||
2725 | module_param_named(dix, scsi_debug_dix, int, S_IRUGO); | ||
2700 | module_param_named(dsense, scsi_debug_dsense, int, S_IRUGO | S_IWUSR); | 2726 | 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); | 2727 | 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); | 2728 | module_param_named(fake_rw, scsi_debug_fake_rw, int, S_IRUGO | S_IWUSR); |
2729 | module_param_named(guard, scsi_debug_guard, int, S_IRUGO); | ||
2730 | module_param_named(lbpu, scsi_debug_lbpu, int, S_IRUGO); | ||
2731 | module_param_named(lbpws, scsi_debug_lbpws, int, S_IRUGO); | ||
2732 | module_param_named(lbpws10, scsi_debug_lbpws10, int, S_IRUGO); | ||
2733 | 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); | 2734 | 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); | 2735 | 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); | 2736 | 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); | 2737 | 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); | 2738 | 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); | 2739 | module_param_named(num_tgts, scsi_debug_num_tgts, int, S_IRUGO | S_IWUSR); |
2740 | 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); | 2741 | module_param_named(opts, scsi_debug_opts, int, S_IRUGO | S_IWUSR); |
2742 | 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); | 2743 | 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); | 2744 | 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); | 2745 | module_param_named(sector_size, scsi_debug_sector_size, int, S_IRUGO); |
2716 | module_param_named(dix, scsi_debug_dix, int, S_IRUGO); | 2746 | module_param_named(unmap_alignment, scsi_debug_unmap_alignment, int, S_IRUGO); |
2717 | module_param_named(dif, scsi_debug_dif, int, S_IRUGO); | 2747 | 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); | 2748 | 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); | 2749 | 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); | 2750 | 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); | 2751 | module_param_named(vpd_use_hostno, scsi_debug_vpd_use_hostno, int, |
2727 | module_param_named(tpu, scsi_debug_tpu, int, S_IRUGO); | 2752 | S_IRUGO | S_IWUSR); |
2728 | module_param_named(tpws, scsi_debug_tpws, int, S_IRUGO); | 2753 | module_param_named(write_same_length, scsi_debug_write_same_length, int, |
2754 | S_IRUGO | S_IWUSR); | ||
2729 | 2755 | ||
2730 | MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); | 2756 | MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); |
2731 | MODULE_DESCRIPTION("SCSI debug adapter driver"); | 2757 | MODULE_DESCRIPTION("SCSI debug adapter driver"); |
@@ -2733,36 +2759,38 @@ MODULE_LICENSE("GPL"); | |||
2733 | MODULE_VERSION(SCSI_DEBUG_VERSION); | 2759 | MODULE_VERSION(SCSI_DEBUG_VERSION); |
2734 | 2760 | ||
2735 | MODULE_PARM_DESC(add_host, "0..127 hosts allowed(def=1)"); | 2761 | MODULE_PARM_DESC(add_host, "0..127 hosts allowed(def=1)"); |
2762 | 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)"); | 2763 | 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)"); | 2764 | MODULE_PARM_DESC(dev_size_mb, "size in MB of ram shared by devs(def=8)"); |
2765 | MODULE_PARM_DESC(dif, "data integrity field type: 0-3 (def=0)"); | ||
2766 | MODULE_PARM_DESC(dix, "data integrity extensions mask (def=0)"); | ||
2738 | MODULE_PARM_DESC(dsense, "use descriptor sense format(def=0 -> fixed)"); | 2767 | MODULE_PARM_DESC(dsense, "use descriptor sense format(def=0 -> fixed)"); |
2739 | MODULE_PARM_DESC(every_nth, "timeout every nth command(def=0)"); | 2768 | 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)"); | 2769 | MODULE_PARM_DESC(fake_rw, "fake reads/writes instead of copying (def=0)"); |
2770 | MODULE_PARM_DESC(guard, "protection checksum: 0=crc, 1=ip (def=0)"); | ||
2771 | MODULE_PARM_DESC(lbpu, "enable LBP, support UNMAP command (def=0)"); | ||
2772 | MODULE_PARM_DESC(lbpws, "enable LBP, support WRITE SAME(16) with UNMAP bit (def=0)"); | ||
2773 | MODULE_PARM_DESC(lbpws10, "enable LBP, support WRITE SAME(10) with UNMAP bit (def=0)"); | ||
2774 | 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)"); | 2775 | 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))"); | 2776 | 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)"); | 2777 | 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))"); | 2778 | 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)"); | 2779 | 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)"); | 2780 | MODULE_PARM_DESC(num_tgts, "number of targets per host to simulate(def=1)"); |
2781 | 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)"); | 2782 | MODULE_PARM_DESC(opts, "1->noise, 2->medium_err, 4->timeout, 8->recovered_err... (def=0)"); |
2783 | MODULE_PARM_DESC(physblk_exp, "physical block exponent (def=0)"); | ||
2748 | MODULE_PARM_DESC(ptype, "SCSI peripheral type(def=0[disk])"); | 2784 | MODULE_PARM_DESC(ptype, "SCSI peripheral type(def=0[disk])"); |
2749 | MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=5[SPC-3])"); | 2785 | 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)"); | 2786 | MODULE_PARM_DESC(sector_size, "logical block size in bytes (def=512)"); |
2753 | MODULE_PARM_DESC(physblk_exp, "physical block exponent (def=0)"); | 2787 | 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)"); | 2788 | 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)"); | 2789 | 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)"); | 2790 | 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)"); | 2791 | 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)"); | 2792 | 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)"); | 2793 | 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 | 2794 | ||
2767 | static char sdebug_info[256]; | 2795 | static char sdebug_info[256]; |
2768 | 2796 | ||
@@ -3150,7 +3178,7 @@ static ssize_t sdebug_map_show(struct device_driver *ddp, char *buf) | |||
3150 | { | 3178 | { |
3151 | ssize_t count; | 3179 | ssize_t count; |
3152 | 3180 | ||
3153 | if (scsi_debug_tpu == 0 && scsi_debug_tpws == 0) | 3181 | if (!scsi_debug_lbp()) |
3154 | return scnprintf(buf, PAGE_SIZE, "0-%u\n", | 3182 | return scnprintf(buf, PAGE_SIZE, "0-%u\n", |
3155 | sdebug_store_sectors); | 3183 | sdebug_store_sectors); |
3156 | 3184 | ||
@@ -3333,8 +3361,8 @@ static int __init scsi_debug_init(void) | |||
3333 | memset(dif_storep, 0xff, dif_size); | 3361 | memset(dif_storep, 0xff, dif_size); |
3334 | } | 3362 | } |
3335 | 3363 | ||
3336 | /* Thin Provisioning */ | 3364 | /* Logical Block Provisioning */ |
3337 | if (scsi_debug_tpu || scsi_debug_tpws) { | 3365 | if (scsi_debug_lbp()) { |
3338 | unsigned int map_bytes; | 3366 | unsigned int map_bytes; |
3339 | 3367 | ||
3340 | scsi_debug_unmap_max_blocks = | 3368 | scsi_debug_unmap_max_blocks = |
@@ -3664,7 +3692,7 @@ int scsi_debug_queuecommand_lck(struct scsi_cmnd *SCpnt, done_funct_t done) | |||
3664 | errsts = resp_readcap16(SCpnt, devip); | 3692 | errsts = resp_readcap16(SCpnt, devip); |
3665 | else if (cmd[1] == SAI_GET_LBA_STATUS) { | 3693 | else if (cmd[1] == SAI_GET_LBA_STATUS) { |
3666 | 3694 | ||
3667 | if (scsi_debug_tpu == 0 && scsi_debug_tpws == 0) { | 3695 | if (scsi_debug_lbp() == 0) { |
3668 | mk_sense_buffer(devip, ILLEGAL_REQUEST, | 3696 | mk_sense_buffer(devip, ILLEGAL_REQUEST, |
3669 | INVALID_COMMAND_OPCODE, 0); | 3697 | INVALID_COMMAND_OPCODE, 0); |
3670 | errsts = check_condition_result; | 3698 | errsts = check_condition_result; |
@@ -3775,8 +3803,10 @@ write: | |||
3775 | } | 3803 | } |
3776 | break; | 3804 | break; |
3777 | case WRITE_SAME_16: | 3805 | case WRITE_SAME_16: |
3806 | case WRITE_SAME: | ||
3778 | if (cmd[1] & 0x8) { | 3807 | if (cmd[1] & 0x8) { |
3779 | if (scsi_debug_tpws == 0) { | 3808 | if ((*cmd == WRITE_SAME_16 && scsi_debug_lbpws == 0) || |
3809 | (*cmd == WRITE_SAME && scsi_debug_lbpws10 == 0)) { | ||
3780 | mk_sense_buffer(devip, ILLEGAL_REQUEST, | 3810 | mk_sense_buffer(devip, ILLEGAL_REQUEST, |
3781 | INVALID_FIELD_IN_CDB, 0); | 3811 | INVALID_FIELD_IN_CDB, 0); |
3782 | errsts = check_condition_result; | 3812 | errsts = check_condition_result; |
@@ -3785,8 +3815,6 @@ write: | |||
3785 | } | 3815 | } |
3786 | if (errsts) | 3816 | if (errsts) |
3787 | break; | 3817 | break; |
3788 | /* fall through */ | ||
3789 | case WRITE_SAME: | ||
3790 | errsts = check_readiness(SCpnt, 0, devip); | 3818 | errsts = check_readiness(SCpnt, 0, devip); |
3791 | if (errsts) | 3819 | if (errsts) |
3792 | break; | 3820 | break; |
@@ -3798,7 +3826,7 @@ write: | |||
3798 | if (errsts) | 3826 | if (errsts) |
3799 | break; | 3827 | break; |
3800 | 3828 | ||
3801 | if (scsi_debug_unmap_max_desc == 0 || scsi_debug_tpu == 0) { | 3829 | if (scsi_debug_unmap_max_desc == 0 || scsi_debug_lbpu == 0) { |
3802 | mk_sense_buffer(devip, ILLEGAL_REQUEST, | 3830 | mk_sense_buffer(devip, ILLEGAL_REQUEST, |
3803 | INVALID_COMMAND_OPCODE, 0); | 3831 | INVALID_COMMAND_OPCODE, 0); |
3804 | errsts = check_condition_result; | 3832 | errsts = check_condition_result; |