[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image |
Date: |
Mon, 18 Feb 2019 15:36:33 +0000 |
12.02.2019 15:35, Andrey Shinkevich wrote:
> Clean QCOW2 image from bitmap obsolete directory when a new one
> is allocated and stored. It slows down the image growth a little bit.
> The flag QCOW2_DISCARD_ALWAYS allows a call to raw_co_pdiscard()
> that does the actual cleaning of the image on disk.
> With the flag QCOW2_DISCARD_OTHER, a reference count of the cluster
> is updated only.
>
> Signed-off-by: Andrey Shinkevich <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
side question: should not we change discard_passthrough[QCOW2_DISCARD_OTHER] to
true or at least flags&BDRV_O_UNMAP by default? What is the reason of not
discarding
things in qcow2-cluster?
> ---
> block/qcow2-bitmap.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
> index b946301..682cb09 100644
> --- a/block/qcow2-bitmap.c
> +++ b/block/qcow2-bitmap.c
> @@ -202,7 +202,7 @@ static void clear_bitmap_table(BlockDriverState *bs,
> uint64_t *bitmap_table,
> continue;
> }
>
> - qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_OTHER);
> + qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_ALWAYS);
> bitmap_table[i] = 0;
> }
> }
> @@ -257,7 +257,7 @@ static int free_bitmap_clusters(BlockDriverState *bs,
> Qcow2BitmapTable *tb)
>
> clear_bitmap_table(bs, bitmap_table, tb->size);
> qcow2_free_clusters(bs, tb->offset, tb->size * sizeof(uint64_t),
> - QCOW2_DISCARD_OTHER);
> + QCOW2_DISCARD_ALWAYS);
> g_free(bitmap_table);
>
> tb->offset = 0;
> @@ -801,7 +801,7 @@ fail:
> g_free(dir);
>
> if (!in_place && dir_offset > 0) {
> - qcow2_free_clusters(bs, dir_offset, dir_size, QCOW2_DISCARD_OTHER);
> + qcow2_free_clusters(bs, dir_offset, dir_size, QCOW2_DISCARD_ALWAYS);
> }
>
> return ret;
> @@ -904,14 +904,14 @@ static int update_ext_header_and_dir(BlockDriverState
> *bs,
> }
>
> if (old_size > 0) {
> - qcow2_free_clusters(bs, old_offset, old_size, QCOW2_DISCARD_OTHER);
> + qcow2_free_clusters(bs, old_offset, old_size, QCOW2_DISCARD_ALWAYS);
> }
>
> return 0;
>
> fail:
> if (new_offset > 0) {
> - qcow2_free_clusters(bs, new_offset, new_size, QCOW2_DISCARD_OTHER);
> + qcow2_free_clusters(bs, new_offset, new_size, QCOW2_DISCARD_ALWAYS);
> }
>
> s->bitmap_directory_offset = old_offset;
> @@ -1242,7 +1242,7 @@ fail:
>
> if (tb_offset > 0) {
> qcow2_free_clusters(bs, tb_offset, tb_size * sizeof(tb[0]),
> - QCOW2_DISCARD_OTHER);
> + QCOW2_DISCARD_ALWAYS);
> }
>
> g_free(tb);
>
--
Best regards,
Vladimir
- [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image, Andrey Shinkevich, 2019/02/12
- Re: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image,
Vladimir Sementsov-Ogievskiy <=
- Re: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image, Max Reitz, 2019/02/27
- Re: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image, Denis Lunev, 2019/02/27
- Re: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image, Max Reitz, 2019/02/27
- Re: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image, Andrey Shinkevich, 2019/02/27
- Re: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image, Max Reitz, 2019/02/27
- Re: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image, Andrey Shinkevich, 2019/02/27
Re: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image, Andrey Shinkevich, 2019/02/25