From 74c853034e1b2ff73f9b7fad7c9f36383b334b34 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Thu, 19 May 2022 15:15:43 +0800 Subject: [PATCH] crimson/onode-staged-tree: fix unaligned reference to shard_pool_t::pool ../src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h:844:44: runtime error: reference binding to misaligned address 0x6250013ee905 for type 'const crimson::os::seastore::onode::pool_t' (aka 'const long'), which requires 8 byte alignment from UndefinedBehaviorSanitizer Signed-off-by: Yingxin Cheng --- .../staged-fltree/stages/key_layout.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h index be138ae84e31c..93176a8fd4046 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h @@ -58,24 +58,26 @@ struct node_offset_packed_t { // TODO: consider alignments struct shard_pool_t { bool operator==(const shard_pool_t& x) const { - return (shard == x.shard && pool == x.pool); + return (shard == x.shard && pool() == x.pool()); } bool operator!=(const shard_pool_t& x) const { return !(*this == x); } + pool_t pool() const { return _pool; } + template static shard_pool_t from_key(const full_key_t& key); shard_t shard; - pool_t pool; + pool_t _pool; } __attribute__((packed)); inline std::ostream& operator<<(std::ostream& os, const shard_pool_t& sp) { - return os << (int)sp.shard << "," << sp.pool; + return os << (int)sp.shard << "," << sp.pool(); } inline MatchKindCMP compare_to(const shard_pool_t& l, const shard_pool_t& r) { auto ret = toMatchKindCMP(l.shard, r.shard); if (ret != MatchKindCMP::EQ) return ret; - return toMatchKindCMP(l.pool, r.pool); + return toMatchKindCMP(l.pool(), r.pool()); } // Note: this is the reversed version of the object hash @@ -621,7 +623,7 @@ class key_view_t { return shard_pool_packed().shard; } pool_t pool() const { - return shard_pool_packed().pool; + return shard_pool_packed().pool(); } crush_hash_t crush() const { return crush_packed().crush; @@ -841,7 +843,7 @@ MatchKindCMP compare_to(const full_key_t& key, const shard_pool_t& target) auto ret = toMatchKindCMP(key.shard(), target.shard); if (ret != MatchKindCMP::EQ) return ret; - return toMatchKindCMP(key.pool(), target.pool); + return toMatchKindCMP(key.pool(), target.pool()); } template -- 2.39.5