Message ID | 20191120103114.24723-3-hare@suse.de (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | scsi: remove legacy cmd_list implementation | expand |
On 11/20/19 2:31 AM, Hannes Reinecke wrote: > +static bool flush_cmds_iter(struct request *rq, void *data, bool reserved) > +{ > + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); > + int status = *(int *)data; > + > + if (reserved) > + return true; Since the SCSI core does not support reserving tags, this early return is dead code. Additionally, I'm not sure this early return would be correct if reserved tag support would be added to the SCSI core. How about leaving out this early return? > + scsi_dma_unmap(scmd); > + scmd->result = status << 16; > + scmd->scsi_done(scmd); > + return true; > +} > + > +/** > + * scsi_host_flush_commands -- Terminate all running commands ^^ Should this have been a single hyphen? Thanks, Bart.
On 11/20/19 5:19 PM, Bart Van Assche wrote: > On 11/20/19 2:31 AM, Hannes Reinecke wrote: >> +static bool flush_cmds_iter(struct request *rq, void *data, bool >> reserved) >> +{ >> + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); >> + int status = *(int *)data; >> + >> + if (reserved) >> + return true; > > Since the SCSI core does not support reserving tags, this early return > is dead code. Additionally, I'm not sure this early return would be > correct if reserved tag support would be added to the SCSI core. How > about leaving out this early return? > Yeah, all right. >> + scsi_dma_unmap(scmd); >> + scmd->result = status << 16; >> + scmd->scsi_done(scmd); >> + return true; >> +} >> + >> +/** >> + * scsi_host_flush_commands -- Terminate all running commands > ^^ > Should this have been a single hyphen? > Maybe. Will be sending an updated version. Cheers, Hannes
flush is such a heavіly overloaded term. What about scsi_host_complete_all_commands?
On 11/26/19 5:55 PM, Christoph Hellwig wrote: > flush is such a heavіly overloaded term. What about > scsi_host_complete_all_commands? > Sure. As it happens I've been struggling with the function name, too, so any meaningful name is good with me. Cheers, Hannes
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 1d669e47b692..c26fa1fe6103 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -650,3 +650,32 @@ void scsi_flush_work(struct Scsi_Host *shost) flush_workqueue(shost->work_q); } EXPORT_SYMBOL_GPL(scsi_flush_work); + +static bool flush_cmds_iter(struct request *rq, void *data, bool reserved) +{ + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); + int status = *(int *)data; + + if (reserved) + return true; + scsi_dma_unmap(scmd); + scmd->result = status << 16; + scmd->scsi_done(scmd); + return true; +} + +/** + * scsi_host_flush_commands -- Terminate all running commands + * @shost: Scsi Host on which commands should be terminated + * @status: Status to be set for the terminated commands + * + * There is no protection against modification of the number + * of outstanding commands. It is the responsibility of the + * caller to ensure that concurrent I/O submission and/or + * completion is stopped when calling this function. + */ +void scsi_host_flush_commands(struct Scsi_Host *shost, int status) +{ + blk_mq_tagset_busy_iter(&shost->tag_set, flush_cmds_iter, &status); +} +EXPORT_SYMBOL_GPL(scsi_host_flush_commands); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index f577647bf5f2..cb9a6fe9ad5b 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -735,6 +735,7 @@ extern int scsi_host_busy(struct Scsi_Host *shost); extern void scsi_host_put(struct Scsi_Host *t); extern struct Scsi_Host *scsi_host_lookup(unsigned short); extern const char *scsi_host_state_name(enum scsi_host_state); +extern void scsi_host_flush_commands(struct Scsi_Host *shost, int status); static inline int __must_check scsi_add_host(struct Scsi_Host *host, struct device *dev)
Add a helper scsi_host_flush_commands() to terminate all outstanding commands on a scsi host. Signed-off-by: Hannes Reinecke <hare@suse.de> --- drivers/scsi/hosts.c | 29 +++++++++++++++++++++++++++++ include/scsi/scsi_host.h | 1 + 2 files changed, 30 insertions(+)