Another blkback issue related to flush
Roger Pau Monné
roger.pau at citrix.com
Wed Sep 4 17:07:48 UTC 2013
Hello,
I've found another issue with blkback handling of flush operations, it
was incorrectly setting one of the bio parameters when using a block
device as backend. The attached patch fixes it, and also includes a
small fix to correctly set the operation when writing the response on
the ring (all responses written by FreeBSD blkback were of type
BLKIF_OP_READ, because nreq->operation was not set).
-------------- next part --------------
>From b6cd715b2a2fcff0321ccaafe9740082f15b5943 Mon Sep 17 00:00:00 2001
From: Roger Pau Monne <roger.pau at citrix.com>
Date: Wed, 4 Sep 2013 18:33:22 +0200
Subject: [PATCH] xen-blkback: fix incorrect handling of flush for block
devices
When issuing a flush operation to a block device (from
xbb_dispatch_dev), bio->bio_caller1 was incorrectly set to
xbb_xen_req, when the bio callback (xbb_bio_done) specifically
expects bio_caller1 to be of type xbb_xen_reqlist.
Also set the request operation to match the one on the request from
the ring, so that when we write the reply the operation matches.
---
sys/dev/xen/blkback/blkback.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c
index fa9a744..58b53e7 100644
--- a/sys/dev/xen/blkback/blkback.c
+++ b/sys/dev/xen/blkback/blkback.c
@@ -1240,6 +1240,7 @@ xbb_get_resources(struct xbb_softc *xbb, struct xbb_xen_reqlist **reqlist,
nreq->reqlist = *reqlist;
nreq->req_ring_idx = ring_idx;
nreq->id = ring_req->id;
+ nreq->operation = ring_req->operation;
if (xbb->abi != BLKIF_PROTOCOL_NATIVE) {
bcopy(ring_req, &nreq->ring_req_storage, sizeof(*ring_req));
@@ -2062,7 +2063,6 @@ xbb_dispatch_dev(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist,
{
struct xbb_dev_data *dev_data;
struct bio *bios[XBB_MAX_SEGMENTS_PER_REQLIST];
- struct xbb_xen_req *nreq;
off_t bio_offset;
struct bio *bio;
struct xbb_sg *xbb_sg;
@@ -2080,7 +2080,6 @@ xbb_dispatch_dev(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist,
bio_idx = 0;
if (operation == BIO_FLUSH) {
- nreq = STAILQ_FIRST(&reqlist->contig_req_list);
bio = g_new_bio();
if (unlikely(bio == NULL)) {
DPRINTF("Unable to allocate bio for BIO_FLUSH\n");
@@ -2094,10 +2093,10 @@ xbb_dispatch_dev(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist,
bio->bio_offset = 0;
bio->bio_data = 0;
bio->bio_done = xbb_bio_done;
- bio->bio_caller1 = nreq;
+ bio->bio_caller1 = reqlist;
bio->bio_pblkno = 0;
- nreq->pendcnt = 1;
+ reqlist->pendcnt = 1;
SDT_PROBE1(xbb, kernel, xbb_dispatch_dev, flush,
device_get_unit(xbb->dev));
--
1.7.7.5 (Apple Git-26)
More information about the freebsd-xen
mailing list