2014-11-21 10:51:34 +00:00
|
|
|
/*
|
|
|
|
* MARS Long Distance Replication Software
|
|
|
|
*
|
|
|
|
* This file is part of MARS project: http://schoebel.github.io/mars/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010-2014 Thomas Schoebel-Theuer
|
|
|
|
* Copyright (C) 2011-2014 1&1 Internet AG
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2012-08-07 12:07:12 +00:00
|
|
|
#ifndef MARS_LIB_LIMITER_H
|
|
|
|
#define MARS_LIB_LIMITER_H
|
|
|
|
|
2012-09-24 09:17:00 +00:00
|
|
|
#include "brick.h"
|
2019-02-20 12:48:21 +00:00
|
|
|
#include "lamport.h"
|
2012-09-24 09:17:00 +00:00
|
|
|
|
2012-08-07 12:07:12 +00:00
|
|
|
#include <linux/utsname.h>
|
|
|
|
|
|
|
|
struct mars_limiter {
|
2012-09-24 09:49:29 +00:00
|
|
|
/* hierarchy tree */
|
|
|
|
struct mars_limiter *lim_father;
|
2012-08-07 12:07:12 +00:00
|
|
|
/* tunables */
|
2016-01-19 08:15:44 +00:00
|
|
|
int lim_max_ops_rate;
|
|
|
|
int lim_max_amount_rate;
|
2013-11-20 13:10:54 +00:00
|
|
|
int lim_max_delay;
|
2013-11-20 14:14:05 +00:00
|
|
|
int lim_min_window;
|
|
|
|
int lim_max_window;
|
2012-09-24 09:49:29 +00:00
|
|
|
/* readable */
|
2016-01-19 08:15:44 +00:00
|
|
|
int lim_ops_rate;
|
|
|
|
int lim_amount_rate;
|
|
|
|
int lim_ops_cumul;
|
|
|
|
int lim_amount_cumul;
|
2015-06-24 07:33:21 +00:00
|
|
|
int lim_total_ops;
|
2016-01-19 08:15:44 +00:00
|
|
|
int lim_total_amount;
|
2019-02-20 12:48:21 +00:00
|
|
|
struct lamport_time lim_stamp;
|
2012-08-07 12:07:12 +00:00
|
|
|
/* internal */
|
2016-01-19 08:15:44 +00:00
|
|
|
long long lim_ops_accu;
|
|
|
|
long long lim_amount_accu;
|
2012-08-07 12:07:12 +00:00
|
|
|
};
|
|
|
|
|
2012-09-24 09:17:00 +00:00
|
|
|
extern int mars_limit(struct mars_limiter *lim, int amount);
|
2012-08-07 12:07:12 +00:00
|
|
|
|
2013-11-20 13:10:54 +00:00
|
|
|
extern void mars_limit_sleep(struct mars_limiter *lim, int amount);
|
2012-08-07 12:07:12 +00:00
|
|
|
|
2017-06-01 06:30:36 +00:00
|
|
|
void mars_limit_reset(struct mars_limiter *lim);
|
|
|
|
|
2012-08-07 12:07:12 +00:00
|
|
|
#endif
|