From: Jan Fajerski Date: Tue, 21 Nov 2017 17:34:28 +0000 (+0100) Subject: include/types: format decimal numbers with decimal factor X-Git-Tag: v13.1.0~258^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d3cecebacdcebcf475808a6204de22dfa94d729d;p=ceph.git include/types: format decimal numbers with decimal factor Until now bytes and objects were formatted using si_t which used 1024 as the factor to pretty print large numbers. For object counts a factor of 1000 is preferred. This commit retires the si_t formatting (as well as prettybyte_t, kb_t and pretty_si_t) completely and adds structs and formatting for binary and decimal units, bin_u_t and dec_u_t respectively. Fixes: http://tracker.ceph.com/issues/22095 Signed-off-by: Jan Fajerski --- diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index b10a64f075b8..6ce948bf5198 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -1747,11 +1747,6 @@ function test_mon_osd_pool_quota() ceph osd pool set-quota tmp-quota-pool max_bytes 10 ceph osd pool set-quota tmp-quota-pool max_objects 10M # - # get quotas - # - ceph osd pool get-quota tmp-quota-pool | grep 'max bytes.*10B' - ceph osd pool get-quota tmp-quota-pool | grep 'max objects.*10M objects' - # # get quotas in json-pretty format # ceph osd pool get-quota tmp-quota-pool --format=json-pretty | \ @@ -1759,6 +1754,28 @@ function test_mon_osd_pool_quota() ceph osd pool get-quota tmp-quota-pool --format=json-pretty | \ grep '"quota_max_bytes":.*10' # + # get quotas + # + ceph osd pool get-quota tmp-quota-pool | grep 'max bytes.*10B' + ceph osd pool get-quota tmp-quota-pool | grep 'max objects.*10M objects' + # + # set valid quotas with unit prefix + # + ceph osd pool set-quota tmp-quota-pool max_bytes 10K + # + # get quotas + # + ceph osd pool get-quota tmp-quota-pool | grep 'max bytes.*10Ki' + # + # set valid quotas with unit prefix + # + ceph osd pool set-quota tmp-quota-pool max_bytes 10Ki + # + # get quotas + # + ceph osd pool get-quota tmp-quota-pool | grep 'max bytes.*10Ki' + # + # # reset pool quotas # ceph osd pool set-quota tmp-quota-pool max_bytes 0 diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index f3bbc6dc8c28..48d4f6e87aaa 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -477,7 +477,7 @@ int main(int argc, const char **argv) if (stats.avail_percent <= g_conf->mon_data_avail_crit) { derr << "error: monitor data filesystem reached concerning levels of" << " available storage space (available: " - << stats.avail_percent << "% " << prettybyte_t(stats.byte_avail) + << stats.avail_percent << "% " << byte_u_t(stats.byte_avail) << ")\nyou may adjust 'mon data avail crit' to a lower value" << " to make this go away (default: " << g_conf->mon_data_avail_crit << "%)\n" << dendl; diff --git a/src/include/types.h b/src/include/types.h index 178051d323a2..5169f6b32cde 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -356,116 +356,87 @@ inline ostream& operator<<(ostream& out, const client_t& c) { // -- -struct prettybyte_t { - uint64_t v; - // cppcheck-suppress noExplicitConstructor - prettybyte_t(uint64_t _v) : v(_v) {} -}; +namespace { + inline ostream& format_u(ostream& out, const uint64_t v, const uint64_t n, + const int index, const uint64_t mult, const char* u) + { + char buffer[32]; + + if (index == 0) { + (void) snprintf(buffer, sizeof(buffer), "%" PRId64 "%s", n, u); + } else if ((v % mult) == 0) { + // If this is an even multiple of the base, always display + // without any decimal fraction. + (void) snprintf(buffer, sizeof(buffer), "%" PRId64 "%s", n, u); + } else { + // We want to choose a precision that reflects the best choice + // for fitting in 5 characters. This can get rather tricky when + // we have numbers that are very close to an order of magnitude. + // For example, when displaying 10239 (which is really 9.999K), + // we want only a single place of precision for 10.0K. We could + // develop some complex heuristics for this, but it's much + // easier just to try each combination in turn. + int i; + for (i = 2; i >= 0; i--) { + if (snprintf(buffer, sizeof(buffer), "%.*f%s", i, + static_cast(v) / mult, u) <= 7) + break; + } + } -inline ostream& operator<<(ostream& out, const prettybyte_t& b) -{ - uint64_t bump_after = 100; - if (b.v > bump_after << 60) - return out << (b.v >> 60) << " EB"; - if (b.v > bump_after << 50) - return out << (b.v >> 50) << " PB"; - if (b.v > bump_after << 40) - return out << (b.v >> 40) << " TB"; - if (b.v > bump_after << 30) - return out << (b.v >> 30) << " GB"; - if (b.v > bump_after << 20) - return out << (b.v >> 20) << " MB"; - if (b.v > bump_after << 10) - return out << (b.v >> 10) << " kB"; - return out << b.v << " bytes"; + return out << buffer; + } } -struct si_t { +/* + * Use this struct to pretty print values that should be formatted with a + * decimal unit prefix (the classic SI units). No actual unit will be added. + */ +struct si_u_t { uint64_t v; - // cppcheck-suppress noExplicitConstructor - si_t(uint64_t _v) : v(_v) {} + explicit si_u_t(uint64_t _v) : v(_v) {}; }; -inline ostream& operator<<(ostream& out, const si_t& b) +inline ostream& operator<<(ostream& out, const si_u_t& b) { - char buffer[32]; uint64_t n = b.v; int index = 0; + uint64_t mult = 1; + const char* u[] = {"", "k", "M", "G", "T", "P", "E"}; - while (n >= 1024 && index < 6) { - n /= 1024; + while (n >= 1000 && index < 7) { + n /= 1000; index++; + mult *= 1000; } - char u = " KMGTPE"[index]; - - if (index == 0) { - (void) snprintf(buffer, sizeof(buffer), "%" PRId64, n); - } else if ((b.v & ((1ULL << 10 * index) - 1)) == 0) { - // If this is an even multiple of the base, always display - // without any decimal fraction. - (void) snprintf(buffer, sizeof(buffer), "%" PRId64 "%c", n, u); - } else { - // We want to choose a precision that reflects the best choice - // for fitting in 5 characters. This can get rather tricky when - // we have numbers that are very close to an order of magnitude. - // For example, when displaying 10239 (which is really 9.999K), - // we want only a single place of precision for 10.0K. We could - // develop some complex heuristics for this, but it's much - // easier just to try each combination in turn. - int i; - for (i = 2; i >= 0; i--) { - if (snprintf(buffer, sizeof(buffer), "%.*f%c", i, - (double)b.v / (1ULL << 10 * index), u) <= 5) - break; - } - } - - return out << buffer; + return format_u(out, b.v, n, index, mult, u[index]); } -struct pretty_si_t { +/* + * Use this struct to pretty print values that should be formatted with a + * binary unit prefix (IEC units). Since binary unit prefixes are to be used for + * "multiples of units in data processing, data transmission, and digital + * information" (so bits and bytes) and so far bits are not printed, the unit + * "B" for "byte" is added besides the multiplier. + */ +struct byte_u_t { uint64_t v; - // cppcheck-suppress noExplicitConstructor - pretty_si_t(uint64_t _v) : v(_v) {} + explicit byte_u_t(uint64_t _v) : v(_v) {}; }; -inline ostream& operator<<(ostream& out, const pretty_si_t& b) +inline ostream& operator<<(ostream& out, const byte_u_t& b) { - uint64_t bump_after = 100; - if (b.v > bump_after << 60) - return out << (b.v >> 60) << " E"; - if (b.v > bump_after << 50) - return out << (b.v >> 50) << " P"; - if (b.v > bump_after << 40) - return out << (b.v >> 40) << " T"; - if (b.v > bump_after << 30) - return out << (b.v >> 30) << " G"; - if (b.v > bump_after << 20) - return out << (b.v >> 20) << " M"; - if (b.v > bump_after << 10) - return out << (b.v >> 10) << " k"; - return out << b.v << " "; -} + uint64_t n = b.v; + int index = 0; + const char* u[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"}; -struct kb_t { - uint64_t v; - // cppcheck-suppress noExplicitConstructor - kb_t(uint64_t _v) : v(_v) {} -}; + while (n >= 1024 && index < 7) { + n /= 1024; + index++; + } -inline ostream& operator<<(ostream& out, const kb_t& kb) -{ - uint64_t bump_after = 100; - if (kb.v > bump_after << 40) - return out << (kb.v >> 40) << " PB"; - if (kb.v > bump_after << 30) - return out << (kb.v >> 30) << " TB"; - if (kb.v > bump_after << 20) - return out << (kb.v >> 20) << " GB"; - if (kb.v > bump_after << 10) - return out << (kb.v >> 10) << " MB"; - return out << kb.v << " kB"; + return format_u(out, b.v, n, index, 1ULL << (10 * index), u[index]); } inline ostream& operator<<(ostream& out, const ceph_mon_subscribe_item& i) diff --git a/src/kv/RocksDBStore.cc b/src/kv/RocksDBStore.cc index b81a103bd90b..26ee903ef997 100644 --- a/src/kv/RocksDBStore.cc +++ b/src/kv/RocksDBStore.cc @@ -444,8 +444,8 @@ int RocksDBStore::load_rocksdb_options(bool create_if_missing, rocksdb::Options& opt.table_factory.reset(rocksdb::NewBlockBasedTableFactory(bbt_opts)); dout(10) << __func__ << " block size " << g_conf->rocksdb_block_size - << ", block_cache size " << prettybyte_t(block_cache_size) - << ", row_cache size " << prettybyte_t(row_cache_size) + << ", block_cache size " << byte_u_t(block_cache_size) + << ", row_cache size " << byte_u_t(row_cache_size) << "; shards " << (1 << g_conf->rocksdb_cache_shard_bits) << ", type " << g_conf->rocksdb_cache_type diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index d1eab7869a8a..92d71dd71039 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -212,9 +212,9 @@ bool HealthMonitor::check_member_health() stats.store_stats.bytes_misc = extra["misc"]; stats.last_update = ceph_clock_now(); dout(10) << __func__ << " avail " << stats.fs_stats.avail_percent << "%" - << " total " << prettybyte_t(stats.fs_stats.byte_total) - << ", used " << prettybyte_t(stats.fs_stats.byte_used) - << ", avail " << prettybyte_t(stats.fs_stats.byte_avail) << dendl; + << " total " << byte_u_t(stats.fs_stats.byte_total) + << ", used " << byte_u_t(stats.fs_stats.byte_used) + << ", avail " << byte_u_t(stats.fs_stats.byte_avail) << dendl; // MON_DISK_{LOW,CRIT,BIG} health_check_map_t next; @@ -238,9 +238,9 @@ bool HealthMonitor::check_member_health() ss << "mon%plurals% %names% %isorare% using a lot of disk space"; auto& d = next.add("MON_DISK_BIG", HEALTH_WARN, ss.str()); ss2 << "mon." << mon->name << " is " - << prettybyte_t(stats.store_stats.bytes_total) + << byte_u_t(stats.store_stats.bytes_total) << " >= mon_data_size_warn (" - << prettybyte_t(g_conf->mon_data_size_warn) << ")"; + << byte_u_t(g_conf->mon_data_size_warn) << ")"; d.detail.push_back(ss2.str()); } diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 9eb62370a4db..0e14ad6443b7 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4617,13 +4617,13 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) if (p->quota_max_objects == 0) rs << "N/A"; else - rs << si_t(p->quota_max_objects) << " objects"; + rs << si_u_t(p->quota_max_objects) << " objects"; rs << "\n" << " max bytes : "; if (p->quota_max_bytes == 0) rs << "N/A"; else - rs << si_t(p->quota_max_bytes) << "B"; + rs << byte_u_t(p->quota_max_bytes); rdata.append(rs.str()); } rdata.append("\n"); @@ -5177,7 +5177,7 @@ bool OSDMonitor::update_pools_status() (uint64_t)sum.num_bytes >= pool.quota_max_bytes) { mon->clog->warn() << "pool '" << pool_name << "' is full" << " (reached quota's max_bytes: " - << si_t(pool.quota_max_bytes) << ")"; + << byte_u_t(pool.quota_max_bytes) << ")"; } if (pool.quota_max_objects > 0 && (uint64_t)sum.num_objects >= pool.quota_max_objects) { diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index c2fd816f191c..cda7ca784abc 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -213,12 +213,12 @@ void PGMapDigest::print_summary(Formatter *f, ostream *out) const } else { *out << " pools: " << pg_pool_sum.size() << " pools, " << num_pg << " pgs\n"; - *out << " objects: " << si_t(pg_sum.stats.sum.num_objects) << " objects, " - << si_t(pg_sum.stats.sum.num_bytes) << "\n"; + *out << " objects: " << si_u_t(pg_sum.stats.sum.num_objects) << " objects, " + << byte_u_t(pg_sum.stats.sum.num_bytes) << "\n"; *out << " usage: " - << si_t(osd_sum.kb_used << 10) << " used, " - << si_t(osd_sum.kb_avail << 10) << " / " - << si_t(osd_sum.kb << 10) << " avail\n"; + << byte_u_t(osd_sum.kb_used << 10) << " used, " + << byte_u_t(osd_sum.kb_avail << 10) << " / " + << byte_u_t(osd_sum.kb << 10) << " avail\n"; *out << " pgs: "; } @@ -338,10 +338,10 @@ void PGMapDigest::print_oneline_summary(Formatter *f, ostream *out) const if (out) *out << num_pg << " pgs: " << states << "; " - << prettybyte_t(pg_sum.stats.sum.num_bytes) << " data, " - << kb_t(osd_sum.kb_used) << " used, " - << kb_t(osd_sum.kb_avail) << " / " - << kb_t(osd_sum.kb) << " avail"; + << byte_u_t(pg_sum.stats.sum.num_bytes) << " data, " + << byte_u_t(osd_sum.kb_used << 10) << " used, " + << byte_u_t(osd_sum.kb_avail << 10) << " / " + << byte_u_t(osd_sum.kb << 10) << " avail"; if (f) { f->dump_unsigned("num_pgs", num_pg); f->dump_unsigned("num_bytes", pg_sum.stats.sum.num_bytes); @@ -362,20 +362,20 @@ void PGMapDigest::print_oneline_summary(Formatter *f, ostream *out) const if (pos_delta.stats.sum.num_rd) { int64_t rd = (pos_delta.stats.sum.num_rd_kb << 10) / (double)stamp_delta; if (out) - *out << pretty_si_t(rd) << "B/s rd, "; + *out << byte_u_t(rd) << "/s rd, "; if (f) f->dump_unsigned("read_bytes_sec", rd); } if (pos_delta.stats.sum.num_wr) { int64_t wr = (pos_delta.stats.sum.num_wr_kb << 10) / (double)stamp_delta; if (out) - *out << pretty_si_t(wr) << "B/s wr, "; + *out << byte_u_t(wr) << "/s wr, "; if (f) f->dump_unsigned("write_bytes_sec", wr); } int64_t iops = (pos_delta.stats.sum.num_rd + pos_delta.stats.sum.num_wr) / (double)stamp_delta; if (out) - *out << pretty_si_t(iops) << "op/s"; + *out << si_u_t(iops) << "op/s"; if (f) f->dump_unsigned("io_sec", iops); } @@ -467,10 +467,10 @@ void PGMapDigest::recovery_rate_summary(Formatter *f, ostream *out, f->dump_int("num_bytes_recovered", pos_delta.stats.sum.num_bytes_recovered); f->dump_int("num_keys_recovered", pos_delta.stats.sum.num_keys_recovered); } else { - *out << pretty_si_t(bps) << "B/s"; + *out << byte_u_t(bps) << "/s"; if (pos_delta.stats.sum.num_keys_recovered) - *out << ", " << pretty_si_t(kps) << "keys/s"; - *out << ", " << pretty_si_t(objps) << "objects/s"; + *out << ", " << si_u_t(kps) << "keys/s"; + *out << ", " << si_u_t(objps) << "objects/s"; } } } @@ -520,7 +520,7 @@ void PGMapDigest::client_io_rate_summary(Formatter *f, ostream *out, if (f) { f->dump_int("read_bytes_sec", rd); } else { - *out << pretty_si_t(rd) << "B/s rd, "; + *out << byte_u_t(rd) << "/s rd, "; } } if (pos_delta.stats.sum.num_wr) { @@ -528,7 +528,7 @@ void PGMapDigest::client_io_rate_summary(Formatter *f, ostream *out, if (f) { f->dump_int("write_bytes_sec", wr); } else { - *out << pretty_si_t(wr) << "B/s wr, "; + *out << byte_u_t(wr) << "/s wr, "; } } int64_t iops_rd = pos_delta.stats.sum.num_rd / (double)delta_stamp; @@ -537,7 +537,7 @@ void PGMapDigest::client_io_rate_summary(Formatter *f, ostream *out, f->dump_int("read_op_per_sec", iops_rd); f->dump_int("write_op_per_sec", iops_wr); } else { - *out << pretty_si_t(iops_rd) << "op/s rd, " << pretty_si_t(iops_wr) << "op/s wr"; + *out << si_u_t(iops_rd) << "op/s rd, " << si_u_t(iops_wr) << "op/s wr"; } } } @@ -572,7 +572,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out, if (f) { f->dump_int("flush_bytes_sec", flush); } else { - *out << pretty_si_t(flush) << "B/s flush"; + *out << byte_u_t(flush) << "/s flush"; have_output = true; } } @@ -583,7 +583,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out, } else { if (have_output) *out << ", "; - *out << pretty_si_t(evict) << "B/s evict"; + *out << byte_u_t(evict) << "/s evict"; have_output = true; } } @@ -594,7 +594,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out, } else { if (have_output) *out << ", "; - *out << pretty_si_t(promote) << "op/s promote"; + *out << si_u_t(promote) << "op/s promote"; have_output = true; } } @@ -604,7 +604,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out, } else { if (have_output) *out << ", "; - *out << pretty_si_t(pos_delta.stats.sum.num_flush_mode_low) << "PG(s) flushing"; + *out << si_u_t(pos_delta.stats.sum.num_flush_mode_low) << "PG(s) flushing"; have_output = true; } } @@ -614,7 +614,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out, } else { if (have_output) *out << ", "; - *out << pretty_si_t(pos_delta.stats.sum.num_flush_mode_high) << "PG(s) flushing (high)"; + *out << si_u_t(pos_delta.stats.sum.num_flush_mode_high) << "PG(s) flushing (high)"; have_output = true; } } @@ -624,7 +624,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out, } else { if (have_output) *out << ", "; - *out << pretty_si_t(pos_delta.stats.sum.num_evict_mode_some) << "PG(s) evicting"; + *out << si_u_t(pos_delta.stats.sum.num_evict_mode_some) << "PG(s) evicting"; have_output = true; } } @@ -634,7 +634,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out, } else { if (have_output) *out << ", "; - *out << pretty_si_t(pos_delta.stats.sum.num_evict_mode_full) << "PG(s) evicting (full)"; + *out << si_u_t(pos_delta.stats.sum.num_evict_mode_full) << "PG(s) evicting (full)"; } } } @@ -787,12 +787,12 @@ void PGMapDigest::dump_pool_stats_full( if (pool->quota_max_objects == 0) tbl << "N/A"; else - tbl << si_t(pool->quota_max_objects); + tbl << si_u_t(pool->quota_max_objects); if (pool->quota_max_bytes == 0) tbl << "N/A"; else - tbl << si_t(pool->quota_max_bytes); + tbl << byte_u_t(pool->quota_max_bytes); } } @@ -836,16 +836,16 @@ void PGMapDigest::dump_fs_stats(stringstream *ss, Formatter *f, bool verbose) co if (verbose) { tbl.define_column("OBJECTS", TextTable::LEFT, TextTable::RIGHT); } - tbl << stringify(si_t(osd_sum.kb*1024)) - << stringify(si_t(osd_sum.kb_avail*1024)) - << stringify(si_t(osd_sum.kb_used*1024)); + tbl << stringify(byte_u_t(osd_sum.kb*1024)) + << stringify(byte_u_t(osd_sum.kb_avail*1024)) + << stringify(byte_u_t(osd_sum.kb_used*1024)); float used = 0.0; if (osd_sum.kb > 0) { used = ((float)osd_sum.kb_used / osd_sum.kb); } tbl << percentify(used*100); if (verbose) { - tbl << stringify(si_t(pg_sum.stats.sum.num_objects)); + tbl << stringify(si_u_t(pg_sum.stats.sum.num_objects)); } tbl << TextTable::endrow; @@ -891,15 +891,15 @@ void PGMapDigest::dump_object_stat_sum( f->dump_int("raw_bytes_used", sum.num_bytes * raw_used_rate * curr_object_copies_rate); } } else { - tbl << stringify(si_t(sum.num_bytes)); + tbl << stringify(byte_u_t(sum.num_bytes)); tbl << percentify(used*100); - tbl << si_t(avail / raw_used_rate); + tbl << byte_u_t(avail / raw_used_rate); tbl << sum.num_objects; if (verbose) { - tbl << stringify(si_t(sum.num_objects_dirty)) - << stringify(si_t(sum.num_rd)) - << stringify(si_t(sum.num_wr)) - << stringify(si_t(sum.num_bytes * raw_used_rate * curr_object_copies_rate)); + tbl << stringify(si_u_t(sum.num_objects_dirty)) + << stringify(byte_u_t(sum.num_rd)) + << stringify(byte_u_t(sum.num_wr)) + << stringify(byte_u_t(sum.num_bytes * raw_used_rate * curr_object_copies_rate)); } } } @@ -1652,9 +1652,9 @@ void PGMap::dump_osd_stats(ostream& ss) const p != osd_stat.end(); ++p) { tab << p->first - << si_t(p->second.kb_used << 10) - << si_t(p->second.kb_avail << 10) - << si_t(p->second.kb << 10) + << byte_u_t(p->second.kb_used << 10) + << byte_u_t(p->second.kb_avail << 10) + << byte_u_t(p->second.kb << 10) << p->second.hb_peers << get_num_pg_by_osd(p->first) << get_num_primary_pg_by_osd(p->first) @@ -1662,9 +1662,9 @@ void PGMap::dump_osd_stats(ostream& ss) const } tab << "sum" - << si_t(osd_sum.kb_used << 10) - << si_t(osd_sum.kb_avail << 10) - << si_t(osd_sum.kb << 10) + << byte_u_t(osd_sum.kb_used << 10) + << byte_u_t(osd_sum.kb_avail << 10) + << byte_u_t(osd_sum.kb << 10) << TextTable::endrow; ss << tab; @@ -1680,9 +1680,9 @@ void PGMap::dump_osd_sum_stats(ostream& ss) const tab.define_column("TOTAL", TextTable::LEFT, TextTable::RIGHT); tab << "sum" - << si_t(osd_sum.kb_used << 10) - << si_t(osd_sum.kb_avail << 10) - << si_t(osd_sum.kb << 10) + << byte_u_t(osd_sum.kb_used << 10) + << byte_u_t(osd_sum.kb_avail << 10) + << byte_u_t(osd_sum.kb << 10) << TextTable::endrow; ss << tab; @@ -2439,9 +2439,9 @@ void PGMap::get_health_checks( p.second.target_max_objects * (ratio / 1000000.0)) { ostringstream ss; ss << "cache pool '" << name << "' with " - << si_t(st.stats.sum.num_objects) + << si_u_t(st.stats.sum.num_objects) << " objects at/near target max " - << si_t(p.second.target_max_objects) << " objects"; + << si_u_t(p.second.target_max_objects) << " objects"; detail.push_back(ss.str()); nearfull = true; } @@ -2451,9 +2451,9 @@ void PGMap::get_health_checks( p.second.target_max_bytes * (ratio / 1000000.0)) { ostringstream ss; ss << "cache pool '" << name - << "' with " << si_t(st.stats.sum.num_bytes) - << "B at/near target max " - << si_t(p.second.target_max_bytes) << "B"; + << "' with " << byte_u_t(st.stats.sum.num_bytes) + << " at/near target max " + << byte_u_t(p.second.target_max_bytes); detail.push_back(ss.str()); nearfull = true; } @@ -2595,15 +2595,15 @@ void PGMap::get_health_checks( } else if (crit_threshold > 0 && sum.num_bytes >= pool.quota_max_bytes*crit_threshold) { ss << "pool '" << pool_name - << "' has " << si_t(sum.num_bytes) << " bytes" - << " (max " << si_t(pool.quota_max_bytes) << ")"; + << "' has " << byte_u_t(sum.num_bytes) + << " (max " << byte_u_t(pool.quota_max_bytes) << ")"; full_detail.push_back(ss.str()); full = true; } else if (warn_threshold > 0 && sum.num_bytes >= pool.quota_max_bytes*warn_threshold) { ss << "pool '" << pool_name - << "' has " << si_t(sum.num_bytes) << " bytes" - << " (max " << si_t(pool.quota_max_bytes) << ")"; + << "' has " << byte_u_t(sum.num_bytes) + << " (max " << byte_u_t(pool.quota_max_bytes) << ")"; nearfull_detail.push_back(ss.str()); nearfull = true; } diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index f76975a011b3..567262c2fbd1 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -164,7 +164,7 @@ int BlueFS::add_block_device(unsigned id, const string& path, bool trim) } dout(1) << __func__ << " bdev " << id << " path " << path - << " size " << pretty_si_t(b->get_size()) << "B" << dendl; + << " size " << byte_u_t(b->get_size()) << dendl; bdev[id] = b; ioc[id] = new IOContext(cct, NULL); return 0; @@ -309,9 +309,9 @@ void BlueFS::get_usage(vector> *usage) (block_all[id].size() - (*usage)[id].first) * 100 / block_all[id].size(); dout(10) << __func__ << " bdev " << id << " free " << (*usage)[id].first - << " (" << pretty_si_t((*usage)[id].first) << "B)" + << " (" << byte_u_t((*usage)[id].first) << ")" << " / " << (*usage)[id].second - << " (" << pretty_si_t((*usage)[id].second) << "B)" + << " (" << byte_u_t((*usage)[id].second) << ")" << ", used " << used << "%" << dendl; } diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index fbd84137211e..615ddfbb0249 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -806,14 +806,14 @@ void BlueStore::Cache::trim( if (current <= target_bytes) { dout(30) << __func__ - << " shard target " << pretty_si_t(target_bytes) + << " shard target " << byte_u_t(target_bytes) << " meta/data ratios " << target_meta_ratio << " + " << target_data_ratio << " (" - << pretty_si_t(target_meta) << " + " - << pretty_si_t(target_buffer) << "), " - << " current " << pretty_si_t(current) << " (" - << pretty_si_t(current_meta) << " + " - << pretty_si_t(current_buffer) << ")" + << byte_u_t(target_meta) << " + " + << byte_u_t(target_buffer) << "), " + << " current " << byte_u_t(current) << " (" + << byte_u_t(current_meta) << " + " + << byte_u_t(current_buffer) << ")" << dendl; return; } @@ -835,16 +835,16 @@ void BlueStore::Cache::trim( uint64_t max_onodes = max_meta / bytes_per_onode; dout(20) << __func__ - << " shard target " << pretty_si_t(target_bytes) + << " shard target " << byte_u_t(target_bytes) << " ratio " << target_meta_ratio << " (" - << pretty_si_t(target_meta) << " + " - << pretty_si_t(target_buffer) << "), " - << " current " << pretty_si_t(current) << " (" - << pretty_si_t(current_meta) << " + " - << pretty_si_t(current_buffer) << ")," - << " need_to_free " << pretty_si_t(need_to_free) << " (" - << pretty_si_t(free_meta) << " + " - << pretty_si_t(free_buffer) << ")" + << byte_u_t(target_meta) << " + " + << byte_u_t(target_buffer) << "), " + << " current " << byte_u_t(current) << " (" + << byte_u_t(current_meta) << " + " + << byte_u_t(current_buffer) << ")," + << " need_to_free " << byte_u_t(need_to_free) << " (" + << byte_u_t(free_meta) << " + " + << byte_u_t(free_buffer) << ")" << " -> max " << max_onodes << " onodes + " << max_buffer << " buffer" << dendl; @@ -1140,7 +1140,7 @@ void BlueStore::TwoQCache::_trim(uint64_t onode_max, uint64_t buffer_max) } if (evicted > 0) { - dout(20) << __func__ << " evicted " << prettybyte_t(evicted) + dout(20) << __func__ << " evicted " << byte_u_t(evicted) << " from warm_in list, done evicting warm_in buffers" << dendl; } @@ -1166,7 +1166,7 @@ void BlueStore::TwoQCache::_trim(uint64_t onode_max, uint64_t buffer_max) } if (evicted > 0) { - dout(20) << __func__ << " evicted " << prettybyte_t(evicted) + dout(20) << __func__ << " evicted " << byte_u_t(evicted) << " from hot list, done evicting hot buffers" << dendl; } @@ -4345,7 +4345,7 @@ int BlueStore::_open_bdev(bool create) goto fail_close; } if (dev_size < cct->_conf->bluestore_bluefs_min) { - dout(1) << __func__ << " main device size " << si_t(dev_size) + dout(1) << __func__ << " main device size " << byte_u_t(dev_size) << " is too small, disable bluestore_bluefs_min for now" << dendl; int r = cct->_conf->set_val("bluestore_bluefs_min", "0"); @@ -4498,7 +4498,7 @@ int BlueStore::_open_alloc() bytes += length; } fm->enumerate_reset(); - dout(1) << __func__ << " loaded " << pretty_si_t(bytes) + dout(1) << __func__ << " loaded " << byte_u_t(bytes) << " in " << num << " extents" << dendl; @@ -5077,9 +5077,9 @@ int BlueStore::_balance_bluefs_freespace(PExtentVector *extents) float bluefs_ratio = (float)bluefs_free / (float)total_free; dout(10) << __func__ - << " bluefs " << pretty_si_t(bluefs_free) + << " bluefs " << byte_u_t(bluefs_free) << " free (" << bluefs_free_ratio - << ") bluestore " << pretty_si_t(my_free) + << ") bluestore " << byte_u_t(my_free) << " free (" << my_free_ratio << "), bluefs_ratio " << bluefs_ratio << dendl; @@ -5090,14 +5090,14 @@ int BlueStore::_balance_bluefs_freespace(PExtentVector *extents) gift = cct->_conf->bluestore_bluefs_gift_ratio * total_free; dout(10) << __func__ << " bluefs_ratio " << bluefs_ratio << " < min_ratio " << cct->_conf->bluestore_bluefs_min_ratio - << ", should gift " << pretty_si_t(gift) << dendl; + << ", should gift " << byte_u_t(gift) << dendl; } else if (bluefs_ratio > cct->_conf->bluestore_bluefs_max_ratio) { reclaim = cct->_conf->bluestore_bluefs_reclaim_ratio * total_free; if (bluefs_total - reclaim < cct->_conf->bluestore_bluefs_min) reclaim = bluefs_total - cct->_conf->bluestore_bluefs_min; dout(10) << __func__ << " bluefs_ratio " << bluefs_ratio << " > max_ratio " << cct->_conf->bluestore_bluefs_max_ratio - << ", should reclaim " << pretty_si_t(reclaim) << dendl; + << ", should reclaim " << byte_u_t(reclaim) << dendl; } // don't take over too much of the freespace @@ -5107,7 +5107,7 @@ int BlueStore::_balance_bluefs_freespace(PExtentVector *extents) uint64_t g = cct->_conf->bluestore_bluefs_min - bluefs_total; dout(10) << __func__ << " bluefs_total " << bluefs_total << " < min " << cct->_conf->bluestore_bluefs_min - << ", should gift " << pretty_si_t(g) << dendl; + << ", should gift " << byte_u_t(g) << dendl; if (g > gift) gift = g; reclaim = 0; @@ -5118,7 +5118,7 @@ int BlueStore::_balance_bluefs_freespace(PExtentVector *extents) uint64_t g = min_free - bluefs_free; dout(10) << __func__ << " bluefs_free " << bluefs_free << " < min " << min_free - << ", should gift " << pretty_si_t(g) << dendl; + << ", should gift " << byte_u_t(g) << dendl; if (g > gift) gift = g; reclaim = 0; @@ -5131,7 +5131,7 @@ int BlueStore::_balance_bluefs_freespace(PExtentVector *extents) // hard cap to fit into 32 bits gift = std::min(gift, 1ull << 31); dout(10) << __func__ << " gifting " << gift - << " (" << pretty_si_t(gift) << ")" << dendl; + << " (" << byte_u_t(gift) << ")" << dendl; // fixme: just do one allocation to start... int r = alloc->reserve(gift); @@ -5168,7 +5168,7 @@ int BlueStore::_balance_bluefs_freespace(PExtentVector *extents) // hard cap to fit into 32 bits reclaim = std::min(reclaim, 1ull << 31); dout(10) << __func__ << " reclaiming " << reclaim - << " (" << pretty_si_t(reclaim) << ")" << dendl; + << " (" << byte_u_t(reclaim) << ")" << dendl; while (reclaim > 0) { // NOTE: this will block and do IO. @@ -5335,7 +5335,7 @@ int BlueStore::_setup_block_symlink_or_file( #endif } dout(1) << __func__ << " resized " << name << " file to " - << pretty_si_t(size) << "B" << dendl; + << byte_u_t(size) << dendl; } VOID_TEMP_FAILURE_RETRY(::close(fd)); } else { diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index 9bae23ce5bf5..abb71a0d45cf 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -158,9 +158,9 @@ int KernelDevice::open(const string& p) dout(1) << __func__ << " size " << size << " (0x" << std::hex << size << std::dec << ", " - << pretty_si_t(size) << "B)" + << byte_u_t(size) << ")" << " block_size " << block_size - << " (" << pretty_si_t(block_size) << "B)" + << " (" << byte_u_t(block_size) << ")" << " " << (rotational ? "rotational" : "non-rotational") << dendl; return 0; diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 546bb245a999..d03beca038a9 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -783,9 +783,9 @@ int NVMEDevice::open(const string& p) // round size down to an even block size &= ~(block_size - 1); - dout(1) << __func__ << " size " << size << " (" << pretty_si_t(size) << "B)" - << " block_size " << block_size << " (" << pretty_si_t(block_size) - << "B)" << dendl; + dout(1) << __func__ << " size " << size << " (" << byte_u_t(size) << ")" + << " block_size " << block_size << " (" << byte_u_t(block_size) + << ")" << dendl; return 0; diff --git a/src/os/bluestore/PMEMDevice.cc b/src/os/bluestore/PMEMDevice.cc index 666336de80fc..606691bbefbb 100644 --- a/src/os/bluestore/PMEMDevice.cc +++ b/src/os/bluestore/PMEMDevice.cc @@ -104,9 +104,9 @@ int PMEMDevice::open(const string& p) dout(1) << __func__ << " size " << size - << " (" << pretty_si_t(size) << "B)" + << " (" << byte_u_t(size) << ")" << " block_size " << block_size - << " (" << pretty_si_t(block_size) << "B)" + << " (" << byte_u_t(block_size) << ")" << dendl; return 0; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 73921cfbc351..3473544ca554 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -706,9 +706,9 @@ void OSDService::promote_throttle_recalibrate() uint64_t attempts, obj, bytes; promote_counter.sample_and_attenuate(&attempts, &obj, &bytes); dout(10) << __func__ << " " << attempts << " attempts, promoted " - << obj << " objects and " << pretty_si_t(bytes) << " bytes; target " + << obj << " objects and " << byte_u_t(bytes) << "; target " << target_obj_sec << " obj/sec or " - << pretty_si_t(target_bytes_sec) << " bytes/sec" + << byte_u_t(target_bytes_sec) << "/sec" << dendl; // calculate what the probability *should* be, given the targets @@ -6102,7 +6102,7 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector& cmd, buffe // having a sane value. If we allow any block size to be set things // can still go sideways. ss << "block 'size' values are capped at " - << prettybyte_t(cct->_conf->osd_bench_max_block_size) << ". If you wish to use" + << byte_u_t(cct->_conf->osd_bench_max_block_size) << ". If you wish to use" << " a higher value, please adjust 'osd_bench_max_block_size'"; r = -EINVAL; goto out; @@ -6115,7 +6115,7 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector& cmd, buffe bsize * duration * cct->_conf->osd_bench_small_size_max_iops; if (count > max_count) { ss << "'count' values greater than " << max_count - << " for a block size of " << prettybyte_t(bsize) << ", assuming " + << " for a block size of " << byte_u_t(bsize) << ", assuming " << cct->_conf->osd_bench_small_size_max_iops << " IOPS," << " for " << duration << " seconds," << " can cause ill effects on osd. " @@ -6138,8 +6138,8 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector& cmd, buffe cct->_conf->osd_bench_large_size_max_throughput * duration; if (count > max_count) { ss << "'count' values greater than " << max_count - << " for a block size of " << prettybyte_t(bsize) << ", assuming " - << prettybyte_t(cct->_conf->osd_bench_large_size_max_throughput) << "/s," + << " for a block size of " << byte_u_t(bsize) << ", assuming " + << byte_u_t(cct->_conf->osd_bench_large_size_max_throughput) << "/s," << " for " << duration << " seconds," << " can cause ill effects on osd. " << " Please adjust 'osd_bench_large_size_max_throughput'" @@ -6153,7 +6153,7 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector& cmd, buffe bsize = osize; dout(1) << " bench count " << count - << " bsize " << prettybyte_t(bsize) << dendl; + << " bsize " << byte_u_t(bsize) << dendl; ObjectStore::Transaction cleanupt; @@ -6233,9 +6233,9 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector& cmd, buffe f->close_section(); f->flush(ss); } else { - ss << "bench: wrote " << prettybyte_t(count) - << " in blocks of " << prettybyte_t(bsize) << " in " - << (end-start) << " sec at " << prettybyte_t(rate) << "/sec"; + ss << "bench: wrote " << byte_u_t(count) + << " in blocks of " << byte_u_t(bsize) << " in " + << (end-start) << " sec at " << byte_u_t(rate) << "/sec"; } } diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 8ba0bb40e580..7dadaaae2387 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -4480,9 +4480,9 @@ public: *tbl << "" << "" << "" << "TOTAL" - << si_t(pgmap.get_osd_sum().kb << 10) - << si_t(pgmap.get_osd_sum().kb_used << 10) - << si_t(pgmap.get_osd_sum().kb_avail << 10) + << byte_u_t(pgmap.get_osd_sum().kb << 10) + << byte_u_t(pgmap.get_osd_sum().kb_used << 10) + << byte_u_t(pgmap.get_osd_sum().kb_avail << 10) << lowprecision_t(average_util) << "" << TextTable::endrow; @@ -4512,9 +4512,9 @@ protected: << c << weightf_t(qi.weight) << weightf_t(reweight) - << si_t(kb << 10) - << si_t(kb_used << 10) - << si_t(kb_avail << 10) + << byte_u_t(kb << 10) + << byte_u_t(kb_used << 10) + << byte_u_t(kb_avail << 10) << lowprecision_t(util) << lowprecision_t(var); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 74b84c0191cd..6b7cb2f2a2aa 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -963,9 +963,9 @@ inline bool operator!=(const osd_stat_t& l, const osd_stat_t& r) { inline ostream& operator<<(ostream& out, const osd_stat_t& s) { - return out << "osd_stat(" << kb_t(s.kb_used) << " used, " - << kb_t(s.kb_avail) << " avail, " - << kb_t(s.kb) << " total, " + return out << "osd_stat(" << byte_u_t(s.kb_used << 10) << " used, " + << byte_u_t(s.kb_avail << 10) << " avail, " + << byte_u_t(s.kb << 10) << " total, " << "peers " << s.hb_peers << " op hist " << s.op_queue_age_hist.h << ")"; diff --git a/src/test/mon/PGMap.cc b/src/test/mon/PGMap.cc index b13da18e23ee..79fe772945fe 100644 --- a/src/test/mon/PGMap.cc +++ b/src/test/mon/PGMap.cc @@ -74,23 +74,23 @@ TEST(pgmap, dump_object_stat_sum_0) pool.type = pg_pool_t::TYPE_REPLICATED; PGMap::dump_object_stat_sum(tbl, nullptr, sum, avail, pool.get_size(), verbose, &pool); - ASSERT_EQ(stringify(si_t(sum.num_bytes)), tbl.get(0, 0)); + ASSERT_EQ(stringify(byte_u_t(sum.num_bytes)), tbl.get(0, 0)); float copies_rate = (static_cast(sum.num_object_copies - sum.num_objects_degraded) / sum.num_object_copies); float used_bytes = sum.num_bytes * copies_rate * pool.get_size(); float used_percent = used_bytes / (used_bytes + avail) * 100; unsigned col = 0; - ASSERT_EQ(stringify(si_t(sum.num_bytes)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(sum.num_bytes)), tbl.get(0, col++)); ASSERT_EQ(percentify(used_percent), tbl.get(0, col++)); - ASSERT_EQ(stringify(si_t(avail/pool.size)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(avail/pool.size)), tbl.get(0, col++)); ASSERT_EQ(stringify(sum.num_objects), tbl.get(0, col++)); - ASSERT_EQ(stringify(si_t(sum.num_objects_dirty)), tbl.get(0, col++)); - ASSERT_EQ(stringify(si_t(sum.num_rd)), tbl.get(0, col++)); - ASSERT_EQ(stringify(si_t(sum.num_wr)), tbl.get(0, col++)); + ASSERT_EQ(stringify(si_u_t(sum.num_objects_dirty)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(sum.num_rd)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(sum.num_wr)), tbl.get(0, col++)); // we can use pool.size for raw_used_rate if it is a replica pool uint64_t raw_bytes_used = sum.num_bytes * pool.get_size() * copies_rate; - ASSERT_EQ(stringify(si_t(raw_bytes_used)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(raw_bytes_used)), tbl.get(0, col++)); } // with table, without formatter, verbose = true, empty, avail > 0 @@ -109,16 +109,16 @@ TEST(pgmap, dump_object_stat_sum_1) pool.type = pg_pool_t::TYPE_REPLICATED; PGMap::dump_object_stat_sum(tbl, nullptr, sum, avail, pool.get_size(), verbose, &pool); - ASSERT_EQ(stringify(si_t(0)), tbl.get(0, 0)); + ASSERT_EQ(stringify(byte_u_t(0)), tbl.get(0, 0)); unsigned col = 0; - ASSERT_EQ(stringify(si_t(0)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(0)), tbl.get(0, col++)); ASSERT_EQ(percentify(0), tbl.get(0, col++)); - ASSERT_EQ(stringify(si_t(avail/pool.size)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(avail/pool.size)), tbl.get(0, col++)); ASSERT_EQ(stringify(0), tbl.get(0, col++)); - ASSERT_EQ(stringify(si_t(0)), tbl.get(0, col++)); - ASSERT_EQ(stringify(si_t(0)), tbl.get(0, col++)); - ASSERT_EQ(stringify(si_t(0)), tbl.get(0, col++)); - ASSERT_EQ(stringify(si_t(0)), tbl.get(0, col++)); + ASSERT_EQ(stringify(si_u_t(0)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(0)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(0)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(0)), tbl.get(0, col++)); } // with table, without formatter, verbose = false, empty, avail = 0 @@ -138,10 +138,10 @@ TEST(pgmap, dump_object_stat_sum_2) PGMap::dump_object_stat_sum(tbl, nullptr, sum, avail, pool.get_size(), verbose, &pool); - ASSERT_EQ(stringify(si_t(0)), tbl.get(0, 0)); + ASSERT_EQ(stringify(byte_u_t(0)), tbl.get(0, 0)); unsigned col = 0; - ASSERT_EQ(stringify(si_t(0)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(0)), tbl.get(0, col++)); ASSERT_EQ(percentify(0), tbl.get(0, col++)); - ASSERT_EQ(stringify(si_t(avail/pool.size)), tbl.get(0, col++)); + ASSERT_EQ(stringify(byte_u_t(avail/pool.size)), tbl.get(0, col++)); ASSERT_EQ(stringify(0), tbl.get(0, col++)); } diff --git a/src/tools/ceph_kvstore_tool.cc b/src/tools/ceph_kvstore_tool.cc index 2103efc87aca..a79023ba3ece 100644 --- a/src/tools/ceph_kvstore_tool.cc +++ b/src/tools/ceph_kvstore_tool.cc @@ -257,7 +257,7 @@ class StoreTool auto cur_duration = std::chrono::duration(coarse_mono_clock::now() - started_at); std::cout << "ts = " << cur_duration.count() << "s, copied " << total_keys - << " keys so far (" << stringify(si_t(total_size)) << ")" + << " keys so far (" << stringify(si_u_t(total_size)) << ")" << std::endl; } while (it->valid()); @@ -267,7 +267,7 @@ class StoreTool std::cout << "summary:" << std::endl; std::cout << " copied " << total_keys << " keys" << std::endl; std::cout << " used " << total_txs << " transactions" << std::endl; - std::cout << " total size " << stringify(si_t(total_size)) << std::endl; + std::cout << " total size " << stringify(si_u_t(total_size)) << std::endl; std::cout << " from '" << store_path << "' to '" << other_path << "'" << std::endl; std::cout << " duration " << time_taken.count() << " seconds" << std::endl; @@ -463,7 +463,7 @@ int main(int argc, const char *argv[]) return 1; } std::cout << "(" << url_escape(prefix) << "," << url_escape(key) - << ") size " << si_t(bl.length()) << std::endl; + << ") size " << si_u_t(bl.length()) << std::endl; } else if (cmd == "set") { if (argc < 8) { diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index 961490ba7ded..d8b78dce874b 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -1317,13 +1317,13 @@ int main(int argc, char **argv) { out_store.apply_transaction(tx); std::cout << "copied " << total_keys << " keys so far (" - << stringify(si_t(total_size)) << ")" << std::endl; + << stringify(byte_u_t(total_size)) << ")" << std::endl; } while (it->valid()); out_store.close(); std::cout << "summary: copied " << total_keys << " keys, using " << total_tx << " transactions, totalling " - << stringify(si_t(total_size)) << std::endl; + << stringify(byte_u_t(total_size)) << std::endl; std::cout << "from '" << store_path << "' to '" << out_path << "'" << std::endl; } else if (cmd == "rewrite-crush") { diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index c1fe40cc98c6..79ac8fe0fdc7 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -2073,7 +2073,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, librados::pool_stat_t& s = i->second; if (!formatter) { tab << pool_name - << si_t(s.num_bytes) + << byte_u_t(s.num_bytes) << s.num_objects << s.num_object_clones << s.num_object_copies @@ -2081,9 +2081,9 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, << s.num_objects_unfound << s.num_objects_degraded << s.num_rd - << si_t(s.num_rd_kb << 10) + << byte_u_t(s.num_rd_kb << 10) << s.num_wr - << si_t(s.num_wr_kb << 10) + << byte_u_t(s.num_wr_kb << 10) << TextTable::endrow; } else { formatter->open_object_section("pool"); @@ -2125,11 +2125,11 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, cout << std::endl; cout << "total_objects " << tstats.num_objects << std::endl; - cout << "total_used " << si_t(tstats.kb_used << 10) + cout << "total_used " << byte_u_t(tstats.kb_used << 10) << std::endl; - cout << "total_avail " << si_t(tstats.kb_avail << 10) + cout << "total_avail " << byte_u_t(tstats.kb_avail << 10) << std::endl; - cout << "total_space " << si_t(tstats.kb << 10) + cout << "total_space " << byte_u_t(tstats.kb << 10) << std::endl; } else { formatter->close_section(); diff --git a/src/tools/rbd/action/Bench.cc b/src/tools/rbd/action/Bench.cc index 95177d7a8726..2da32bb7e6c8 100644 --- a/src/tools/rbd/action/Bench.cc +++ b/src/tools/rbd/action/Bench.cc @@ -199,8 +199,8 @@ int do_bench(librbd::Image& image, io_type_t io_type, uint64_t size = 0; image.size(&size); if (io_size > size) { - std::cerr << "rbd: io-size " << prettybyte_t(io_size) << " " - << "larger than image size " << prettybyte_t(size) << std::endl; + std::cerr << "rbd: io-size " << byte_u_t(io_size) << " " + << "larger than image size " << byte_u_t(size) << std::endl; return -EINVAL; } diff --git a/src/tools/rbd/action/DiskUsage.cc b/src/tools/rbd/action/DiskUsage.cc index ab7dfada2e18..2df2d3606fd0 100644 --- a/src/tools/rbd/action/DiskUsage.cc +++ b/src/tools/rbd/action/DiskUsage.cc @@ -78,8 +78,8 @@ static int compute_image_disk_usage(const std::string& name, full_name += "@" + snap_name; } tbl << full_name - << stringify(si_t(size)) - << stringify(si_t(*used_size)) + << stringify(byte_u_t(size)) + << stringify(byte_u_t(*used_size)) << TextTable::endrow; } return 0; @@ -230,8 +230,8 @@ out: } else { if (count > 1) { tbl << "" - << stringify(si_t(total_prov)) - << stringify(si_t(total_used)) + << stringify(byte_u_t(total_prov)) + << stringify(byte_u_t(total_used)) << TextTable::endrow; } std::cout << tbl; diff --git a/src/tools/rbd/action/Info.cc b/src/tools/rbd/action/Info.cc index 6927a303b056..74ef95328371 100644 --- a/src/tools/rbd/action/Info.cc +++ b/src/tools/rbd/action/Info.cc @@ -204,11 +204,11 @@ static int do_show_info(librados::IoCtx &io_ctx, librbd::Image& image, f->dump_int("format", (old_format ? 1 : 2)); } else { std::cout << "rbd image '" << imgname << "':\n" - << "\tsize " << prettybyte_t(info.size) << " in " + << "\tsize " << byte_u_t(info.size) << " in " << info.num_objs << " objects" << std::endl << "\torder " << info.order - << " (" << prettybyte_t(info.obj_size) << " objects)" + << " (" << si_u_t(info.obj_size) << " objects)" << std::endl; if (!imgid.empty()) { std::cout << "\tid: " << imgid << std::endl; @@ -292,7 +292,7 @@ static int do_show_info(librados::IoCtx &io_ctx, librbd::Image& image, std::cout << " (trash " << parent_id << ")"; } std::cout << std::endl; - std::cout << "\toverlap: " << prettybyte_t(overlap) << std::endl; + std::cout << "\toverlap: " << byte_u_t(overlap) << std::endl; } } @@ -302,7 +302,7 @@ static int do_show_info(librados::IoCtx &io_ctx, librbd::Image& image, f->dump_unsigned("stripe_unit", image.get_stripe_unit()); f->dump_unsigned("stripe_count", image.get_stripe_count()); } else { - std::cout << "\tstripe unit: " << prettybyte_t(image.get_stripe_unit()) + std::cout << "\tstripe unit: " << byte_u_t(image.get_stripe_unit()) << std::endl << "\tstripe count: " << image.get_stripe_count() << std::endl; } diff --git a/src/tools/rbd/action/Journal.cc b/src/tools/rbd/action/Journal.cc index 734831d2286d..a189d59631cf 100644 --- a/src/tools/rbd/action/Journal.cc +++ b/src/tools/rbd/action/Journal.cc @@ -78,7 +78,7 @@ static int do_show_journal_info(librados::Rados& rados, librados::IoCtx& io_ctx, std::cout << "\theader_oid: " << header_oid << std::endl; std::cout << "\tobject_oid_prefix: " << object_oid_prefix << std::endl; std::cout << "\torder: " << static_cast(order) << " (" - << prettybyte_t(1ull << order) << " objects)"<< std::endl; + << si_u_t(1ull << order) << " objects)"<< std::endl; std::cout << "\tsplay_width: " << static_cast(splay_width) << std::endl; if (!object_pool_name.empty()) { std::cout << "\tobject_pool: " << object_pool_name << std::endl; diff --git a/src/tools/rbd/action/List.cc b/src/tools/rbd/action/List.cc index 1068f73fe8be..e6810b9a4c0d 100644 --- a/src/tools/rbd/action/List.cc +++ b/src/tools/rbd/action/List.cc @@ -91,7 +91,7 @@ int list_process_image(librados::Rados* rados, WorkerEntry* w, bool lflag, Forma f->close_section(); } else { tbl << w->name - << stringify(si_t(info.size)) + << stringify(byte_u_t(info.size)) << parent << ((old_format) ? '1' : '2') << "" // protect doesn't apply to images @@ -131,7 +131,7 @@ int list_process_image(librados::Rados* rados, WorkerEntry* w, bool lflag, Forma f->close_section(); } else { tbl << w->name + "@" + s->name - << stringify(si_t(s->size)) + << stringify(byte_u_t(s->size)) << parent << ((old_format) ? '1' : '2') << (is_protected ? "yes" : "") diff --git a/src/tools/rbd/action/Snap.cc b/src/tools/rbd/action/Snap.cc index 70b822130285..d07b7448b4fc 100644 --- a/src/tools/rbd/action/Snap.cc +++ b/src/tools/rbd/action/Snap.cc @@ -114,7 +114,7 @@ int do_list_snaps(librbd::Image& image, Formatter *f, bool all_snaps, librados:: } f->close_section(); } else { - t << s->id << s->name << stringify(prettybyte_t(s->size)) << tt_str; + t << s->id << s->name << stringify(byte_u_t(s->size)) << tt_str; if (all_snaps) { ostringstream oss; diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc index c4b6fda1255a..522b6332bb61 100644 --- a/src/tools/rbd_nbd/rbd-nbd.cc +++ b/src/tools/rbd_nbd/rbd-nbd.cc @@ -806,8 +806,8 @@ static int do_map(int argc, const char *argv[], Config *cfg) if (info.size > ULONG_MAX) { r = -EFBIG; - cerr << "rbd-nbd: image is too large (" << prettybyte_t(info.size) - << ", max is " << prettybyte_t(ULONG_MAX) << ")" << std::endl; + cerr << "rbd-nbd: image is too large (" << byte_u_t(info.size) + << ", max is " << byte_u_t(ULONG_MAX) << ")" << std::endl; goto close_nbd; }