Skip to content

Commit c6b58b1

Browse files
committed
crimson/os/seastore: duplicate_for_write() to move set_laddr() into Cache
Signed-off-by: Yingxin Cheng <[email protected]>
1 parent f6762a8 commit c6b58b1

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/crimson/os/seastore/cache.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,10 +1155,13 @@ CachedExtentRef Cache::duplicate_for_write(
11551155
LOG_PREFIX(Cache::duplicate_for_write);
11561156
assert(i->is_fully_loaded());
11571157

1158-
if (i->is_mutable())
1158+
if (i->is_mutable()) {
11591159
return i;
1160+
}
11601161

11611162
if (i->is_exist_clean()) {
1163+
assert(i->is_logical());
1164+
assert(static_cast<LogicalCachedExtent&>(*i).has_laddr());
11621165
i->version++;
11631166
i->state = CachedExtent::extent_state_t::EXIST_MUTATION_PENDING;
11641167
i->last_committed_crc = i->calc_crc32c();
@@ -1189,6 +1192,12 @@ CachedExtentRef Cache::duplicate_for_write(
11891192

11901193
ret->version++;
11911194
ret->state = CachedExtent::extent_state_t::MUTATION_PENDING;
1195+
if (i->is_logical()) {
1196+
auto& lextent = static_cast<LogicalCachedExtent&>(*i);
1197+
assert(lextent.has_laddr());
1198+
assert(ret->is_logical());
1199+
static_cast<LogicalCachedExtent&>(*ret).set_laddr(lextent.get_laddr());
1200+
}
11921201
DEBUGT("{} -> {}", t, *i, *ret);
11931202
return ret;
11941203
}

src/crimson/os/seastore/transaction_manager.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -322,18 +322,7 @@ class TransactionManager : public ExtentCallbackInterface {
322322

323323
/// Obtain mutable copy of extent
324324
LogicalChildNodeRef get_mutable_extent(Transaction &t, LogicalChildNodeRef ref) {
325-
LOG_PREFIX(TransactionManager::get_mutable_extent);
326-
auto ret = cache->duplicate_for_write(
327-
t,
328-
ref)->cast<LogicalChildNode>();
329-
if (!ret->has_laddr()) {
330-
SUBDEBUGT(seastore_tm, "duplicate from {}", t, *ref);
331-
ret->set_laddr(ref->get_laddr());
332-
} else {
333-
assert(ref->is_mutable());
334-
assert(&*ref == &*ret);
335-
}
336-
return ret;
325+
return cache->duplicate_for_write(t, ref)->cast<LogicalChildNode>();
337326
}
338327

339328
using ref_iertr = LBAManager::ref_iertr;

0 commit comments

Comments
 (0)