diff --git a/bcache.c b/bcache.c index fc20e640..6ba5fad7 100644 --- a/bcache.c +++ b/bcache.c @@ -864,7 +864,7 @@ void show_super_cache(struct cache_sb *sb, bool force_csum) show_cache_member(sb, sb->nr_this_dev); } -struct cache_sb *query_dev(char *dev, bool force_csum) +struct cache_sb *query_dev(char *dev, bool force_csum, bool print_sb) { struct cache_sb sb_stack, *sb = &sb_stack; size_t bytes = sizeof(*sb); @@ -890,15 +890,14 @@ struct cache_sb *query_dev(char *dev, bool force_csum) } } - return sb; -} + if(print_sb) { + if (!SB_IS_BDEV(sb)) + show_super_cache(sb, force_csum); + else + show_super_backingdev(sb, force_csum); + } -void print_dev_info(struct cache_sb *sb, bool force_csum) -{ - if (!SB_IS_BDEV(sb)) - show_super_cache(sb, force_csum); - else - show_super_backingdev(sb, force_csum); + return sb; } static void list_cacheset_devs(char *cset_dir, char *cset_name) { diff --git a/bcache.h b/bcache.h index 0dff6139..3a551d1e 100644 --- a/bcache.h +++ b/bcache.h @@ -57,12 +57,11 @@ long strtoul_or_die(const char *, size_t, const char *); void show_super_backingdev(struct cache_sb *, bool); void show_super_cache(struct cache_sb *, bool); -struct cache_sb *query_dev(char *, bool); +struct cache_sb *query_dev(char *, bool, bool); int list_cachesets(char *, bool); char *parse_array_to_list(char *const *); int register_bcache(); int probe(char *, int); -void print_dev_info(struct cache_sb *, bool); void sb_state(struct cache_sb *, char *); void read_stat_dir(DIR *, char *, char *, bool); diff --git a/bcacheadm.c b/bcacheadm.c index 57264307..76e53941 100644 --- a/bcacheadm.c +++ b/bcacheadm.c @@ -362,11 +362,8 @@ int bcache_query_devs (NihCommand *command, char *const *args) int i; - for (i = 0; args[i] != NULL; i++) { - printf("query-devs on: %s\n", args[i]); - struct cache_sb *sb = query_dev(args[i], false); - print_dev_info(sb, force_csum); - } + for (i = 0; args[i] != NULL; i++) + query_dev(args[i], force_csum, true); } int bcache_status (NihCommand *command, char *const *args) @@ -376,7 +373,7 @@ int bcache_status (NihCommand *command, char *const *args) char *dev0 = NULL, *dev1 = NULL; for (i = 0; args[i] != NULL; i++) { - struct cache_sb *sb = query_dev(args[i], false); + struct cache_sb *sb = query_dev(args[i], false, false); struct cache_member *m = ((struct cache_member *) sb->d) + sb->nr_this_dev; long long unsigned cache_tier = CACHE_TIER(m);