From owner-freebsd-xen@FreeBSD.ORG Wed Sep 4 17:07:47 2013 Return-Path: Delivered-To: freebsd-xen@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id CDD241DD; Wed, 4 Sep 2013 17:07:47 +0000 (UTC) (envelope-from roger.pau@citrix.com) Received: from SMTP.EU.CITRIX.COM (smtp.eu.citrix.com [46.33.159.39]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 23FE22411; Wed, 4 Sep 2013 17:07:46 +0000 (UTC) X-IronPort-AV: E=Sophos;i="4.89,1022,1367971200"; d="scan'208,223";a="8427668" Received: from lonpmailmx01.citrite.net ([10.30.203.162]) by LONPIPO01.EU.CITRIX.COM with ESMTP/TLS/RC4-MD5; 04 Sep 2013 17:07:45 +0000 Received: from [172.16.1.30] (10.68.19.166) by LONPMAILMX01.citrite.net (10.30.203.162) with Microsoft SMTP Server id 8.3.298.1; Wed, 4 Sep 2013 18:07:44 +0100 Message-ID: <522768EA.6010809@citrix.com> Date: Wed, 4 Sep 2013 19:07:54 +0200 From: =?ISO-8859-1?Q?Roger_Pau_Monn=E9?= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: "freebsd-xen@freebsd.org" Subject: Another blkback issue related to flush Content-Type: multipart/mixed; boundary="------------090500030802030106080200" Cc: "Justin T. Gibbs" X-BeenThere: freebsd-xen@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion of the freebsd port to xen - implementation and usage List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Sep 2013 17:07:48 -0000 --------------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 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--