From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6LTK-0001ZI-VY for qemu-devel@nongnu.org; Tue, 28 Aug 2012 09:04:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T6LTF-0002zs-3P for qemu-devel@nongnu.org; Tue, 28 Aug 2012 09:04:46 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:48795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6LTE-0002zZ-Qe for qemu-devel@nongnu.org; Tue, 28 Aug 2012 09:04:41 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 28 Aug 2012 14:04:35 +0100 Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7SD4Rsh5832886 for ; Tue, 28 Aug 2012 13:04:27 GMT Received: from d06av06.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7SD4X9I031841 for ; Tue, 28 Aug 2012 07:04:33 -0600 From: Stefan Hajnoczi Date: Tue, 28 Aug 2012 14:04:27 +0100 Message-Id: <1346159067-28734-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH for-1.2] qed: refuse unaligned zero writes with a backing file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Anthony Liguori , Stefan Hajnoczi Zero writes have cluster granularity in QED. Therefore they can only be used to zero entire clusters. If the zero write request leaves sectors untouched, zeroing the entire cluster would obscure the backing file. Instead return -ENOTSUP, which is handled by block.c:bdrv_co_do_write_zeroes() and falls back to a regular write. The qemu-iotests 034 test cases covers this scenario. Signed-off-by: Stefan Hajnoczi --- block/qed.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block/qed.c b/block/qed.c index a02dbfd..21cb239 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1363,10 +1363,21 @@ static int coroutine_fn bdrv_qed_co_write_zeroes(BlockDriverState *bs, int nb_sectors) { BlockDriverAIOCB *blockacb; + BDRVQEDState *s = bs->opaque; QEDWriteZeroesCB cb = { .done = false }; QEMUIOVector qiov; struct iovec iov; + /* Refuse if there are untouched backing file sectors */ + if (bs->backing_hd) { + if (qed_offset_into_cluster(s, sector_num * BDRV_SECTOR_SIZE) != 0) { + return -ENOTSUP; + } + if (qed_offset_into_cluster(s, nb_sectors * BDRV_SECTOR_SIZE) != 0) { + return -ENOTSUP; + } + } + /* Zero writes start without an I/O buffer. If a buffer becomes necessary * then it will be allocated during request processing. */ -- 1.7.10.4