]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
file-posix, gluster: Handle zero block status hint better
authorEric Blake <eblake@redhat.com>
Fri, 9 May 2025 20:40:19 +0000 (15:40 -0500)
committerEric Blake <eblake@redhat.com>
Wed, 14 May 2025 20:49:27 +0000 (15:49 -0500)
Although the previous patch to change 'bool want_zero' into a bitmask
made no semantic change, it is now time to differentiate.  When the
caller specifically wants to know what parts of the file read as zero,
we need to use lseek and actually reporting holes, rather than
short-circuiting and advertising full allocation.

This change will be utilized in later patches to let mirroring
optimize for the case when the destination already reads as zeroes.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20250509204341.3553601-17-eblake@redhat.com>

block/file-posix.c
block/gluster.c

index 805a1a2949b9fa5a03ce10a48c8d49cbe5149eff..ec95b748696b3c6cbdbdbbaa2f4c1fd05724955b 100644 (file)
@@ -3289,7 +3289,8 @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs,
         return ret;
     }
 
-    if (mode != BDRV_WANT_PRECISE) {
+    if (!(mode & BDRV_WANT_ZERO)) {
+        /* There is no backing file - all bytes are allocated in this file.  */
         *pnum = bytes;
         *map = offset;
         *file = bs;
index 1a2ef53e9b0389315c1e1776d2d4e1facc1fa71d..89abd40f313608727723ff199f0efc6246a9a9fb 100644 (file)
@@ -1478,7 +1478,7 @@ static int coroutine_fn qemu_gluster_co_block_status(BlockDriverState *bs,
         return ret;
     }
 
-    if (mode != BDRV_WANT_PRECISE) {
+    if (!(mode & BDRV_WANT_ZERO)) {
         *pnum = bytes;
         *map = offset;
         *file = bs;