Commit d2a228da authored by Mark Fasheh's avatar Mark Fasheh

Update our printed text

Make almost all bare printf's 'qprintf'. Exceptions:

- blocksize and hash type prints are verbose instead

- The 'kernel processed data' print becomes a vprintf. It's not
  typically useful.
Signed-off-by: 's avatarMark Fasheh <mfasheh@suse.de>
parent 7ea30a21
......@@ -571,12 +571,12 @@ out_nofiles:
static void print_header(void)
{
printf("Using %uK blocks\n", blocksize / 1024);
printf("Using hash: %s\n", csum_mod->name);
vprintf("Using %uK blocks\n", blocksize / 1024);
vprintf("Using hash: %s\n", csum_mod->name);
#ifdef DEBUG_BUILD
printf("Debug build, performance may be impacted.\n");
#endif
printf("Gathering file list...\n");
qprintf("Gathering file list...\n");
}
static int create_update_hashfile(int argc, char **argv, int filelist_idx)
......@@ -636,7 +636,7 @@ static int create_update_hashfile(int argc, char **argv, int filelist_idx)
if (ret)
goto out;
} else {
printf("Adding files from database for hashing.\n");
qprintf("Adding files from database for hashing.\n");
ret = dbfile_scan_files();
if (ret)
......@@ -733,8 +733,8 @@ int main(int argc, char **argv)
* This option is for isolating the file scan
* stage. Exit the program now.
*/
printf("Hashfile \"%s\" written, exiting.\n",
serialize_fname);
qprintf("Hashfile \"%s\" written, exiting.\n",
serialize_fname);
goto out;
}
break;
......@@ -763,7 +763,7 @@ int main(int argc, char **argv)
break;
}
printf("Loading only duplicated hashes from hashfile.\n");
qprintf("Loading only duplicated hashes from hashfile.\n");
ret = dbfile_load_hashes(&dups_tree);
if (ret)
......
......@@ -529,7 +529,7 @@ static void run_pool(GThreadPool *pool)
GError *err = NULL;
struct filerec *file, *tmp;
printf("Using %u threads for file hashing phase\n", io_threads);
qprintf("Using %u threads for file hashing phase\n", io_threads);
list_for_each_entry_safe(file, tmp, &filerec_list, rec_list) {
if (file->flags & FILEREC_NEEDS_SCAN) {
......@@ -662,10 +662,10 @@ static void csum_whole_file_init(GMutex **mutex, void *location,
cur_scan_files = __atomic_add_fetch(&_cur_scan_files, 1, __ATOMIC_SEQ_CST);
printf("[%0*llu/%llu] (%05.2f%%) csum: %s\n",
leading_spaces, cur_scan_files, files_to_scan,
(double)cur_scan_files / (double)files_to_scan * 100,
file->filename);
qprintf("[%0*llu/%llu] (%05.2f%%) csum: %s\n",
leading_spaces, cur_scan_files, files_to_scan,
(double)cur_scan_files / (double)files_to_scan * 100,
file->filename);
if (do_lookup_extents) {
*fc = alloc_fiemap_ctxt();
......@@ -835,8 +835,8 @@ int populate_tree()
run_pool(pool);
printf("Total files: %d\n", params.num_files);
printf("Total hashes: %d\n", params.num_hashes);
qprintf("Total files: %d\n", params.num_files);
qprintf("Total hashes: %d\n", params.num_hashes);
g_dataset_destroy(&params);
}
......
......@@ -63,7 +63,7 @@ static void print_extent_search_status(unsigned long long processed)
int width = 40;
float progress;
if (!stdout_is_tty || verbose || debug)
if (!stdout_is_tty || verbose || debug || quiet)
return;
progress = (float) processed / search_total;
......@@ -94,7 +94,7 @@ static void print_extent_search_status(unsigned long long processed)
static void clear_extent_search_status(unsigned long long processed,
int err)
{
if (!stdout_is_tty || verbose || debug)
if (!stdout_is_tty || verbose || debug || quiet)
return;
if (err)
......@@ -446,8 +446,8 @@ static int find_all_dupes_filewise(struct hash_tree *tree,
GThreadPool *pool = NULL;
unsigned long long pushed = 0;
printf("Hashing completed. Using %u threads to calculate duplicate "
"extents. This may take some time.\n", cpu_threads);
qprintf("Hashing completed. Using %u threads to calculate duplicate "
"extents. This may take some time.\n", cpu_threads);
pool = g_thread_pool_new((GFunc) find_dupes_worker, res,
cpu_threads, TRUE, &err);
......
......@@ -59,6 +59,9 @@ void print_dupes_table(struct results_tree *res)
struct dupe_extents *dext;
struct extent *extent;
if (quiet)
return;
printf("Simple read and compare of file data found %u instances of "
"extents that might benefit from deduplication.\n",
res->num_dupes);
......@@ -280,12 +283,15 @@ static int dedupe_extent_list(struct dupe_extents *dext, uint64_t *fiemap_bytes,
abort_on(dext->de_num_dupes < 2);
/* Dedupe extents with id %s*/
g_mutex_lock(&console_mutex);
printf("[%p] (%0*llu/%llu) Try to dedupe extents with id ",
g_thread_self(), leading_spaces, passno, total_dedupe_passes);
debug_print_digest_short(stdout, dext->de_hash);
printf("\n");
g_mutex_unlock(&console_mutex);
if (!quiet) {
g_mutex_lock(&console_mutex);
printf("[%p] (%0*llu/%llu) Try to dedupe extents with id ",
g_thread_self(), leading_spaces, passno,
total_dedupe_passes);
debug_print_digest_short(stdout, dext->de_hash);
printf("\n");
g_mutex_unlock(&console_mutex);
}
shared_prev = shared_post = 0ULL;
/*
......@@ -301,7 +307,7 @@ static int dedupe_extent_list(struct dupe_extents *dext, uint64_t *fiemap_bytes,
get_extent_info(dext);
clean_deduped(&dext);
if (!dext) {
printf("[%p] Skipping - extents are already deduped.\n",
qprintf("[%p] Skipping - extents are already deduped.\n",
g_thread_self());
return DEDUPE_EXTENTS_CLEANED;
}
......@@ -392,16 +398,18 @@ run_dedupe:
* case but always do cleanup.
*/
if (ctxt->num_queued) {
g_mutex_lock(&console_mutex);
printf("[%p] Dedupe %u extents (id: ", g_thread_self(),
ctxt->num_queued);
debug_print_digest_short(stdout, dext->de_hash);
printf(") with target: (%s, %s), "
"\"%s\"\n",
pretty_size(ctxt->orig_file_off),
pretty_size(ctxt->orig_len),
ctxt->ioctl_file->filename);
g_mutex_unlock(&console_mutex);
if (!quiet) {
g_mutex_lock(&console_mutex);
printf("[%p] Dedupe %u extents (id: ",
g_thread_self(), ctxt->num_queued);
debug_print_digest_short(stdout, dext->de_hash);
printf(") with target: (%s, %s), "
"\"%s\"\n",
pretty_size(ctxt->orig_file_off),
pretty_size(ctxt->orig_len),
ctxt->ioctl_file->filename);
g_mutex_unlock(&console_mutex);
}
ret = dedupe_extents(ctxt);
if (ret == 0) {
......@@ -888,7 +896,7 @@ void dedupe_results(struct results_tree *res, struct hash_tree *hashes)
}
}
printf("Using %u threads for dedupe phase\n", io_threads);
qprintf("Using %u threads for dedupe phase\n", io_threads);
dedupe_pool = g_thread_pool_new((GFunc) dedupe_worker, &counts,
io_threads, TRUE, &err);
......@@ -918,16 +926,12 @@ void dedupe_results(struct results_tree *res, struct hash_tree *hashes)
g_thread_pool_free(dedupe_pool, FALSE, TRUE);
if (ret == 0) {
if (fiemap_during_dedupe) {
printf("Kernel processed data (excludes target files): "
"%s\nComparison of extent info shows a net "
vprintf("Kernel processed data (excludes target files): "
"%s\n", pretty_size(counts.kern_bytes));
if (fiemap_during_dedupe)
printf("Comparison of extent info shows a net "
"change in shared extents of: %s\n",
pretty_size(counts.kern_bytes),
pretty_size(counts.fiemap_bytes));
} else {
printf("Kernel processed data (excludes target files): "
"%s\n", pretty_size(counts.kern_bytes));
}
}
}
......@@ -947,7 +951,7 @@ int fdupes_dedupe(void)
continue;
}
printf("Queue entire file for dedupe: %s\n", file->filename);
qprintf("Queue entire file for dedupe: %s\n", file->filename);
if (ctxt == NULL) {
ctxt = new_dedupe_ctxt(MAX_DEDUPES_PER_IOCTL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment