]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/seastore: implement read/write_onode_root()
authorYingxin Cheng <yingxin.cheng@intel.com>
Mon, 21 Sep 2020 02:15:38 +0000 (10:15 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Tue, 1 Dec 2020 04:50:53 +0000 (12:50 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/lba_manager/btree/btree_lba_manager.cc
src/crimson/os/seastore/root_block.h
src/crimson/os/seastore/transaction_manager.h

index eff6c52dad02bbaeaa6a71c697670ea1f00302a0..5eb68051c8187c15fe1242707e71cb3ceeb59c1d 100644 (file)
@@ -119,6 +119,16 @@ public:
   using get_root_ret = get_root_ertr::future<RootBlockRef>;
   get_root_ret get_root(Transaction &t);
 
+  /**
+   * get_root_fast
+   *
+   * returns t.root and assume it is already present/read in t
+   */
+  RootBlockRef get_root_fast(Transaction &t) {
+    assert(t.root);
+    return t.root;
+  }
+
   /**
    * get_extent
    *
index 2b424a578fd15586582985235fb6b3d37228628d..a837ae37e62e5a955d955b306a3322335d0f743a 100644 (file)
@@ -36,7 +36,8 @@ BtreeLBAManager::mkfs_ret BtreeLBAManager::mkfs(
         1,
         0,
         root_leaf->get_paddr(),
-        make_record_relative_paddr(0)};
+        make_record_relative_paddr(0),
+        L_ADDR_NULL};
     return mkfs_ertr::now();
   });
 }
index 25322d769ea6d6e5f471c1c7c29d6076b117191f..4a5024caa62f1a8e43e0ab1102537f35f981a681 100644 (file)
@@ -18,6 +18,7 @@ struct __attribute__((aligned(8), packed)) root_t {
   depth_t segment_depth = 0;
   paddr_t lba_root_addr;
   paddr_t segment_root;
+  laddr_t onode_root = L_ADDR_NULL;
 
   void adjust_addrs_from_base(paddr_t base) {
     if (lba_root_addr.is_relative()) {
index 18259a45b3cc89d82bea795472e8ae8afda8218a..674c33feabfb26004646e1b8de2e8a6f7f848b9c 100644 (file)
@@ -250,6 +250,32 @@ public:
     return segment_manager.release(id);
   }
 
+  /**
+   * read_onode_root
+   *
+   * Get onode-tree root logical address
+   */
+  using read_onode_root_ertr = crimson::errorator<
+    crimson::ct_error::input_output_error
+    >;
+  using read_onode_root_ret = read_onode_root_ertr::future<laddr_t>;
+  read_onode_root_ret read_onode_root(Transaction &t) {
+    return cache.get_root(t).safe_then([](auto croot) {
+      return croot->get_root().onode_root;
+    });
+  }
+
+  /**
+   * write_onode_root
+   *
+   * Write onode-tree root logical address, must be called after read.
+   */
+  void write_onode_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().onode_root = addr;
+  }
+
   ~TransactionManager();
 
 private: