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 | \
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
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;
// --
-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<double>(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)
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
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;
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());
}
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");
(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) {
} 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: ";
}
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);
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);
}
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";
}
}
}
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) {
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;
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";
}
}
}
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;
}
}
} else {
if (have_output)
*out << ", ";
- *out << pretty_si_t(evict) << "B/s evict";
+ *out << byte_u_t(evict) << "/s evict";
have_output = true;
}
}
} else {
if (have_output)
*out << ", ";
- *out << pretty_si_t(promote) << "op/s promote";
+ *out << si_u_t(promote) << "op/s promote";
have_output = true;
}
}
} 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;
}
}
} 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;
}
}
} 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;
}
}
} 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)";
}
}
}
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);
}
}
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;
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));
}
}
}
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)
}
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;
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;
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;
}
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;
}
} 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;
}
}
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;
(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;
}
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;
}
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;
}
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;
}
}
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;
}
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");
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;
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;
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
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;
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;
// hard cap to fit into 32 bits
gift = std::min<uint64_t>(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);
// hard cap to fit into 32 bits
reclaim = std::min<uint64_t>(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.
#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 {
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;
// 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;
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;
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
// 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;
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. "
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'"
bsize = osize;
dout(1) << " bench count " << count
- << " bsize " << prettybyte_t(bsize) << dendl;
+ << " bsize " << byte_u_t(bsize) << dendl;
ObjectStore::Transaction cleanupt;
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";
}
}
*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;
<< 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);
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
<< ")";
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<float>(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
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
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++));
}
auto cur_duration = std::chrono::duration<double>(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());
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;
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) {
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") {
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
<< 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");
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();
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;
}
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;
} else {
if (count > 1) {
tbl << "<TOTAL>"
- << 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;
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;
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;
}
}
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;
}
std::cout << "\theader_oid: " << header_oid << std::endl;
std::cout << "\tobject_oid_prefix: " << object_oid_prefix << std::endl;
std::cout << "\torder: " << static_cast<int>(order) << " ("
- << prettybyte_t(1ull << order) << " objects)"<< std::endl;
+ << si_u_t(1ull << order) << " objects)"<< std::endl;
std::cout << "\tsplay_width: " << static_cast<int>(splay_width) << std::endl;
if (!object_pool_name.empty()) {
std::cout << "\tobject_pool: " << object_pool_name << std::endl;
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
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" : "")
}
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;
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;
}