From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6jpW-0006yM-GR for qemu-devel@nongnu.org; Wed, 29 Aug 2012 11:05:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T6jpU-00033N-6o for qemu-devel@nongnu.org; Wed, 29 Aug 2012 11:05:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6jpT-00032z-UQ for qemu-devel@nongnu.org; Wed, 29 Aug 2012 11:05:16 -0400 From: Kevin Wolf Date: Wed, 29 Aug 2012 17:05:07 +0200 Message-Id: <1346252709-5680-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1346252709-5680-1-git-send-email-kwolf@redhat.com> References: <1346252709-5680-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 1/3] qed: refuse unaligned zero writes with a backing file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: 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 Reviewed-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- block/qed.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) 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.6.5