Skip to content

Commit

Permalink
librbd/cache/pwl: initialize number_log_entries
Browse files Browse the repository at this point in the history
Using uninitialized number_log_entries cause writesame req space
calculation error. sometimes fail in TestMockCacheSSDWriteLog.writesame.

Fixes: https://tracker.ceph.com/issues/52852

Signed-off-by: Yin Congmin <[email protected]>
  • Loading branch information
CongMinYin committed Oct 8, 2021
1 parent ee7ad78 commit dd33684
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/librbd/cache/pwl/Request.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class C_BlockIORequest : public Context {
virtual void setup_buffer_resources(
uint64_t *bytes_cached, uint64_t *bytes_dirtied, uint64_t *bytes_allocated,
uint64_t *number_lanes, uint64_t *number_log_entries,
uint64_t *number_unpublished_reserves) {};
uint64_t *number_unpublished_reserves) = 0;

protected:
utime_t m_arrived_time;
Expand Down
1 change: 1 addition & 0 deletions src/librbd/cache/pwl/rwl/Request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void C_WriteSameRequest<T>::setup_buffer_resources(
uint64_t *number_lanes, uint64_t *number_log_entries,
uint64_t *number_unpublished_reserves) {
ceph_assert(this->image_extents.size() == 1);
*number_log_entries = 1;
*bytes_dirtied += this->image_extents[0].second;
auto pattern_length = this->bl.length();
this->m_resources.buffers.emplace_back();
Expand Down
4 changes: 2 additions & 2 deletions src/librbd/cache/pwl/ssd/Request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ void C_WriteRequest<T>::setup_buffer_resources(
uint64_t *number_lanes, uint64_t *number_log_entries,
uint64_t *number_unpublished_reserves) {

auto image_extents_size = this->image_extents.size();
*bytes_cached = 0;
*bytes_allocated = 0;
*number_log_entries = image_extents_size;
*number_log_entries = this->image_extents.size();

for (auto &extent : this->image_extents) {
*bytes_cached += extent.second;
Expand All @@ -48,6 +47,7 @@ void C_WriteSameRequest<T>::setup_buffer_resources(
uint64_t *number_lanes, uint64_t *number_log_entries,
uint64_t *number_unpublished_reserves) {
ceph_assert(this->image_extents.size() == 1);
*number_log_entries = 1;
*bytes_dirtied = this->image_extents[0].second;
*bytes_cached = this->bl.length();
*bytes_allocated = round_up_to(*bytes_cached, MIN_WRITE_ALLOC_SSD_SIZE);
Expand Down

0 comments on commit dd33684

Please sign in to comment.