Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mon, osd: add create-time for pool #21690

Merged
merged 1 commit into from Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mon/OSDMonitor.cc
Expand Up @@ -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;
Expand Down
14 changes: 12 additions & 2 deletions src/osd/osd_types.cc
Expand Up @@ -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());
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/osd/osd_types.h
Expand Up @@ -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
Expand Down Expand Up @@ -1456,6 +1457,7 @@ struct pg_pool_t {

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; }
Expand Down