btrfs-progs: subvol sync: print count and progress

By default print how many subvolumes are considered for checks, either
found or specified on the command line. Once a subvolume is removed from
the list print the progress from the total count.

  $ btrfs subvolume sync /path
  Waiting for 130 subvolumes
  Subvolume id 256 is gone (1/130)
  Subvolume id 257 is gone (2/130)
  ...
  Subvolume id 384 is gone (129/130)
  Subvolume id 385 is gone (130/130)

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-01-13 16:45:19 +01:00
parent 347c8209e8
commit 7305c69cf9

View file

@ -49,7 +49,10 @@ static int wait_for_subvolume_cleaning(int fd, size_t count, uint64_t *ids,
{
size_t i;
enum btrfs_util_error err;
size_t done = 0;
pr_verbose(LOG_DEFAULT, "Waiting for %zu subvolume%s\n", count,
(count > 1 ? "s" : ""));
while (1) {
bool clean = true;
@ -58,8 +61,9 @@ static int wait_for_subvolume_cleaning(int fd, size_t count, uint64_t *ids,
continue;
err = btrfs_util_subvolume_info_fd(fd, ids[i], NULL);
if (err == BTRFS_UTIL_ERROR_SUBVOLUME_NOT_FOUND) {
pr_verbose(LOG_DEFAULT, "Subvolume id %" PRIu64 " is gone\n",
ids[i]);
done++;
pr_verbose(LOG_DEFAULT, "Subvolume id %" PRIu64 " is gone (%zu/%zu)\n",
ids[i], done, count);
ids[i] = 0;
} else if (err) {
error_btrfs_util(err);