]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include: Bug fixes for CompatSet
authorDavid Zafman <david.zafman@inktank.com>
Tue, 17 Sep 2013 20:39:57 +0000 (13:39 -0700)
committerDavid Zafman <david.zafman@inktank.com>
Thu, 26 Sep 2013 18:24:40 +0000 (11:24 -0700)
FeatureSet insert/remove
  Use 64-bit arithmetic to allow features past 31
  Allow feature 63 by fixing assert in insert
CompatSet::unsupported() bugs
  Ignore feature 0 which became illegal
  Use 64-bit arithmetic when computing mask
  Use id in insert() and to get correct feature name
  Use the right map to get name for diff.ro_compat

Caused by 80979bbe92409e6f098566e18be6ed59ad9d111a
Caused by 470796b5456592ee5179bbd44b72910a2d7f6aca

Backport: dumpling, cuttlefish

Signed-off-by: David Zafman <david.zafman@inktank.com>
src/include/CompatSet.h

index 26c438c05f20b1b0a80620984137a663d59d5af1..31246e186b2d8f44faff4b011c601341dcc77bd0 100644 (file)
@@ -36,8 +36,8 @@ struct CompatSet {
     FeatureSet() : mask(1), names() {}
     void insert(Feature f) {
       assert(f.id > 0);
-      assert(f.id < 63);
-      mask |= (1<<f.id);
+      assert(f.id < 64);
+      mask |= ((uint64_t)1<<f.id);
       names[f.id] = f.name;
     }
 
@@ -50,7 +50,7 @@ struct CompatSet {
     void remove(uint64_t f) {
       if (names.count(f)) {
        names.erase(f);
-       mask &= ~(1<<f);
+       mask &= ~((uint64_t)1<<f);
       }
     }
     void remove(Feature f) {
@@ -156,19 +156,16 @@ struct CompatSet {
       ((other.ro_compat.mask ^ ro_compat.mask) & other.ro_compat.mask);
     uint64_t other_incompat =
       ((other.incompat.mask ^ incompat.mask) & other.incompat.mask);
-    for (int i = 0; i < 64; ++i) {
-      int mask = 1 << i;
+    for (int id = 1; id < 64; ++id) {
+      uint64_t mask = (uint64_t)1 << id;
       if (mask & other_compat) {
-       diff.compat.insert( Feature(mask & other_compat,
-                                   other.compat.names[mask&other_compat]));
+       diff.compat.insert( Feature(id, other.compat.names[id]));
       }
       if (mask & other_ro_compat) {
-       diff.ro_compat.insert(Feature(mask & other_ro_compat,
-                                     other.compat.names[mask&other_ro_compat]));
+       diff.ro_compat.insert(Feature(id, other.ro_compat.names[id]));
       }
       if (mask & other_incompat) {
-       diff.incompat.insert( Feature(mask & other_incompat,
-                                     other.incompat.names[mask&other_incompat]));
+       diff.incompat.insert( Feature(id, other.incompat.names[id]));
       }
     }
     return diff;