mirror of
https://github.com/ceph/ceph
synced 2025-01-10 21:20:46 +00:00
mon, osd: add create-time for pool
We want to know how old the pools currently are, on which mgr/balancer can make some time-related smart decisions based. Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
parent
0cb3e64221
commit
47359a3b8e
@ -6470,6 +6470,7 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid,
|
||||
int64_t pool = ++pending_inc.new_pool_max;
|
||||
pg_pool_t empty;
|
||||
pg_pool_t *pi = pending_inc.get_new_pool(pool, &empty);
|
||||
pi->create_time = ceph_clock_now();
|
||||
pi->type = pool_type;
|
||||
pi->fast_read = fread;
|
||||
pi->flags = g_conf->osd_pool_default_flags;
|
||||
|
@ -1163,6 +1163,7 @@ const char *pg_pool_t::APPLICATION_NAME_RGW("rgw");
|
||||
|
||||
void pg_pool_t::dump(Formatter *f) const
|
||||
{
|
||||
f->dump_stream("create_time") << get_create_time();
|
||||
f->dump_unsigned("flags", get_flags());
|
||||
f->dump_string("flags_names", get_flags_string());
|
||||
f->dump_int("type", get_type());
|
||||
@ -1554,7 +1555,7 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t v = 26;
|
||||
uint8_t v = 27;
|
||||
// NOTE: any new encoding dependencies must be reflected by
|
||||
// SIGNIFICANT_FEATURES
|
||||
if (!(features & CEPH_FEATURE_NEW_OSDOP_ENCODING)) {
|
||||
@ -1563,6 +1564,8 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
|
||||
v = 21;
|
||||
} else if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
|
||||
v = 24;
|
||||
} else if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
|
||||
v = 26;
|
||||
}
|
||||
|
||||
ENCODE_START(v, 5, bl);
|
||||
@ -1638,12 +1641,15 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
|
||||
if (v >= 26) {
|
||||
encode(application_metadata, bl);
|
||||
}
|
||||
if (v >= 27) {
|
||||
encode(create_time, bl);
|
||||
}
|
||||
ENCODE_FINISH(bl);
|
||||
}
|
||||
|
||||
void pg_pool_t::decode(bufferlist::iterator& bl)
|
||||
{
|
||||
DECODE_START_LEGACY_COMPAT_LEN(26, 5, 5, bl);
|
||||
DECODE_START_LEGACY_COMPAT_LEN(27, 5, 5, bl);
|
||||
decode(type, bl);
|
||||
decode(size, bl);
|
||||
decode(crush_rule, bl);
|
||||
@ -1793,6 +1799,9 @@ void pg_pool_t::decode(bufferlist::iterator& bl)
|
||||
if (struct_v >= 26) {
|
||||
decode(application_metadata, bl);
|
||||
}
|
||||
if (struct_v >= 27) {
|
||||
decode(create_time, bl);
|
||||
}
|
||||
DECODE_FINISH(bl);
|
||||
calc_pg_masks();
|
||||
calc_grade_table();
|
||||
@ -1803,6 +1812,7 @@ void pg_pool_t::generate_test_instances(list<pg_pool_t*>& o)
|
||||
pg_pool_t a;
|
||||
o.push_back(new pg_pool_t(a));
|
||||
|
||||
a.create_time = utime_t(4,5);
|
||||
a.type = TYPE_REPLICATED;
|
||||
a.size = 2;
|
||||
a.crush_rule = 3;
|
||||
|
@ -1295,6 +1295,7 @@ struct pg_pool_t {
|
||||
}
|
||||
}
|
||||
|
||||
utime_t create_time;
|
||||
uint64_t flags; ///< FLAG_*
|
||||
__u8 type; ///< TYPE_*
|
||||
__u8 size, min_size; ///< number of osds in each pg
|
||||
@ -1456,6 +1457,7 @@ public:
|
||||
|
||||
void dump(Formatter *f) const;
|
||||
|
||||
const utime_t &get_create_time() const { return create_time; }
|
||||
uint64_t get_flags() const { return flags; }
|
||||
bool has_flag(uint64_t f) const { return flags & f; }
|
||||
void set_flag(uint64_t f) { flags |= f; }
|
||||
|
Loading…
Reference in New Issue
Block a user