Skip to content

Commit

Permalink
Merge pull request #41068 from idryomov/wip-rbd-pwl-ssd-capacity
Browse files Browse the repository at this point in the history
librbd/cache/pwl/ssd/WriteLog: decrement m_bytes_allocated when retiring

Reviewed-by: Mahati Chamarthy <mahati.chamarthy@intel.com>
  • Loading branch information
idryomov committed May 3, 2021
2 parents c804989 + 2a974fd commit 7f17f21
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 132 deletions.
29 changes: 15 additions & 14 deletions src/librbd/cache/pwl/AbstractWriteLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,17 @@ void AbstractWriteLog<I>::log_perf() {
template <typename I>
void AbstractWriteLog<I>::periodic_stats() {
std::lock_guard locker(m_lock);
ldout(m_image_ctx.cct, 1) << "STATS: "
<< "m_free_log_entries=" << m_free_log_entries << ", "
<< "m_log_entries=" << m_log_entries.size() << ", "
<< "m_dirty_log_entries=" << m_dirty_log_entries.size() << ", "
<< "m_bytes_allocated=" << m_bytes_allocated << ", "
<< "m_bytes_cached=" << m_bytes_cached << ", "
<< "m_bytes_dirty=" << m_bytes_dirty << ", "
<< "bytes available=" << m_bytes_allocated_cap - m_bytes_allocated << ", "
<< "m_current_sync_gen=" << m_current_sync_gen << ", "
<< "m_flushed_sync_gen=" << m_flushed_sync_gen << ", "
ldout(m_image_ctx.cct, 1) << "STATS: m_log_entries=" << m_log_entries.size()
<< ", m_dirty_log_entries=" << m_dirty_log_entries.size()
<< ", m_free_log_entries=" << m_free_log_entries
<< ", m_bytes_allocated=" << m_bytes_allocated
<< ", m_bytes_cached=" << m_bytes_cached
<< ", m_bytes_dirty=" << m_bytes_dirty
<< ", bytes available=" << m_bytes_allocated_cap - m_bytes_allocated
<< ", m_first_valid_entry=" << m_first_valid_entry
<< ", m_first_free_entry=" << m_first_free_entry
<< ", m_current_sync_gen=" << m_current_sync_gen
<< ", m_flushed_sync_gen=" << m_flushed_sync_gen
<< dendl;
}

Expand Down Expand Up @@ -1463,7 +1464,7 @@ template <typename I>
bool AbstractWriteLog<I>::check_allocation(C_BlockIORequestT *req,
uint64_t &bytes_cached, uint64_t &bytes_dirtied, uint64_t &bytes_allocated,
uint64_t &num_lanes, uint64_t &num_log_entries,
uint64_t &num_unpublished_reserves, uint64_t bytes_allocated_cap){
uint64_t &num_unpublished_reserves) {
bool alloc_succeeds = true;
bool no_space = false;
{
Expand All @@ -1487,11 +1488,11 @@ bool AbstractWriteLog<I>::check_allocation(C_BlockIORequestT *req,
no_space = true; /* Entries must be retired */
}
/* Don't attempt buffer allocate if we've exceeded the "full" threshold */
if (m_bytes_allocated + bytes_allocated > bytes_allocated_cap) {
if (m_bytes_allocated + bytes_allocated > m_bytes_allocated_cap) {
if (!req->has_io_waited_for_buffers()) {
req->set_io_waited_for_buffers(true);
ldout(m_image_ctx.cct, 1) << "Waiting for allocation cap (cap="
<< bytes_allocated_cap
ldout(m_image_ctx.cct, 5) << "Waiting for allocation cap (cap="
<< m_bytes_allocated_cap
<< ", allocated=" << m_bytes_allocated
<< ") in write [" << *req << "]" << dendl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librbd/cache/pwl/AbstractWriteLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class AbstractWriteLog {
uint64_t &bytes_cached, uint64_t &bytes_dirtied,
uint64_t &bytes_allocated,
uint64_t &num_lanes, uint64_t &num_log_entries,
uint64_t &num_unpublished_reserves, uint64_t bytes_allocated_cap);
uint64_t &num_unpublished_reserves);
void append_scheduled(
pwl::GenericLogOperations &ops, bool &ops_remain, bool &appending,
bool isRWL=false);
Expand Down
6 changes: 3 additions & 3 deletions src/librbd/cache/pwl/rwl/WriteLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -938,9 +938,9 @@ bool WriteLog<I>::alloc_resources(C_BlockIORequestT *req) {
req->setup_buffer_resources(&bytes_cached, &bytes_dirtied, &bytes_allocated,
&num_lanes, &num_log_entries, &num_unpublished_reserves);

alloc_succeeds = this->check_allocation(req, bytes_cached, bytes_dirtied, bytes_allocated,
num_lanes, num_log_entries, num_unpublished_reserves,
this->m_bytes_allocated_cap);
alloc_succeeds = this->check_allocation(req, bytes_cached, bytes_dirtied,
bytes_allocated, num_lanes, num_log_entries,
num_unpublished_reserves);

std::vector<WriteBufferAllocation>& buffers = req->get_resources_buffers();
if (!alloc_succeeds) {
Expand Down

0 comments on commit 7f17f21

Please sign in to comment.