aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2020-03-24 22:18:25 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2020-04-22 17:37:46 -0400
commit8ae70a062d6807e2ce01449c43338773284900b7 (patch)
tree435a2e7e17b3da7982ac00cd8085695bf65225b2
parent7109cb51517267ef0631da293d80a26f4e18d3ba (diff)
downloadlinux-8ae70a062d6807e2ce01449c43338773284900b7.tar.gz
scsi: scsi_debug: Optimal transfer length granularity is in blocks
Unlike the physical block size which is reported as an exponent, the optimal transfer length granularity is expressed in logical blocks in SBC. Change the module parameter to reflect this. Allowing non-powers of two to be specified is beneficial in that it allows us to have regression tests for the core code which handles devices that report bogus values in this field. Fixes: 86e6828a8aed ("scsi: scsi_debug: Add OPTIMAL TRANSFER LENGTH GRANULARITY option.") Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/scsi_debug.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 4c6c448dc2df61..cff41070706926 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -124,7 +124,7 @@ static const char *sdebug_version_date = "20190125";
#define DEF_OPTS 0
#define DEF_OPT_BLKS 1024
#define DEF_PHYSBLK_EXP 0
-#define DEF_OPT_XFERLEN_EXP 0
+#define DEF_OPT_XFERLEN_GRAN 0
#define DEF_PTYPE TYPE_DISK
#define DEF_REMOVABLE false
#define DEF_SCSI_LEVEL 7 /* INQUIRY, byte2 [6->SPC-4; 7->SPC-5] */
@@ -640,7 +640,7 @@ static int sdebug_num_tgts = DEF_NUM_TGTS; /* targets per host */
static int sdebug_opt_blks = DEF_OPT_BLKS;
static int sdebug_opts = DEF_OPTS;
static int sdebug_physblk_exp = DEF_PHYSBLK_EXP;
-static int sdebug_opt_xferlen_exp = DEF_OPT_XFERLEN_EXP;
+static int sdebug_opt_xferlen_gran = DEF_OPT_XFERLEN_GRAN;
static int sdebug_ptype = DEF_PTYPE; /* SCSI peripheral device type */
static int sdebug_scsi_level = DEF_SCSI_LEVEL;
static int sdebug_sector_size = DEF_SECTOR_SIZE;
@@ -1314,9 +1314,8 @@ static int inquiry_vpd_b0(unsigned char *arr)
memcpy(arr, vpdb0_data, sizeof(vpdb0_data));
/* Optimal transfer length granularity */
- if (sdebug_opt_xferlen_exp != 0 &&
- sdebug_physblk_exp < sdebug_opt_xferlen_exp)
- gran = 1 << sdebug_opt_xferlen_exp;
+ if (sdebug_opt_xferlen_gran != 0)
+ gran = sdebug_opt_xferlen_gran;
else
gran = 1 << sdebug_physblk_exp;
put_unaligned_be16(gran, arr + 2);
@@ -4450,7 +4449,7 @@ module_param_named(num_tgts, sdebug_num_tgts, int, S_IRUGO | S_IWUSR);
module_param_named(opt_blks, sdebug_opt_blks, int, S_IRUGO);
module_param_named(opts, sdebug_opts, int, S_IRUGO | S_IWUSR);
module_param_named(physblk_exp, sdebug_physblk_exp, int, S_IRUGO);
-module_param_named(opt_xferlen_exp, sdebug_opt_xferlen_exp, int, S_IRUGO);
+module_param_named(opt_xferlen_gran, sdebug_opt_xferlen_gran, int, S_IRUGO);
module_param_named(ptype, sdebug_ptype, int, S_IRUGO | S_IWUSR);
module_param_named(removable, sdebug_removable, bool, S_IRUGO | S_IWUSR);
module_param_named(scsi_level, sdebug_scsi_level, int, S_IRUGO);
@@ -4510,7 +4509,7 @@ MODULE_PARM_DESC(num_tgts, "number of targets per host to simulate(def=1)");
MODULE_PARM_DESC(opt_blks, "optimal transfer length in blocks (def=1024)");
MODULE_PARM_DESC(opts, "1->noise, 2->medium_err, 4->timeout, 8->recovered_err... (def=0)");
MODULE_PARM_DESC(physblk_exp, "physical block exponent (def=0)");
-MODULE_PARM_DESC(opt_xferlen_exp, "optimal transfer length granularity exponent (def=physblk_exp)");
+MODULE_PARM_DESC(opt_xferlen_gran, "optimal transfer length granularity (def=1 << physblk_exp)");
MODULE_PARM_DESC(ptype, "SCSI peripheral type(def=0[disk])");
MODULE_PARM_DESC(removable, "claim to have removable media (def=0)");
MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=7[SPC-5])");