[Libguestfs] [PATCH 5/8] New API: btrfs_quota_rescan
Richard W.M. Jones
rjones at redhat.com
Fri Dec 5 12:33:32 UTC 2014
On Tue, Dec 02, 2014 at 05:33:35PM +0800, Hu Tao wrote:
> btrfs_quota_rescan trashs all qgroup numbers and scans the metadata
> again with the current config.
>
> Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
> ---
> daemon/btrfs.c | 31 +++++++++++++++++++++++++++++++
> generator/actions.ml | 9 +++++++++
> src/MAX_PROC_NR | 2 +-
> 3 files changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/daemon/btrfs.c b/daemon/btrfs.c
> index 5fcb85b..6918d4f 100644
> --- a/daemon/btrfs.c
> +++ b/daemon/btrfs.c
> @@ -1057,3 +1057,34 @@ int do_btrfs_quota_disable (const char *path)
>
> return 0;
> }
> +
> +int do_btrfs_quota_rescan (const char *path)
> +{
> + const size_t MAX_ARGS = 64;
> + const char *argv[MAX_ARGS];
> + size_t i = 0;
> + CLEANUP_FREE char *path_buf = NULL;
> + CLEANUP_FREE char *err = NULL;
> + CLEANUP_FREE char *out = NULL;
> + int r;
> +
> + path_buf = sysroot_path (path);
> + if (path_buf == NULL) {
> + reply_with_perror ("malloc");
> + return -1;
> + }
> +
> + ADD_ARG (argv, i, str_btrfs);
> + ADD_ARG (argv, i, "quota");
> + ADD_ARG (argv, i, "rescan");
> + ADD_ARG (argv, i, path_buf);
> + ADD_ARG (argv, i, NULL);
> +
> + r = commandv (&out, &err, argv);
> + if (r == -1) {
> + reply_with_error ("%s: %s", path, err);
> + return -1;
> + }
> +
> + return 0;
> +}
> diff --git a/generator/actions.ml b/generator/actions.ml
> index ab1a07a..f24d5d7 100644
> --- a/generator/actions.ml
> +++ b/generator/actions.ml
> @@ -12063,6 +12063,15 @@ Enable subvolume quota support for filesystem which contains C<path>." };
> longdesc = "\
> Disable subvolume quota support for filesystem which contains C<path>." };
>
> + { defaults with
> + name = "btrfs_quota_rescan";
> + style = RErr, [Pathname "path"], [];
> + proc_nr = Some 429;
> + optional = Some "btrfs"; camel_name = "BTRFSQuotaRescan";
> + shortdesc = "trash all qgroup numbers and scan the metadata again with the current config";
> + longdesc = "\
> +Trash all qgroup numbers and scan the metadata again with the current config." };
> +
> ]
>
> (* Non-API meta-commands available only in guestfish.
> diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
> index 43d371a..3560666 100644
> --- a/src/MAX_PROC_NR
> +++ b/src/MAX_PROC_NR
> @@ -1 +1 @@
> -428
> +429
ACK. Could use a simple test.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
More information about the Libguestfs
mailing list