qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: lirans@il.ibm.com
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3 v4] Expose a mechanisem to trace block writes
Date: Wed, 21 Oct 2009 13:21:09 -0500	[thread overview]
Message-ID: <4ADF5115.2010603@codemonkey.ws> (raw)
In-Reply-To: <12553646173152-git-send-email-lirans@il.ibm.com>

Hi Liran,

lirans@il.ibm.com wrote:
> To support live migration without shared storage we need to be able to trace
> writes to disk while migrating. This Patch expose handler registration for 
> above components to be notified about block writes.
>
> diff --git a/block.c b/block.c
> index 33f3d65..bf5f7a6 100644
> --- a/block.c
> +++ b/block.c
> @@ -61,6 +61,8 @@ BlockDriverState *bdrv_first;
>  
>  static BlockDriver *first_drv;
>  
> +static BlockDriverDirtyHandler *bdrv_dirty_handler = NULL;
> +
>   

Should be a property of a BlockDriverState.  IOW, we should register a 
dirty callback for each block device we're interested in.

>  int path_is_absolute(const char *path)
>  {
>      const char *p;
> @@ -626,6 +628,10 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num,
>      if (bdrv_check_request(bs, sector_num, nb_sectors))
>          return -EIO;
>  
> +    if(bdrv_dirty_handler != NULL) {
> +      bdrv_dirty_handler(bs, sector_num, nb_sectors);
> +    }
> +    
>      return drv->bdrv_write(bs, sector_num, buf, nb_sectors);
>  }
>   

CodingStyle seems off.

We have to be careful in these cases to check for whether we're dealing 
with BDRV_FILE.  In the case of something like qcow2, you would get two 
dirty callbacks as this code stands.  The first would be what the guest 
actually writes and then the second (and potentially third) would be 
qcow2 metadata updates along with writing the actual data to disk.

In terms of an interface, I think it would be better to register a 
bitmap and to poll the block driver periodically to see which bits have 
changed.  This is how ram dirty tracking works and I think keeping these 
interfaces consistent is a good thing.

I'd suggest tracking dirtiness in relatively large chunks (at least 2MB).

>  
> @@ -1359,6 +1370,10 @@ BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
>      if (bdrv_check_request(bs, sector_num, nb_sectors))
>          return NULL;
>  
> +    if(bdrv_dirty_handler != NULL) {
> +      bdrv_dirty_handler(bs, sector_num, nb_sectors);
> +    }
> +    
>      ret = drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sectors,
>                                 cb, opaque);
>   

The check should be in the completion callback as AIO requests can be 
canceled.  You're potentially giving a false positive.

Regards,

Anthony Liguori

  reply	other threads:[~2009-10-21 18:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-12 16:23 [Qemu-devel] [PATCH 1/3 v4] Expose a mechanisem to trace block writes lirans
2009-10-21 18:21 ` Anthony Liguori [this message]
2009-10-22 11:01   ` Liran Schour
  -- strict thread matches above, loose matches on Subject: below --
2009-10-12 15:08 lirans
2009-10-12 15:08 lirans

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=4ADF5115.2010603@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=lirans@il.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /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).