mirror of
https://github.com/schoebel/mars
synced 2025-01-31 04:11:58 +00:00
all: allow throttling of bulk write requests
This commit is contained in:
parent
0a8292cb80
commit
9134be1a3e
@ -324,6 +324,9 @@ extern struct banning mars_global_ban;
|
||||
|
||||
extern atomic_t mars_global_io_flying;
|
||||
|
||||
extern int mars_throttle_start;
|
||||
extern int mars_throttle_end;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Some special brick types for avoidance of cyclic references.
|
||||
|
@ -37,6 +37,17 @@
|
||||
#include <linux/blkdev.h>
|
||||
|
||||
#include "mars.h"
|
||||
#include "lib_limiter.h"
|
||||
|
||||
///////////////////////// global tuning ////////////////////////
|
||||
|
||||
int if_throttle_start_size = 0; // in kb
|
||||
EXPORT_SYMBOL_GPL(if_throttle_start_size);
|
||||
|
||||
struct mars_limiter if_throttle = {
|
||||
.lim_max_rate = 10000,
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(if_throttle);
|
||||
|
||||
///////////////////////// own type definitions ////////////////////////
|
||||
|
||||
@ -373,6 +384,11 @@ if_make_request(struct request_queue *q, struct bio *bio)
|
||||
goto done;
|
||||
}
|
||||
|
||||
// throttling of too big write requests
|
||||
if (rw && if_throttle_start_size > 0 && total_len / 1024 >= if_throttle_start_size) {
|
||||
mars_limit_sleep(&if_throttle, total_len / 1024);
|
||||
}
|
||||
|
||||
#ifdef DENY_READA // provisinary -- we should introduce an equivalent of READA also to the MARS infrastructure
|
||||
if (ahead) {
|
||||
atomic_inc(&input->total_reada_count);
|
||||
|
@ -11,6 +11,13 @@
|
||||
|
||||
//#define USE_TIMER (HZ/10) // use this ONLY for debugging
|
||||
|
||||
///////////////////////// global tuning ////////////////////////
|
||||
|
||||
extern int if_throttle_start_size; // in kb
|
||||
extern struct mars_limiter if_throttle;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
/* I don't want to enhance / intrude into struct bio for compatibility reasons
|
||||
* (support for a variety of kernel versions).
|
||||
* The following is just a silly workaround which could be removed again.
|
||||
|
@ -127,6 +127,12 @@ int mars_fast_fullsync =
|
||||
;
|
||||
EXPORT_SYMBOL_GPL(mars_fast_fullsync);
|
||||
|
||||
int mars_throttle_start = 0;
|
||||
EXPORT_SYMBOL_GPL(mars_throttle_start);
|
||||
|
||||
int mars_throttle_end = 99;
|
||||
EXPORT_SYMBOL_GPL(mars_throttle_end);
|
||||
|
||||
int mars_emergency_mode = 0;
|
||||
EXPORT_SYMBOL_GPL(mars_emergency_mode);
|
||||
|
||||
@ -169,6 +175,19 @@ int compute_emergency_mode(void)
|
||||
|
||||
mars_remaining_space("/mars", &global_total_space, &rest);
|
||||
|
||||
if (mars_throttle_start > 0 &&
|
||||
mars_throttle_end > mars_throttle_start &&
|
||||
global_total_space > 0) {
|
||||
loff_t percent = rest * 100 / global_total_space;
|
||||
if (percent < mars_throttle_start) {
|
||||
if_throttle_start_size = 0;
|
||||
} else if (percent >= mars_throttle_end) {
|
||||
if_throttle_start_size = 1;
|
||||
} else {
|
||||
if_throttle_start_size = (mars_throttle_end - percent) * 1024 / (mars_throttle_end - mars_throttle_start) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
#define CHECK_LIMIT(LIMIT_VAR) \
|
||||
if (LIMIT_VAR > 0) \
|
||||
limit += (loff_t)LIMIT_VAR * 1024 * 1024; \
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "../lib_mapfree.h"
|
||||
#include "../mars_bio.h"
|
||||
#include "../mars_aio.h"
|
||||
#include "../mars_if.h"
|
||||
#include "../mars_copy.h"
|
||||
#include "../mars_client.h"
|
||||
#include "../mars_server.h"
|
||||
@ -258,6 +259,10 @@ ctl_table mars_table[] = {
|
||||
INT_ENTRY("required_free_space_4_gb", global_free_space_4, 0600),
|
||||
INT_ENTRY("mars_emergency_mode", mars_emergency_mode, 0600),
|
||||
INT_ENTRY("mars_reset_emergency", mars_reset_emergency, 0600),
|
||||
INT_ENTRY("write_throttle_start", mars_throttle_start, 0600),
|
||||
INT_ENTRY("write_throttle_end", mars_throttle_end, 0600),
|
||||
INT_ENTRY("write_throttle_size_limit", if_throttle_start_size, 0400),
|
||||
LIMITER_ENTRIES(&if_throttle, "write_throttle", "kb"),
|
||||
#ifdef CONFIG_MARS_LOADAVG_LIMIT
|
||||
INT_ENTRY("loadavg_limit", mars_max_loadavg, 0600),
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user