Add assert !writeback_bytes

This commit is contained in:
Vitaliy Filippov
2025-02-19 01:15:46 +03:00
parent 78ca4538bf
commit ccbc0c5928
2 changed files with 18 additions and 5 deletions
+1 -1
View File
@@ -673,7 +673,7 @@ void cluster_client_t::execute_internal(cluster_op_t *op)
}
// Just copy and acknowledge the operation
wb->copy_write(op, CACHE_DIRTY);
while (wb->writeback_bytes + op->len > client_max_buffered_bytes || wb->writeback_queue_size > client_max_buffered_ops)
while (wb->writeback_bytes > client_max_buffered_bytes || wb->writeback_queue_size > client_max_buffered_ops)
{
// Initiate some writeback (asynchronously)
wb->start_writebacks(this, 1);
+17 -4
View File
@@ -105,7 +105,10 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
(*dirty_it->second.refcnt)++;
if (dirty_it->second.state == CACHE_DIRTY)
{
writeback_bytes -= op->len;
if (dirty_it->second.buf)
{
writeback_bytes -= op->len;
}
writeback_queue_size++;
}
break;
@@ -115,7 +118,10 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
// Only leave the beginning
if (dirty_it->second.state == CACHE_DIRTY)
{
writeback_bytes -= old_end - op->offset;
if (dirty_it->second.buf)
{
writeback_bytes -= old_end - op->offset;
}
if (is_right_merged(dirty_it))
{
writeback_queue_size++;
@@ -130,7 +136,10 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
// Only leave the end
if (dirty_it->second.state == CACHE_DIRTY)
{
writeback_bytes -= new_end - dirty_it->first.stripe;
if (dirty_it->second.buf)
{
writeback_bytes -= new_end - dirty_it->first.stripe;
}
if (is_left_merged(dirty_it))
{
writeback_queue_size++;
@@ -155,7 +164,10 @@ void writeback_cache_t::copy_write(cluster_op_t *op, int state, uint64_t new_flu
// Remove the whole buffer
if (dirty_it->second.state == CACHE_DIRTY)
{
writeback_bytes -= dirty_it->second.len;
if (dirty_it->second.buf)
{
writeback_bytes -= dirty_it->second.len;
}
bool lm = is_left_merged(dirty_it);
bool rm = is_right_merged(dirty_it);
if (!lm && !rm)
@@ -387,6 +399,7 @@ void writeback_cache_t::start_writebacks(cluster_client_t *cli, int count)
assert(writeback_queue_size > 0);
writeback_queue_size--;
writeback_bytes -= off - from_it->first.stripe;
assert(writeback_queue_size > 0 || !writeback_bytes);
flush_buffers(cli, from_it, to_it);
}
queue_copy.erase(queue_copy.begin(), queue_copy.begin()+i);