From: Rusty Russell <rusty@rustcorp.com.au>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm-devel <kvm-devel@lists.sourceforge.net>,
Jens Axboe <jens.axboe@oracle.com>,
xen-devel <xen-devel@lists.xensource.com>,
virtualization <virtualization@lists.linux-foundation.org>
Subject: Re: More virtio users
Date: Sun, 10 Jun 2007 22:37:40 +1000 [thread overview]
Message-ID: <1181479060.16428.37.camel@localhost.localdomain> (raw)
In-Reply-To: <466BB34B.9050105@qumranet.com>
On Sun, 2007-06-10 at 11:16 +0300, Avi Kivity wrote:
> Rusty Russell wrote:
> > Lguest doesn't have a framebuffer, so maybe this is a good thing for me
> > to hack on, but I promised myself I'd finish NAPI for the net device,
> > and tag for block device first.
> >
>
> If you're touching the block device, passing a request's io priority to
> the host can be useful.
OK, here's the interdiff. I still don't handle non-fs requests, but I
haven't seen any yet. I should probably BUG_ON() there and wait for
Jens to scream...
Changes:
1) Make virtio_blk.h userspace-friendly.
2) /dev/vbN -> /dev/vdN
3) Ordered tags, handed thru to other end.
4) Hand ioprio to other end, too.
diff -u b/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
--- b/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c Sun Jun 10 22:09:10 2007 +1000
@@ -33,18 +33,19 @@
struct virtio_blk_inhdr in_hdr;
};
-/* Jens gave me this nice helper to end all chunks of a request. */
-static void end_dequeued_request(struct request *req, int uptodate)
+static void end_tagged_request(struct request *req,
+ request_queue_t *q, int uptodate)
{
if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
BUG();
add_disk_randomness(req->rq_disk);
+ blk_queue_end_tag(q, req);
end_that_request_last(req, uptodate);
}
static void finish(struct virtio_blk *vblk, struct virtblk_req *vbr)
{
- end_dequeued_request(vbr->req, !vbr->failed);
+ end_tagged_request(vbr->req, vblk->disk->queue, !vbr->failed);
list_del(&vbr->list);
mempool_free(vbr, vblk->pool);
/* In case queue is stopped waiting for more buffers. */
@@ -120,7 +121,7 @@
goto detach_inbuf_full;
pr_debug("Write: %p in=%lu out=%lu\n", vbr,
- vbr->out_hdr.id, vbr->out_id);
+ (long)vbr->out_hdr.id, (long)vbr->out_id);
list_add_tail(&vbr->list, &vblk->reqs);
return true;
@@ -157,7 +158,7 @@
goto detach_inbuf_full;
pr_debug("Read: %p in=%lu out=%lu\n", vbr,
- vbr->out_hdr.id, vbr->out_id);
+ (long)vbr->out_hdr.id, (long)vbr->out_id);
list_add_tail(&vbr->list, &vblk->reqs);
return true;
@@ -178,10 +179,9 @@
/* FIXME: handle these iff capable. */
if (!blk_fs_request(req)) {
- pr_debug("Got non-command 0x%08x\n", req->cmd_type);
+ printk("Got non-command 0x%08x\n", req->cmd_type);
req->errors++;
- blkdev_dequeue_request(req);
- end_dequeued_request(req, 0);
+ end_tagged_request(req, vblk->disk->queue, 0);
continue;
}
@@ -193,6 +193,8 @@
vbr->req = req;
vbr->out_hdr.type = rq_data_dir(req);
vbr->out_hdr.sector = req->sector;
+ vbr->out_hdr.tag = req->tag;
+ vbr->out_hdr.ioprio = req->ioprio;
if (rq_data_dir(req) == WRITE) {
if (!do_write(q, vblk, vbr))
@@ -201,7 +203,6 @@
if (!do_read(q, vblk, vbr))
goto stop;
}
- blkdev_dequeue_request(req);
}
sync:
@@ -261,16 +262,25 @@
goto out_put_disk;
}
- sprintf(vblk->disk->disk_name, "vb%c", virtblk_index++);
+ sprintf(vblk->disk->disk_name, "vd%c", virtblk_index++);
vblk->disk->major = major;
vblk->disk->first_minor = 0;
vblk->disk->private_data = vblk;
vblk->disk->fops = &virtblk_fops;
+ err = blk_queue_init_tags(vblk->disk->queue, 100 /* FIXME */, NULL);
+ if (err)
+ goto out_cleanup_queue;
+
+ blk_queue_ordered(vblk->disk->queue, QUEUE_ORDERED_TAG, NULL);
+ blk_queue_prep_rq(vblk->disk->queue, blk_queue_start_tag);
+
/* Caller can do blk_queue_max_hw_segments(), set_capacity()
* etc then add_disk(). */
return vblk->disk;
+out_cleanup_queue:
+ blk_cleanup_queue(vblk->disk->queue);
out_put_disk:
put_disk(vblk->disk);
out_unregister_blkdev:
diff -u b/include/linux/virtio_blk.h b/include/linux/virtio_blk.h
--- b/include/linux/virtio_blk.h
+++ b/include/linux/virtio_blk.h Sun Jun 10 22:09:10 2007 +1000
@@ -3,26 +3,31 @@
#include <linux/types.h>
-struct gendisk;
-struct virtio_device;
-struct hd_geometry;
/* This is the first element of the scatter-gather list. */
struct virtio_blk_outhdr
{
/* 0 == read, 1 == write */
- u32 type;
+ __u32 type;
+ /* Ordered tag. */
+ __u16 tag;
+ /* Linux's ioprio. */
+ __u16 ioprio;
/* Sector (ie. 512 byte offset) */
- unsigned long sector;
+ __u64 sector;
/* Where to put reply. */
- unsigned long id;
+ __u64 id;
};
struct virtio_blk_inhdr
{
/* 1 = OK, 0 = not ok. */
- unsigned long status;
+ unsigned char status;
};
+#ifdef __KERNEL__
+struct gendisk;
+struct virtio_device;
+
struct gendisk *virtblk_probe(struct virtio_device *vdev);
void virtblk_remove(struct gendisk *disk);
-
+#endif /* __KERNEL__ */
#endif /* _LINUX_VIRTIO_BLK_H */
only in patch2:
unchanged:
--- a/include/linux/Kbuild Sun Jun 10 18:25:37 2007 +1000
+++ b/include/linux/Kbuild Sun Jun 10 22:09:10 2007 +1000
@@ -341,6 +341,7 @@ unifdef-y += utsname.h
unifdef-y += utsname.h
unifdef-y += videodev2.h
unifdef-y += videodev.h
+unifdef-y += virtio_blk.h
unifdef-y += wait.h
unifdef-y += wanrouter.h
unifdef-y += watchdog.h
next prev parent reply other threads:[~2007-06-10 12:37 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-10 7:33 More virtio users Avi Kivity
2007-06-10 8:06 ` Muli Ben-Yehuda
2007-06-10 8:09 ` Avi Kivity
2007-06-12 22:07 ` [kvm-devel] [Xen-devel] " Arnd Bergmann
2007-06-12 23:40 ` [kvm-devel] " Caitlin Bestler
2007-06-12 23:54 ` [kvm-devel] [Xen-devel] " Arnd Bergmann
2007-06-13 5:28 ` [kvm-devel] " Muli Ben-Yehuda
2007-06-14 19:41 ` Caitlin Bestler
[not found] ` <1EF1E44200D82B47BD5BA61171E8CE9D04269D6E-Wx+fQJ8T8QJuheSVJXE+poKqz+Jmtwh+qs7JOtOhHmkAvxtiuMwx3w@public.gmane.org>
2007-06-14 23:39 ` [Xen-devel] " Arnd Bergmann
[not found] ` <200706150139.36770.arnd-r2nGTMty4D4@public.gmane.org>
2007-06-15 16:26 ` Caitlin Bestler
2007-06-10 8:13 ` Rusty Russell
2007-06-10 8:16 ` Avi Kivity
2007-06-10 12:37 ` Rusty Russell [this message]
2007-06-11 6:41 ` Jens Axboe
2007-06-11 7:29 ` Rusty Russell
2007-06-11 7:33 ` Jens Axboe
2007-06-12 0:31 ` Rusty Russell
2007-06-12 6:24 ` Jens Axboe
2007-06-12 7:52 ` Rusty Russell
2007-06-12 7:56 ` Jens Axboe
2007-06-11 8:16 ` [Xen-devel] " Gerd Hoffmann
2007-06-11 8:19 ` Avi Kivity
2007-06-11 19:24 ` Anthony Liguori
2007-06-11 23:19 ` Rusty Russell
2007-06-12 0:47 ` [Xen-devel] " Benjamin Herrenschmidt
[not found] ` <1181603983.16428.100.camel__36651.2330751449$1181608748$gmane$org@localhost.localdomain>
2007-06-12 3:36 ` Anthony Liguori
2007-06-12 4:07 ` [Xen-devel] " Benjamin Herrenschmidt
2007-06-11 13:44 ` Markus Armbruster
2007-06-11 3:04 ` ron minnich
2007-06-12 22:01 ` [kvm-devel] " Arnd Bergmann
[not found] ` <200706130001.21431.arnd-r2nGTMty4D4@public.gmane.org>
2007-06-14 16:27 ` [Xen-devel] " Mark Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1181479060.16428.37.camel@localhost.localdomain \
--to=rusty@rustcorp.com.au \
--cc=avi@qumranet.com \
--cc=jens.axboe@oracle.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=virtualization@lists.linux-foundation.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox