Patchwork qcow2: Remove abort on free_clusters failure

login
register
mail settings
Submitter Kevin Wolf
Date April 27, 2010, 10:35 a.m.
Message ID <1272364518-9386-1-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/51047/
State New
Headers show

Comments

Kevin Wolf - April 27, 2010, 10:35 a.m.
While it's true that during regular operation free_clusters failure would be a
bug, an I/O error can always happen. There's no need to kill the VM, the worst
thing that can happen (and it will) is that we leak some clusters.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qcow2-refcount.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Stefan Hajnoczi - April 27, 2010, 12:52 p.m.
On Tue, Apr 27, 2010 at 11:35 AM, Kevin Wolf <kwolf@redhat.com> wrote:
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -638,7 +638,7 @@ void qcow2_free_clusters(BlockDriverState *bs,
>     ret = update_refcount(bs, offset, size, -1);
>     if (ret < 0) {
>         fprintf(stderr, "qcow2_free_clusters failed: %s\n", strerror(-ret));
> -        abort();
> +        /* TODO Remember the clusters to free them later and avoid leaking */
>     }
>  }

Has there been discussion on a fix mode for qemu-img check?  For qcow2
it could write new refcounts, calculated by traversing the L1/L2
tables of the image and snapshots.  Perhaps it would also dump out the
orphaned clusters to a lost+found.

Stefan
Kevin Wolf - April 27, 2010, 12:56 p.m.
Am 27.04.2010 14:52, schrieb Stefan Hajnoczi:
> On Tue, Apr 27, 2010 at 11:35 AM, Kevin Wolf <kwolf@redhat.com> wrote:
>> --- a/block/qcow2-refcount.c
>> +++ b/block/qcow2-refcount.c
>> @@ -638,7 +638,7 @@ void qcow2_free_clusters(BlockDriverState *bs,
>>     ret = update_refcount(bs, offset, size, -1);
>>     if (ret < 0) {
>>         fprintf(stderr, "qcow2_free_clusters failed: %s\n", strerror(-ret));
>> -        abort();
>> +        /* TODO Remember the clusters to free them later and avoid leaking */
>>     }
>>  }
> 
> Has there been discussion on a fix mode for qemu-img check?  For qcow2
> it could write new refcounts, calculated by traversing the L1/L2
> tables of the image and snapshots.  Perhaps it would also dump out the
> orphaned clusters to a lost+found.

No real discussion, but it's somewhere among the low priority tasks on
my todo list. So I agree this would make sense, at least for the trivial
errors.

Another thing I was considering is to distinguish between errors and
warnings in qemu-img check. I keep getting reports about image
corruption which turn out to be just some leaked clusters because they
killed their qemu process at some point.

Kevin

Patch

diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 95491d3..744107c 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -638,7 +638,7 @@  void qcow2_free_clusters(BlockDriverState *bs,
     ret = update_refcount(bs, offset, size, -1);
     if (ret < 0) {
         fprintf(stderr, "qcow2_free_clusters failed: %s\n", strerror(-ret));
-        abort();
+        /* TODO Remember the clusters to free them later and avoid leaking */
     }
 }