Skip to contentSkip to conversation

New blktap implementation

PATCH In review Dutch Meyer 1 participant 1 message Oct 31, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 New blktap implementation

Patch 3 of 3.

This is a new and rewritten version of blktap that we have developed at Citrix. The current version of blktap is left functionally unmodified. The change set consists of three patches.

0) A patch to deprecate the open source blktap, by moving it and issuing
a warning whenever it is used. No functionality is modified in this patch, it is just housekeeping.

1) A patch to add a new blktap implementation that is feature equivalent
to (or better than) the current open source blktap. This will eventually replace the current blktap implementation.

2) Fix several bugs in the qcow tools.

3) A kernel patch to add a new unified blktap2 module that will
eventually replace blktap.

The new blktap implementation has several improvements.

* Isolation from xenstore - Blktap devices can now be created in dom0 as
virtual block devices without coordination from xen and have few dependencies on xenstore in normal operation.

* Improved development environment for tapdisks, simpler request
forwarding, new request scheduler.

* Pause scripts updated to support live qcow snapshot (see xmsnap
script)

* New tapdisk type: Block Mason disks allow a set of tapdisks to be
flexibly arranged into graph structure and modified on-the-fly. Several example modules for Block Mason are included. Block Mason disks are constructed and modified with a declarative configuration language. These capabilities are discussed in more depth in an upcoming paper in the First Workshop on IO Virtualization, available HERE:
http://www.cs.ubc.ca/~dmeyer/blockmason-wiov-final.pdf

--Dutch

* * *

drivers/xen/Makefile +1 -0
diff -r e410857fd83c drivers/xen/Makefile
@@ -8,6 +8,7 @@
 obj-$(CONFIG_XEN_BALLOON)		+= balloon/
 obj-$(CONFIG_XEN_BLKDEV_BACKEND)	+= blkback/
 obj-$(CONFIG_XEN_BLKDEV_TAP)		+= blktap/
+obj-$(CONFIG_XEN_BLKDEV_TAP)            += blktap2/
 obj-$(CONFIG_XEN_NETDEV_BACKEND)	+= netback/
 obj-$(CONFIG_XEN_TPMDEV_BACKEND)	+= tpmback/
 obj-$(CONFIG_XEN_BLKDEV_FRONTEND)	+= blkfront/
drivers/xen/blkback/Makefile +1 -1
diff -r e410857fd83c drivers/xen/blkback/Makefile
@@ -1,3 +1,3 @@
 obj-$(CONFIG_XEN_BLKDEV_BACKEND) := blkbk.o
 
-blkbk-y	:= blkback.o xenbus.o interface.o vbd.o
+blkbk-y	:= blkback.o xenbus.o interface.o vbd.o blkback-pagemap.o
drivers/xen/blkback/blkback-pagemap.c new file +91 -0

91 lines not on this page · raw message

drivers/xen/blkback/blkback-pagemap.h new file +17 -0
diff -r e410857fd83c drivers/xen/blkback/blkback-pagemap.h
@@ -0,0 +1,17 @@
+#ifndef _BLKBACK_PAGEMAP_H_
+#define _BLKBACK_PAGEMAP_H_
+
+#include <xen/interface/xen.h>
+#include <xen/interface/grant_table.h>
+
+typedef unsigned int busid_t;
+
+struct blkback_pagemap {
+	domid_t          domid;
+	busid_t          busid;
+	grant_ref_t      gref;
+};
+
+struct blkback_pagemap blkback_pagemap_read(struct page *);
+
+#endif
drivers/xen/blkback/blkback.c +8 -0
diff -r e410857fd83c drivers/xen/blkback/blkback.c
@@ -173,6 +173,7 @@
 		handle = pending_handle(req, i);
 		if (handle == BLKBACK_INVALID_HANDLE)
 			continue;
+		blkback_pagemap_clear(virt_to_page(vaddr(req, i)));
 		gnttab_set_unmap_op(&unmap[invcount], vaddr(req, i),
 				    GNTMAP_host_map, handle);
 		pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
@@ -464,6 +465,10 @@
 			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT));
 		seg[i].buf  = map[i].dev_bus_addr | 
 			(req->seg[i].first_sect << 9);
+		blkback_pagemap_set(vaddr_pagenr(pending_req, i),
+				    virt_to_page(vaddr(pending_req, i)),
+				    blkif->domid, req->handle,
+				    req->seg[i].gref);
 	}
 
 	if (ret)
@@ -615,6 +620,9 @@
 					mmap_pages, GFP_KERNEL);
 	pending_pages         = alloc_empty_pages_and_pagevec(mmap_pages);
 
+	if (blkback_pagemap_init(mmap_pages))
+		goto out_of_memory;
+
 	if (!pending_reqs || !pending_grant_handles || !pending_pages)
 		goto out_of_memory;
 
drivers/xen/blkback/common.h +6 -0
diff -r e410857fd83c drivers/xen/blkback/common.h
@@ -43,6 +43,8 @@
 #include <xen/gnttab.h>
 #include <xen/driver_util.h>
 #include <xen/xenbus.h>
+#include "blkback-pagemap.h"
+
 
 #define DPRINTK(_f, _a...)			\
 	pr_debug("(file=%s, line=%d) " _f,	\
@@ -136,4 +138,8 @@
 int blkback_barrier(struct xenbus_transaction xbt,
 		    struct backend_info *be, int state);
 
+int blkback_pagemap_init(int);
+void blkback_pagemap_set(int, struct page *, domid_t, busid_t, grant_ref_t);
+void blkback_pagemap_clear(struct page *);
+
 #endif /* __BLKIF__BACKEND__COMMON_H__ */
drivers/xen/blktap/blktap.c +9 -8
diff -r e410857fd83c drivers/xen/blktap/blktap.c
@@ -116,6 +116,7 @@
 					[req id, idx] tuple                  */
 	blkif_t *blkif;               /*Associate blkif with tapdev          */
 	struct domid_translate_ext trans; /*Translation from domid to bus.   */
+	struct vm_foreign_map foreign_map;
 } tap_blkif_t;
 
 static struct tap_blkif *tapfds[MAX_TAP_DEV];
@@ -330,7 +331,7 @@
 					       ptep, is_fullmm);
 
 	info = vma->vm_file->private_data;
-	map = vma->vm_private_data;
+	map = info->foreign_map.map;
 
 	/* TODO Should these be changed to if statements? */
 	BUG_ON(!info);
@@ -615,7 +616,8 @@
 			info->vma, info->vma->vm_start, 
 			info->vma->vm_end - info->vma->vm_start, NULL);
 
-		kfree(info->vma->vm_private_data);
+		kfree(info->foreign_map.map);
+		info->foreign_map.map = NULL;
 
 		info->vma = NULL;
 	}
@@ -707,7 +709,8 @@
 	for (i = 0; i < ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT); i++)
 		map[i] = NULL;
     
-	vma->vm_private_data = map;
+	info->foreign_map.map = map;
+	vma->vm_private_data = &info->foreign_map;
 	vma->vm_flags |= VM_FOREIGN;
 	vma->vm_flags |= VM_DONTCOPY;
 
@@ -1173,7 +1176,7 @@
 		for (j = 0; j < pending_req->nr_pages; j++) {
 
 			unsigned long kvaddr, uvaddr;
-			struct page **map = info->vma->vm_private_data;
+			struct page **map = info->foreign_map.map;
 			struct page *pg;
 			int offset;
 
@@ -1467,8 +1470,7 @@
 							  >> PAGE_SHIFT));
 			offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT;
 			pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
-			((struct page **)info->vma->vm_private_data)[offset] =
-				pg;
+			info->foreign_map.map[offset] = pg;
 		}
 	} else {
 		for (i = 0; i < nseg; i++) {
@@ -1495,8 +1497,7 @@
 
 			offset = (uvaddr - info->vma->vm_start) >> PAGE_SHIFT;
 			pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT);
-			((struct page **)info->vma->vm_private_data)[offset] =
-				pg;
+			info->foreign_map.map[offset] = pg;
 		}
 	}
 
drivers/xen/blktap2/Makefile new file +3 -0
diff -r e410857fd83c drivers/xen/blktap2/Makefile
@@ -0,0 +1,3 @@
+obj-y := blktap.o
+
+blktap-objs := control.o ring.o wait_queue.o device.o request.o sysfs.o
drivers/xen/blktap2/blktap.h new file +241 -0

241 lines not on this page · raw message

drivers/xen/blktap2/control.c new file +277 -0

277 lines not on this page · raw message

drivers/xen/blktap2/device.c new file +1134 -0

1,134 lines not on this page · raw message

drivers/xen/blktap2/request.c new file +296 -0

296 lines not on this page · raw message

drivers/xen/blktap2/ring.c new file +613 -0

613 lines not on this page · raw message

drivers/xen/blktap2/sysfs.c new file +425 -0

216 lines not on this page · raw message

drivers/xen/blktap2/wait_queue.c new file +40 -0
diff -r e410857fd83c drivers/xen/blktap2/wait_queue.c

Lines of this file are not shown. View the raw message.

include/linux/mm.h +7 -0
diff -r e410857fd83c include/linux/mm.h

Lines of this file are not shown. View the raw message.

include/linux/page-flags.h +10 -0
diff -r e410857fd83c include/linux/page-flags.h

Lines of this file are not shown. View the raw message.

mm/memory.c +3 -1
diff -r e410857fd83c mm/memory.c

Lines of this file are not shown. View the raw message.

mm/mmap.c +11 -1
diff -r e410857fd83c mm/mmap.c

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Part of the diff is not shown here. View the raw message.