@@ -222,15 +222,19 @@ Disable subvolume quota support for a filesystem.
*enable* <path>::
Enable subvolume quota support for a filesystem.
-*rescan* [-s] <path>::
+*rescan* [-s|-w|-W] <path>::
Trash all qgroup numbers and scan the metadata again with the current config.
+
`Options`
+
-s::::
-show status of a running rescan operation.
+Show status of a running rescan operation.
+
-w::::
-wait for rescan operation to finish(can be already in progress).
+Start rescan operation and wait until it has finished before exiting. If a rescan is already running, wait until it finishes and then exit without starting a new one.
+
+-W::::
+Wait for rescan operation to finish and then exit. If a rescan is not already running, exit silently.
EXIT STATUS
-----------
@@ -121,14 +121,20 @@ static int cmd_quota_rescan(int argc, char **argv)
int wait_for_completion = 0;
while (1) {
- int c = getopt(argc, argv, "sw");
+ int c = getopt(argc, argv, "swW");
if (c < 0)
break;
switch (c) {
case 's':
ioctlnum = BTRFS_IOC_QUOTA_RESCAN_STATUS;
break;
+ case 'W':
+ ioctlnum = 0;
+ wait_for_completion = 1;
+ break;
case 'w':
+ /* Reset it in case the user did both -W and -w */
+ ioctlnum = BTRFS_IOC_QUOTA_RESCAN;
wait_for_completion = 1;
break;
default:
@@ -136,8 +142,9 @@ static int cmd_quota_rescan(int argc, char **argv)
}
}
- if (ioctlnum != BTRFS_IOC_QUOTA_RESCAN && wait_for_completion) {
- error("switch -w cannot be used with -s");
+ if (ioctlnum == BTRFS_IOC_QUOTA_RESCAN_STATUS && wait_for_completion) {
+ error("switch -%c cannot be used with -s",
+ ioctlnum ? 'w' : 'W');
return 1;
}
@@ -151,8 +158,10 @@ static int cmd_quota_rescan(int argc, char **argv)
if (fd < 0)
return 1;
- ret = ioctl(fd, ioctlnum, &args);
- e = errno;
+ if (ioctlnum) {
+ ret = ioctl(fd, ioctlnum, &args);
+ e = errno;
+ }
if (ioctlnum == BTRFS_IOC_QUOTA_RESCAN_STATUS) {
close_file_or_dir(fd, dirstream);
@@ -169,7 +178,7 @@ static int cmd_quota_rescan(int argc, char **argv)
return 0;
}
- if (ret == 0) {
+ if (ioctlnum == BTRFS_IOC_QUOTA_RESCAN && ret == 0) {
printf("quota rescan started\n");
fflush(stdout);
} else if (ret < 0 && (!wait_for_completion || e != EINPROGRESS)) {