From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: kwolf@redhat.com, mreitz@redhat.com, den@openvz.org,
vsementsov@virtuozzo.com, andrey.shinkevich@virtuozzo.com
Subject: [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image
Date: Tue, 12 Feb 2019 15:35:51 +0300 [thread overview]
Message-ID: <1549974951-731285-1-git-send-email-andrey.shinkevich@virtuozzo.com> (raw)
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 <andrey.shinkevich@virtuozzo.com>
---
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);
--
1.8.3.1
next reply other threads:[~2019-02-12 12:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 12:35 Andrey Shinkevich [this message]
2019-02-18 15:36 ` [Qemu-devel] [PATCH] Discard old bitmap directories in QCOW2 image Vladimir Sementsov-Ogievskiy
2019-02-27 13:00 ` Max Reitz
2019-02-27 13:16 ` Denis Lunev
2019-02-27 13:25 ` Max Reitz
2019-02-27 15:15 ` Andrey Shinkevich
2019-02-27 15:22 ` Max Reitz
2019-02-27 15:48 ` Andrey Shinkevich
2019-04-01 18:00 ` Max Reitz
2019-04-02 6:52 ` Andrey Shinkevich
2019-02-25 16:30 ` Andrey Shinkevich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1549974951-731285-1-git-send-email-andrey.shinkevich@virtuozzo.com \
--to=andrey.shinkevich@virtuozzo.com \
--cc=den@openvz.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).