@@ -2135,6 +2135,7 @@ static const char * const cmd_qgroup_clear_stale_usage[] = {
static int cmd_qgroup_clear_stale(const struct cmd_struct *cmd, int argc, char **argv)
{
+ enum btrfs_util_error err;
int ret = 0;
int fd;
char *path = NULL;
@@ -2151,6 +2152,11 @@ static int cmd_qgroup_clear_stale(const struct cmd_struct *cmd, int argc, char *
if (fd < 0)
return 1;
+ /* Sync the fs so that the qgroup numbers are uptodate. */
+ err = btrfs_util_sync_fd(fd);
+ if (err)
+ warning("sync ioctl failed on '%s': %m", path);
+
ret = qgroups_search_all(fd, &qgroup_lookup);
if (ret == -ENOTTY) {
error("can't list qgroups: quotas not enabled");
Since qgroup numbers are only updated at transaction commit time, it's better to do the a sync before reading the quota tree, to reduce the chance of uncommitted qgroup changes. Signed-off-by: Qu Wenruo <wqu@suse.com> --- cmds/qgroup.c | 6 ++++++ 1 file changed, 6 insertions(+)