Re: [PATCH 2/9] scsi: add scsi_host_flush_commands() helper

Hannes Reinecke
2019-11-19T06:52:33Z

On 11/18/19 11:57 PM, Bart Van Assche wrote:
> On 11/18/19 1:22 AM, Hannes Reinecke wrote:
>> +/**
>> + * 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
>> + */
>> +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;
>> +    scmd->result = status << 16;
>> +    scmd->scsi_done(scmd);
>> +    return true;
>> +}
>> +
>> +void scsi_host_flush_commands(struct Scsi_Host *shost, int status)
>> +{
>> +    blk_mq_tagset_busy_iter(&shost->tag_set, flush_cmds_iter, &status);
>> +}
>
> Should the kernel-doc comment be moved from the static function to the
> exported function? Please also add a comment that it is only safe to
> call scsi_host_flush_commands() from inside a LLD reset handler.
>
I'd rather say that concurrent I/O submission must be prevented from the
caller. But yes, will be updating the comments.

Cheers,

Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 247165 (AG München), GF: Felix Imendörffer