Xen blkback for 2.6.40.
Subsystems (2)
RFC PATCH 1/1 Xen blkback for 2.6.40.
I am proposing this patch for 2.6.40. This is an RFC at this point.
The git tree for this specific patch is
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.git devel/xen-blkback-v3.squashed
(the full tree is devel/xen-blkback-v3)
Please take a look at the patch. I know that I need to rewrite the description to have more details for the upstream community - and that will be shortly supplied.
Any thoughts on what I should address/remove/augment/etc would be appreciated. And whether the code has any obvious pitfalls?
The code was originally lifted from 2.6.18, then ported to 2.6.32, and now I have backported it to 2.6.38/.39. scripts/checkpatch.pl had been applied and also some re-ordering of the code has been done to make it easier to read.
PATCH 1/1 xen/blkback: add xen-blkback support
This is driver of the Xen blkback squashed in one patch
from git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.git devel/xen-blkback-v3
The blkback drive is "pass-through" type driver that takes the I/O's from the guest (in Linux that would be the xen-blkfront driver) and submits the I/Os using the 'submit_bio' to the appropiate backend.
--- block/blk-core.c | 2 + drivers/xen/Kconfig | 8 + drivers/xen/Makefile | 1 + drivers/xen/blkback/Makefile | 3 + drivers/xen/blkback/blkback.c | 765 +++++++++++++++++++++++++++++++++++++++ drivers/xen/blkback/common.h | 142 ++++++++ drivers/xen/blkback/interface.c | 185 ++++++++++ drivers/xen/blkback/vbd.c | 162 +++++++++ drivers/xen/blkback/xenbus.c | 562 ++++++++++++++++++++++++++++ include/xen/blkif.h | 122 +++++++ 10 files changed, 1952 insertions(+), 0 deletions(-) create mode 100644 drivers/xen/blkback/Makefile create mode 100644 drivers/xen/blkback/blkback.c create mode 100644 drivers/xen/blkback/common.h create mode 100644 drivers/xen/blkback/interface.c create mode 100644 drivers/xen/blkback/vbd.c create mode 100644 drivers/xen/blkback/xenbus.c create mode 100644 include/xen/blkif.h
block/blk-core.c +2 -0
@@ -351,6 +351,7 @@ void blk_put_queue(struct request_queue *q) {kobject_put (&q->kobj); } +EXPORT_SYMBOL_GPL (blk_put_queue);/* * Note: If a driver supplied the queue lock, it should not zap that lock
@@ -572,6 +573,7 @@ int blk_get_queue(struct request_queue *q)return 1 ; } +EXPORT_SYMBOL_GPL (blk_get_queue);static inline void blk_free_request (struct request_queue *q,struct request *rq) {
drivers/xen/Kconfig +8 -0
@@ -37,6 +37,14 @@ config XEN_BACKEND Support for backend device drivers that provide I/O services to other virtual machines. +config XEN_BLKDEV_BACKEND + tristate "Block-device backend driver" + depends on XEN_BACKEND && BLOCK + help + The block-device backend driver allows the kernel to export its + block devices to other guests via a high-performance shared-memory + interface. + config XENFS tristate "Xen filesystem" default y
drivers/xen/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o obj-$(CONFIG_XEN_DEV_EVTCHN) += xen-evtchn.o obj-$(CONFIG_XEN_GNTDEV) += xen-gntdev.o obj-$(CONFIG_XEN_GRANT_DEV_ALLOC) += xen-gntalloc.o +obj-$(CONFIG_XEN_BLKDEV_BACKEND) += blkback/ obj-$(CONFIG_XENFS) += xenfs/ obj-$(CONFIG_XEN_SYS_HYPERVISOR) += sys-hypervisor.o obj-$(CONFIG_XEN_PLATFORM_PCI) += xen-platform-pci.o
drivers/xen/blkback/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_XEN_BLKDEV_BACKEND) := xen-blkback.o + +xen-blkback-y := blkback.o xenbus.o interface.o vbd.o
drivers/xen/blkback/blkback.c new file +765 -0
765 lines not on this page · raw message
drivers/xen/blkback/common.h new file +142 -0
142 lines not on this page · raw message
drivers/xen/blkback/interface.c new file +185 -0
185 lines not on this page · raw message
drivers/xen/blkback/vbd.c new file +162 -0
162 lines not on this page · raw message
drivers/xen/blkback/xenbus.c new file +562 -0
562 lines not on this page · raw message
include/xen/blkif.h new file +122 -0
122 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [PATCH] xen/blkback: add xen-blkback support
Talk about self-review :-)
Quoted 17 lines
index 90f22cc..9b60e69 100644
block/blk-core.c +2
-0@@ -351,6 +351,7 @@ void blk_put_queue(struct request_queue *q) {kobject_put (&q->kobj); } +EXPORT_SYMBOL_GPL (blk_put_queue);/* * Note: If a driver supplied the queue lock, it should not zap that lock @@ -572,6 +573,7 @@ int blk_get_queue(struct request_queue *q)return 1 ; } +EXPORT_SYMBOL_GPL (blk_get_queue);
.. snip..
Quoted 1 line
+static void dispatch_rw_block_io(struct
blkif_st*blkif,
.. snip..
Quoted 1 line
block/blk-core.c +1
-0+struct request_queue *q;
.. snip
Quoted 3 lines
block/blk-core.c +3
-0+ q =bdev_get_queue (preq.bdev); +if (!q) + goto fail_response;
.. snip..
block/blk-core.c
Quoted 10 lines
block/blk-core.c +10
-0+/* Get a reference count for the disk queue and start sending I/O */ +blk_get_queue (q); +blk_start_plug (&plug); + +for (i =0 ; i < nbio; i++) +submit_bio (operation, biolist[i]); + +blk_finish_plug (&plug); +/* Let the I/Os go.. */ +blk_put_queue (q);
Hmm, let me remove those get/puts. They are actually not necessary as we already hold a reference count when we opened the device.
Re: Re: [PATCH] xen/blkback: add xen-blkback support
Quoted 31 lines · Konrad Rzeszutek Wilk
Talk about self-review :-)
Quoted 17 lines
index 90f22cc..9b60e69 100644
block/blk-core.c +2
-0@@ -351,6 +351,7 @@ void blk_put_queue(struct request_queue *q) {kobject_put (&q->kobj); } +EXPORT_SYMBOL_GPL (blk_put_queue);/* * Note: If a driver supplied the queue lock, it should not zap that lock @@ -572,6 +573,7 @@ int blk_get_queue(struct request_queue *q)return 1 ; } +EXPORT_SYMBOL_GPL (blk_get_queue);.. snip..
Quoted 1 line
+static void dispatch_rw_block_io(struct
blkif_st*blkif,.. snip..
Quoted 1 line
block/blk-core.c +1
-0+struct request_queue *q;.. snip
Quoted 3 lines
block/blk-core.c +3
-0+ q =bdev_get_queue (preq.bdev); +if (!q) + goto fail_response;.. snip..
Quoted 13 lines
block/blk-core.c
Quoted 10 lines
block/blk-core.c +10
-0+/* Get a reference count for the disk queue and start sending I/O */ +blk_get_queue (q); +blk_start_plug (&plug); + +for (i =0 ; i < nbio; i++) +submit_bio (operation, biolist[i]); + +blk_finish_plug (&plug); +/* Let the I/Os go.. */ +blk_put_queue (q);Hmm, let me remove those get/puts. They are actually not necessary as we already hold a reference count when we opened the device.
Ack. I never noticed these weren't exported.
But bdev_get_queue is not an addref, just an accessor macro, as you're probably aware of.
But get/put is normally managed entirely in block/ and implied by the request and bdev interfaces.
Cheers,
Daniel
Re: Re: [PATCH] xen/blkback: add xen-blkback support
Quoted 7 lines
Quoted 2 lines
Hmm, let me remove those get/puts. They are actually not necessary as we already hold a reference count when we opened the device.
Ack. I never noticed these weren't exported.
But
bdev_get_queueis not an addref, just an accessor macro, as you're probably aware of.
Yes.
Quoted 3 lines
But get/put is normally managed entirely in
block/and implied by the request and bdev interfaces.
And I found the reason for all of that. Way back in the past (2.6.18) we would be checking the request_queue->flag to make sure it did not have the QUEUE_FLAG_DEAD flag set. Over the years the block API started doing that in the submit_bio path and .. well, we don't need this check anymore.
Quoted 10 lines · Konrad Rzeszutek Wilk
I am proposing this patch for 2.6.40. This is an RFC at this point.
The git tree for this specific patch is
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.gitdevel/xen-blkback-v3.squashed(the full tree is devel/xen-blkback-v3)
Please take a look at the patch. I know that I need to rewrite the description to have more details for the upstream community - and that will be shortly supplied.
Quoted 6 lines
Any thoughts on what I should address/remove/augment/etc would be appreciated. And whether the code has any obvious pitfalls?
The code was originally lifted from 2.6.18, then ported to 2.6.32, and now I have backported it to 2.6.38/.39.
scripts/checkpatch.plhad been applied and also some re-ordering of the code has been done to make it easier to read.
If propose to consider eliminating vbd.c and interface.c, inlining the critical bits where they belong, respectively.
Leaving only blkback.c for the data- and xenbus.c for the control path.
I don't think there's anything notable in there which has more than a single position to call it from. It always looked like out of some abstraction layer to me, maybe with blktap1 in mind. Beyond that, I don't see that getting anywhere.
Daniel
Quoted 14 lines · Daniel Stodden
Quoted 13 lines · Konrad Rzeszutek Wilk
I am proposing this patch for 2.6.40. This is an RFC at this point.
The git tree for this specific patch is
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.gitdevel/xen-blkback-v3.squashed(the full tree is devel/xen-blkback-v3)
Please take a look at the patch. I know that I need to rewrite the description to have more details for the upstream community - and that will be shortly supplied.
Any thoughts on what I should address/remove/augment/etc would be appreciated. And whether the code has any obvious pitfalls?
Quoted 6 lines
Quoted 3 lines
The code was originally lifted from 2.6.18, then ported to 2.6.32, and now I have backported it to 2.6.38/.39.
scripts/checkpatch.plhad been applied and also some re-ordering of the code has been done to make it easier to read.If propose to consider eliminating
vbd.candinterface.c, inlining the critical bits where they belong, respectively.
Ok. Let me take an axe to that.
Quoted 2 lines
Leaving only
blkback.cfor the data- andxenbus.cfor the control path.
<nods>
Quoted 8 lines
I don't think there's anything notable in there which has more than a single position to call it from. It always looked like out of some abstraction layer to me, maybe with blktap1 in mind. Beyond that, I don't see that getting anywhere.
Daniel