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

@ -261,6 +261,8 @@ int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned c
count = 0;
do {
bw_limit(handle->bw, block_size - count);
/* read the full block to support O_DIRECT */
read_ret = pread(handle->f, block_buffer + count, block_size - count, offset + count);
if (read_ret < 0) {
@ -372,6 +374,7 @@ struct snapraid_handle* handle_mapping(struct snapraid_state* state, unsigned* h
handle[j].file = 0;
handle[j].f = -1;
handle[j].valid_size = 0;
handle[j].bw = 0;
}
/* set the vector */