Merge PR #23471 into master

* refs/pull/23471/head:
	mon/PGMap: fix spacing around pretty-printed SI units
	include/types: render SI units adjacent to number

Reviewed-by: Kefu Chai <kchai@redhat.com>
Reviewed-by: João Eduardo Luís <joao@suse.de>
This commit is contained in:
Sage Weil 2018-08-09 14:35:56 -05:00
commit ebaa80690d
3 changed files with 14 additions and 14 deletions

View File

@ -1786,7 +1786,7 @@ function test_mon_osd_pool_quota()
# get quotas
#
ceph osd pool get-quota tmp-quota-pool | grep 'max bytes.*10 B'
ceph osd pool get-quota tmp-quota-pool | grep 'max objects.*10 M objects'
ceph osd pool get-quota tmp-quota-pool | grep 'max objects.*10.*M objects'
#
# set valid quotas with unit prefix
#

View File

@ -363,11 +363,11 @@ namespace {
char buffer[32];
if (index == 0) {
(void) snprintf(buffer, sizeof(buffer), "%" PRId64 " %s", n, u);
(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);
(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
@ -378,7 +378,7 @@ namespace {
// easier just to try each combination in turn.
int i;
for (i = 2; i >= 0; i--) {
if (snprintf(buffer, sizeof(buffer), "%.*f %s", i,
if (snprintf(buffer, sizeof(buffer), "%.*f%s", i,
static_cast<double>(v) / mult, u) <= 7)
break;
}
@ -429,7 +429,7 @@ inline ostream& operator<<(ostream& out, const byte_u_t& b)
{
uint64_t n = b.v;
int index = 0;
const char* u[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"};
const char* u[] = {" B", " KiB", " MiB", " GiB", " TiB", " PiB", " EiB"};
while (n >= 1024 && index < 7) {
n /= 1024;

View File

@ -376,7 +376,7 @@ void PGMapDigest::print_oneline_summary(Formatter *f, ostream *out) const
}
int64_t iops = (pos_delta.stats.sum.num_rd + pos_delta.stats.sum.num_wr) / (double)stamp_delta;
if (out)
*out << si_u_t(iops) << "op/s";
*out << si_u_t(iops) << " op/s";
if (f)
f->dump_unsigned("io_sec", iops);
}
@ -470,8 +470,8 @@ void PGMapDigest::recovery_rate_summary(Formatter *f, ostream *out,
} else {
*out << byte_u_t(bps) << "/s";
if (pos_delta.stats.sum.num_keys_recovered)
*out << ", " << si_u_t(kps) << "keys/s";
*out << ", " << si_u_t(objps) << "objects/s";
*out << ", " << si_u_t(kps) << " keys/s";
*out << ", " << si_u_t(objps) << " objects/s";
}
}
}
@ -538,7 +538,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 << si_u_t(iops_rd) << "op/s rd, " << si_u_t(iops_wr) << "op/s wr";
*out << si_u_t(iops_rd) << " op/s rd, " << si_u_t(iops_wr) << " op/s wr";
}
}
}
@ -595,7 +595,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out,
} else {
if (have_output)
*out << ", ";
*out << si_u_t(promote) << "op/s promote";
*out << si_u_t(promote) << " op/s promote";
have_output = true;
}
}
@ -605,7 +605,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out,
} else {
if (have_output)
*out << ", ";
*out << si_u_t(pos_delta.stats.sum.num_flush_mode_low) << "PG(s) flushing";
*out << si_u_t(pos_delta.stats.sum.num_flush_mode_low) << " PGs flushing";
have_output = true;
}
}
@ -615,7 +615,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out,
} else {
if (have_output)
*out << ", ";
*out << si_u_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) << " PGs flushing (high)";
have_output = true;
}
}
@ -625,7 +625,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out,
} else {
if (have_output)
*out << ", ";
*out << si_u_t(pos_delta.stats.sum.num_evict_mode_some) << "PG(s) evicting";
*out << si_u_t(pos_delta.stats.sum.num_evict_mode_some) << " PGs evicting";
have_output = true;
}
}
@ -635,7 +635,7 @@ void PGMapDigest::cache_io_rate_summary(Formatter *f, ostream *out,
} else {
if (have_output)
*out << ", ";
*out << si_u_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) << " PGs evicting (full)";
}
}
}