diff --git a/Documentation/btrfs-qgroup.asciidoc b/Documentation/btrfs-qgroup.asciidoc index 0c9f5940..127d7914 100644 --- a/Documentation/btrfs-qgroup.asciidoc +++ b/Documentation/btrfs-qgroup.asciidoc @@ -89,7 +89,14 @@ the btrfs filesystem identified by . + `Options` + -The same as *assign* subcommand. +--rescan:::: +(default since: 4.19) Automatically schedule quota rescan if the removed qgroup +relation would lead to quota inconsistency. See 'QUOTA RESCAN' for more +information. +--no-rescan:::: +Explicitly ask not to do a rescan, even if the removal will make the quotas +inconsistent. This may be useful for repeated calls where the rescan would add +unnecessary overhead. *show* [options] :: Show all qgroups in the btrfs filesystem identified by . diff --git a/cmds/qgroup.c b/cmds/qgroup.c index 6bfb4949..c77ea6f1 100644 --- a/cmds/qgroup.c +++ b/cmds/qgroup.c @@ -45,34 +45,30 @@ static int _cmd_qgroup_assign(const struct cmd_struct *cmd, int assign, struct btrfs_ioctl_qgroup_assign_args args; DIR *dirstream = NULL; - if (assign) { - optind = 0; - while (1) { - enum { GETOPT_VAL_RESCAN = 256, GETOPT_VAL_NO_RESCAN }; - static const struct option long_options[] = { - { "rescan", no_argument, NULL, - GETOPT_VAL_RESCAN }, - { "no-rescan", no_argument, NULL, - GETOPT_VAL_NO_RESCAN }, - { NULL, 0, NULL, 0 } - }; - int c = getopt_long(argc, argv, "", long_options, NULL); + optind = 0; + while (1) { + enum { GETOPT_VAL_RESCAN = 256, GETOPT_VAL_NO_RESCAN }; + static const struct option long_options[] = { + { "rescan", no_argument, NULL, GETOPT_VAL_RESCAN }, + { "no-rescan", no_argument, NULL, GETOPT_VAL_NO_RESCAN }, + { NULL, 0, NULL, 0 } + }; + int c; - if (c < 0) - break; - switch (c) { - case GETOPT_VAL_RESCAN: - rescan = true; - break; - case GETOPT_VAL_NO_RESCAN: - rescan = false; - break; - default: - usage_unknown_option(cmd, argv); - } + c = getopt_long(argc, argv, "", long_options, NULL); + if (c < 0) + break; + + switch (c) { + case GETOPT_VAL_RESCAN: + rescan = true; + break; + case GETOPT_VAL_NO_RESCAN: + rescan = false; + break; + default: + usage_unknown_option(cmd, argv); } - } else { - clean_args_no_options(cmd, argc, argv); } if (check_argc_exact(argc - optind, 3)) @@ -180,8 +176,11 @@ static int cmd_qgroup_assign(const struct cmd_struct *cmd, static DEFINE_SIMPLE_COMMAND(qgroup_assign, "assign"); static const char * const cmd_qgroup_remove_usage[] = { - "btrfs qgroup remove ", + "btrfs qgroup remove [options] ", "Remove a child qgroup SRC from DST.", + "", + "--rescan schedule qutoa rescan if needed", + "--no-rescan don't schedule quota rescan", NULL };