osd: prevent upgrade from older than v7

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2014-11-23 20:27:08 -08:00
parent d1973f3ba0
commit 9d1466cb6e
3 changed files with 17 additions and 1 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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;