qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-1.2] qed: refuse unaligned zero writes with


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH for-1.2] qed: refuse unaligned zero writes with a backing file
Date: Tue, 28 Aug 2012 15:25:16 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0

Il 28/08/2012 15:04, Stefan Hajnoczi ha scritto:
> 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.

Reviewed-by: Paolo Bonzini <address@hidden>

Makes sense since both streaming and copy-on-read will do cluster-aligned 
writes.

The "right fix" would not be much more complex though, something like this, 
right?
(untested).

diff --git a/block/qed.c b/block/qed.c
index a02dbfd..a885671 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1133,8 +1133,14 @@ static void qed_aio_write_alloc(QEDAIOCB *acb, size_t 
len)
             return;
         }
 
+        if (qed_offset_into_cluster(s, acb->cur_pos) != 0 ||
+            qed_offset_into_cluster(s, acb->cur_pos + acb->cur_qiov.size) != 
0) {
+            goto copy;
+        }
+
         cb = qed_aio_write_zero_cluster;
     } else {
+copy:
         cb = qed_aio_write_prefill;
         acb->cur_cluster = qed_alloc_clusters(s, acb->cur_nclusters);
     }

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]