2 /***************************************************************************/
3 /* H A R D D I S K H A N D L I N G U T I L I T Y F U N C T I O N S */
4 /***************************************************************************/
6 static bool disk_init()
10 for (i = 0; i < N_DISKS; i++) {
11 disk[i].aggregate_bw = DISK_DEFAULT_AGGREGATE_BW;
12 disk[i].sched_budget = DISK_DEFAULT_SCHED_BUDGET;
13 disk[i].weight_sum = 0;
14 disk[i].thread_num = 0;
20 static inline unsigned int disk_sched_ioprio(unsigned int weight) {
26 return 8 - 1 - (weight / 2);
29 static inline unsigned int disk_sched_ioweight(frsh_resource_id_t disk_id, struct timespec budget, struct timespec period) {
32 unsigned long int q_i, p_i;
34 th = disk[disk_id_2_index(disk_id)].aggregate_bw / 10E9;
35 b = disk[disk_id_2_index(disk_id)].sched_budget;
38 q_i = timespec_to_usec(budget);
39 p_i = timespec_to_usec(period);
46 weight = (DISK_WEIGHT_MAX * q_i ) / (p_i - (b / th));
55 static inline float disk_sched_iobandwidth(frsh_resource_id_t disk_id, unsigned int weight) {
56 return (float) weight * (disk[disk_id_2_index(disk_id)].aggregate_bw / disk[disk_id_2_index(disk_id)].weight_sum);