On Wed, 2018-11-14 at 16:25 +0800, Ming Lei wrote:
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -697,6 +697,12 @@ static bool scsi_end_request(struct request *req,
> blk_status_t error,
>                */
>               scsi_mq_uninit_cmd(cmd);
>  
> +             /*
> +              * queue is still alive, so grab the ref for preventing it
> +              * from being cleaned up during running queue.
> +              */
> +             percpu_ref_get(&q->q_usage_counter);
> +

I think the above comment is misleading. In the block layer a queue is called
alive if the "dying" flag has not been set. When the above call to
percpu_ref_get() occurs it is not guaranteed that that flag has not yet been
set. But it is guaranteed that q->q_usage_counter is not zero. I would prefer
if the comment would be modified.

What's not clear to me is why this patch only protects the blk-mq path but
not the legacy path. Does the legacy path need similar protection? It also
triggers a queue run after having finished a request.

Otherwise this patch looks fine to me.

Bart.

Reply via email to