[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCHv2] Added xfs support to vfs_minimum_size.



On Tue, Oct 27, 2015 at 06:20:45PM +0300, Maxim Perevedentsev wrote:
> ---
>  daemon/daemon.h      |  1 +
>  daemon/fs-min-size.c |  7 +++++++
>  daemon/xfs.c         | 16 ++++++++++++++++
>  generator/actions.ml |  6 +++++-
>  4 files changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/daemon/daemon.h b/daemon/daemon.h
> index 4a969dd..1f0cd30 100644
> --- a/daemon/daemon.h
> +++ b/daemon/daemon.h
> @@ -269,6 +269,7 @@ extern int copy_xattrs (const char *src, const char *dest);
>  extern int xfs_set_uuid (const char *device, const char *uuid);
>  extern int xfs_set_uuid_random (const char *device);
>  extern int xfs_set_label (const char *device, const char *label);
> +extern int64_t xfs_minimum_size (const char *path);
> 
>  /*-- debug-bmap.c --*/
>  extern char *debug_bmap (const char *subcmd, size_t argc, char *const *const argv);
> diff --git a/daemon/fs-min-size.c b/daemon/fs-min-size.c
> index ca71c4d..ba0f739 100644
> --- a/daemon/fs-min-size.c
> +++ b/daemon/fs-min-size.c
> @@ -73,6 +73,13 @@ do_vfs_minimum_size (const mountable_t *mountable)
>      r = btrfs_minimum_size (path);
>    }
> 
> +  else if (STREQ (vfs_type, "xfs")) {
> +    CLEANUP_FREE char *path = get_mount_point (mountable->device);
> +    if (path == NULL)
> +      return -1;
> +    r = xfs_minimum_size (path);
> +  }
> +
>    else
>      NOT_SUPPORTED (-1, "don't know how to get minimum size of '%s' filesystems",
>                     vfs_type);
> diff --git a/daemon/xfs.c b/daemon/xfs.c
> index f748902..abc2736 100644
> --- a/daemon/xfs.c
> +++ b/daemon/xfs.c
> @@ -660,3 +660,19 @@ do_xfs_repair (const char *device,
> 
>    return r;
>  }
> +
> +int64_t
> +xfs_minimum_size (const char *path)
> +{
> +  CLEANUP_FREE guestfs_int_xfsinfo *info = do_xfs_info (path);
> +
> +  if (info == NULL)
> +    return -1;
> +
> +  // XFS does not support shrinking.
> +  if (INT64_MAX / info->xfs_blocksize < info->xfs_datablocks) {
> +    reply_with_error ("filesystem size too big: overflow");
> +    return -1;
> +  }
> +  return info->xfs_blocksize * info->xfs_datablocks;
> +}
> diff --git a/generator/actions.ml b/generator/actions.ml
> index 8832410..d8af08d 100644
> --- a/generator/actions.ml
> +++ b/generator/actions.ml
> @@ -12765,6 +12765,10 @@ To read the UUID on a filesystem, call C<guestfs_vfs_uuid>." };
>          [["mkfs"; "btrfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"];
>           ["mount"; "/dev/sda1"; "/"];
>           ["vfs_minimum_size"; "/dev/sda1"]]), [];
> +      InitPartition, Always, TestRun (
> +        [["mkfs"; "xfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"];
> +         ["mount"; "/dev/sda1"; "/"];
> +         ["vfs_minimum_size"; "/dev/sda1"]]), [];
>      ];
>      shortdesc = "get minimum filesystem size";
>      longdesc = "\
> @@ -12774,7 +12778,7 @@ This is the minimum possible size for filesystem shrinking.
>  If getting minimum size of specified filesystem is not supported,
>  this will fail and set errno as ENOTSUP.
> 
> -See also L<ntfsresize(8)>, L<resize2fs(8)>, L<btrfs(8)>." };
> +See also L<ntfsresize(8)>, L<resize2fs(8)>, L<btrfs(8)>, L<xfs_info(8)>." };

Thanks - pushed.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]