From eb27307055895d305c0ff1e3f87c215f79ad8bbf Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 14 Jan 2010 16:27:14 -0800 Subject: [PATCH] add versioning and awareness bla bla --- src/cmon.cc | 14 ++++++++++---- src/mds/CInode.cc | 7 ++++--- src/mds/mdstypes.h | 3 ++- src/osd/osd_types.h | 10 +++++++--- src/osdc/Journaler.cc | 18 ++++++++++++------ 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/cmon.cc b/src/cmon.cc index 9631e7f310f40..5c35cf81ef8da 100644 --- a/src/cmon.cc +++ b/src/cmon.cc @@ -111,11 +111,17 @@ int main(int argc, const char **argv) bufferlist features; store.get_bl_ss(features, COMPAT_SET_LOC, 0); if (features.length() == 0) { - cerr << "mon fs missing feature list. Exiting now" << std::endl; - exit(1); + cerr << "WARNING: mon fs missing feature list.\n" + << "Assuming it is old-style and introducing one." << std::endl; + //we only want the baseline ~v.18 features assumed to be on disk. + //They'll be first in the incompat list. + ondisk_features = CompatSet(NULL, 0, NULL, 0, + ceph_mon_feature_incompat, + 1); + } else { + bufferlist::iterator it = features.begin(); + ondisk_features.decode(it); } - bufferlist::iterator it = features.begin(); - ondisk_features.decode(it); if (!mon_features.writeable(ondisk_features)) { cerr << "monitor executable cannot read disk! Missing features: " diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index e9e049f5d1ff4..65fba2d463606 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -726,17 +726,18 @@ void CInode::fetch(Context *fin) void CInode::_fetched(bufferlist& bl, Context *fin) { dout(10) << "_fetched" << dendl; + CompatSet& mds_features = mdcache->mds->mds_features; bufferlist::iterator p = bl.begin(); nstring magic; ::decode(magic, p); dout(10) << " magic is '" << magic << "' (expecting '" << CEPH_FS_ONDISK_MAGIC << "')" << dendl; - if (magic != CEPH_FS_ONDISK_MAGIC) { + if (magic != CEPH_FS_ONDISK_MAGIC && magic != CEPH_FS_OLD_ONDISK_MAGIC) { dout(0) << "on disk magic '" << magic << "' != my magic '" << CEPH_FS_ONDISK_MAGIC << "'" << dendl; fin->finish(-EINVAL); } else { - ondisk_ino_features.decode(p); - CompatSet& mds_features = mdcache->mds->mds_features; + if (magic != CEPH_FS_OLD_ONDISK_MAGIC) ondisk_ino_features.decode(p); + else ondisk_ino_features = mds_features; if ( !mds_features.writeable(ondisk_ino_features)) { dout(0) << "mds data on-disk uses unknown features!" << dendl; CompatSet diff = mds_features.unsupported(ondisk_ino_features); diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 4f574aa61045a..494a075e20e75 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -20,7 +20,8 @@ using namespace std; #include -#define CEPH_FS_ONDISK_MAGIC "ceph fs volume v011" +#define CEPH_FS_ONDISK_MAGIC "ceph fs volume v012" +#define CEPH_FS_OLD_ONDISK_MAGIC "ceph fs volume v011" //#define MDS_REF_SET // define me for improved debug output, sanity checking diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 1d64080d695b8..365874f73b73f 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -29,7 +29,8 @@ #define CEPH_OSD_NEARFULL_RATIO .8 #define CEPH_OSD_FULL_RATIO .95 - +//this #define copied from OSD.h +#define CEPH_OSD_FEATURE_INCOMPAT_BASE "initial feature set(~v.18)" /* osdreqid_t - caller name + incarnation# + tid to unique identify this request @@ -1027,7 +1028,7 @@ public: } void encode(bufferlist &bl) const { - __u8 v = 1; + __u8 v = 2; ::encode(v, bl); ::encode(magic, bl); @@ -1052,7 +1053,10 @@ public: ::decode(oldest_map, bl); ::decode(newest_map, bl); ::decode(weight, bl); - compat_features.decode(bl); + if (v >= 2) compat_features.decode(bl); + else { //upgrade it! + compat_features.incompat.insert(CEPH_OSD_FEATURE_INCOMPAT_BASE); + } ::decode(clean_thru, bl); ::decode(mounted, bl); } diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc index d4111578e09a5..d3d17ad1274d8 100644 --- a/src/osdc/Journaler.cc +++ b/src/osdc/Journaler.cc @@ -125,12 +125,18 @@ void Journaler::_finish_read_head(int r, bufferlist& bl) ::decode(h, p); if (h.magic != magic) { - dout(0) << "on disk magic '" << h.magic << "' != my magic '" - << magic << "'" << dendl; - list ls; - ls.swap(waitfor_recover); - finish_contexts(ls, -EINVAL); - return; + //special-case nasty hack for an upgrade path +#define CEPH_FS_ONDISK_MAGIC "ceph fs volume v012" +#define CEPH_FS_OLD_ONDISK_MAGIC "ceph fs volume v011" + if (strcmp(magic, CEPH_FS_ONDISK_MAGIC) != 0 + && strcmp(h.magic.c_str(), CEPH_FS_OLD_ONDISK_MAGIC) != 0) { + dout(0) << "on disk magic '" << h.magic << "' != my magic '" + << magic << "'" << dendl; + list ls; + ls.swap(waitfor_recover); + finish_contexts(ls, -EINVAL); + return; + } } set_layout(&h.layout); -- 2.39.5