From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Dong Xu Wang <wdongxu@linux.vnet.ibm.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v6] block:add-cow file format
Date: Fri, 6 Jan 2012 08:22:20 +0000 [thread overview]
Message-ID: <20120106082220.GA18074@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <20120105154607.GA6894@amt.cnet>
On Thu, Jan 05, 2012 at 01:46:08PM -0200, Marcelo Tosatti wrote:
> On Thu, Dec 29, 2011 at 05:36:59PM +0800, Dong Xu Wang wrote:
> > From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
> >
> > Introduce a new file format: add-cow. The usage can be found in add-cow.txt of
> > this patch.
> >
> > CC: Kevin Wolf <kwolf@redhat.com>
> > CC: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> > Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
> > ---
> > After applying this patch, qemu might can not compile, need apply this patch first:
> > http://lists.gnu.org/archive/html/qemu-devel/2011-12/msg02527.html
> >
> > Makefile.objs | 1 +
> > block.c | 2 +-
> > block.h | 1 +
> > block/add-cow.c | 429 ++++++++++++++++++++++++++++++++++++++++++++++++
> > block_int.h | 1 +
> > docs/specs/add-cow.txt | 72 ++++++++
> > 6 files changed, 505 insertions(+), 1 deletions(-)
> > create mode 100644 block/add-cow.c
> > create mode 100644 docs/specs/add-cow.txt
> >
>
>
> > + s->bitmap_size = ((bs->total_sectors + 7) >> 3);
> > + s->bitmap = qemu_blockalign(bs, s->bitmap_size);
> > +
> > + ret = bdrv_pread(bs->file, sizeof(header), s->bitmap,
> > + s->bitmap_size);
> > + if (ret != s->bitmap_size) {
> > + goto fail;
> > + }
>
> As noted previously, it is not acceptable to read the entire bitmap in
> memory since it might be very large. A cache, which limits the in-memory
> size of the bitmap, must be created. In the qcow2-cache.c file you can
> find an example (thats for qcow2 metadata cache). You can divide the
> bitmap in chunks of say, 4k, and have:
>
> int is_bit_set(int64_t bitnum, BlockDriverState *bs)
> {
> int64_t bitmap_entry = bitnum >> bits_per_entry;
>
> if (!is_in_bitmap_cache(bs, bitmap_entry))
> read_from_disk(bs, bitmap_entry);
>
> return lookup_bitmap_cache(bs, bitnum);
> }
>
> And then limit the cache to a few megabytes.
>
> Also when setting a bit you must update cache and write
> to disk.
I suspect it's also better to increase the bitmap granularity. The
bitmap should track allocation at a larger "cluster" size like 64 KB.
That way we reduce the number of I/O operations required to update
metadata - it reduces the amount of metadata by a factor of 65536 / 512
= 128.
If you imagine a random write workload with 4 KB block size there is an
advantage to a 64 KB cluster size since later I/Os may require no bitmap
updates where we already allocated a cluster in an earlier operation.
The downside of a larger bitmap granularity is that writes are increased
to 64 KB, but if you run a benchmark I guess there is a threshold around
32 or 64 KB where the reduction in I/O operations makes up for the
larger I/O size. It depends on your disks.
Stefan
next prev parent reply other threads:[~2012-01-06 9:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-29 9:36 [Qemu-devel] [PATCH v6] block:add-cow file format Dong Xu Wang
2011-12-30 14:09 ` Stefan Hajnoczi
2011-12-31 9:17 ` Dong Xu Wang
2012-01-01 16:56 ` Stefan Hajnoczi
2012-01-05 15:46 ` Marcelo Tosatti
2012-01-06 8:22 ` Stefan Hajnoczi [this message]
2012-01-09 5:18 ` Dong Xu Wang
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=20120106082220.GA18074@stefanha-thinkpad.localdomain \
--to=stefanha@linux.vnet.ibm.com \
--cc=kwolf@redhat.com \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wdongxu@linux.vnet.ibm.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).