snapper/pr790.patch
2024-02-05 14:58:17 +08:00

41 lines
1.1 KiB
Diff

diff --git a/snapper/BtrfsUtils.cc b/snapper/BtrfsUtils.cc
index 53bcb92a..47193ed1 100644
--- a/snapper/BtrfsUtils.cc
+++ b/snapper/BtrfsUtils.cc
@@ -284,21 +284,25 @@
struct btrfs_ioctl_quota_rescan_args args;
memset(&args, 0, sizeof(args));
- if (ioctl(fd, BTRFS_IOC_QUOTA_RESCAN, &args) < 0)
- throw runtime_error_with_errno("ioctl(BTRFS_IOC_QUOTA_RESCAN) failed", errno);
-
- while (true)
+ for (int i = 0;; ++i)
{
- sleep(1);
-
- memset(&args, 0, sizeof(args));
+ if (ioctl(fd, BTRFS_IOC_QUOTA_RESCAN, &args) == 0)
+ break;
- if (ioctl(fd, BTRFS_IOC_QUOTA_RESCAN_STATUS, &args) < 0)
- throw runtime_error_with_errno("ioctl(BTRFS_IOC_QUOTA_RESCAN_STATUS) failed", errno);
+ if (errno == EINPROGRESS)
+ {
+ if (i == 0)
+ y2war("waiting for old quota rescan to finish");
+
+ sleep(1);
+ continue;
+ }
- if (!args.flags)
- break;
+ throw runtime_error_with_errno("ioctl(BTRFS_IOC_QUOTA_RESCAN) failed", errno);
}
+
+ if (ioctl(fd, BTRFS_IOC_QUOTA_RESCAN_WAIT, &args) < 0)
+ throw runtime_error_with_errno("ioctl(BTRFS_IOC_QUOTA_WAIT_RESCAN) failed", errno);
}