bio: allow throttling for testing

This commit is contained in:
Thomas Schoebel-Theuer 2021-02-05 08:01:01 +01:00 committed by Thomas Schoebel-Theuer
parent 8e4c6781ee
commit 133ff979b5
3 changed files with 21 additions and 0 deletions

View File

@ -39,6 +39,7 @@
#include "mars.h"
#include "lib_timing.h"
#include "lib_mapfree.h"
#include "lib_limiter.h"
#include "mars_bio.h"
@ -73,6 +74,13 @@ struct threshold bio_io_threshold[2] = {
};
EXPORT_SYMBOL_GPL(bio_io_threshold);
#ifdef CONFIG_MARS_DEBUG
struct mars_limiter bio_throttle_read = {
};
struct mars_limiter bio_throttle_write = {
};
#endif
///////////////////////// own type definitions ////////////////////////
///////////////////////// own helper functions ////////////////////////
@ -344,6 +352,15 @@ static int bio_ref_get(struct bio_output *output, struct mref_object *mref)
mref_a->do_dealloc = true;
}
#ifdef CONFIG_MARS_DEBUG
/* Only for testing, e.g. simulation of degraded RAID etc
*/
if (mref->ref_flags & MREF_WRITE)
mars_limit_sleep(&bio_throttle_write, (mref->ref_len + 512) / 1024);
else
mars_limit_sleep(&bio_throttle_read, (mref->ref_len + 512) / 1024);
#endif
status = make_bio(output->brick, mref->ref_data, mref->ref_len, mref->ref_pos, mref_a, &mref_a->bio);
if (unlikely(status < 0 || !mref_a->bio)) {
MARS_ERR("could not create bio, status = %d\n", status);

View File

@ -32,6 +32,8 @@
#ifdef CONFIG_MARS_DEBUG
#define MARS_BIO_DEBUG
extern struct mars_limiter bio_throttle_read;
extern struct mars_limiter bio_throttle_write;
#endif
extern int bio_nr_requests;

View File

@ -444,6 +444,8 @@ struct ctl_table mars_table[] = {
#ifdef CONFIG_MARS_DEBUG
INT_ENTRY("debug_crash_mode", mars_crash_mode, 0600),
INT_ENTRY("debug_hang_mode", mars_hang_mode, 0600),
LIMITER_ENTRIES(&bio_throttle_read, "debug_bio_throttle_read", "kb"),
LIMITER_ENTRIES(&bio_throttle_write, "debug_bio_throttle_write", "kb"),
#endif
INT_ENTRY("logger_completion_semantics", trans_logger_completion_semantics, 0600),
INT_ENTRY("logger_do_crc", trans_logger_do_crc, 0600),