From 21cc46bb3aaf3315ceeef786710f6874c1ab6e86 Mon Sep 17 00:00:00 2001 From: Yin Congmin Date: Mon, 15 Mar 2021 15:34:35 +0800 Subject: [PATCH] rbd/cache/pwl: update wait_buffer state and add wake_up Signed-off-by: Yin Congmin --- src/librbd/cache/pwl/AbstractWriteLog.cc | 10 ++++++++-- src/librbd/cache/pwl/rwl/WriteLog.cc | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/librbd/cache/pwl/AbstractWriteLog.cc b/src/librbd/cache/pwl/AbstractWriteLog.cc index b08d5df7962da..a658b60b2fe47 100644 --- a/src/librbd/cache/pwl/AbstractWriteLog.cc +++ b/src/librbd/cache/pwl/AbstractWriteLog.cc @@ -1355,7 +1355,9 @@ void AbstractWriteLog::dispatch_deferred_writes(void) } ceph_assert(!allocated); if (!allocated && front_req) { - /* front_req->alloc_resources() failed on the last iteration. We'll stop dispatching. */ + /* front_req->alloc_resources() failed on the last iteration. + * We'll stop dispatching. */ + wake_up(); front_req = nullptr; ceph_assert(!cleared_dispatching_flag); m_dispatching_deferred_ops = false; @@ -1477,7 +1479,7 @@ bool AbstractWriteLog::check_allocation(C_BlockIORequestT *req, /* Don't attempt buffer allocate if we've exceeded the "full" threshold */ if (m_bytes_allocated + bytes_allocated > bytes_allocated_cap) { if (!req->has_io_waited_for_buffers()) { - req->set_io_waited_for_entries(true); + req->set_io_waited_for_buffers(true); ldout(m_image_ctx.cct, 1) << "Waiting for allocation cap (cap=" << bytes_allocated_cap << ", allocated=" << m_bytes_allocated @@ -1504,6 +1506,10 @@ bool AbstractWriteLog::check_allocation(C_BlockIORequestT *req, m_bytes_allocated += bytes_allocated; m_bytes_cached += bytes_cached; m_bytes_dirty += bytes_dirtied; + if (req->has_io_waited_for_buffers()) { + req->set_io_waited_for_buffers(false); + } + } else { alloc_succeeds = false; } diff --git a/src/librbd/cache/pwl/rwl/WriteLog.cc b/src/librbd/cache/pwl/rwl/WriteLog.cc index 4cea78dfc8d60..0dba120f93107 100644 --- a/src/librbd/cache/pwl/rwl/WriteLog.cc +++ b/src/librbd/cache/pwl/rwl/WriteLog.cc @@ -785,7 +785,8 @@ void WriteLog::process_work() { (utime_t(ceph_clock_now() - started).to_msec() < RETIRE_BATCH_TIME_LIMIT_MS))) { if (!retire_entries((this->m_shutting_down || this->m_invalidating || (this->m_bytes_allocated > aggressive_high_water_bytes) || - (m_log_entries.size() > aggressive_high_water_entries)) + (m_log_entries.size() > aggressive_high_water_entries) || + this->m_alloc_failed_since_retire) ? MAX_ALLOC_PER_TRANSACTION : MAX_FREE_PER_TRANSACTION)) { break; @@ -888,7 +889,7 @@ void WriteLog::reserve_cache(C_BlockIORequestT *req, buffer.allocation_lat = ceph_clock_now() - before_reserve; if (TOID_IS_NULL(buffer.buffer_oid)) { if (!req->has_io_waited_for_buffers()) { - req->set_io_waited_for_entries(true); + req->set_io_waited_for_buffers(true); } ldout(m_image_ctx.cct, 5) << "can't allocate all data buffers: " << pmemobj_errormsg() << ". " -- 2.39.5