]>
Commit | Line | Data |
---|---|---|
cc90b958 BS |
1 | From: kwolf@suse.de |
2 | Subject: blktap: Write Barriers | |
3 | Patch-mainline: obsolete | |
4 | ||
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); | |
11 | break; | |
12 | ||
13 | + case BLKIF_OP_WRITE_BARRIER: | |
14 | + /* TODO Some counter? */ | |
15 | + /* Fall through */ | |
16 | case BLKIF_OP_WRITE: | |
17 | blkif->st_wr_req++; | |
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) | |
21 | { | |
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; | |
24 | + int op, operation; | |
25 | struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2]; | |
26 | unsigned int nseg; | |
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; | |
30 | struct mm_struct *mm; | |
31 | ||
32 | + switch (req->operation) { | |
33 | + case BLKIF_OP_READ: | |
34 | + operation = READ; | |
35 | + break; | |
36 | + case BLKIF_OP_WRITE: | |
37 | + operation = WRITE; | |
38 | + break; | |
39 | + case BLKIF_OP_WRITE_BARRIER: | |
40 | + operation = WRITE_BARRIER; | |
41 | + break; | |
42 | + default: | |
43 | + operation = 0; /* make gcc happy */ | |
44 | + BUG(); | |
45 | + } | |
46 | + | |
47 | if (blkif->dev_num < 0 || blkif->dev_num > MAX_TAP_DEV) | |
48 | goto fail_response; | |
49 | ||
50 | @@ -1404,7 +1422,7 @@ static void dispatch_rw_block_io(blkif_t | |
51 | ||
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; | |
58 | op = 0; | |
59 | @@ -1421,7 +1439,7 @@ static void dispatch_rw_block_io(blkif_t | |
60 | kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i); | |
61 | ||
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 | |
69 | ||
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 | |
82 | int err; | |
83 | ||
84 | struct xenbus_device *dev = be->dev; | |
85 | + struct xenbus_transaction xbt; | |
86 | ||
87 | + /* Write feature-barrier to xenstore */ | |
88 | +again: | |
89 | + err = xenbus_transaction_start(&xbt); | |
90 | + if (err) { | |
91 | + xenbus_dev_fatal(dev, err, "starting transaction"); | |
92 | + return; | |
93 | + } | |
94 | + | |
95 | + err = xenbus_printf(xbt, dev->nodename, "feature-barrier", "1"); | |
96 | + if (err) { | |
97 | + xenbus_dev_fatal(dev, err, "writing feature-barrier"); | |
98 | + xenbus_transaction_end(xbt, 1); | |
99 | + return; | |
100 | + } | |
101 | + | |
102 | + err = xenbus_transaction_end(xbt, 0); | |
103 | + if (err == -EAGAIN) | |
104 | + goto again; | |
105 | + | |
106 | + /* Switch state */ | |
107 | err = xenbus_switch_state(dev, XenbusStateConnected); | |
108 | if (err) | |
109 | xenbus_dev_fatal(dev, err, "switching to Connected state", |