qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] block: Fix bdrv_is_allocated() for short backing files
Date: Wed, 7 May 2014 10:31:12 +0200	[thread overview]
Message-ID: <20140507083112.GC4045@noname.str.redhat.com> (raw)
In-Reply-To: <53693DD0.40107@redhat.com>

Am 06.05.2014 um 21:53 hat Max Reitz geschrieben:
> On 06.05.2014 15:30, Kevin Wolf wrote:
> >bdrv_is_allocated() shouldn't return true for sectors that are
> >unallocated, but after the end of a short backing file, even though
> >such sectors are (correctly) marked as containing zeros.
> >
> >Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> >---
> >  block.c               |  8 +++++---
> >  include/block/block.h | 11 +++++++----
> >  2 files changed, 12 insertions(+), 7 deletions(-)
> >
> >diff --git a/block.c b/block.c
> >index c90c71a..d3a9906 100644
> >--- a/block.c
> >+++ b/block.c
> >@@ -3883,6 +3883,10 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
> >                                       *pnum, pnum);
> >      }
> >+    if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {
> >+        ret |= BDRV_BLOCK_ALLOCATED;
> >+    }
> >+
> 
> Shouldn't BDRV_BLOCK_ALLOCATED be set in the
> !bs->drv->bdrv_co_get_block_status case as well?

It should. Thanks, I'll send a v2.

> >      if (!(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO)) {
> >          if (bdrv_unallocated_blocks_are_zero(bs)) {
> >              ret |= BDRV_BLOCK_ZERO;
> >@@ -3959,9 +3963,7 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num,
> >      if (ret < 0) {
> >          return ret;
> >      }
> >-    return
> >-        (ret & BDRV_BLOCK_DATA) ||
> >-        ((ret & BDRV_BLOCK_ZERO) && !bdrv_has_zero_init(bs));
> >+    return (ret & BDRV_BLOCK_ALLOCATED);
> >  }
> >  /*
> >diff --git a/include/block/block.h b/include/block/block.h
> >index 2fda81c..ad4c7e8 100644
> >--- a/include/block/block.h
> >+++ b/include/block/block.h
> >@@ -116,6 +116,8 @@ typedef enum {
> >  /* BDRV_BLOCK_DATA: data is read from bs->file or another file
> >   * BDRV_BLOCK_ZERO: sectors read as zero
> >   * BDRV_BLOCK_OFFSET_VALID: sector stored in bs->file as raw data
> >+ * BDRV_BLOCK_ALLOCATED: the content of the block is determined by this
> >+ *                       layer (as opposed to the backing file)
> 
> I guess this is above BDRV_BLOCK_RAW (albeit having a greater value)
> because it is not only used internally? (to pick up on the topic of
> OCD :-P)

Because it felt right. This may or may not be equivalent.

Kevin

      reply	other threads:[~2014-05-07  8:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-06 13:30 [Qemu-devel] [PATCH] block: Fix bdrv_is_allocated() for short backing files Kevin Wolf
2014-05-06 15:23 ` Paolo Bonzini
2014-05-06 19:53 ` Max Reitz
2014-05-07  8:31   ` Kevin Wolf [this message]

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=20140507083112.GC4045@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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).