* [PATCH] scsi_debug: Add two new parameters to scsi_debug driver
@ 2018-02-03 18:38 Laurence Oberman
2018-02-06 14:11 ` Douglas Gilbert
2018-02-07 1:20 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Laurence Oberman @ 2018-02-03 18:38 UTC (permalink / raw)
To: dgilbert, linux-scsi, Bart.VanAssche; +Cc: Laurence Oberman
---
This patch adds two new parameters to the scsi_debug driver.
During various fault injection scenarios it would be useful to be able
to pick a specific starting sector and number of follow on sectors
where a MEDIUM ERROR for reads would be returned against a scsi-debug
device.
Right now this only works against sector 0x1234 and OPT_MEDIUM_ERR_NUM
follow on sectors.
However during testing of md-raid and other scenarios I wanted more
flexibility.
The idea is add 2 new parameters:
medium_error_start
medium_error_count
If medium_error_start is set then we don't use the default of
OPT_MEDIUM_ERR_ADDR, but use that set value.
If medium_error_count is set we use that value otherwise default to
OPT_MEDIUM_ERR_NUM.
Signed-off-by: Laurence Oberman <loberman@redhat.com>
Tested-by : Laurence Oberman <loberman@redhat.com>
drivers/scsi/scsi_debug.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index a5986da..5a5aba0 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -616,6 +616,8 @@ enum sdeb_opcode_index {
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_medium_error_start = OPT_MEDIUM_ERR_ADDR;
+static int sdebug_medium_error_count = OPT_MEDIUM_ERR_NUM;
static atomic_t retired_max_queue; /* if > 0 then was prior max_queue */
static int sdebug_ndelay = DEF_NDELAY; /* if > 0 then unit is nanoseconds */
static int sdebug_no_lun_0 = DEF_NO_LUN_0;
@@ -2712,8 +2714,8 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
}
if (unlikely((SDEBUG_OPT_MEDIUM_ERR & sdebug_opts) &&
- (lba <= (OPT_MEDIUM_ERR_ADDR + OPT_MEDIUM_ERR_NUM - 1)) &&
- ((lba + num) > OPT_MEDIUM_ERR_ADDR))) {
+ (lba <= (sdebug_medium_error_start + sdebug_medium_error_count - 1)) &&
+ ((lba + num) > sdebug_medium_error_start))) {
/* claim unrecoverable read error */
mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0);
/* set info field and valid bit for fixed descriptor */
@@ -4440,6 +4442,8 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
module_param_named(lowest_aligned, sdebug_lowest_aligned, int, S_IRUGO);
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(medium_error_start, sdebug_medium_error_start, int, S_IRUGO | S_IWUSR);
+module_param_named(medium_error_count, sdebug_medium_error_count, int, S_IRUGO | S_IWUSR);
module_param_named(ndelay, sdebug_ndelay, int, S_IRUGO | S_IWUSR);
module_param_named(no_lun_0, sdebug_no_lun_0, int, S_IRUGO | S_IWUSR);
module_param_named(no_uld, sdebug_no_uld, int, S_IRUGO);
@@ -4497,6 +4501,8 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)");
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(medium_error_start, "starting sector number to return MEDIUM error");
+MODULE_PARM_DESC(medium_error_count, "count of sectors to return follow on MEDIUM error");
MODULE_PARM_DESC(ndelay, "response delay in nanoseconds (def=0 -> ignore)");
MODULE_PARM_DESC(no_lun_0, "no LU number 0 (def=0 -> have lun 0)");
MODULE_PARM_DESC(no_uld, "stop ULD (e.g. sd driver) attaching (def=0))");
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi_debug: Add two new parameters to scsi_debug driver
2018-02-03 18:38 [PATCH] scsi_debug: Add two new parameters to scsi_debug driver Laurence Oberman
@ 2018-02-06 14:11 ` Douglas Gilbert
2018-02-07 1:20 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Douglas Gilbert @ 2018-02-06 14:11 UTC (permalink / raw)
To: Laurence Oberman, linux-scsi, Bart.VanAssche
On 2018-02-03 01:38 PM, Laurence Oberman wrote:
> ---
> This patch adds two new parameters to the scsi_debug driver.
> During various fault injection scenarios it would be useful to be able
> to pick a specific starting sector and number of follow on sectors
> where a MEDIUM ERROR for reads would be returned against a scsi-debug
> device.
>
> Right now this only works against sector 0x1234 and OPT_MEDIUM_ERR_NUM
> follow on sectors.
> However during testing of md-raid and other scenarios I wanted more
> flexibility.
>
> The idea is add 2 new parameters:
> medium_error_start
> medium_error_count
>
> If medium_error_start is set then we don't use the default of
> OPT_MEDIUM_ERR_ADDR, but use that set value.
> If medium_error_count is set we use that value otherwise default to
> OPT_MEDIUM_ERR_NUM.
>
> Signed-off-by: Laurence Oberman <loberman@redhat.com>
> Tested-by : Laurence Oberman <loberman@redhat.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
>
> drivers/scsi/scsi_debug.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index a5986da..5a5aba0 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -616,6 +616,8 @@ enum sdeb_opcode_index {
> 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_medium_error_start = OPT_MEDIUM_ERR_ADDR;
> +static int sdebug_medium_error_count = OPT_MEDIUM_ERR_NUM;
> static atomic_t retired_max_queue; /* if > 0 then was prior max_queue */
> static int sdebug_ndelay = DEF_NDELAY; /* if > 0 then unit is nanoseconds */
> static int sdebug_no_lun_0 = DEF_NO_LUN_0;
> @@ -2712,8 +2714,8 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
> }
>
> if (unlikely((SDEBUG_OPT_MEDIUM_ERR & sdebug_opts) &&
> - (lba <= (OPT_MEDIUM_ERR_ADDR + OPT_MEDIUM_ERR_NUM - 1)) &&
> - ((lba + num) > OPT_MEDIUM_ERR_ADDR))) {
> + (lba <= (sdebug_medium_error_start + sdebug_medium_error_count - 1)) &&
> + ((lba + num) > sdebug_medium_error_start))) {
> /* claim unrecoverable read error */
> mk_sense_buffer(scp, MEDIUM_ERROR, UNRECOVERED_READ_ERR, 0);
> /* set info field and valid bit for fixed descriptor */
> @@ -4440,6 +4442,8 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
> module_param_named(lowest_aligned, sdebug_lowest_aligned, int, S_IRUGO);
> 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(medium_error_start, sdebug_medium_error_start, int, S_IRUGO | S_IWUSR);
> +module_param_named(medium_error_count, sdebug_medium_error_count, int, S_IRUGO | S_IWUSR);
> module_param_named(ndelay, sdebug_ndelay, int, S_IRUGO | S_IWUSR);
> module_param_named(no_lun_0, sdebug_no_lun_0, int, S_IRUGO | S_IWUSR);
> module_param_named(no_uld, sdebug_no_uld, int, S_IRUGO);
> @@ -4497,6 +4501,8 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
> MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)");
> 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(medium_error_start, "starting sector number to return MEDIUM error");
> +MODULE_PARM_DESC(medium_error_count, "count of sectors to return follow on MEDIUM error");
> MODULE_PARM_DESC(ndelay, "response delay in nanoseconds (def=0 -> ignore)");
> MODULE_PARM_DESC(no_lun_0, "no LU number 0 (def=0 -> have lun 0)");
> MODULE_PARM_DESC(no_uld, "stop ULD (e.g. sd driver) attaching (def=0))");
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi_debug: Add two new parameters to scsi_debug driver
2018-02-03 18:38 [PATCH] scsi_debug: Add two new parameters to scsi_debug driver Laurence Oberman
2018-02-06 14:11 ` Douglas Gilbert
@ 2018-02-07 1:20 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2018-02-07 1:20 UTC (permalink / raw)
To: Laurence Oberman; +Cc: dgilbert, linux-scsi, Bart.VanAssche
Laurence,
The patch description needs to go before the "---" separator. I fixed it
up.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-07 1:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-03 18:38 [PATCH] scsi_debug: Add two new parameters to scsi_debug driver Laurence Oberman
2018-02-06 14:11 ` Douglas Gilbert
2018-02-07 1:20 ` Martin K. Petersen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.