diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 016760c99a2..6182481cf6f 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2793,6 +2793,11 @@ void OSD::load_pgs() pg->read_state(store, bl); 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; diff --git a/src/osd/PG.h b/src/osd/PG.h index 4a804c80bcc..1e435b087ed 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -281,8 +281,14 @@ public: pg_info_t info; __u8 info_struct_v; static const __u8 cur_struct_v = 8; + // v7 was SnapMapper addition in 86658392516d5175b2756659ef7ffaaf95b0f8ad + // (first appeared in cuttlefish). + static const __u8 compat_struct_v = 7; bool must_upgrade() { - return info_struct_v < 8; + return info_struct_v < cur_struct_v; + } + bool can_upgrade() { + return info_struct_v >= compat_struct_v; } void upgrade( ObjectStore *store, diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 69abc6677c4..fd560e63f91 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -2795,6 +2795,11 @@ int main(int argc, char **argv) ret = 1; goto out; } + if (struct_ver < PG::compat_struct_v) { + cerr << "PG is too old to upgrade, use older Ceph version" << std::endl; + ret = 1; + goto out; + } if (debug) cerr << "struct_v " << (int)struct_ver << std::endl;