crimson/os/seastore: initialize crc *after* read

Previously, all extents ended up initialized to the same crc value
upon read -- the one for an empty buffer.  This bug wasn't detected
because an extent was always evicted and reread following the first
write and subsequently kept in cache once initially written.

Also, add crc to operator<< for extents.

Signed-off-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
Samuel Just 2020-08-21 13:15:21 -07:00
parent 9016932fef
commit 05c62821d9
2 changed files with 4 additions and 3 deletions

View File

@ -135,14 +135,14 @@ public:
ref->set_paddr(offset);
ref->state = CachedExtent::extent_state_t::CLEAN;
/* TODO: crc should be checked against LBA manager */
ref->last_committed_crc = ref->get_crc32c();
return segment_manager.read(
offset,
length,
ref->get_bptr()).safe_then(
[this, ref=std::move(ref)]() mutable {
/* TODO: crc should be checked against LBA manager */
ref->last_committed_crc = ref->get_crc32c();
ref->on_clean_read();
ref->complete_io();
add_extent(ref);

View File

@ -120,6 +120,7 @@ public:
<< ", version=" << version
<< ", paddr=" << get_paddr()
<< ", state=" << state
<< ", last_committed_crc=" << last_committed_crc
<< ", refcount=" << use_count();
print_detail(out);
return out << ")";