From: Greg Farnum Date: Thu, 23 Jan 2014 01:15:56 +0000 (-0800) Subject: Monitor: use a single static accessor for getting CompatSet features off disk X-Git-Tag: v0.78~251^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=df4df46df0091b27db305e72c555f02711952ef3;p=ceph.git Monitor: use a single static accessor for getting CompatSet features off disk This way we don't need to maintain two working code paths. Signed-off-by: Greg Farnum --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 6b88e9994f09..b665b83b8bb2 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -322,43 +322,43 @@ int Monitor::check_features(MonitorDBStore *store) CompatSet required = get_supported_features(); CompatSet ondisk; - bufferlist features; - store->get(MONITOR_NAME, COMPAT_SET_LOC, features); - if (features.length() == 0) { + read_features_off_disk(store, &ondisk); + + if (!required.writeable(ondisk)) { + CompatSet diff = required.unsupported(ondisk); + generic_derr << "ERROR: on disk data includes unsupported features: " << diff << dendl; + return -EPERM; + } + + return 0; +} + +void Monitor::read_features_off_disk(MonitorDBStore *store, CompatSet *features) +{ + bufferlist featuresbl; + store->get(MONITOR_NAME, COMPAT_SET_LOC, featuresbl); + if (featuresbl.length() == 0) { generic_dout(0) << "WARNING: mon fs missing feature list.\n" - << "Assuming it is old-style and introducing one." << dendl; + << "Assuming it is old-style and introducing one." << dendl; //we only want the baseline ~v.18 features assumed to be on disk. //If new features are introduced this code needs to disappear or //be made smarter. - ondisk = get_legacy_features(); + *features = get_legacy_features(); bufferlist bl; - ondisk.encode(bl); + features->encode(bl); MonitorDBStore::Transaction t; t.put(MONITOR_NAME, COMPAT_SET_LOC, bl); store->apply_transaction(t); } else { - bufferlist::iterator it = features.begin(); - ondisk.decode(it); + bufferlist::iterator it = featuresbl.begin(); + features->decode(it); } - - if (!required.writeable(ondisk)) { - CompatSet diff = required.unsupported(ondisk); - generic_derr << "ERROR: on disk data includes unsupported features: " << diff << dendl; - return -EPERM; - } - - return 0; } void Monitor::read_features() { - bufferlist bl; - store->get(MONITOR_NAME, COMPAT_SET_LOC, bl); - assert(bl.length()); - - bufferlist::iterator p = bl.begin(); - ::decode(features, p); + read_features_off_disk(store, &features); dout(10) << "features " << features << dendl; } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index be16da83af39..fcdb7ba977e5 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -750,6 +750,8 @@ public: // features static CompatSet get_supported_features(); static CompatSet get_legacy_features(); + /// read the ondisk features into the CompatSet pointed to by read_features + static void read_features_off_disk(MonitorDBStore *store, CompatSet *read_features); void read_features(); void write_features(MonitorDBStore::Transaction &t);