qubes-linux-kernel/patches.xen/xen-blktap-write-barriers

106 lines
3.2 KiB
Plaintext
Raw Normal View History

From: kwolf@suse.de
Subject: blktap: Write Barriers
Patch-mainline: obsolete
--- head-2010-04-29.orig/drivers/xen/blktap/blktap.c 2010-04-29 09:52:39.000000000 +0200
+++ head-2010-04-29/drivers/xen/blktap/blktap.c 2010-04-29 10:16:10.000000000 +0200
@@ -1388,6 +1388,9 @@ static int do_block_io_op(blkif_t *blkif
dispatch_rw_block_io(blkif, &req, pending_req);
break;
+ case BLKIF_OP_WRITE_BARRIER:
+ /* TODO Some counter? */
+ /* Fall through */
case BLKIF_OP_WRITE:
blkif->st_wr_req++;
dispatch_rw_block_io(blkif, &req, pending_req);
@@ -1419,7 +1422,7 @@ static void dispatch_rw_block_io(blkif_t
pending_req_t *pending_req)
{
extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]);
- int op, operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
+ int op, operation;
struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
unsigned int nseg;
int ret, i, nr_sects = 0;
@@ -1431,6 +1434,21 @@ static void dispatch_rw_block_io(blkif_t
struct mm_struct *mm;
struct vm_area_struct *vma = NULL;
+ switch (req->operation) {
+ case BLKIF_OP_READ:
+ operation = READ;
+ break;
+ case BLKIF_OP_WRITE:
+ operation = WRITE;
+ break;
+ case BLKIF_OP_WRITE_BARRIER:
+ operation = WRITE_BARRIER;
+ break;
+ default:
+ operation = 0; /* make gcc happy */
+ BUG();
+ }
+
if (blkif->dev_num < 0 || blkif->dev_num >= MAX_TAP_DEV)
goto fail_response;
@@ -1470,7 +1488,7 @@ static void dispatch_rw_block_io(blkif_t
pending_req->blkif = blkif;
pending_req->id = req->id;
- pending_req->operation = operation;
+ pending_req->operation = req->operation;
pending_req->status = BLKIF_RSP_OKAY;
pending_req->nr_pages = nseg;
op = 0;
@@ -1487,7 +1505,7 @@ static void dispatch_rw_block_io(blkif_t
kvaddr = idx_to_kaddr(mmap_idx, pending_idx, i);
flags = GNTMAP_host_map;
- if (operation == WRITE)
+ if (operation != READ)
flags |= GNTMAP_readonly;
gnttab_set_map_op(&map[op], kvaddr, flags,
req->seg[i].gref, blkif->domid);
@@ -1504,7 +1522,7 @@ static void dispatch_rw_block_io(blkif_t
flags = GNTMAP_host_map | GNTMAP_application_map
| GNTMAP_contains_pte;
- if (operation == WRITE)
+ if (operation != READ)
flags |= GNTMAP_readonly;
gnttab_set_map_op(&map[op], ptep, flags,
req->seg[i].gref, blkif->domid);
--- head-2010-04-29.orig/drivers/xen/blktap/xenbus.c 2010-04-29 10:15:31.000000000 +0200
+++ head-2010-04-29/drivers/xen/blktap/xenbus.c 2010-04-29 10:16:08.000000000 +0200
@@ -402,7 +402,28 @@ static void connect(struct backend_info
int err;
struct xenbus_device *dev = be->dev;
+ struct xenbus_transaction xbt;
+ /* Write feature-barrier to xenstore */
+again:
+ err = xenbus_transaction_start(&xbt);
+ if (err) {
+ xenbus_dev_fatal(dev, err, "starting transaction");
+ return;
+ }
+
+ err = xenbus_printf(xbt, dev->nodename, "feature-barrier", "1");
+ if (err) {
+ xenbus_dev_fatal(dev, err, "writing feature-barrier");
+ xenbus_transaction_end(xbt, 1);
+ return;
+ }
+
+ err = xenbus_transaction_end(xbt, 0);
+ if (err == -EAGAIN)
+ goto again;
+
+ /* Switch state */
err = xenbus_switch_state(dev, XenbusStateConnected);
if (err)
xenbus_dev_fatal(dev, err, "switching to Connected state",