Add bandwidth limit feature --bw-limit

This commit is contained in:
Allan Clark 2025-03-27 12:57:41 -07:00 • committed by Andrea Mazzoleni
parent 15a5fac6e9
commit 5886923bb1
19 changed files with 205 additions and 5 deletions

View file

@ -864,6 +864,8 @@ int parity_write(struct snapraid_parity_handle* handle, block_off_t pos, unsigne
if (split->valid_size < offset + block_size)
split->valid_size = offset + block_size;
bw_limit(handle->bw, block_size);
write_ret = pwrite(split->f, block_buffer, block_size, offset);
if (write_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */
/* LCOV_EXCL_START */
@ -915,6 +917,8 @@ int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned
count = 0;
do {
bw_limit(handle->bw, block_size - count);
read_ret = pread(split->f, block_buffer + count, block_size - count, offset + count);
if (read_ret < 0) {
/* LCOV_EXCL_START */