Re: [Bug] double ->queue_rq() because of timeout in ->queue_rq()

Ming Lei
2022-10-21T00:58:13Z

On Thu, Oct 20, 2022 at 01:26:48PM -0700, Bart Van Assche wrote:
> On 10/20/22 02:10, Ming Lei wrote:
> > [ ... ]
>
> Hi Ming,
>
> Fixing this in the block layer seems fine to me. A few comments:
>
> > + /* Before walking tags, we must ensure any submit started before the
> > + * current time has finished. Since the submit uses srcu or rcu, wait
> > + * for a synchronization point to ensure all running submits have
> > + * finished
> > + */
>
> Should the above comment follow the style of other comments in the block
> layer?

OK.

>
> > + blk_mq_wait_quiesce_done(q);
> > +
> > + blk_mq_queue_tag_busy_iter(q, blk_mq_check_expired, &expired);
>
> The above doesn't look sufficient to me since .queue_rq() may be called
> while blk_mq_queue_tag_busy_iter() is in progress. How about moving the
> blk_mq_wait_quiesce_done() call into blk_mq_check_expired() and preventing
> new .queue_rq() calls before the timeout handler is called?

blk_mq_timeout_work() records the time before calling
blk_mq_wait_quiesce_done(), and only handle requests which is timed out
before the recorded jiffies, so new queued request won't be covered
in this time.

Thanks,
Ming