aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_debug.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2012-03-08 01:03:59 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-03-27 03:26:36 -0400
commitbe1dd78de5686c062bb3103f9e86d444a10ed783 (patch)
tree38f8bc382c9594fa5c949ca2fe63b288a2736147 /drivers/scsi/scsi_debug.c
parent49d0e64b6a61acea3bcdd6b36be3972111edecc5 (diff)
[SCSI] scsi_debug: add LBPRZ support
Add LBPRZ support to scsi_debug; i.e. read zeros for unmapped blocks. Rather than checking for unmapped blocks at read time, this just zeroes them on the backing store at unmap time so it behaves the same way. This also adds a module parameter to disable it. lbprz, "unmapped blocks return 0 on read (def=1)" [jejb: fix whitespace errors] Signed-off-by: Eric Sandeen <sandeen@redhat.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/scsi_debug.c')
-rw-r--r--drivers/scsi/scsi_debug.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 8917154d96c7..e4ba924c303d 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -101,6 +101,7 @@ static const char * scsi_debug_version_date = "20100324";
101#define DEF_LBPU 0 101#define DEF_LBPU 0
102#define DEF_LBPWS 0 102#define DEF_LBPWS 0
103#define DEF_LBPWS10 0 103#define DEF_LBPWS10 0
104#define DEF_LBPRZ 1
104#define DEF_LOWEST_ALIGNED 0 105#define DEF_LOWEST_ALIGNED 0
105#define DEF_NO_LUN_0 0 106#define DEF_NO_LUN_0 0
106#define DEF_NUM_PARTS 0 107#define DEF_NUM_PARTS 0
@@ -186,6 +187,7 @@ static int scsi_debug_vpd_use_hostno = DEF_VPD_USE_HOSTNO;
186static unsigned int scsi_debug_lbpu = DEF_LBPU; 187static unsigned int scsi_debug_lbpu = DEF_LBPU;
187static unsigned int scsi_debug_lbpws = DEF_LBPWS; 188static unsigned int scsi_debug_lbpws = DEF_LBPWS;
188static unsigned int scsi_debug_lbpws10 = DEF_LBPWS10; 189static unsigned int scsi_debug_lbpws10 = DEF_LBPWS10;
190static unsigned int scsi_debug_lbprz = DEF_LBPRZ;
189static unsigned int scsi_debug_unmap_alignment = DEF_UNMAP_ALIGNMENT; 191static unsigned int scsi_debug_unmap_alignment = DEF_UNMAP_ALIGNMENT;
190static unsigned int scsi_debug_unmap_granularity = DEF_UNMAP_GRANULARITY; 192static unsigned int scsi_debug_unmap_granularity = DEF_UNMAP_GRANULARITY;
191static unsigned int scsi_debug_unmap_max_blocks = DEF_UNMAP_MAX_BLOCKS; 193static unsigned int scsi_debug_unmap_max_blocks = DEF_UNMAP_MAX_BLOCKS;
@@ -775,7 +777,7 @@ static int inquiry_evpd_b1(unsigned char *arr)
775 return 0x3c; 777 return 0x3c;
776} 778}
777 779
778/* Thin provisioning VPD page (SBC-3) */ 780/* Logical block provisioning VPD page (SBC-3) */
779static int inquiry_evpd_b2(unsigned char *arr) 781static int inquiry_evpd_b2(unsigned char *arr)
780{ 782{
781 memset(arr, 0, 0x8); 783 memset(arr, 0, 0x8);
@@ -790,6 +792,9 @@ static int inquiry_evpd_b2(unsigned char *arr)
790 if (scsi_debug_lbpws10) 792 if (scsi_debug_lbpws10)
791 arr[1] |= 1 << 5; 793 arr[1] |= 1 << 5;
792 794
795 if (scsi_debug_lbprz)
796 arr[1] |= 1 << 2;
797
793 return 0x8; 798 return 0x8;
794} 799}
795 800
@@ -1071,8 +1076,11 @@ static int resp_readcap16(struct scsi_cmnd * scp,
1071 arr[13] = scsi_debug_physblk_exp & 0xf; 1076 arr[13] = scsi_debug_physblk_exp & 0xf;
1072 arr[14] = (scsi_debug_lowest_aligned >> 8) & 0x3f; 1077 arr[14] = (scsi_debug_lowest_aligned >> 8) & 0x3f;
1073 1078
1074 if (scsi_debug_lbp()) 1079 if (scsi_debug_lbp()) {
1075 arr[14] |= 0x80; /* LBPME */ 1080 arr[14] |= 0x80; /* LBPME */
1081 if (scsi_debug_lbprz)
1082 arr[14] |= 0x40; /* LBPRZ */
1083 }
1076 1084
1077 arr[15] = scsi_debug_lowest_aligned & 0xff; 1085 arr[15] = scsi_debug_lowest_aligned & 0xff;
1078 1086
@@ -2046,10 +2054,13 @@ static void unmap_region(sector_t lba, unsigned int len)
2046 block = lba + alignment; 2054 block = lba + alignment;
2047 rem = do_div(block, granularity); 2055 rem = do_div(block, granularity);
2048 2056
2049 if (rem == 0 && lba + granularity <= end && 2057 if (rem == 0 && lba + granularity <= end && block < map_size) {
2050 block < map_size)
2051 clear_bit(block, map_storep); 2058 clear_bit(block, map_storep);
2052 2059 if (scsi_debug_lbprz)
2060 memset(fake_storep +
2061 block * scsi_debug_sector_size, 0,
2062 scsi_debug_sector_size);
2063 }
2053 lba += granularity - rem; 2064 lba += granularity - rem;
2054 } 2065 }
2055} 2066}
@@ -2731,6 +2742,7 @@ module_param_named(guard, scsi_debug_guard, int, S_IRUGO);
2731module_param_named(lbpu, scsi_debug_lbpu, int, S_IRUGO); 2742module_param_named(lbpu, scsi_debug_lbpu, int, S_IRUGO);
2732module_param_named(lbpws, scsi_debug_lbpws, int, S_IRUGO); 2743module_param_named(lbpws, scsi_debug_lbpws, int, S_IRUGO);
2733module_param_named(lbpws10, scsi_debug_lbpws10, int, S_IRUGO); 2744module_param_named(lbpws10, scsi_debug_lbpws10, int, S_IRUGO);
2745module_param_named(lbprz, scsi_debug_lbprz, int, S_IRUGO);
2734module_param_named(lowest_aligned, scsi_debug_lowest_aligned, int, S_IRUGO); 2746module_param_named(lowest_aligned, scsi_debug_lowest_aligned, int, S_IRUGO);
2735module_param_named(max_luns, scsi_debug_max_luns, int, S_IRUGO | S_IWUSR); 2747module_param_named(max_luns, scsi_debug_max_luns, int, S_IRUGO | S_IWUSR);
2736module_param_named(max_queue, scsi_debug_max_queue, int, S_IRUGO | S_IWUSR); 2748module_param_named(max_queue, scsi_debug_max_queue, int, S_IRUGO | S_IWUSR);
@@ -2772,6 +2784,7 @@ MODULE_PARM_DESC(guard, "protection checksum: 0=crc, 1=ip (def=0)");
2772MODULE_PARM_DESC(lbpu, "enable LBP, support UNMAP command (def=0)"); 2784MODULE_PARM_DESC(lbpu, "enable LBP, support UNMAP command (def=0)");
2773MODULE_PARM_DESC(lbpws, "enable LBP, support WRITE SAME(16) with UNMAP bit (def=0)"); 2785MODULE_PARM_DESC(lbpws, "enable LBP, support WRITE SAME(16) with UNMAP bit (def=0)");
2774MODULE_PARM_DESC(lbpws10, "enable LBP, support WRITE SAME(10) with UNMAP bit (def=0)"); 2786MODULE_PARM_DESC(lbpws10, "enable LBP, support WRITE SAME(10) with UNMAP bit (def=0)");
2787MODULE_PARM_DESC(lbprz, "unmapped blocks return 0 on read (def=1)");
2775MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)"); 2788MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)");
2776MODULE_PARM_DESC(max_luns, "number of LUNs per target to simulate(def=1)"); 2789MODULE_PARM_DESC(max_luns, "number of LUNs per target to simulate(def=1)");
2777MODULE_PARM_DESC(max_queue, "max number of queued commands (1 to 255(def))"); 2790MODULE_PARM_DESC(max_queue, "max number of queued commands (1 to 255(def))");