Skip to content

Commit

Permalink
crimson/os/seastore: don't set INVALID extents to CLEAN when reading
Browse files Browse the repository at this point in the history
extents

CLEAN_PENDING extents may be invalidated before read completes:

1. transaction A retired an laddr, which lead to a RetirePlaceHolder in
   Cache
2. transaction B try to read that extent, and replace A's
   RetirePlaceHolder with it;
3. transaction A commits and invalidate that extent;
4. transaction B complete reading that extent;

In this case, we shouldn't set the extent's state to CLEAN

Signed-off-by: Xuehan Xu <[email protected]>
  • Loading branch information
xxhdx1985126 committed Mar 21, 2023
1 parent e1587ee commit 729dabd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/crimson/os/seastore/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -1321,11 +1321,15 @@ class Cache {
).safe_then(
[extent=std::move(extent)]() mutable {
LOG_PREFIX(Cache::read_extent);
extent->state = CachedExtent::extent_state_t::CLEAN;
/* TODO: crc should be checked against LBA manager */
extent->last_committed_crc = extent->get_crc32c();

extent->on_clean_read();
if (likely(extent->state == CachedExtent::extent_state_t::CLEAN_PENDING)) {
extent->state = CachedExtent::extent_state_t::CLEAN;
/* TODO: crc should be checked against LBA manager */
extent->last_committed_crc = extent->get_crc32c();

extent->on_clean_read();
} else {
ceph_assert(!extent->is_valid());
}
extent->complete_io();
SUBDEBUG(seastore_cache, "read extent done -- {}", *extent);
return get_extent_ertr::make_ready_future<TCachedExtentRef<T>>(
Expand Down

0 comments on commit 729dabd

Please sign in to comment.