diff --git a/utils/cached_file.hh b/utils/cached_file.hh index fd64326e20..e570d1aae7 100644 --- a/utils/cached_file.hh +++ b/utils/cached_file.hh @@ -168,12 +168,14 @@ private: : read_ahead * page_size; std::optional units; + std::optional await_guard; if (permit) { units = permit->consume_memory(size); + await_guard.emplace(*permit); } return _file.dma_read_exactly(idx * page_size, size) - .then([this, units = std::move(units), idx] (temporary_buffer&& buf) mutable { + .then([this, ag = std::move(await_guard), units = std::move(units), idx] (temporary_buffer&& buf) mutable { cached_page::ptr_type first_page; while (buf.size()) { auto this_size = std::min(page_size, buf.size());