Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Sep 2013 19:07:54 +0200
From:      =?ISO-8859-1?Q?Roger_Pau_Monn=E9?= <roger.pau@citrix.com>
To:        "freebsd-xen@freebsd.org" <freebsd-xen@freebsd.org>
Cc:        "Justin T. Gibbs" <gibbs@freebsd.org>
Subject:   Another blkback issue related to flush
Message-ID:  <522768EA.6010809@citrix.com>

next in thread | raw e-mail | index | archive | help
--------------090500030802030106080200
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit

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).

--------------090500030802030106080200
Content-Type: text/plain; charset="UTF-8"; x-mac-type=0; x-mac-creator=0;
	name="0001-xen-blkback-fix-incorrect-handling-of-flush-for-bloc.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename*0="0001-xen-blkback-fix-incorrect-handling-of-flush-for-bloc.pa";
	filename*1="tch"

>From b6cd715b2a2fcff0321ccaafe9740082f15b5943 Mon Sep 17 00:00:00 2001
From: Roger Pau Monne <roger.pau@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)


--------------090500030802030106080200--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?522768EA.6010809>