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-25 11:24:22 -0700 |
commit | ed50707c20197bd64719d9a236683d4f459e7129 (patch) | |
tree | 71a9430b682c9e66dd0d9215ce552ed6fee322b5 | |
parent | 6f342872cdd211e24deb19f5e00380494514c437 (diff) | |
download | ceph-ed50707c20197bd64719d9a236683d4f459e7129.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>
(cherry picked from commit 04a21d1c2ec438cc61e761c3bb8d99558bbedef6)
-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 ac532fcef81..863f443efcd 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; |