]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/object_data_handler: take indirect offset into
authorXuehan Xu <xuxuehan@qianxin.com>
Wed, 12 Jul 2023 10:35:17 +0000 (18:35 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Thu, 10 Aug 2023 05:14:22 +0000 (13:14 +0800)
account when reading object data

Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/object_data_handler.cc
src/crimson/os/seastore/transaction_manager.h

index a82668eb02553914556a0ad075400630a4b20403..0da4c9a38efe5f31d310caf47c398d5485b60c48 100644 (file)
@@ -730,14 +730,15 @@ operate_ret operate_left(context_t ctx, LBAMappingRef &pin, const overwrite_plan
         std::nullopt,
         std::nullopt);
     } else {
+      extent_len_t off = pin->get_intermediate_offset();
       return ctx.tm.read_pin<ObjectDataBlock>(
        ctx.t, pin->duplicate()
-      ).si_then([prepend_len](auto left_extent) {
+      ).si_then([prepend_len, off](auto left_extent) {
         return get_iertr::make_ready_future<operate_ret_bare>(
           std::nullopt,
           std::make_optional(bufferptr(
             left_extent->get_bptr(),
-            0,
+            off,
             prepend_len)));
       });
     }
@@ -758,9 +759,10 @@ operate_ret operate_left(context_t ctx, LBAMappingRef &pin, const overwrite_plan
         std::move(left_to_write_extent),
         std::nullopt);
     } else {
+      extent_len_t off = pin->get_intermediate_offset();
       return ctx.tm.read_pin<ObjectDataBlock>(
        ctx.t, pin->duplicate()
-      ).si_then([prepend_offset=extent_len, prepend_len,
+      ).si_then([prepend_offset=extent_len + off, prepend_len,
                  left_to_write_extent=std::move(left_to_write_extent)]
                 (auto left_extent) mutable {
         return get_iertr::make_ready_future<operate_ret_bare>(
@@ -811,7 +813,10 @@ operate_ret operate_right(context_t ctx, LBAMappingRef &pin, const overwrite_pla
         std::nullopt,
         std::nullopt);
     } else {
-      auto append_offset = overwrite_plan.data_end - right_pin_begin;
+      auto append_offset =
+       overwrite_plan.data_end
+       - right_pin_begin
+       + pin->get_intermediate_offset();
       return ctx.tm.read_pin<ObjectDataBlock>(
        ctx.t, pin->duplicate()
       ).si_then([append_offset, append_len](auto right_extent) {
@@ -840,7 +845,10 @@ operate_ret operate_right(context_t ctx, LBAMappingRef &pin, const overwrite_pla
         std::move(right_to_write_extent),
         std::nullopt);
     } else {
-      auto append_offset = overwrite_plan.data_end - right_pin_begin;
+      auto append_offset =
+       overwrite_plan.data_end
+       - right_pin_begin
+       + pin->get_intermediate_offset();
       return ctx.tm.read_pin<ObjectDataBlock>(
        ctx.t, pin->duplicate()
       ).si_then([append_offset, append_len,
@@ -1002,7 +1010,7 @@ ObjectDataHandler::clear_ret ObjectDataHandler::trim_data_reservation(
              bl.append(
                bufferptr(
                  extent->get_bptr(),
-                 0,
+                 pin.get_intermediate_offset(),
                  size - pin_offset
              ));
               bl.append_zero(append_len);
@@ -1352,19 +1360,30 @@ ObjectDataHandler::read_ret ObjectDataHandler::read(
                    } else {
                      auto key = pin->get_key();
                      bool is_indirect = pin->is_indirect();
+                      extent_len_t off = pin->get_intermediate_offset();
+                     DEBUGT("reading {}~{}, indirect: {}, "
+                       "intermediate offset: {}, current: {}, end: {}",
+                       ctx.t,
+                       key,
+                       pin->get_length(),
+                       is_indirect,
+                       off,
+                       current,
+                       end);
                      return ctx.tm.read_pin<ObjectDataBlock>(
                        ctx.t,
                        std::move(pin)
-                     ).si_then([&ret, &current, end, key, is_indirect](auto extent) {
+                     ).si_then([&ret, &current, end, key, off,
+                               is_indirect](auto extent) {
                        ceph_assert(
                          is_indirect
-                           ? (key + extent->get_length()) >= end
+                           ? (key - off + extent->get_length()) >= end
                            : (extent->get_laddr() + extent->get_length()) >= end);
                        ceph_assert(end > current);
                        ret.append(
                          bufferptr(
                            extent->get_bptr(),
-                           current - (is_indirect ? key : extent->get_laddr()),
+                           off + current - (is_indirect ? key : extent->get_laddr()),
                            end - current));
                        current = end;
                        return seastar::now();
index afc7a648886dc7caed7f085bb59f89302ca28a47..b008ba6bef0d59e5ee57ad8dc84a9c57a90f4bd6 100644 (file)
@@ -761,7 +761,9 @@ private:
     return cache->get_absent_extent<T>(
       t,
       pref.get_val(),
-      pref.get_length(),
+      pref.is_indirect() ?
+       pref.get_intermediate_length() :
+       pref.get_length(),
       [pin=std::move(pin)]
       (T &extent) mutable {
        assert(!extent.has_laddr());
@@ -801,7 +803,9 @@ private:
       type,
       pref.get_val(),
       pref.get_key(),
-      pref.get_length(),
+      pref.is_indirect() ?
+       pref.get_intermediate_length() :
+       pref.get_length(),
       [pin=std::move(pin)](CachedExtent &extent) mutable {
        auto &lextent = static_cast<LogicalCachedExtent&>(extent);
        assert(!lextent.has_laddr());