#include <stdarg.h>
#include <xenctrl.h>
#include <time.h>
+#include <syslog.h>
#include "utils.h"
#include "talloc.h"
/* write rate limit */
wrl_creditt wrl_credit; /* [ -wrl_config_writecost, +_dburst ] */
struct wrl_timestampt wrl_timestamp;
+ bool wrl_delay_logged;
};
static LIST_HEAD(domains);
static long wrl_ndomains;
static wrl_creditt wrl_reserve; /* [-wrl_config_newdoms_dburst, +_gburst ] */
+static time_t wrl_log_last_warning; /* 0: no previous warning */
void wrl_gettime_now(struct wrl_timestampt *now_wt)
{
wakeup);
}
+#define WRL_LOG(now, ...) \
+ (syslog(LOG_WARNING, "write rate limit: " __VA_ARGS__))
+
void wrl_apply_debit_actual(struct domain *domain)
{
struct wrl_timestampt now;
trace("wrl: domain %u credit=%ld (reserve=%ld)\n",
domain->domid,
(long)domain->wrl_credit, (long)wrl_reserve);
+
+ if (domain->wrl_credit < 0) {
+ if (!domain->wrl_delay_logged) {
+ domain->wrl_delay_logged = true;
+ WRL_LOG(now, "domain %ld is affected",
+ (long)domain->domid);
+ } else if (!wrl_log_last_warning) {
+ WRL_LOG(now, "rate limiting restarts");
+ }
+ wrl_log_last_warning = now.sec;
+ }
+}
+
+void wrl_log_periodic(struct wrl_timestampt now)
+{
+ if (wrl_log_last_warning &&
+ (now.sec - wrl_log_last_warning) > WRL_LOGEVERY) {
+ WRL_LOG(now, "not in force recently");
+ wrl_log_last_warning = 0;
+ }
}
void wrl_apply_debit_direct(struct connection *conn)
#define WRL_DBURST 10
#define WRL_GBURST 1000
#define WRL_NEWDOMS 5
+#define WRL_LOGEVERY 120 /* seconds */
struct wrl_timestampt {
time_t sec;
void wrl_check_timeout(struct domain *domain,
struct wrl_timestampt now,
int *ptimeout);
+void wrl_log_periodic(struct wrl_timestampt now);
void wrl_apply_debit_direct(struct connection *conn);
void wrl_apply_debit_trans_commit(struct connection *conn);