Skip to content

Commit 6217c2c

Browse files
committed
crimson/os/seastore: distinguish between is_mutation_pending() and has_mutation()
Signed-off-by: Yingxin Cheng <[email protected]>
1 parent 8b37bb0 commit 6217c2c

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

src/crimson/os/seastore/cache.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ record_t Cache::prepare_record(
12731273
i->set_modify_time(commit_time);
12741274
DEBUGT("mutated extent with {}B delta -- {}",
12751275
t, delta_length, *i);
1276-
if (!i->is_exist_mutation_pending()) {
1276+
if (i->is_mutation_pending()) {
12771277
DEBUGT("commit replace extent ... -- {}, prior={}",
12781278
t, *i, *i->prior_instance);
12791279

@@ -1298,6 +1298,8 @@ record_t Cache::prepare_record(
12981298
// the existing extents should be added into Cache
12991299
// during complete_commit to sync with gc transaction.
13001300
commit_replace_extent(t, i, i->prior_instance);
1301+
} else {
1302+
assert(i->is_exist_mutation_pending());
13011303
}
13021304

13031305
i->prepare_write();

src/crimson/os/seastore/cached_extent.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ class CachedExtent
439439
if (!e.is_pending()) {
440440
set_prior_instance(&e);
441441
} else {
442-
assert(e.is_mutation_pending());
442+
assert(e.has_mutation());
443443
set_prior_instance(e.prior_instance);
444444
}
445445
e.get_bptr().copy_out(
@@ -565,12 +565,12 @@ class CachedExtent
565565
}
566566

567567
bool is_stable_writting() const {
568-
// MUTATION_PENDING/INITIAL_WRITE_PENDING and under-io extents are already
568+
// mutated/INITIAL_WRITE_PENDING and under-io extents are already
569569
// stable and visible, see prepare_record().
570570
//
571571
// XXX: It might be good to mark this case as DIRTY/CLEAN from the definition,
572572
// which probably can make things simpler.
573-
return (is_mutation_pending() || is_initial_pending()) && is_pending_io();
573+
return (has_mutation() || is_initial_pending()) && is_pending_io();
574574
}
575575

576576
/// Returns true if extent is stable and shared among transactions
@@ -583,11 +583,15 @@ class CachedExtent
583583
}
584584

585585
/// Returns true if extent has a pending delta
586-
bool is_mutation_pending() const {
586+
bool has_mutation() const {
587587
return state == extent_state_t::MUTATION_PENDING
588588
|| state == extent_state_t::EXIST_MUTATION_PENDING;
589589
}
590590

591+
bool is_mutation_pending() const {
592+
return state == extent_state_t::MUTATION_PENDING;
593+
}
594+
591595
/// Returns true if extent is a fresh extent
592596
bool is_initial_pending() const {
593597
return state == extent_state_t::INITIAL_WRITE_PENDING;
@@ -636,10 +640,10 @@ class CachedExtent
636640

637641
/// Returns true if extent or prior_instance has been invalidated
638642
bool has_been_invalidated() const {
639-
return !is_valid() || (is_mutation_pending() && !prior_instance->is_valid());
643+
return !is_valid() || (prior_instance && !prior_instance->is_valid());
640644
}
641645

642-
/// Returns true if extent is a plcaeholder
646+
/// Returns true if extent is a placeholder
643647
bool is_placeholder() const {
644648
return is_retired_placeholder_type(get_type());
645649
}
@@ -1077,7 +1081,7 @@ class CachedExtent
10771081
if (is_initial_pending() && addr.is_record_relative()) {
10781082
return addr.block_relative_to(get_paddr());
10791083
} else {
1080-
ceph_assert(!addr.is_record_relative() || is_mutation_pending());
1084+
ceph_assert(!addr.is_record_relative() || has_mutation());
10811085
return addr;
10821086
}
10831087
}

src/crimson/os/seastore/object_data_handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct ObjectDataBlock : crimson::os::seastore::LogicalChildNode {
128128
}
129129

130130
void prepare_commit() final {
131-
if (is_mutation_pending() || is_exist_mutation_pending()) {
131+
if (has_mutation()) {
132132
ceph_assert(!cached_overwrites.is_empty());
133133
if (cached_overwrites.has_cached_bptr()) {
134134
set_bptr(cached_overwrites.move_cached_bptr());

src/crimson/os/seastore/transaction.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class Transaction {
151151
assert(read_set.count(ref->prior_instance->get_paddr(), extent_cmp_t{}));
152152
ref->reset_prior_instance();
153153
} else {
154+
assert(ref->is_stable_written());
154155
// && retired_set.count(ref->get_paddr()) == 0
155156
// If it's already in the set, insert here will be a noop,
156157
// which is what we want.
@@ -285,9 +286,10 @@ class Transaction {
285286
assert(ref->is_exist_mutation_pending() ||
286287
read_set.count(ref->prior_instance->get_paddr(), extent_cmp_t{}));
287288
mutated_block_list.push_back(ref);
288-
if (!ref->is_exist_mutation_pending()) {
289+
if (ref->is_mutation_pending()) {
289290
write_set.insert(*ref);
290291
} else {
292+
assert(ref->is_exist_mutation_pending());
291293
// already added as fresh extent in write_set
292294
assert(write_set.exists(*ref));
293295
}

src/crimson/os/seastore/transaction_manager.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,10 @@ TransactionManager::rewrite_extent_ret TransactionManager::rewrite_extent(
633633
assert(extent->get_version() > 0);
634634
if (is_root_type(extent->get_type())) {
635635
// pass
636-
} else if (extent->get_version() == 1 && extent->is_mutation_pending()) {
636+
} else if (extent->get_version() == 1 && extent->has_mutation()) {
637637
t.get_rewrite_stats().account_n_dirty();
638638
} else {
639+
// extent->get_version() > 1 or DIRTY
639640
t.get_rewrite_stats().account_dirty(extent->get_version());
640641
}
641642
if (epm->can_inplace_rewrite(t, extent)) {

0 commit comments

Comments
 (0)