scsi_debug: Support configuring the maximum segment size
PATCH v2 1/1 scsi_debug: Support configuring the maximum segment size
Add a kernel module parameter for configuring the maximum segment size.
Note: blk_validate_limits() considers zero as the default and changes it into a valid value. Values between 1 and BLK_MIN_SEGMENT_SIZE are rejected by blk_validate_limits().
This patch enables testing SCSI support for segments smaller than the page size.
---
Cc: John Garry <[email protected]>
Cc: Doug Gilbert <[email protected]>
Changes compared to v1:
- Removed sdebug_driver_template.max_segment_size.
- Changed the default max_segment_size value from BLK_MAX_SEGMENT_SIZE into UINT_MAX (this is the same as the current limit, -1U).
- Explained in the patch description that blk_validate_limits() rejects values between 1 and BLK_MIN_SEGMENT_SIZE.
drivers/scsi/scsi_debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +4 -1
@@ -915,6 +915,7 @@ static int sdebug_host_max_queue; /* per host */static int sdebug_lowest_aligned =DEF_LOWEST_ALIGNED ;static int sdebug_max_luns =DEF_MAX_LUNS ;static int sdebug_max_queue =SDEBUG_CANQUEUE ;/* per submit queue */ +static unsigned int sdebug_max_segment_size =UINT_MAX ;static unsigned int sdebug_medium_error_start =OPT_MEDIUM_ERR_ADDR ;static int sdebug_medium_error_count =OPT_MEDIUM_ERR_NUM ;static int sdebug_ndelay =DEF_NDELAY ;/* if > 0 then unit is nanoseconds */
@@ -7366,6 +7367,7 @@ module_param_named(lowest_aligned, sdebug_lowest_aligned, int, S_IRUGO);module_param_named (lun_format, sdebug_lun_am_i, int,S_IRUGO |S_IWUSR );module_param_named (max_luns, sdebug_max_luns, int,S_IRUGO |S_IWUSR );module_param_named (max_queue, sdebug_max_queue, int,S_IRUGO |S_IWUSR ); +module_param_named (max_segment_size, sdebug_max_segment_size, uint,S_IRUGO );module_param_named (medium_error_count, sdebug_medium_error_count, int,S_IRUGO |S_IWUSR ); module_param_named(medium_error_start, sdebug_medium_error_start, int,
@@ -7449,6 +7451,7 @@ MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)");MODULE_PARM_DESC (lun_format,"LUN format: 0->peripheral (def); 1 --> flat address method" );MODULE_PARM_DESC (max_luns,"number of LUNs per target to simulate(def=1)" );MODULE_PARM_DESC (max_queue,"max number of queued commands (1 to max(def))" ); +MODULE_PARM_DESC (max_segment_size,"max bytes in a single segment" );MODULE_PARM_DESC (medium_error_count,"count of sectors to return follow on MEDIUM error" );MODULE_PARM_DESC (medium_error_start,"starting sector number to return MEDIUM error" );MODULE_PARM_DESC (ndelay,"response delay in nanoseconds (def=0 -> ignore)" );
@@ -9539,7 +9542,6 @@ static const struct scsi_host_template sdebug_driver_template = { .sg_tablesize = SG_MAX_SEGMENTS, .cmd_per_lun = DEF_CMD_PER_LUN, .max_sectors = -1U, - .max_segment_size = -1U, .module = THIS_MODULE, .skip_settle_delay = 1, .track_queue_depth = 1,
@@ -9566,6 +9568,7 @@ static int sdebug_driver_probe(struct device *dev) } hpnt->can_queue = sdebug_max_queue; hpnt->cmd_per_lun = sdebug_max_queue; + hpnt->max_segment_size = sdebug_max_segment_size;if (!sdebug_clustering) hpnt->dma_boundary =PAGE_SIZE -1 ;
Quoted 4 lines · Bart Van Assche
Add a kernel module parameter for configuring the maximum segment size.
Note:blk_validate_limits()considers zero as the default and changes it into a valid value. Values between 1 andBLK_MIN_SEGMENT_SIZEare rejected byblk_validate_limits().
I thought that scsi_host_alloc() will change 0 -> BLK_MAX_SEGMENT_SIZE, right?
And I would suggest to reject non-zero max_segment_size modparam < BLK_MIN_SEGMENT_SIZE
Quoted 63 lines
This patch enables testing SCSI support for segments smaller than the page size.
Signed-off-by Bart Van Assche <[email protected]>---
Cc: John Garry <[email protected]>
Cc: Doug Gilbert <[email protected]>Changes compared to v1:
- Removed sdebug_driver_template.max_segment_size.
- Changed the defaultmax_segment_sizevalue fromBLK_MAX_SEGMENT_SIZEintoUINT_MAX(this is the same as the current limit, -1U).
- Explained in the patch description thatblk_validate_limits()rejects values between 1 andBLK_MIN_SEGMENT_SIZE.drivers/scsi/scsi_debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/scsi/scsi_debug.c +4
-1@@ -915,6 +915,7 @@ static int sdebug_host_max_queue; /* per host */static int sdebug_lowest_aligned =DEF_LOWEST_ALIGNED ;static int sdebug_max_luns =DEF_MAX_LUNS ;static int sdebug_max_queue =SDEBUG_CANQUEUE ;/* per submit queue */ +static unsigned int sdebug_max_segment_size =UINT_MAX ;static unsigned int sdebug_medium_error_start =OPT_MEDIUM_ERR_ADDR ;static int sdebug_medium_error_count =OPT_MEDIUM_ERR_NUM ;static int sdebug_ndelay =DEF_NDELAY ;/* if > 0 then unit is nanoseconds */ @@ -7366,6 +7367,7 @@ module_param_named(lowest_aligned, sdebug_lowest_aligned, int, S_IRUGO);module_param_named (lun_format, sdebug_lun_am_i, int,S_IRUGO |S_IWUSR );module_param_named (max_luns, sdebug_max_luns, int,S_IRUGO |S_IWUSR );module_param_named (max_queue, sdebug_max_queue, int,S_IRUGO |S_IWUSR ); +module_param_named (max_segment_size, sdebug_max_segment_size, uint,S_IRUGO );module_param_named (medium_error_count, sdebug_medium_error_count, int,S_IRUGO |S_IWUSR ); module_param_named(medium_error_start, sdebug_medium_error_start, int,@@ -7449,6 +7451,7 @@ MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)");MODULE_PARM_DESC (lun_format,"LUN format: 0->peripheral (def); 1 --> flat address method" );MODULE_PARM_DESC (max_luns,"number of LUNs per target to simulate(def=1)" );MODULE_PARM_DESC (max_queue,"max number of queued commands (1 to max(def))" ); +MODULE_PARM_DESC (max_segment_size,"max bytes in a single segment" );MODULE_PARM_DESC (medium_error_count,"count of sectors to return follow on MEDIUM error" );MODULE_PARM_DESC (medium_error_start,"starting sector number to return MEDIUM error" );MODULE_PARM_DESC (ndelay,"response delay in nanoseconds (def=0 -> ignore)" );@@ -9539,7 +9542,6 @@ static const struct scsi_host_template sdebug_driver_template = { .sg_tablesize = SG_MAX_SEGMENTS, .cmd_per_lun = DEF_CMD_PER_LUN, .max_sectors = -1U, - .max_segment_size = -1U, .module = THIS_MODULE, .skip_settle_delay = 1, .track_queue_depth = 1,@@ -9566,6 +9568,7 @@ static int sdebug_driver_probe(struct device *dev) } hpnt->can_queue = sdebug_max_queue; hpnt->cmd_per_lun = sdebug_max_queue; + hpnt->max_segment_size = sdebug_max_segment_size;if (!sdebug_clustering) hpnt->dma_boundary =PAGE_SIZE -1 ;