On Mon, 2007-07-09 at 17:54 +0200, Martin Peschke wrote:
> static void do_virtblk_request(request_queue_t *q)
> {
>       struct virtio_blk *vblk = q->queuedata;
>       struct request *req;
>       struct virtblk_req *vbr;
>       int issued = 0;
> 
>       while ((req = elv_next_request(q)) != NULL) {
>               vbr = mempool_alloc(vblk->pool, GFP_ATOMIC);
>               if (!vbr) {
>                       blk_stop_queue(q);
>                       break;
>               }
> 
>               BUG_ON(req->nr_phys_segments > ARRAY_SIZE(vblk->sg));
>               vbr->req = req;
>               if (!do_req(q, vblk, req, vbr)) {
>                       /* Queue full?  Wait. */
>                       blk_stop_queue(q);
>                       mempool_free(vbr, vblk->pool);
>                       break;
>               }
>               blkdev_dequeue_request(req);
>               issued++;
>       }
> 
>       if (issued)
>               vblk->vq->ops->sync(vblk->vq);
> }

Hi Martin!

        I like this: moving the allocation into do_req() makes it even simpler:

static void do_virtblk_request(request_queue_t *q)
{
        struct virtio_blk *vblk = NULL;
        struct request *req;
        unsigned int issued = 0;

        while ((req = elv_next_request(q)) != NULL) {
                vblk = req->rq_disk->private_data;
                BUG_ON(req->nr_phys_segments > ARRAY_SIZE(vblk->sg));

                if (!do_req(q, vblk, req)) {
                        /* Queue full?  Wait. */
                        blk_stop_queue(q);
                        break;
                }
                blkdev_dequeue_request(req);
                issued++;
        }

        if (issued)
                vblk->vq->ops->sync(vblk->vq);
}

Thanks!
Rusty.

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/virtualization

Reply via email to