Skip to contentSkip to conversation

qcow2: Return the original error code in qcow2_co_pwrite_zeroes()

PATCH Applied Alberto Garcia 5 participants 5 messages Sep 9, 2020 – Sep 11, 2020 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qcow2: Return the original error code in qcow2_co_pwrite_zeroes()

This function checks the current status of a (sub)cluster in order to see if an unaligned 'write zeroes' request can be done efficiently by simply updating the L2 metadata and without having to write actual zeroes to disk.

If the situation does not allow using the fast path then the function returns -ENOTSUP and the caller falls back to writing zeroes.

If can happen however that the aforementioned check returns an actual error code so in this case we should pass it to the caller.

---
 block/qcow2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2.c +1 -1
index da56b1a4df..ca46cbd795 100644
@@ -3916,7 +3916,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs,
              type != QCOW2_SUBCLUSTER_ZERO_PLAIN &&
              type != QCOW2_SUBCLUSTER_ZERO_ALLOC)) {
             qemu_co_mutex_unlock(&s->lock);
-            return -ENOTSUP;
+            return ret < 0 ? ret : -ENOTSUP;
         }
     } else {
         qemu_co_mutex_lock(&s->lock);
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Alberto Garcia

This function checks the current status of a (sub)cluster in order to see if an unaligned 'write zeroes' request can be done efficiently by simply updating the L2 metadata and without having to write actual zeroes to disk.

If the situation does not allow using the fast path then the function returns -ENOTSUP and the caller falls back to writing zeroes.

Quoted 7 lines

If can happen however that the aforementioned check returns an actual error code so in this case we should pass it to the caller.

---
  block/qcow2.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 1/1
#2 lore raw
In reply to Alberto Garcia
Quoted 22 lines · Alberto Garcia

This function checks the current status of a (sub)cluster in order to see if an unaligned 'write zeroes' request can be done efficiently by simply updating the L2 metadata and without having to write actual zeroes to disk.

If the situation does not allow using the fast path then the function returns -ENOTSUP and the caller falls back to writing zeroes.

If can happen however that the aforementioned check returns an actual error code so in this case we should pass it to the caller.

---
 block/qcow2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2.c +0 -0
index da56b1a4df..ca46cbd795 100644

block/qcow2.c static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, · line 3922

Quoted 8 lines
block/qcow2.c +1 -1
@@ -3916,7 +3916,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs,
              type != QCOW2_SUBCLUSTER_ZERO_PLAIN &&
              type != QCOW2_SUBCLUSTER_ZERO_ALLOC)) {
             qemu_co_mutex_unlock(&s->lock);
-            return -ENOTSUP;
+            return ret < 0 ? ret : -ENOTSUP;
         }
     } else {
         qemu_co_mutex_lock(&s->lock);
Reviewed-by on v1 1/1
#3 lore raw
In reply to Alberto Garcia

Am 09.09.2020 um 14:37 hat Alberto Garcia geschrieben:

Quoted 5 lines

This function checks the current status of a (sub)cluster in order to see if an unaligned 'write zeroes' request can be done efficiently by simply updating the L2 metadata and without having to write actual zeroes to disk.

Quoted 7 lines

If the situation does not allow using the fast path then the function returns -ENOTSUP and the caller falls back to writing zeroes.

If can happen however that the aforementioned check returns an actual error code so in this case we should pass it to the caller.

Applied
#4 lore raw
In reply to Alberto Garcia
Quoted 8 lines · Alberto Garcia

This function checks the current status of a (sub)cluster in order to see if an unaligned 'write zeroes' request can be done efficiently by simply updating the L2 metadata and without having to write actual zeroes to disk.

If the situation does not allow using the fast path then the function returns -ENOTSUP and the caller falls back to writing zeroes.

Quoted 7 lines

If can happen however that the aforementioned check returns an actual error code so in this case we should pass it to the caller.

---
 block/qcow2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, applied to my block branch:

https://git.xanclic.moe/XanClic/qemu/commits/branch/block