[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/4] block: add image fragmentation statistics t
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH 1/4] block: add image fragmentation statistics to qemu-img |
Date: |
Mon, 12 Mar 2012 13:07:17 +0000 |
On Wed, Mar 7, 2012 at 9:22 AM, Dong Xu Wang <address@hidden> wrote:
> From: Dong Xu Wang <address@hidden>
>
> Discussion can be found at:
> http://patchwork.ozlabs.org/patch/128730/
>
> This patch add image fragmentation statistics while using qemu-img info.
>
> Signed-off-by: Dong Xu Wang <address@hidden>
> ---
> block.c | 13 +++++++++++++
> block.h | 7 +++++++
> block_int.h | 1 +
> qemu-img.c | 9 +++++++++
> 4 files changed, 30 insertions(+), 0 deletions(-)
>
> diff --git a/block.c b/block.c
> index 52ffe14..947607b 100644
> --- a/block.c
> +++ b/block.c
> @@ -2588,6 +2588,19 @@ int bdrv_get_info(BlockDriverState *bs,
> BlockDriverInfo *bdi)
> return drv->bdrv_get_info(bs, bdi);
> }
>
> +int bdrv_get_fragment(BlockDriverState *bs, BlockFragInfo *bfi)
bdrv_get_fraginfo() makes it clearer that this function gets a summary
of fragmentation information. bdrv_get_fragment() makes me think it
gets one specific "fragment".
> +{
> + BlockDriver *drv = bs->drv;
> + if (!drv) {
> + return -ENOMEDIUM;
> + }
> + if (!drv->bdrv_get_fragment) {
> + return -ENOTSUP;
> + }
> + memset(bfi, 0, sizeof(*bfi));
> + return drv->bdrv_get_fragment(bs, bfi);
For now this .drv_get_fraginfo() interface makes sense but if we merge
the QCOW2<->QED in-place conversion patch series in the future it will
be possible to implement this in a generic way because image formats
will expose their guest -> host mapping.
> @@ -1126,6 +1127,14 @@ static int img_info(int argc, char **argv)
> printf("cluster_size: %d\n", bdi.cluster_size);
> }
> }
> + if (bdrv_get_fragment(bs, &bfi) >= 0) {
I think we need a separate sub-command for fragmentation info:
qemu-img fraginfo <image-file>
Utilities that invoke qemu-img info want it to be fast. Reading all
metadata from a large image can take several seconds. Since many
qemu-img info users don't need to see the fragmentation information,
it makes sense to put it in a new sub-command.
> + if (bfi.total_clusters != 0 && bfi.allocated_clusters != 0) {
> + printf("%lld/%lld = %0.2f%% allocated, %0.2f%% fragmented\n",
Please use the PRId64 macro instead of %lld because some compilers
warn when uint64_t is not typedefed to long long int.
Stefan
Re: [Qemu-devel] [PATCH 1/4] block: add image fragmentation statistics to qemu-img,
Stefan Hajnoczi <=