Skip to content

Commit 6f892fe

Browse files
committed
crimson/os/seastore: more accurate usages to is_mutable() vs is_data_stable()
Generally, prefer is_mutable() than !is_data_stable(), and is_data_stable() than !is_mutable(). Signed-off-by: Yingxin Cheng <[email protected]>
1 parent 6217c2c commit 6f892fe

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

src/crimson/os/seastore/cache.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ CachedExtentRef Cache::duplicate_for_write(
11621162
Transaction &t,
11631163
CachedExtentRef i) {
11641164
LOG_PREFIX(Cache::duplicate_for_write);
1165+
ceph_assert(i->is_valid());
11651166
assert(i->is_fully_loaded());
11661167

11671168
#ifndef NDEBUG

src/crimson/os/seastore/cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ class Cache : public ExtentTransViewRetriever {
633633
//
634634
// TODO(implement fine-grained-wait)
635635
assert(!extent->is_range_loaded(partial_off, partial_len));
636-
assert(!extent->is_mutable());
636+
assert(extent->is_data_stable());
637637
if (extent->is_pending_io()) {
638638
std::optional<Transaction::src_t> src;
639639
if (p_src) {
@@ -1685,7 +1685,7 @@ class Cache : public ExtentTransViewRetriever {
16851685
CachedExtent &extent,
16861686
extent_len_t increased_length,
16871687
const Transaction::src_t* p_src) {
1688-
assert(!extent.is_mutable());
1688+
assert(extent.is_data_stable());
16891689

16901690
if (extent.primary_ref_list_hook.is_linked()) {
16911691
assert(extent.is_stable_clean() && !extent.is_placeholder());

src/crimson/os/seastore/cached_extent.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,8 @@ class CachedExtent
542542
return TCachedExtentRef<const T>(static_cast<const T*>(this));
543543
}
544544

545-
/// Returns true if extent can be mutated in an open transaction
545+
/// Returns true if extent can be mutated in an open transaction,
546+
/// normally equivalent to !is_data_stable.
546547
bool is_mutable() const {
547548
return state == extent_state_t::INITIAL_WRITE_PENDING ||
548549
state == extent_state_t::MUTATION_PENDING ||
@@ -578,6 +579,8 @@ class CachedExtent
578579
return is_stable_written() || is_stable_writting();
579580
}
580581

582+
/// Returns true if extent can not be mutated,
583+
/// normally equivalent to !is_mutable.
581584
bool is_data_stable() const {
582585
return is_stable() || is_exist_clean();
583586
}

src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_accessor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class NodeExtentAccessorT {
305305
assert(p_recorder->node_type() == NODE_TYPE);
306306
assert(p_recorder->field_type() == FIELD_TYPE);
307307
recorder = static_cast<recorder_t*>(p_recorder);
308-
} else if (!extent->is_mutable() && extent->is_valid()) {
308+
} else if (extent->is_stable()) {
309309
state = nextent_state_t::READ_ONLY;
310310
// mut is empty
311311
assert(extent->get_recorder() == nullptr ||
@@ -355,7 +355,7 @@ class NodeExtentAccessorT {
355355
void prepare_mutate(context_t c) {
356356
assert(!is_retired());
357357
if (state == nextent_state_t::READ_ONLY) {
358-
assert(!extent->is_mutable());
358+
assert(extent->is_stable());
359359
auto ref_recorder = recorder_t::create_for_encode(c.vb);
360360
recorder = static_cast<recorder_t*>(ref_recorder.get());
361361
extent = extent->mutate(c, std::move(ref_recorder));

src/crimson/os/seastore/transaction_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ class TransactionManager : public ExtentCallbackInterface {
563563
std::optional<ceph::bufferptr> original_bptr;
564564
// TODO: preserve the bufferspace if partially loaded
565565
if (ext && ext->is_fully_loaded()) {
566-
ceph_assert(!ext->is_mutable());
566+
ceph_assert(ext->is_data_stable());
567567
ceph_assert(ext->get_length() >= original_len);
568568
ceph_assert(ext->get_paddr() == original_paddr);
569569
original_bptr = ext->get_bptr();

0 commit comments

Comments
 (0)