btrfs_quota_rescan trashs all qgroup numbers and scans the metadata
again with the current config.
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
daemon/btrfs.c | 33 +++++++++++++++++++++++++++++++++
generator/actions.ml | 21 +++++++++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index ee07e7e..71229f1 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1051,3 +1051,36 @@ error:
return -1;
return r;
}
+
+int
+do_btrfs_quota_rescan (const mountable_t *fs)
+{
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+ char *fs_buf = NULL;
+ CLEANUP_FREE char *err = NULL;
+ CLEANUP_FREE char *out = NULL;
+ int r = -1;
+
+ fs_buf = mount (fs);
+ if (fs_buf == NULL)
+ goto error;
+
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "quota");
+ ADD_ARG (argv, i, "rescan");
+ ADD_ARG (argv, i, fs_buf);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (&out, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", fs_buf, err);
+ goto error;
+ }
+
+error:
+ if (fs_buf && umount (fs_buf, fs) != 0)
+ return -1;
+ return r;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index d669b59..3e5aab0 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12097,6 +12097,27 @@ Return detailed information of the subvolume." };
longdesc = "\
Enable or disable subvolume quota support for filesystem which contains
C<path>." };
+ { defaults with
+ name = "btrfs_quota_rescan";
+ style = RErr, [Mountable_or_Path "fs"], [];
+ proc_nr = Some 428;
+ optional = Some "btrfs"; camel_name = "BTRFSQuotaRescan";
+ tests = [
+ InitPartition, Always, TestRun (
+ [["mkfs_btrfs"; "/dev/sda1"; ""; "";
"NOARG"; ""; "NOARG"; "NOARG"; "";
""];
+ ["btrfs_quota_enable"; "/dev/sda1"; "true"];
+ ["btrfs_quota_rescan"; "/dev/sda1"]]), [];
+ InitPartition, Always, TestRun (
+ [["mkfs_btrfs"; "/dev/sda1"; ""; "";
"NOARG"; ""; "NOARG"; "NOARG"; "";
""];
+ ["mount"; "/dev/sda1"; "/"];
+ ["btrfs_quota_enable"; "/"; "true"];
+ ["btrfs_quota_rescan"; "/"]]), [];
+ ];
+
+ 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 d2a1e59..43d371a 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-427
+428
--
1.9.3