Message ID | 1601268657-940-6-git-send-email-muneendra.kumar@broadcom.com |
---|---|
State | New |
Headers | show |
Series | scsi: Support to handle Intermittent errors | expand |
On 9/28/20 6:50 AM, Muneendra wrote: > Added a new routine scsi_chg_noretries_abort_io_device(). > This functions accepts two arguments Scsi_device and an integer(set). > > When set is passed as 1 > this routine will set SCMD_NORETRIES_ABORT bit in > scmd->state for all the pending io's on the scsi device associated > with target port. > > When set is passed as 0 > This routine will clear SCMD_NORETRIES_ABORT bit in > scmd->state for all the pending io's on the scsi device associated > with target port. > > Export the symbol so the routine can be called by scsi_transport_fc.c > > Added new function declaration scsi_chg_noretries_abort_io_device in > scsi_priv.h > > Signed-off-by: Muneendra <muneendra.kumar@broadcom.com> > > --- > v2: > Renamed the below functions as > scsi_set_noretries_abort_io_device ->scsi_chg_noretries_abort_io_device > __scsi_set_noretries_abort_io_device->__scsi_set_noretries_abort_io_device > which accepts the value as an arg to set/clear the SCMD_NORETRIES_ABORT bit > --- > drivers/scsi/scsi_error.c | 76 +++++++++++++++++++++++++++++++++++++++ > drivers/scsi/scsi_priv.h | 2 ++ > 2 files changed, 78 insertions(+) > > diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c > index 3f14ea10d5da..c0943f08b469 100644 > --- a/drivers/scsi/scsi_error.c > +++ b/drivers/scsi/scsi_error.c > @@ -271,6 +271,82 @@ void scsi_eh_scmd_add(struct scsi_cmnd *scmd) > call_rcu(&scmd->rcu, scsi_eh_inc_host_failed); > } > > +static bool > +scsi_clear_noretries_abort_io(struct request *rq, void *priv, bool reserved) > +{ > + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); > + struct scsi_device *sdev = scmd->device; > + > + /* only clear SCMD_NORETRIES_ABORT on ios on a specific sdev */ > + if (sdev != priv) > + return true; > + > + /*Clear the SCMD_NORETRIES_ABORT bit*/ > + if (READ_ONCE(rq->state) == MQ_RQ_IN_FLIGHT) > + clear_bit(SCMD_NORETRIES_ABORT, &scmd->state); > + return true; > +} > + > +static bool > +scsi_set_noretries_abort_io(struct request *rq, void *priv, bool reserved) > +{ > + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); > + struct scsi_device *sdev = scmd->device; > + > + /* only set SCMD_NORETRIES_ABORT on ios on a specific sdev */ > + if (sdev != priv) > + return true; > + /* we don't want this command reissued on abort success > + * so set SCMD_NORETRIES_ABORT bit to ensure it > + * won't get reissued > + */ > + if (READ_ONCE(rq->state) == MQ_RQ_IN_FLIGHT) > + set_bit(SCMD_NORETRIES_ABORT, &scmd->state); > + return true; > +} > + Do we really care about the 'in flight' parameter? Why not set it on every command? And meanwhile we do have scsi command iterators (scsi_host_busy_iter); maybe one should be using them here. > +static int > +__scsi_chg_noretries_abort_io_device(struct scsi_device *sdev, int set) > +{ > + > + if (sdev->sdev_state != SDEV_RUNNING) > + return -EINVAL; > + > + if (blk_queue_init_done(sdev->request_queue)) { > + > + blk_mq_quiesce_queue(sdev->request_queue); > + > + if (set) > + blk_mq_tagset_busy_iter(&sdev->host->tag_set, > + scsi_set_noretries_abort_io, sdev); > + else > + blk_mq_tagset_busy_iter(&sdev->host->tag_set, > + scsi_clear_noretries_abort_io, sdev); > + > + blk_mq_unquiesce_queue(sdev->request_queue); > + } > + return 0; > +} 'set' is a boolean, so why not use the 'boolean' type here? And I'm not sure if we need to check for 'blk_queue_init_done()'; surely that's always the case for SDEV_RUNNING? > + > +/* > + * scsi_chg_noretries_abort_io_device - set/clear the SCMD_NORETRIES_ABORT > + * bit for all the pending io's on a device > + * @sdev: scsi_device > + * @set: indicates to clear (0) or set (1) the SCMD_NORETRIES_ABORT flag > + */ > +int > +scsi_chg_noretries_abort_io_device(struct scsi_device *sdev, int set) > +{ > + struct Scsi_Host *shost = sdev->host; > + int ret = -EINVAL; > + > + mutex_lock(&shost->scan_mutex); > + ret = __scsi_chg_noretries_abort_io_device(sdev, set); > + mutex_unlock(&shost->scan_mutex); > + return ret; > +} > +EXPORT_SYMBOL(scsi_chg_noretries_abort_io_device); > + > /** > * scsi_times_out - Timeout function for normal scsi commands. > * @req: request that is timing out. > diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h > index d12ada035961..aba98a3294ce 100644 > --- a/drivers/scsi/scsi_priv.h > +++ b/drivers/scsi/scsi_priv.h > @@ -81,6 +81,8 @@ void scsi_eh_ready_devs(struct Scsi_Host *shost, > int scsi_eh_get_sense(struct list_head *work_q, > struct list_head *done_q); > int scsi_noretry_cmd(struct scsi_cmnd *scmd); > +extern int scsi_chg_noretries_abort_io_device(struct scsi_device *sdev, > + int set); > > /* scsi_lib.c */ > extern int scsi_maybe_unblock_host(struct scsi_device *sdev); > Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 3f14ea10d5da..c0943f08b469 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -271,6 +271,82 @@ void scsi_eh_scmd_add(struct scsi_cmnd *scmd) call_rcu(&scmd->rcu, scsi_eh_inc_host_failed); } +static bool +scsi_clear_noretries_abort_io(struct request *rq, void *priv, bool reserved) +{ + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); + struct scsi_device *sdev = scmd->device; + + /* only clear SCMD_NORETRIES_ABORT on ios on a specific sdev */ + if (sdev != priv) + return true; + + /*Clear the SCMD_NORETRIES_ABORT bit*/ + if (READ_ONCE(rq->state) == MQ_RQ_IN_FLIGHT) + clear_bit(SCMD_NORETRIES_ABORT, &scmd->state); + return true; +} + +static bool +scsi_set_noretries_abort_io(struct request *rq, void *priv, bool reserved) +{ + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); + struct scsi_device *sdev = scmd->device; + + /* only set SCMD_NORETRIES_ABORT on ios on a specific sdev */ + if (sdev != priv) + return true; + /* we don't want this command reissued on abort success + * so set SCMD_NORETRIES_ABORT bit to ensure it + * won't get reissued + */ + if (READ_ONCE(rq->state) == MQ_RQ_IN_FLIGHT) + set_bit(SCMD_NORETRIES_ABORT, &scmd->state); + return true; +} + +static int +__scsi_chg_noretries_abort_io_device(struct scsi_device *sdev, int set) +{ + + if (sdev->sdev_state != SDEV_RUNNING) + return -EINVAL; + + if (blk_queue_init_done(sdev->request_queue)) { + + blk_mq_quiesce_queue(sdev->request_queue); + + if (set) + blk_mq_tagset_busy_iter(&sdev->host->tag_set, + scsi_set_noretries_abort_io, sdev); + else + blk_mq_tagset_busy_iter(&sdev->host->tag_set, + scsi_clear_noretries_abort_io, sdev); + + blk_mq_unquiesce_queue(sdev->request_queue); + } + return 0; +} + +/* + * scsi_chg_noretries_abort_io_device - set/clear the SCMD_NORETRIES_ABORT + * bit for all the pending io's on a device + * @sdev: scsi_device + * @set: indicates to clear (0) or set (1) the SCMD_NORETRIES_ABORT flag + */ +int +scsi_chg_noretries_abort_io_device(struct scsi_device *sdev, int set) +{ + struct Scsi_Host *shost = sdev->host; + int ret = -EINVAL; + + mutex_lock(&shost->scan_mutex); + ret = __scsi_chg_noretries_abort_io_device(sdev, set); + mutex_unlock(&shost->scan_mutex); + return ret; +} +EXPORT_SYMBOL(scsi_chg_noretries_abort_io_device); + /** * scsi_times_out - Timeout function for normal scsi commands. * @req: request that is timing out. diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index d12ada035961..aba98a3294ce 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -81,6 +81,8 @@ void scsi_eh_ready_devs(struct Scsi_Host *shost, int scsi_eh_get_sense(struct list_head *work_q, struct list_head *done_q); int scsi_noretry_cmd(struct scsi_cmnd *scmd); +extern int scsi_chg_noretries_abort_io_device(struct scsi_device *sdev, + int set); /* scsi_lib.c */ extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
Added a new routine scsi_chg_noretries_abort_io_device(). This functions accepts two arguments Scsi_device and an integer(set). When set is passed as 1 this routine will set SCMD_NORETRIES_ABORT bit in scmd->state for all the pending io's on the scsi device associated with target port. When set is passed as 0 This routine will clear SCMD_NORETRIES_ABORT bit in scmd->state for all the pending io's on the scsi device associated with target port. Export the symbol so the routine can be called by scsi_transport_fc.c Added new function declaration scsi_chg_noretries_abort_io_device in scsi_priv.h Signed-off-by: Muneendra <muneendra.kumar@broadcom.com> --- v2: Renamed the below functions as scsi_set_noretries_abort_io_device ->scsi_chg_noretries_abort_io_device __scsi_set_noretries_abort_io_device->__scsi_set_noretries_abort_io_device which accepts the value as an arg to set/clear the SCMD_NORETRIES_ABORT bit --- drivers/scsi/scsi_error.c | 76 +++++++++++++++++++++++++++++++++++++++ drivers/scsi/scsi_priv.h | 2 ++ 2 files changed, 78 insertions(+)