]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os: define device_spec_t as packed 49408/head
authorKefu Chai <tchaikov@gmail.com>
Tue, 13 Dec 2022 10:23:43 +0000 (18:23 +0800)
committerKefu Chai <tchaikov@gmail.com>
Tue, 13 Dec 2022 10:36:17 +0000 (18:36 +0800)
per C++ standard 20, alignas cannot be applied to scoped enum. despite
that there is a resolution to address this, see
https://cplusplus.github.io/CWG/issues/2354.html, it's not included in
C++20. so we have to use a different way to address

> runtime error: reference binding to misaligned address 0x610000008395
> for type 'device_type_t', which requires 4 byte alignment

otherwise the code would fail to compile with Clang-15, like:

> <source>:3:13: error: 'alignas' attribute cannot be applied to an enumeration

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/crimson/os/seastore/device.h
src/crimson/os/seastore/seastore_types.h

index 24a3d4bac2bea49803bd2205b9d7493f0cf0d401..3b479d7b9b7030673a6a1a2cfe58520aad91288d 100644 (file)
@@ -14,7 +14,7 @@ namespace crimson::os::seastore {
 
 using magic_t = uint64_t;
 
-struct device_spec_t{
+struct device_spec_t {
   magic_t magic = 0;
   device_type_t dtype = device_type_t::NONE;
   device_id_t id = DEVICE_ID_NULL;
@@ -25,7 +25,7 @@ struct device_spec_t{
     denc(v.id, p);
     DENC_FINISH(p);
   }
-};
+} __attribute__ ((packed));
 
 std::ostream& operator<<(std::ostream&, const device_spec_t&);
 
index 761577ec85c9b195733bc6a6cbdf53a21721aa4a..f98f800ffc8ee359b467dfb90608fb2bb5972752 100644 (file)
@@ -871,7 +871,7 @@ constexpr auto PLACEMENT_HINT_NULL = placement_hint_t::NUM_HINTS;
 
 std::ostream& operator<<(std::ostream& out, placement_hint_t h);
 
-enum class alignas(4) device_type_t : uint_fast8_t {
+enum class device_type_t : uint8_t {
   NONE = 0,
   HDD,
   SSD,