Re: [PATCH v4 1/2] virtio-blk: support polling I/O

Suwan Kim
2022-04-05T11:48:29Z

On Tue, Apr 05, 2022 at 08:26:34AM +0100, Stefan Hajnoczi wrote:
> On Tue, Apr 05, 2022 at 02:31:21PM +0900, Suwan Kim wrote:
> > +static int virtblk_poll(struct blk_mq_hw_ctx *hctx, struct io_comp_batch *iob)
> > +{
> > + struct virtio_blk *vblk = hctx->queue->queuedata;
> > + struct virtio_blk_vq *vq = hctx->driver_data;
> > + struct virtblk_req *vbr;
> > + bool req_done = false;
> > + unsigned long flags;
> > + unsigned int len;
> > + int found = 0;
> > +
> > + spin_lock_irqsave(&vq->lock, flags);
> > +
> > + while ((vbr = virtqueue_get_buf(vq->vq, &len)) != NULL) {
> > + struct request *req = blk_mq_rq_from_pdu(vbr);
> >
> > - return blk_mq_virtio_map_queues(&set->map[HCTX_TYPE_DEFAULT],
> > - vblk->vdev, 0);
> > + found++;
> > + if (!blk_mq_add_to_batch(req, iob, vbr->status,
> > + virtblk_complete_batch))
> > + blk_mq_complete_request(req);
> > + req_done = true;
> > + }
> > +
> > + if (req_done)
>
> Minor nit: req_done can be replaced with found > 0.

It looks better. I will fix it.
Thanks for the feedback!

Regards,
Suwan Kim