]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: use 64 bit values for zone_state_t
authorSage Weil <sage@newdream.net>
Tue, 7 Sep 2021 17:36:32 +0000 (12:36 -0500)
committerSage Weil <sage@newdream.net>
Fri, 29 Oct 2021 13:55:57 +0000 (09:55 -0400)
Simpler and future-proof for devices with zones >= 4GB.

Signed-off-by: Sage Weil <sage@newdream.net>
src/crimson/os/alienstore/CMakeLists.txt
src/os/CMakeLists.txt
src/os/bluestore/zoned_types.cc [deleted file]
src/os/bluestore/zoned_types.h

index b685b94b54f1a07c9d18a0537c3d3a974f4e2e0b..c57c1410778bf7103c23cdf28af582b4fb1c3220 100644 (file)
@@ -62,7 +62,6 @@ set(alien_store_srcs
   ${PROJECT_SOURCE_DIR}/src/os/memstore/MemStore.cc)
 if(WITH_ZBD)
   list(APPEND alien_store_srcs
-    ${PROJECT_SOURCE_DIR}/src/os/bluestore/zoned_types.cc
     ${PROJECT_SOURCE_DIR}/src/os/bluestore/ZonedFreelistManager.cc
     ${PROJECT_SOURCE_DIR}/src/os/bluestore/ZonedAllocator.cc)
 endif()
index 377360f9af688596ab9a279d17201eea838b5641..387f150d27b765c3fec1591345503e0434bd2e0a 100644 (file)
@@ -40,7 +40,6 @@ endif(WITH_BLUESTORE)
 
 if(WITH_ZBD)
   list(APPEND libos_srcs
-    bluestore/zoned_types.cc
     bluestore/ZonedFreelistManager.cc
     bluestore/ZonedAllocator.cc)
 endif()
diff --git a/src/os/bluestore/zoned_types.cc b/src/os/bluestore/zoned_types.cc
deleted file mode 100644 (file)
index 549a357..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "zoned_types.h"
-
-using ceph::decode;
-using ceph::encode;
-
-std::ostream& operator<<(std::ostream& out,
-                         const zone_state_t& zone_state) {
-  return out << std::hex
-            << " dead bytes: 0x" << zone_state.get_num_dead_bytes()
-            << " write pointer: 0x"  << zone_state.get_write_pointer()
-            << " " << std::dec;
-}
-
-void zone_state_t::encode(ceph::buffer::list &bl) const {
-  uint64_t v = static_cast<uint64_t>(num_dead_bytes) << 32 | write_pointer;
-  ::encode(v, bl);
-}
-
-void zone_state_t::decode(ceph::buffer::list::const_iterator &p) {
-  uint64_t v;
-  ::decode(v, p);
-  num_dead_bytes = v >> 32;
-  write_pointer = v;  // discard left-most 32 bits
-}
index 6ff5d5f313e4361139b63fde52560b1acc7bd155..c92f2ada0996724e369a463a37a6e69f49fd9516 100644 (file)
@@ -8,19 +8,25 @@
 #include "os/kv.h"
 
 // Tracks two bits of information about the state of a zone: (1) number of dead
-// bytes in a zone and (2) the write pointer.  We assume that for now 32 bits is
-// enough for the zone capacity and represent these as uint32_t, and we store
-// them as a single 64-bit value in RocksDB so that we can use the existing
+// bytes in a zone and (2) the write pointer.  We use the existing
 // Int64ArrayMergeOperator for merge and avoid the cost of point queries.
 //
 // We use the same struct for an on-disk and in-memory representation of the
 // state.
 struct zone_state_t {
-  uint32_t num_dead_bytes = 0;
-  uint32_t write_pointer = 0;
+  uint64_t num_dead_bytes = 0;
+  uint64_t write_pointer = 0;
 
-  void encode(ceph::buffer::list &bl) const;
-  void decode(ceph::buffer::list::const_iterator &p);
+  void encode(ceph::buffer::list &bl) const {
+    using ceph::encode;
+    encode(write_pointer, bl);
+    encode(num_dead_bytes, bl);
+  }
+  void decode(ceph::buffer::list::const_iterator &p) {
+    using ceph::decode;
+    decode(write_pointer, p);
+    decode(num_dead_bytes, p);
+  }
 
   uint64_t get_num_dead_bytes() const {
     return num_dead_bytes;
@@ -37,8 +43,15 @@ struct zone_state_t {
   void increment_write_pointer(uint64_t num_bytes) {
     write_pointer += num_bytes;
   }
-};
 
-std::ostream& operator<<(std::ostream& out, const zone_state_t& zone_state);
+  friend std::ostream& operator<<(
+    std::ostream& out,
+    const zone_state_t& zone_state) {
+    return out << std::hex
+              << " dead bytes: 0x" << zone_state.get_num_dead_bytes()
+              << " write pointer: 0x"  << zone_state.get_write_pointer()
+              << " " << std::dec;
+  }
+};
 
 #endif