All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Hanna Reitz <hreitz@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
	Kevin Wolf <kwolf@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH 4/4] block/file: Add file-specific image info
Date: Tue, 3 May 2022 13:50:47 -0500	[thread overview]
Message-ID: <20220503185047.4w4ulpdrzn2wbpdq@redhat.com> (raw)
In-Reply-To: <20220503145529.37070-5-hreitz@redhat.com>

On Tue, May 03, 2022 at 04:55:29PM +0200, Hanna Reitz wrote:
> Add some (optional) information that the file driver can provide for
> image files, namely the extent size.
> 
> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
> ---
>  qapi/block-core.json | 26 ++++++++++++++++++++++++--
>  block/file-posix.c   | 30 ++++++++++++++++++++++++++++++
>  2 files changed, 54 insertions(+), 2 deletions(-)
> 

> +++ b/block/file-posix.c
> @@ -3068,6 +3068,34 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
>      return 0;
>  }
>  
> +static ImageInfoSpecific *raw_get_specific_info(BlockDriverState *bs,
> +                                                Error **errp)
> +{
> +    BDRVRawState *s = bs->opaque;
> +    ImageInfoSpecificFile *file_info = g_new0(ImageInfoSpecificFile, 1);
> +    ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1);
> +
> +    *spec_info = (ImageInfoSpecific){
> +        .type = IMAGE_INFO_SPECIFIC_KIND_FILE,
> +        .u.file.data = file_info,
> +    };
> +
> +#ifdef FS_IOC_FSGETXATTR
> +    {
> +        struct fsxattr attr;
> +        int ret;
> +
> +        ret = ioctl(s->fd, FS_IOC_FSGETXATTR, &attr);
> +        if (!ret && attr.fsx_extsize != 0) {
> +            file_info->has_extent_size = true;
> +            file_info->extent_size = attr.fsx_extsize;
> +        }
> +    }
> +#endif

Can/should we fall back to stat's st_blksize when the ioctl produces
nothing?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



  reply	other threads:[~2022-05-03 18:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-03 14:55 [PATCH 0/4] block/file: Show extent size in qemu-img info Hanna Reitz
2022-05-03 14:55 ` [PATCH 1/4] block: Improve empty format-specific info dump Hanna Reitz
2022-05-03 18:44   ` Eric Blake
2022-05-04  8:18   ` Kevin Wolf
2022-05-03 14:55 ` [PATCH 2/4] block: Add protocol-specific image info Hanna Reitz
2022-05-03 18:47   ` Eric Blake
2022-05-04  8:36   ` Kevin Wolf
2022-05-04 11:25     ` Hanna Reitz
2022-05-03 14:55 ` [PATCH 3/4] block: Print protocol-specific information Hanna Reitz
2022-05-03 18:48   ` Eric Blake
2022-05-03 14:55 ` [PATCH 4/4] block/file: Add file-specific image info Hanna Reitz
2022-05-03 18:50   ` Eric Blake [this message]
2022-05-04  7:10     ` Hanna Reitz
2022-05-04  8:46   ` Kevin Wolf
2022-05-04 11:26     ` Hanna Reitz

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=20220503185047.4w4ulpdrzn2wbpdq@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.