]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore: adjust collection_manager interfaces
authorSamuel Just <sjust@redhat.com>
Thu, 11 Feb 2021 02:59:35 +0000 (18:59 -0800)
committerSamuel Just <sjust@redhat.com>
Wed, 24 Feb 2021 02:43:39 +0000 (18:43 -0800)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/collection_manager.h
src/crimson/os/seastore/root_block.h
src/crimson/os/seastore/seastore_types.h
src/crimson/os/seastore/transaction_manager.h

index cacf2ee9a187e91ae272f31a6be834f3ed4a3cbf..3b3abf2d36a7a52272a30b19983d2e910aa3e6df 100644 (file)
 
 namespace crimson::os::seastore {
 
-/**
-  * coll_root_t
-  *
-  * Information for locating CollectionManager information, addr should be
-  * embedded into the TransactionManager root.
-  */
-  class coll_root_t {
-    laddr_t coll_root_laddr;
-    segment_off_t size = 0;
-
-    enum state_t : uint8_t {
-      CLEAN = 0,   /// No pending mutations
-      MUTATED = 1, /// coll_root_laddr state must be written back to persistence
-      NONE = 0xFF  /// Not yet mounted, should not be exposed to user
-    } state = NONE;
-
-  public:
-    coll_root_t() : state(state_t::NONE) {}
-
-    coll_root_t(laddr_t laddr, size_t size)
-      : coll_root_laddr(laddr), size(size), state(state_t::CLEAN) {}
-
-    bool must_update() const {
-      return state == MUTATED;
-    }
-
-    void update(laddr_t addr, segment_off_t s) {
-      state = state_t::MUTATED;
-      coll_root_laddr = addr;
-      size = s;
-    }
-
-    laddr_t get_location() const {
-      return coll_root_laddr;
-    }
-    auto get_size() const {
-      return size;
-    }
-  };
-
-  struct coll_info_t {
-    unsigned split_bits;
-
-    coll_info_t(unsigned bits)
+struct coll_info_t {
+  unsigned split_bits;
+  
+  coll_info_t(unsigned bits)
     : split_bits(bits) {}
-
-    bool operator==(const coll_info_t &rhs) const {
-      return split_bits == rhs.split_bits;
-    }
-  };
+  
+  bool operator==(const coll_info_t &rhs) const {
+    return split_bits == rhs.split_bits;
+  }
+};
 
 /// Interface for maintaining set of collections
 class CollectionManager {
index 1e8ba9f5de886d534c08d1252be2d7a11ffa013e..c4c1036e23ceecfe0ad65343eca61f416530d056 100644 (file)
@@ -20,6 +20,7 @@ struct __attribute__((aligned(8), packed)) root_t {
   paddr_t segment_root;
   laddr_t onode_root = L_ADDR_NULL;
   laddr_t collection_root = L_ADDR_NULL;
+  segment_off_t collection_root_size = 0;
 
   void adjust_addrs_from_base(paddr_t base) {
     if (lba_root_addr.is_relative()) {
index 0c1bea23d69350ee053f733302d0128618bae9f8..0e78e863c8656cd93d6c16053431c6ef6553d250 100644 (file)
@@ -364,6 +364,46 @@ struct record_t {
   std::vector<delta_info_t> deltas;
 };
 
+/**
+ * coll_root_t
+ *
+ * Information for locating CollectionManager information, addr should be
+ * embedded into the TransactionManager root.
+ */
+class coll_root_t {
+  laddr_t coll_root_laddr;
+  segment_off_t size = 0;
+  
+  enum state_t : uint8_t {
+    CLEAN = 0,   /// No pending mutations
+    MUTATED = 1, /// coll_root_laddr state must be written back to persistence
+    NONE = 0xFF  /// Not yet mounted, should not be exposed to user
+  } state = NONE;
+  
+public:
+  coll_root_t() : state(state_t::NONE) {}
+  
+  coll_root_t(laddr_t laddr, segment_off_t size)
+    : coll_root_laddr(laddr), size(size), state(state_t::CLEAN) {}
+  
+  bool must_update() const {
+    return state == MUTATED;
+  }
+  
+  void update(laddr_t addr, segment_off_t s) {
+    state = state_t::MUTATED;
+    coll_root_laddr = addr;
+    size = s;
+  }
+  
+  laddr_t get_location() const {
+    return coll_root_laddr;
+  }
+  auto get_size() const {
+    return size;
+  }
+};
+
 }
 
 WRITE_CLASS_DENC_BOUNDED(crimson::os::seastore::seastore_meta_t)
index c978ed5a1e709b3703fb0c2e4bba6ae405f1c51d..6e616a804377a4519841b86c064694343769b6d9 100644 (file)
@@ -348,10 +348,14 @@ public:
    * Get collection root addr
    */
   using read_collection_root_ertr = base_ertr;
-  using read_collection_root_ret = read_collection_root_ertr::future<laddr_t>;
+  using read_collection_root_ret = read_collection_root_ertr::future<
+    coll_root_t>;
   read_collection_root_ret read_collection_root(Transaction &t) {
-    return cache.get_root(t).safe_then([](auto croot) {
-      return croot->get_root().collection_root;
+    return cache->get_root(t).safe_then([](auto croot) {
+      return coll_root_t{
+       croot->get_root().collection_root,
+       croot->get_root().collection_root_size
+      };
     });
   }
 
@@ -360,10 +364,11 @@ public:
    *
    * Update collection root addr
    */
-  void write_collection_root(Transaction &t, laddr_t addr) {
-    auto croot = cache.get_root_fast(t);
-    croot = cache.duplicate_for_write(t, croot)->cast<RootBlock>();
-    croot->get_root().collection_root = addr;
+  void write_collection_root(Transaction &t, coll_root_t cmroot) {
+    auto croot = cache->get_root_fast(t);
+    croot = cache->duplicate_for_write(t, croot)->cast<RootBlock>();
+    croot->get_root().collection_root = cmroot.get_location();
+    croot->get_root().collection_root_size = cmroot.get_size();
   }
 
   ~TransactionManager();