qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PULL 39/42] block: look for zero blocks in bs->file


From: Peter Lieven
Subject: Re: [Qemu-devel] [PULL 39/42] block: look for zero blocks in bs->file
Date: Fri, 13 Sep 2013 11:14:08 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8

On 13.09.2013 11:10, Paolo Bonzini wrote:
Il 13/09/2013 11:08, Peter Lieven ha scritto:
On 13.09.2013 10:00, Peter Lieven wrote:
On 06.09.2013 17:39, Stefan Hajnoczi wrote:
From: Paolo Bonzini <address@hidden>

Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
   block.c | 16 +++++++++++++++-
   1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/block.c b/block.c
index 3c39769..a325efc 100644
--- a/block.c
+++ b/block.c
@@ -3075,7 +3075,7 @@ static int64_t coroutine_fn
bdrv_co_get_block_status(BlockDriverState *bs,
   {
       int64_t length;
       int64_t n;
-    int64_t ret;
+    int64_t ret, ret2;
         length = bdrv_getlength(bs);
       if (length < 0) {
@@ -3117,6 +3117,20 @@ static int64_t coroutine_fn
bdrv_co_get_block_status(BlockDriverState *bs,
               }
           }
       }
+
+    if (bs->file &&
+        (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&
+        (ret & BDRV_BLOCK_OFFSET_VALID)) {
+        ret2 = bdrv_co_get_block_status(bs->file, ret >>
BDRV_SECTOR_BITS,
+                                        *pnum, pnum);
+        if (ret2 >= 0) {
+            /* Ignore errors.  This is just providing extra
information, it
+             * is useful but not necessary.
+             */
+            ret |= (ret2 & BDRV_BLOCK_ZERO);
+        }
+    }
+
       return ret;
   }
for allocated blocks in iscsi this actually leads to 2 call outs to
iscsi_get_block_status.

because the raw driver passes the get_block_status request to bs->file.

correct patch?
Correct but a bit hackish... Stefan, Kevin, any ideas?
add a BDRV_BLOCK_RAW flag to the get_block_status flags?



reply via email to

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