int count;
};
-void (*qos_distribution_func)(struct qos_module *qos, int fd, struct metrics_pid_aggr_info *infos, int count);
+void (*qos_distribution_func)(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count);
-void qos_distribution_proportional(struct qos_module *qos, int fd, struct metrics_pid_aggr_info *infos, int count)
+void qos_distribution_proportional(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count)
{
const double proportion = (double) qos->max_throughput / (metrics_get_total(qos->log_metrics) ?: 1);
- for (int i = 0; i < count; ++i) {
- struct metrics_pid_aggr_info *const single_info = infos + i;
- dprintf(fd, "pidlimit|%d=%d\n", single_info->pid, (int) (single_info->count * proportion + 0.5));
- }
+ for (int i = 0; i < count; ++i)
+ infos[i].count = (int) (infos[i].count * proportion + 0.5);
}
-void qos_distribution_equal(struct qos_module *qos, int fd, struct metrics_pid_aggr_info *infos, int count)
+void qos_distribution_equal(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count)
{
/* round upwards so that it's never 0, to give all clients a chance
* to log at least something (so a developer can tell it's alive) */
const int equal_limit_for_everybody = (qos->max_throughput + (count - 1)) / count;
- for (int i = 0; i < count; ++i) {
- struct metrics_pid_aggr_info *const single_info = infos + i;
- dprintf(fd, "pidlimit|%d=%d\n", single_info->pid, equal_limit_for_everybody);
- }
+ for (int i = 0; i < count; ++i)
+ infos[i].count = equal_limit_for_everybody;
}
void qos_create_limits_file(struct qos_module *qos, bool is_limiting)
}
}
- qos_distribution_func(qos, fd, aggr_infos, aggr_count);
+ qos_distribution_func(qos, aggr_infos, aggr_count);
+ for (int i = 0; i < aggr_count; ++i)
+ if (aggr_infos[i].count >= 0)
+ dprintf(fd, "pidlimit|%d=%d\n", aggr_infos[i].pid, aggr_infos[i].count);
}
void qos_set_next_update_time(struct qos_module *qos, struct timespec now)
data->qos_threshold_reapply = log_config_get_int(&conf, "qos_threshold_reapply_logs", DEFAULT_QOS_THRESHOLD_REAPPLY_LOGS);
struct {
- void (*func)(struct qos_module *qos, int fd, struct metrics_pid_aggr_info *infos, int count);
+ void (*func)(struct qos_module *qos, struct metrics_pid_aggr_info *infos, int count);
const char *name;
} const qos_methods[] = {
{ qos_distribution_proportional, "proportional" },