summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-08-28 14:04:27 +0100
committerDoug Goldstein <cardoe@cardoe.com>2012-11-21 15:25:32 -0600
commite076697bd2761461d29612c0d6be4237a054769a (patch)
tree6ccd6fc21ed5010a8ec8a03b4c64437ff420429f
parentlinux-user: fix emulation of getdents (diff)
downloadqemu-kvm-e076697bd2761461d29612c0d6be4237a054769a.tar.gz
qemu-kvm-e076697bd2761461d29612c0d6be4237a054769a.tar.bz2
qemu-kvm-e076697bd2761461d29612c0d6be4237a054769a.zip
qed: refuse unaligned zero writes with a backing file
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 <stefanha@linux.vnet.ibm.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> (cherry picked from commit ef72f76e58107bd4096018c3db2912d28249308e)
-rw-r--r--block/qed.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/block/qed.c b/block/qed.c
index 30a31f907..49ac93e84 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1370,10 +1370,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.
*/