Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Eric Sandeen and committed by
James Bottomley
be1dd78d 49d0e64b

+18 -5
+18 -5
drivers/scsi/scsi_debug.c
··· 101 101 #define DEF_LBPU 0 102 102 #define DEF_LBPWS 0 103 103 #define DEF_LBPWS10 0 104 + #define DEF_LBPRZ 1 104 105 #define DEF_LOWEST_ALIGNED 0 105 106 #define DEF_NO_LUN_0 0 106 107 #define DEF_NUM_PARTS 0 ··· 187 186 static unsigned int scsi_debug_lbpu = DEF_LBPU; 188 187 static unsigned int scsi_debug_lbpws = DEF_LBPWS; 189 188 static unsigned int scsi_debug_lbpws10 = DEF_LBPWS10; 189 + static unsigned int scsi_debug_lbprz = DEF_LBPRZ; 190 190 static unsigned int scsi_debug_unmap_alignment = DEF_UNMAP_ALIGNMENT; 191 191 static unsigned int scsi_debug_unmap_granularity = DEF_UNMAP_GRANULARITY; 192 192 static unsigned int scsi_debug_unmap_max_blocks = DEF_UNMAP_MAX_BLOCKS; ··· 777 775 return 0x3c; 778 776 } 779 777 780 - /* Thin provisioning VPD page (SBC-3) */ 778 + /* Logical block provisioning VPD page (SBC-3) */ 781 779 static int inquiry_evpd_b2(unsigned char *arr) 782 780 { 783 781 memset(arr, 0, 0x8); ··· 791 789 792 790 if (scsi_debug_lbpws10) 793 791 arr[1] |= 1 << 5; 792 + 793 + if (scsi_debug_lbprz) 794 + arr[1] |= 1 << 2; 794 795 795 796 return 0x8; 796 797 } ··· 1076 1071 arr[13] = scsi_debug_physblk_exp & 0xf; 1077 1072 arr[14] = (scsi_debug_lowest_aligned >> 8) & 0x3f; 1078 1073 1079 - if (scsi_debug_lbp()) 1074 + if (scsi_debug_lbp()) { 1080 1075 arr[14] |= 0x80; /* LBPME */ 1076 + if (scsi_debug_lbprz) 1077 + arr[14] |= 0x40; /* LBPRZ */ 1078 + } 1081 1079 1082 1080 arr[15] = scsi_debug_lowest_aligned & 0xff; 1083 1081 ··· 2054 2046 block = lba + alignment; 2055 2047 rem = do_div(block, granularity); 2056 2048 2057 - if (rem == 0 && lba + granularity <= end && 2058 - block < map_size) 2049 + if (rem == 0 && lba + granularity <= end && block < map_size) { 2059 2050 clear_bit(block, map_storep); 2060 - 2051 + if (scsi_debug_lbprz) 2052 + memset(fake_storep + 2053 + block * scsi_debug_sector_size, 0, 2054 + scsi_debug_sector_size); 2055 + } 2061 2056 lba += granularity - rem; 2062 2057 } 2063 2058 } ··· 2742 2731 module_param_named(lbpu, scsi_debug_lbpu, int, S_IRUGO); 2743 2732 module_param_named(lbpws, scsi_debug_lbpws, int, S_IRUGO); 2744 2733 module_param_named(lbpws10, scsi_debug_lbpws10, int, S_IRUGO); 2734 + module_param_named(lbprz, scsi_debug_lbprz, int, S_IRUGO); 2745 2735 module_param_named(lowest_aligned, scsi_debug_lowest_aligned, int, S_IRUGO); 2746 2736 module_param_named(max_luns, scsi_debug_max_luns, int, S_IRUGO | S_IWUSR); 2747 2737 module_param_named(max_queue, scsi_debug_max_queue, int, S_IRUGO | S_IWUSR); ··· 2784 2772 MODULE_PARM_DESC(lbpu, "enable LBP, support UNMAP command (def=0)"); 2785 2773 MODULE_PARM_DESC(lbpws, "enable LBP, support WRITE SAME(16) with UNMAP bit (def=0)"); 2786 2774 MODULE_PARM_DESC(lbpws10, "enable LBP, support WRITE SAME(10) with UNMAP bit (def=0)"); 2775 + MODULE_PARM_DESC(lbprz, "unmapped blocks return 0 on read (def=1)"); 2787 2776 MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)"); 2788 2777 MODULE_PARM_DESC(max_luns, "number of LUNs per target to simulate(def=1)"); 2789 2778 MODULE_PARM_DESC(max_queue, "max number of queued commands (1 to 255(def))");