On Mon, Apr 26, 2021 at 07:28:18PM -0700, Bart Van Assche wrote: > On 4/26/21 6:45 PM, Ming Lei wrote: > > + * We grab one request reference before calling @fn and release it after > > + * @fn returns. So far we don't support to pass the request reference to > > + * one new conetxt in @fn. > ^^^^^^^ > context? > > > +void blk_mq_put_rq_ref(struct request *rq) > > +{ > > + if (is_flush_rq(rq, rq->mq_hctx)) > > + rq->end_io(rq, 0); > > + else if (refcount_dec_and_test(&rq->ref)) > > + __blk_mq_free_request(rq); > > +} > > Will rq->end_io() be called twice when a tag iteration function > encounters a flush request? It could be, see flush_end_io(): static void flush_end_io(struct request *flush_rq, blk_status_t error) { ... spin_lock_irqsave(&fq->mq_flush_lock, flags); if (!refcount_dec_and_test(&flush_rq->ref)) { fq->rq_status = error; spin_unlock_irqrestore(&fq->mq_flush_lock, flags); return; } ... Thanks, Ming