diff --git a/cmds/scrub.c b/cmds/scrub.c index f68a8afe..5fd38d27 100644 --- a/cmds/scrub.c +++ b/cmds/scrub.c @@ -121,26 +121,26 @@ struct scrub_fs_stat { static void print_scrub_full(struct btrfs_scrub_progress *sp) { - printf("\tdata_extents_scrubbed: %lld\n", sp->data_extents_scrubbed); - printf("\ttree_extents_scrubbed: %lld\n", sp->tree_extents_scrubbed); - printf("\tdata_bytes_scrubbed: %lld\n", sp->data_bytes_scrubbed); - printf("\ttree_bytes_scrubbed: %lld\n", sp->tree_bytes_scrubbed); - printf("\tread_errors: %lld\n", sp->read_errors); - printf("\tcsum_errors: %lld\n", sp->csum_errors); - printf("\tverify_errors: %lld\n", sp->verify_errors); - printf("\tno_csum: %lld\n", sp->no_csum); - printf("\tcsum_discards: %lld\n", sp->csum_discards); - printf("\tsuper_errors: %lld\n", sp->super_errors); - printf("\tmalloc_errors: %lld\n", sp->malloc_errors); - printf("\tuncorrectable_errors: %lld\n", sp->uncorrectable_errors); - printf("\tunverified_errors: %lld\n", sp->unverified_errors); - printf("\tcorrected_errors: %lld\n", sp->corrected_errors); - printf("\tlast_physical: %lld\n", sp->last_physical); + pr_verbose(LOG_DEFAULT, "\tdata_extents_scrubbed: %lld\n", sp->data_extents_scrubbed); + pr_verbose(LOG_DEFAULT, "\ttree_extents_scrubbed: %lld\n", sp->tree_extents_scrubbed); + pr_verbose(LOG_DEFAULT, "\tdata_bytes_scrubbed: %lld\n", sp->data_bytes_scrubbed); + pr_verbose(LOG_DEFAULT, "\ttree_bytes_scrubbed: %lld\n", sp->tree_bytes_scrubbed); + pr_verbose(LOG_DEFAULT, "\tread_errors: %lld\n", sp->read_errors); + pr_verbose(LOG_DEFAULT, "\tcsum_errors: %lld\n", sp->csum_errors); + pr_verbose(LOG_DEFAULT, "\tverify_errors: %lld\n", sp->verify_errors); + pr_verbose(LOG_DEFAULT, "\tno_csum: %lld\n", sp->no_csum); + pr_verbose(LOG_DEFAULT, "\tcsum_discards: %lld\n", sp->csum_discards); + pr_verbose(LOG_DEFAULT, "\tsuper_errors: %lld\n", sp->super_errors); + pr_verbose(LOG_DEFAULT, "\tmalloc_errors: %lld\n", sp->malloc_errors); + pr_verbose(LOG_DEFAULT, "\tuncorrectable_errors: %lld\n", sp->uncorrectable_errors); + pr_verbose(LOG_DEFAULT, "\tunverified_errors: %lld\n", sp->unverified_errors); + pr_verbose(LOG_DEFAULT, "\tcorrected_errors: %lld\n", sp->corrected_errors); + pr_verbose(LOG_DEFAULT, "\tlast_physical: %lld\n", sp->last_physical); } #define PRINT_SCRUB_ERROR(test, desc) do { \ if (test) \ - printf(" %s=%llu", desc, test); \ + pr_verbose(LOG_DEFAULT, " %s=%llu", desc, test); \ } while (0) static void print_scrub_summary(struct btrfs_scrub_progress *p, struct scrub_stats *s, @@ -167,7 +167,7 @@ static void print_scrub_summary(struct btrfs_scrub_progress *p, struct scrub_sta err_cnt2 = p->corrected_errors + p->uncorrectable_errors; if (p->malloc_errors) - printf("*** WARNING: memory allocation failed while scrubbing. " + pr_verbose(LOG_DEFAULT, "*** WARNING: memory allocation failed while scrubbing. " "results may be inaccurate\n"); if (s->in_progress) { @@ -180,16 +180,16 @@ static void print_scrub_summary(struct btrfs_scrub_progress *p, struct scrub_sta t[sizeof(t) - 1] = '\0'; strftime(t, sizeof(t), "%c", &tm); - printf("Time left: %llu:%02llu:%02llu\n", + pr_verbose(LOG_DEFAULT, "Time left: %llu:%02llu:%02llu\n", sec_left / 3600, (sec_left / 60) % 60, sec_left % 60); - printf("ETA: %s\n", t); - printf("Total to scrub: %s\n", + pr_verbose(LOG_DEFAULT, "ETA: %s\n", t); + pr_verbose(LOG_DEFAULT, "Total to scrub: %s\n", pretty_size_mode(bytes_total, unit_mode)); - printf("Bytes scrubbed: %s (%.2f%%)\n", + pr_verbose(LOG_DEFAULT, "Bytes scrubbed: %s (%.2f%%)\n", pretty_size_mode(bytes_scrubbed, unit_mode), 100.0 * bytes_scrubbed / bytes_total); } else { - printf("Total to scrub: %s\n", + pr_verbose(LOG_DEFAULT, "Total to scrub: %s\n", pretty_size_mode(bytes_total, unit_mode)); } /* @@ -197,25 +197,25 @@ static void print_scrub_summary(struct btrfs_scrub_progress *p, struct scrub_sta * by --raw, otherwise it's human readable */ if (unit_mode == UNITS_RAW) { - printf("Rate: %s/s\n", + pr_verbose(LOG_DEFAULT, "Rate: %s/s\n", pretty_size_mode(bytes_per_sec, UNITS_RAW)); } else { - printf("Rate: %s/s\n", + pr_verbose(LOG_DEFAULT, "Rate: %s/s\n", pretty_size(bytes_per_sec)); } - printf("Error summary: "); + pr_verbose(LOG_DEFAULT, "Error summary: "); if (err_cnt || err_cnt2) { PRINT_SCRUB_ERROR(p->read_errors, "read"); PRINT_SCRUB_ERROR(p->super_errors, "super"); PRINT_SCRUB_ERROR(p->verify_errors, "verify"); PRINT_SCRUB_ERROR(p->csum_errors, "csum"); - printf("\n"); - printf(" Corrected: %llu\n", p->corrected_errors); - printf(" Uncorrectable: %llu\n", p->uncorrectable_errors); - printf(" Unverified: %llu\n", p->unverified_errors); + pr_verbose(LOG_DEFAULT, "\n"); + pr_verbose(LOG_DEFAULT, " Corrected: %llu\n", p->corrected_errors); + pr_verbose(LOG_DEFAULT, " Uncorrectable: %llu\n", p->uncorrectable_errors); + pr_verbose(LOG_DEFAULT, " Unverified: %llu\n", p->unverified_errors); } else { - printf(" no errors found\n"); + pr_verbose(LOG_DEFAULT, " no errors found\n"); } } @@ -287,37 +287,37 @@ static void _print_scrub_ss(struct scrub_stats *ss) unsigned hours; if (!ss || !ss->t_start) { - printf("\tno stats available\n"); + pr_verbose(LOG_DEFAULT, "\tno stats available\n"); return; } if (ss->t_resumed) { localtime_r(&ss->t_resumed, &tm); strftime(t, sizeof(t), "%c", &tm); t[sizeof(t) - 1] = '\0'; - printf("Scrub resumed: %s\n", t); + pr_verbose(LOG_DEFAULT, "Scrub resumed: %s\n", t); } else { localtime_r(&ss->t_start, &tm); strftime(t, sizeof(t), "%c", &tm); t[sizeof(t) - 1] = '\0'; - printf("Scrub started: %s\n", t); + pr_verbose(LOG_DEFAULT, "Scrub started: %s\n", t); } seconds = ss->duration; hours = ss->duration / (60 * 60); gmtime_r(&seconds, &tm); strftime(t, sizeof(t), "%M:%S", &tm); - printf("Status: %s\n", + pr_verbose(LOG_DEFAULT, "Status: %s\n", (ss->in_progress ? "running" : (ss->canceled ? "aborted" : (ss->finished ? "finished" : "interrupted")))); - printf("Duration: %u:%s\n", hours, t); + pr_verbose(LOG_DEFAULT, "Duration: %u:%s\n", hours, t); } static void print_scrub_dev(struct btrfs_ioctl_dev_info_args *di, struct btrfs_scrub_progress *p, int raw, const char *append, struct scrub_stats *ss) { - printf("\nScrub device %s (id %llu) %s\n", di->path, di->devid, + pr_verbose(LOG_DEFAULT, "\nScrub device %s (id %llu) %s\n", di->path, di->devid, append ? append : ""); _print_scrub_ss(ss); @@ -1562,7 +1562,7 @@ static int scrub_start(const struct cmd_struct *cmd, int argc, char **argv, total_bytes_used += di_args[i].bytes_used; } if (!do_stats_per_dev) { - printf("scrub %s for %s\n", append, fsid); + pr_verbose(LOG_DEFAULT, "scrub %s for %s\n", append, fsid); print_fs_stat(&fs_stat, print_raw, total_bytes_used); } } @@ -1830,7 +1830,7 @@ static int cmd_scrub_status(const struct cmd_struct *cmd, int argc, char **argv) } in_progress = is_scrub_running_in_kernel(fdmnt, di_args, fi_args.num_devices); - printf("UUID: %s\n", fsid); + pr_verbose(LOG_DEFAULT, "UUID: %s\n", fsid); if (do_stats_per_dev) { for (i = 0; i < fi_args.num_devices; ++i) {