From: Charlie Shepherd <charlie@ctshepherd.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kwolf@redhat.com, stefanha@gmail.com, gabriel@kerneis.info,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] Make cow_co_is_allocated and cow_update_bitmap more efficient
Date: Wed, 21 Aug 2013 11:31:05 +0100 [thread overview]
Message-ID: <521496E9.4010901@ctshepherd.com> (raw)
In-Reply-To: <5214861D.6090304@redhat.com>
On 21/08/2013 10:19, Paolo Bonzini wrote:
> Il 21/08/2013 11:11, Charlie Shepherd ha scritto:
>> It still seems
>> worthwhile to me to be as efficient as possible, I guess that means
>> processing a sector's worth of metadata at a time?
> Yes, that's what my patches do. My is_allocated and flushing strategy +
> something like your replacement of cow_set_bit (just without the
> unbounded allocation) should be pretty good.
>
> Perhaps you can use a cow_co_is_allocated loop after writing the data.
> If it returns 0, you flush (the first time only) and call your
> cow_update_bitmap. Then you advance by num_same sectors and go on until
> you did all the nb_sectors. The disadvantage is that it does two reads
> (one in cow_co_is_allocated, one in cow_update_bitmap). The advantage
> is that unbounded allocation goes away because cow_co_is_allocated will
> never consider more than a sector of bitmap data. And you can reuse all
> your cow_update_bitmap code.
Agreed. But can the two functions not share the same read data? As in:
cow_is_allocated(char *buf) {
return test_bits(buf)
}
cow_co_is_allocated(Bdrv *b) {
char sector[SECTOR_SIZE]
bdrv_read(b, sector, sector_num)
return cow_is_allocated(sector)
}
cow_update_bitmap(Bdrv *b) {
while (sector) {
char buf[SECTOR_SIZE]
bdrv_read(b, buf, sector_num)
if (cow_is_allocated(buf)) {
if (!flushed)
bdrv_flush()
cow_update_bitmap_sector(buf)
bdrv_write(buf)
}
}
}
> To be as efficient as possible, you could keep a memory copy of the
> bitmap, so that you only have to do writes, not reads. The memory copy
> would be somewhat expensive of course but perhaps reasonable (256M of
> memory for a 1T image). The largest cost would be loading the bitmap
> from memory at startup. But that can be done later.
Yes I considered that option too. I guess it can be considered as
another patch, with the performance implicated measured against the
results of this patch.
Charlie
next prev parent reply other threads:[~2013-08-21 10:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 18:34 [Qemu-devel] [PATCH 1/2] Make cow_co_is_allocated and cow_update_bitmap more efficient Charlie Shepherd
2013-08-20 18:37 ` Charlie Shepherd
2013-08-20 20:48 ` Paolo Bonzini
2013-08-20 22:53 ` Charlie Shepherd
2013-08-21 8:14 ` Paolo Bonzini
2013-08-21 9:11 ` Charlie Shepherd
2013-08-21 9:19 ` Paolo Bonzini
2013-08-21 10:31 ` Charlie Shepherd [this message]
2013-08-21 10:38 ` Paolo Bonzini
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=521496E9.4010901@ctshepherd.com \
--to=charlie@ctshepherd.com \
--cc=gabriel@kerneis.info \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.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 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.