crimson/seastore: introduce TransactionManager::read_extent(t, offset)
authorYingxin Cheng <yingxin.cheng@intel.com>
Mon, 31 May 2021 02:11:01 +0000 (10:11 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 11 Jun 2021 14:43:58 +0000 (22:43 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/transaction_manager.h

index 5a4cdb702e571f4051fd4febdd346c294af7b137..9f398c8a4008416a7c520b2f9d13607b89cad30d 100644 (file)
@@ -214,6 +214,28 @@ public:
     });
   }
 
+  /**
+   * read_extent
+   *
+   * Read extent of type T at offset
+   */
+  template <typename T>
+  read_extent_ret<T> read_extent(
+    Transaction &t,
+    laddr_t offset) {
+    LOG_PREFIX(TransactionManager::read_extent);
+    return get_pin(
+      t, offset
+    ).safe_then([this, FNAME, &t, offset] (auto pin) {
+      if (!pin->get_paddr().is_real()) {
+        ERRORT("offset {} got wrong pin {}",
+               t, offset, *pin);
+        ceph_assert(0 == "Should be impossible");
+      }
+      return this->pin_to_extent<T>(t, std::move(pin));
+    });
+  }
+
   /// Obtain mutable copy of extent
   LogicalCachedExtentRef get_mutable_extent(Transaction &t, LogicalCachedExtentRef ref) {
     LOG_PREFIX(TransactionManager::get_mutable_extent);