2 Subject: blktap: Write Barriers
3 Patch-mainline: obsolete
5 Index: head-2008-11-10/drivers/xen/blktap/blktap.c
6 ===================================================================
7 --- head-2008-11-10.orig/drivers/xen/blktap/blktap.c 2008-11-10 12:10:23.000000000 +0100
8 +++ head-2008-11-10/drivers/xen/blktap/blktap.c 2008-11-10 12:14:32.000000000 +0100
9 @@ -1324,6 +1324,9 @@ static int do_block_io_op(blkif_t *blkif
10 dispatch_rw_block_io(blkif, &req, pending_req);
13 + case BLKIF_OP_WRITE_BARRIER:
14 + /* TODO Some counter? */
18 dispatch_rw_block_io(blkif, &req, pending_req);
19 @@ -1355,7 +1358,7 @@ static void dispatch_rw_block_io(blkif_t
20 pending_req_t *pending_req)
22 extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]);
23 - int op, operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
25 struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
27 int ret, i, nr_sects = 0;
28 @@ -1366,6 +1369,21 @@ static void dispatch_rw_block_io(blkif_t
29 uint16_t mmap_idx = pending_req->mem_idx;
32 + switch (req->operation) {
36 + case BLKIF_OP_WRITE:
39 + case BLKIF_OP_WRITE_BARRIER:
40 + operation = WRITE_BARRIER;
43 + operation = 0; /* make gcc happy */
47 if (blkif->dev_num < 0 || blkif->dev_num > MAX_TAP_DEV)
50 @@ -1404,7 +1422,7 @@ static void dispatch_rw_block_io(blkif_t
52 pending_req->blkif = blkif;
53 pending_req->id = req->id;
54 - pending_req->operation = operation;
55 + pending_req->operation = req->operation;
56 pending_req->status = BLKIF_RSP_OKAY;
57 pending_req->nr_pages = nseg;
59 @@ -1421,7 +1439,7 @@ static void dispatch_rw_block_io(blkif_t
60 kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i);
62 flags = GNTMAP_host_map;
63 - if (operation == WRITE)
64 + if (operation != READ)
65 flags |= GNTMAP_readonly;
66 gnttab_set_map_op(&map[op], kvaddr, flags,
67 req->seg[i].gref, blkif->domid);
68 @@ -1438,7 +1456,7 @@ static void dispatch_rw_block_io(blkif_t
70 flags = GNTMAP_host_map | GNTMAP_application_map
71 | GNTMAP_contains_pte;
72 - if (operation == WRITE)
73 + if (operation != READ)
74 flags |= GNTMAP_readonly;
75 gnttab_set_map_op(&map[op], ptep, flags,
76 req->seg[i].gref, blkif->domid);
77 Index: head-2008-11-10/drivers/xen/blktap/xenbus.c
78 ===================================================================
79 --- head-2008-11-10.orig/drivers/xen/blktap/xenbus.c 2008-11-10 12:14:29.000000000 +0100
80 +++ head-2008-11-10/drivers/xen/blktap/xenbus.c 2008-11-10 12:14:32.000000000 +0100
81 @@ -395,7 +395,28 @@ static void connect(struct backend_info
84 struct xenbus_device *dev = be->dev;
85 + struct xenbus_transaction xbt;
87 + /* Write feature-barrier to xenstore */
89 + err = xenbus_transaction_start(&xbt);
91 + xenbus_dev_fatal(dev, err, "starting transaction");
95 + err = xenbus_printf(xbt, dev->nodename, "feature-barrier", "1");
97 + xenbus_dev_fatal(dev, err, "writing feature-barrier");
98 + xenbus_transaction_end(xbt, 1);
102 + err = xenbus_transaction_end(xbt, 0);
103 + if (err == -EAGAIN)
107 err = xenbus_switch_state(dev, XenbusStateConnected);
109 xenbus_dev_fatal(dev, err, "switching to Connected state",