From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel <qemu-devel@nongnu.org>,
qemu-block@nongnu.org, nbd-general@lists.sourceforge.net
Cc: kwolf@redhat.com, "Denis V. Lunev" <den@openvz.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Eric Blake <eblake@redhat.com>, Wouter Verhelst <w@uter.be>
Subject: [Qemu-devel] write_zeroes/trim on the whole disk
Date: Fri, 23 Sep 2016 21:32:12 +0300 [thread overview]
Message-ID: <57E5752C.3080407@virtuozzo.com> (raw)
Hi all!
There is a following problem. When we need to write_zeroes or trim the
whole disk, we have to do it iteratively, because of 32-bit restriction
on request length.
For example, current implementation of mirror (see mirror_dirty_init())
do this by chunks of 2147418112 bytes (with default granularity of
65536). So, to zero 16tb disk we will make 8192 requests instead of one.
Incremental zeroing of 1tb qcow2 takes > 80 seconds for me (see below).
This means ~20 minutes for copying empty 16tb qcow2 disk which is
obviously a waste of time.
We see the following solutions for nbd:
||
1. Add command NBD_MAKE_EMPTY, with flag, saying what should be done:
trim or write_zeroes.
2. Add flag NBD_CMD_FLAG_WHOLE for commands NBD_TRIM and
NBD_WRITE_ZEROES, which will say (with zeroed offset and lenght of the
request), that the whole disk should be discarded/zeroed.
3. Increase length field of the request to 64bit.
As soon as we have some way to empty disk in nbd, we can use
qcow2_make_empty, to trim the whole disk (and something similar should
be done for zeroing).
What do you think about this all, and which way has a chance to get into
nbd proto?
== test incremental qcow2 zeroing in mirror ==
1. enable it. If we will use nbd, it will be enabled.
diff --git a/block/mirror.c b/block/mirror.c
index f9d1fec..4ac0c39 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -556,7 +556,7 @@ static int coroutine_fn
mirror_dirty_init(MirrorBlockJob *s)
end = s->bdev_length / BDRV_SECTOR_SIZE;
- if (base == NULL && !bdrv_has_zero_init(target_bs)) {
+ if (base == NULL) {
if (!bdrv_can_write_zeroes_with_unmap(target_bs)) {
bdrv_set_dirty_bitmap(s->dirty_bitmap, 0, end);
return 0;
==== test ====
qemu-img create -f qcow2 /tmp/1tb.qcow2 1T
virsh start backup-vm --paused
Domain backup-vm started
virsh qemu-monitor-command backup-vm
{"execute":"blockdev-add","arguments":{"options": {"aio": "native",
"file": {"driver": "file", "filename": "/tmp/1tb.qcow2"}, "discard":
"unmap", "cache": {"direct": true}, "driver": "qcow2", "id": "disk"}}}
{"return":{},"id":"libvirt-32"}
/usr/bin/time -f '%e seconds' sh -c 'virsh qemu-monitor-event' &
virsh qemu-monitor-command backup-vm
{"execute":"drive-mirror","arguments":{"device": "disk", "sync": "full",
"target": "/tmp/targ"}}
{"return":{},"id":"libvirt-33"}
[root@kvm qemu]# event BLOCK_JOB_READY at 1474652677.668624 for domain
backup-vm:
{"device":"disk","len":1099511627776,"offset":1099511627776,"speed":0,"type":"mirror"}
events received: 1
86.39 seconds
- the same for 2tb empty disk: 180.19 seconds
- and without patch, it takes < 1 second, of course.
--
Best regards,
Vladimir
next reply other threads:[~2016-09-23 18:32 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 18:32 Vladimir Sementsov-Ogievskiy [this message]
2016-09-23 19:00 ` [Qemu-devel] write_zeroes/trim on the whole disk Eric Blake
2016-09-23 21:21 ` Wouter Verhelst
2016-09-24 7:54 ` Denis V. Lunev
2016-09-24 10:31 ` [Qemu-devel] [Nbd] " Alex Bligh
2016-09-24 22:07 ` Wouter Verhelst
2016-09-24 12:06 ` [Qemu-devel] " Vladimir Sementsov-Ogievskiy
2016-09-24 12:27 ` Vladimir Sementsov-Ogievskiy
2016-09-26 8:47 ` Kevin Wolf
2016-09-26 12:49 ` Paolo Bonzini
2016-09-24 13:42 ` Vladimir Sementsov-Ogievskiy
2016-09-24 16:20 ` Vladimir Sementsov-Ogievskiy
2016-09-24 16:35 ` Alex Bligh
2016-09-24 16:44 ` Vladimir Sementsov-Ogievskiy
2016-09-24 16:48 ` Vladimir Sementsov-Ogievskiy
2016-09-24 16:52 ` Alex Bligh
2016-09-24 17:01 ` Alex Bligh
2016-09-24 16:31 ` Alex Bligh
2016-09-24 16:42 ` Vladimir Sementsov-Ogievskiy
2016-09-24 16:49 ` Alex Bligh
2016-09-24 17:13 ` Vladimir Sementsov-Ogievskiy
2016-09-24 17:32 ` Alex Bligh
2016-09-24 17:47 ` Vladimir Sementsov-Ogievskiy
2016-09-24 18:24 ` Alex Bligh
2016-09-24 20:19 ` Vladimir Sementsov-Ogievskiy
2016-09-24 22:30 ` Wouter Verhelst
2016-09-24 17:33 ` Vladimir Sementsov-Ogievskiy
2016-09-24 20:14 ` [Qemu-devel] [Nbd] " Carl-Daniel Hailfinger
2016-09-24 20:32 ` Vladimir Sementsov-Ogievskiy
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=57E5752C.3080407@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=den@openvz.org \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=nbd-general@lists.sourceforge.net \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=w@uter.be \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.