On Wed, May 12, 2021 at 03:03:40PM -0700, Sagi Grimberg wrote: > > > On 5/12/21 6:15 AM, Christoph Hellwig wrote: > > Replace the blk_poll interface that requires the caller to keep a queue > > and cookie from the submissions with polling based on the bio. > > > > Polling for the bio itself leads to a few advantages: > > > > - the cookie construction can made entirely private in blk-mq.c > > - the caller does not need to remember the request_queue and cookie > > separately and thus sidesteps their lifetime issues > > - keeping the device and the cookie inside the bio allows to trivially > > support polling BIOs remapping by stacking drivers > > - a lot of code to propagate the cookie back up the submission path can > > be removed entirely. > > > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> ... > > +int bio_poll(struct bio *bio, unsigned int flags) > > +{ > > + struct request_queue *q = bio->bi_bdev->bd_disk->queue; > > + blk_qc_t cookie = READ_ONCE(bio->bi_cookie); > > + > > + if (cookie == BLK_QC_T_NONE || > > + !test_bit(QUEUE_FLAG_POLL, &q->queue_flags)) > > + return 0; > > + > > + if (current->plug) > > + blk_flush_plug_list(current->plug, false); > > + > > + /* not yet implemented, so this should not happen */ > > + if (WARN_ON_ONCE(!queue_is_mq(q))) > > What happens if the I/O wasn't (yet) queued to the bottom device > (i.e. no available path in nvme-mpath)? > > In this case the disk would be the mpath device node (which is > not mq...) ->bi_cookie is only set in blk_mq_start_request() for blk-mq request, if the I/O isn't queued to bottom device, it won't be polled because ->bi_cookie is still BLK_QC_T_NONE. Thanks, Ming