@@ -293,55 +293,67 @@ class TransactionManager : public ExtentCallbackInterface {
293293 // must be user-oriented required by maybe_init
294294 assert (is_user_transaction (t.get_src ()));
295295
296- extent_len_t direct_partial_off = partial_off;
297- bool is_clone = pin.is_clone ();
298- std::optional<indirect_info_t > maybe_indirect_info;
299- if (pin.is_indirect ()) {
300- auto intermediate_offset = pin.get_intermediate_offset ();
301- direct_partial_off = intermediate_offset + partial_off;
302- maybe_indirect_info = indirect_info_t {
303- intermediate_offset, pin.get_length ()};
304- }
305-
306- LOG_PREFIX (TransactionManager::read_pin);
307- SUBDEBUGT (seastore_tm, " {} {} 0x{:x}~0x{:x} direct_off=0x{:x} ..." ,
308- t, T::TYPE, pin, partial_off, partial_len, direct_partial_off);
309-
310296 return pin.refresh (
311- ).si_then ([&t, this , direct_partial_off, partial_len,
312- maybe_init=std::move (maybe_init)](auto npin) mutable {
313- // checking the lba child must be atomic with creating
314- // and linking the absent child
315- auto ret = get_extent_if_linked<T>(t, std::move (npin));
316- if (ret.index () == 1 ) {
317- return std::get<1 >(ret
318- ).si_then ([direct_partial_off, partial_len, this , &t](auto extent) {
319- return cache->read_extent_maybe_partial (
320- t, std::move (extent), direct_partial_off, partial_len);
321- }).si_then ([maybe_init=std::move (maybe_init)](auto extent) {
322- if (!extent->is_seen_by_users ()) {
323- maybe_init (*extent);
324- extent->set_seen_by_users ();
325- }
326- return std::move (extent);
327- });
297+ ).si_then ([this , &t](auto npin) {
298+ if (npin.is_indirect ()) {
299+ return lba_manager->complete_indirect_lba_mapping (
300+ t, std::move (npin));
328301 } else {
329- auto &r = std::get<0 >(ret);
330- return this ->pin_to_extent <T>(
331- t, std::move (r.mapping ), std::move (r.child_pos ),
332- direct_partial_off, partial_len,
333- std::move (maybe_init));
302+ return LBAManager::complete_lba_mapping_iertr::make_ready_future<
303+ LBAMapping>(std::move (npin));
334304 }
335- }).si_then ([FNAME, maybe_indirect_info, is_clone, &t](TCachedExtentRef<T> ext) {
336- if (maybe_indirect_info.has_value ()) {
337- SUBDEBUGT (seastore_tm, " got indirect +0x{:x}~0x{:x} is_clone={} {}" ,
338- t, maybe_indirect_info->intermediate_offset ,
339- maybe_indirect_info->length , is_clone, *ext);
340- } else {
341- SUBDEBUGT (seastore_tm, " got direct is_clone={} {}" ,
342- t, is_clone, *ext);
305+ }).si_then ([&t, this , partial_off, partial_len,
306+ maybe_init=std::move (maybe_init)](auto npin) mutable {
307+
308+ extent_len_t direct_partial_off = partial_off;
309+ bool is_clone = npin.is_clone ();
310+ std::optional<indirect_info_t > maybe_indirect_info;
311+ if (npin.is_indirect ()) {
312+ auto intermediate_offset = npin.get_intermediate_offset ();
313+ direct_partial_off = intermediate_offset + partial_off;
314+ maybe_indirect_info = indirect_info_t {
315+ intermediate_offset, npin.get_length ()};
343316 }
344- return maybe_indirect_extent_t <T>{ext, maybe_indirect_info, is_clone};
317+
318+ LOG_PREFIX (TransactionManager::read_pin);
319+ SUBDEBUGT (seastore_tm, " {} {} 0x{:x}~0x{:x} direct_off=0x{:x} ..." ,
320+ t, T::TYPE, npin, partial_off, partial_len, direct_partial_off);
321+
322+ return [this , &t, npin, direct_partial_off, partial_len,
323+ maybe_init=std::move (maybe_init)]() mutable {
324+ // checking the lba child must be atomic with creating
325+ // and linking the absent child
326+ auto ret = get_extent_if_linked<T>(t, std::move (npin));
327+ if (ret.index () == 1 ) {
328+ return std::get<1 >(ret
329+ ).si_then ([direct_partial_off, partial_len, this , &t](auto extent) {
330+ return cache->read_extent_maybe_partial (
331+ t, std::move (extent), direct_partial_off, partial_len);
332+ }).si_then ([maybe_init=std::move (maybe_init)](auto extent) {
333+ if (!extent->is_seen_by_users ()) {
334+ maybe_init (*extent);
335+ extent->set_seen_by_users ();
336+ }
337+ return std::move (extent);
338+ });
339+ } else {
340+ auto &r = std::get<0 >(ret);
341+ return this ->pin_to_extent <T>(
342+ t, std::move (r.mapping ), std::move (r.child_pos ),
343+ direct_partial_off, partial_len,
344+ std::move (maybe_init));
345+ }
346+ }().si_then ([FNAME, maybe_indirect_info, is_clone, &t](TCachedExtentRef<T> ext) {
347+ if (maybe_indirect_info.has_value ()) {
348+ SUBDEBUGT (seastore_tm, " got indirect +0x{:x}~0x{:x} is_clone={} {}" ,
349+ t, maybe_indirect_info->intermediate_offset ,
350+ maybe_indirect_info->length , is_clone, *ext);
351+ } else {
352+ SUBDEBUGT (seastore_tm, " got direct is_clone={} {}" ,
353+ t, is_clone, *ext);
354+ }
355+ return maybe_indirect_extent_t <T>{ext, maybe_indirect_info, is_clone};
356+ });
345357 });
346358 }
347359
0 commit comments