On Wed, Nov 14, 2018 at 07:02:28AM -0800, Bart Van Assche wrote: > 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. I am fine with either way given we know the context, not mention the first thing blk_cleanup_queue() does is to call blk_set_queue_dying(). > > 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. The queue_lock is held for protecting everything, so such issue in legacy path. Thanks, Ming