Re: [PATCH V4 2/5] nvme: add helper interface to flush in-flight requests

From: jianchao.wang
Date: Thu Mar 08 2018 - 20:59:52 EST


Hi Sagi

Thanks for your precious time for review and comment.

On 03/09/2018 02:21 AM, Sagi Grimberg wrote:

>> +EXPORT_SYMBOL_GPL(nvme_abort_requests_sync);
>> +
>> +static void nvme_comp_req(struct request *req, void *data, bool reserved)
>
> Not a very good name...

Yes, indeed.

>
>> +{
>> +ÂÂÂ struct nvme_ctrl *ctrl = (struct nvme_ctrl *)data;
>> +
>> +ÂÂÂ if (!test_bit(NVME_REQ_ABORTED, &nvme_req(req)->flags))
>> +ÂÂÂÂÂÂÂ return;
>> +
>> +ÂÂÂ WARN_ON(!blk_mq_request_started(req));
>> +
>> +ÂÂÂ if (ctrl->tagset && ctrl->tagset->ops->complete) {
>
> What happens when this called on the admin tagset when the controller
> does not have an io tagset?

Yes, nvme_ctrl.admin_tagset should be used here for adminq request.


>
>> +ÂÂÂÂÂÂÂ clear_bit(NVME_REQ_ABORTED, &nvme_req(req)->flags);
>> +ÂÂÂÂÂÂÂ /*
>> +ÂÂÂÂÂÂÂÂ * We set the status to NVME_SC_ABORT_REQ, then ioq request
>> +ÂÂÂÂÂÂÂÂ * will be requeued and adminq one will be failed.
>> +ÂÂÂÂÂÂÂÂ */
>> +ÂÂÂÂÂÂÂ nvme_req(req)->status = NVME_SC_ABORT_REQ;
>> +ÂÂÂÂÂÂÂ /*
>> +ÂÂÂÂÂÂÂÂ * For ioq request, blk_mq_requeue_request should be better
>> +ÂÂÂÂÂÂÂÂ * here. But the nvme code will still setup the cmd even if
>> +ÂÂÂÂÂÂÂÂ * the RQF_DONTPREP is set. We have to use .complete to free
>> +ÂÂÂÂÂÂÂÂ * the cmd and then requeue it.
>
> IMO, its better to fix nvme to not setup the command if RQF_DONTPREP is on (other than the things it must setup).

Yes, I used to consider change that.
But I'm not sure whether there is special consideration there.
If you and Keith think it is ok that not setup command when RQF_DONTPREP is set, we could do that.

>
>> +ÂÂÂÂÂÂÂÂ *
>> +ÂÂÂÂÂÂÂÂ * For adminq request, invoking .complete directly will miss
>> +ÂÂÂÂÂÂÂÂ * blk_mq_sched_completed_request, but this is ok because we
>> +ÂÂÂÂÂÂÂÂ * won't have io scheduler for adminq.
>> +ÂÂÂÂÂÂÂÂ */
>> +ÂÂÂÂÂÂÂ ctrl->tagset->ops->complete(req);
>
> I don't think that directly calling .complete is a good idea...

Yes, indeed.

Thanks a lot
Jianchao