From 133ff979b5dac5988ca31b2dd1373be95ab362a4 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Fri, 5 Feb 2021 08:01:01 +0100 Subject: [PATCH] bio: allow throttling for testing --- kernel/mars_bio.c | 17 +++++++++++++++++ kernel/mars_bio.h | 2 ++ kernel/sy_old/mars_proc.c | 2 ++ 3 files changed, 21 insertions(+) diff --git a/kernel/mars_bio.c b/kernel/mars_bio.c index c180d4d9..1b36a556 100644 --- a/kernel/mars_bio.c +++ b/kernel/mars_bio.c @@ -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); diff --git a/kernel/mars_bio.h b/kernel/mars_bio.h index aca48f09..28ab19b0 100644 --- a/kernel/mars_bio.h +++ b/kernel/mars_bio.h @@ -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; diff --git a/kernel/sy_old/mars_proc.c b/kernel/sy_old/mars_proc.c index 04813e18..54c97099 100644 --- a/kernel/sy_old/mars_proc.c +++ b/kernel/sy_old/mars_proc.c @@ -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),