qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, uril@redhat.com
Subject: [Qemu-devel] [PATCH 1/3] block-qcow2: keep highest allocated offset
Date: Tue,  9 Mar 2010 19:53:34 -0300	[thread overview]
Message-ID: <1268175216-3600-2-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1268175216-3600-1-git-send-email-lcapitulino@redhat.com>

From: Uri Lublin <uril@redhat.com>

We want to know the highest allocated offset for qcow2 images.

It can be useful for allocating more diskspace for an image
(e.g. an lvm logical volume) before we run out-of-disk-space.

In this version image refcount table is not scanned.
Also highest-alloc is not kept when the process exits.
Thus it only keeps the highest offset of the current run.

Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 block/qcow2-refcount.c |    3 +++
 block/qcow2.c          |    2 ++
 block/qcow2.h          |    3 +++
 3 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 917fc88..9cb38c8 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -550,6 +550,9 @@ retry:
             size,
             (s->free_cluster_index - nb_clusters) << s->cluster_bits);
 #endif
+    if (s->highest_alloc < s->free_cluster_index) {
+        s->highest_alloc = s->free_cluster_index;
+    }
     return (s->free_cluster_index - nb_clusters) << s->cluster_bits;
 }
 
diff --git a/block/qcow2.c b/block/qcow2.c
index 5b6dad9..d9af90b 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -230,6 +230,8 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
     if (qcow_read_extensions(bs, sizeof(header), ext_end))
         goto fail;
 
+    s->highest_alloc = 0;
+
     /* read the backing file name */
     if (header.backing_file_offset != 0) {
         len = header.backing_file_size;
diff --git a/block/qcow2.h b/block/qcow2.h
index de9397a..6cc50e6 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -112,6 +112,9 @@ typedef struct BDRVQcowState {
     uint32_t crypt_method_header;
     AES_KEY aes_encrypt_key;
     AES_KEY aes_decrypt_key;
+
+    int64_t highest_alloc; /* highest cluester allocated (in clusters) */
+
     uint64_t snapshots_offset;
     int snapshots_size;
     int nb_snapshots;
-- 
1.7.0.1

  reply	other threads:[~2010-03-09 22:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-09 22:53 [Qemu-devel] [PATCH 0/3]: BLOCK_WATERMARK QMP event Luiz Capitulino
2010-03-09 22:53 ` Luiz Capitulino [this message]
2010-03-09 22:53 ` [Qemu-devel] [PATCH 2/3] monitor: Introduce block_watermark command Luiz Capitulino
2010-03-09 22:53 ` [Qemu-devel] [PATCH 3/3] QMP: Introduce BLOCK_WATERMARK event Luiz Capitulino
2010-03-09 23:03 ` [Qemu-devel] [PATCH 0/3]: BLOCK_WATERMARK QMP event Anthony Liguori
2010-03-09 23:18   ` Luiz Capitulino
2010-03-09 23:08 ` Anthony Liguori
2010-03-09 23:22   ` Luiz Capitulino
2010-03-09 23:25     ` Luiz Capitulino
2010-03-09 23:55       ` Anthony Liguori
2010-03-10 21:02         ` Luiz Capitulino
2010-03-09 23:46     ` Anthony Liguori
2010-03-10  8:40   ` Kevin Wolf
2010-03-10 21:09     ` Luiz Capitulino
2010-03-10 21:20     ` Anthony Liguori
2010-03-11  8:34       ` Kevin Wolf
2010-03-11 14:19         ` Anthony Liguori
2010-03-11 14:58           ` Avi Kivity
2010-03-11 15:07             ` Anthony Liguori
2010-03-11 15:09               ` Avi Kivity
2010-03-11 16:16           ` Kevin Wolf
2010-03-10  8:33 ` [Qemu-devel] " Kevin Wolf
2010-03-10  9:28   ` Christoph Hellwig
2010-03-10 21:11     ` Luiz Capitulino

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=1268175216-3600-2-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=uril@redhat.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).