diff options
author | David Zafman <david.zafman@inktank.com> | 2013-09-17 13:39:57 -0700 |
---|---|---|
committer | David Zafman <david.zafman@inktank.com> | 2013-09-23 13:12:41 -0700 |
commit | 04a21d1c2ec438cc61e761c3bb8d99558bbedef6 (patch) | |
tree | fa872e340925016f474b90a4ad2be23d76084af6 | |
parent | 2f289bf325a3c1179fe861d6d09944c2e6cced77 (diff) | |
download | ceph-04a21d1c2ec438cc61e761c3bb8d99558bbedef6.tar.gz |
include: Bug fixes for CompatSet
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>
-rw-r--r-- | src/include/CompatSet.h | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/include/CompatSet.h b/src/include/CompatSet.h index 26c438c05f2..31246e186b2 100644 --- a/src/include/CompatSet.h +++ b/src/include/CompatSet.h @@ -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; |