derr << "failed to list pgs: " << cpp_strerror(-r) << dendl;
}
- bool has_upgraded = false;
-
for (vector<coll_t>::iterator it = ls.begin();
it != ls.end();
++it) {
// read pg state, log
pg->read_state(store);
- if (pg->must_upgrade()) {
- if (!pg->can_upgrade()) {
- derr << "PG needs upgrade, but on-disk data is too old; upgrade to"
- << " an older version first." << dendl;
- assert(0 == "PG too old to upgrade");
- }
- if (!has_upgraded) {
- derr << "PGs are upgrading" << dendl;
- has_upgraded = true;
- }
- dout(10) << "PG " << pg->pg_id
- << " must upgrade..." << dendl;
- pg->upgrade(store);
- }
-
service.init_splits_between(pg->pg_id, pg->get_osdmap(), osdmap);
// generate state for PG's current mapping
void PG::upgrade(ObjectStore *store)
{
+ dout(0) << __func__ << " " << info_struct_v << " -> " << latest_struct_v
+ << dendl;
assert(info_struct_v <= 10);
ObjectStore::Transaction t;
assert(info_struct_v == 10);
// update infover_key
- if (info_struct_v < cur_struct_v) {
+ if (info_struct_v < latest_struct_v) {
map<string,bufferlist> v;
- __u8 ver = cur_struct_v;
+ __u8 ver = latest_struct_v;
::encode(ver, v[infover_key]);
t.omap_setkeys(coll, pgmeta_oid, v);
}
ghobject_t pgmeta_oid(pgid.make_pgmeta_oid());
t.touch(coll, pgmeta_oid);
map<string,bufferlist> values;
- __u8 struct_v = cur_struct_v;
+ __u8 struct_v = latest_struct_v;
::encode(struct_v, values[infover_key]);
t.omap_setkeys(coll, pgmeta_oid, values);
}
info_struct_v);
assert(r >= 0);
+ if (info_struct_v < compat_struct_v) {
+ derr << "PG needs upgrade, but on-disk data is too old; upgrade to"
+ << " an older version first." << dendl;
+ assert(0 == "PG too old to upgrade");
+ }
+
last_written_info = info;
ostringstream oss;
// log any weirdness
log_weirdness();
+
+ if (info_struct_v < latest_struct_v) {
+ upgrade(store);
+ }
}
void PG::log_weirdness()
// pg state
pg_info_t info; ///< current pg info
pg_info_t last_written_info; ///< last written info
- __u8 info_struct_v;
-public:
- static const __u8 cur_struct_v = 10;
+ __u8 info_struct_v = 0;
+ static const __u8 latest_struct_v = 10;
// v10 is the new past_intervals encoding
// v9 was fastinfo_key addition
// v8 was the move to a per-pg pgmeta object
// v7 was SnapMapper addition in 86658392516d5175b2756659ef7ffaaf95b0f8ad
// (first appeared in cuttlefish).
static const __u8 compat_struct_v = 10;
-protected:
- bool must_upgrade() {
- return info_struct_v < cur_struct_v;
- }
- bool can_upgrade() {
- return info_struct_v >= compat_struct_v;
- }
void upgrade(ObjectStore *store);
protected: