Lines Matching refs:du
25 static void disk_util_free(struct disk_util *du) in disk_util_free() argument
27 if (du == last_du) in disk_util_free()
30 while (!flist_empty(&du->slaves)) { in disk_util_free()
33 slave = flist_first_entry(&du->slaves, struct disk_util, slavelist); in disk_util_free()
38 fio_mutex_remove(du->lock); in disk_util_free()
39 sfree(du); in disk_util_free()
42 static int get_io_ticks(struct disk_util *du, struct disk_util_stat *dus) in get_io_ticks() argument
51 dprint(FD_DISKUTIL, "open stat file: %s\n", du->path); in get_io_ticks()
53 f = fopen(du->path, "r"); in get_io_ticks()
63 dprint(FD_DISKUTIL, "%s: %s", du->path, p); in get_io_ticks()
78 dprint(FD_DISKUTIL, "%s: stat read ok? %d\n", du->path, ret == 1); in get_io_ticks()
84 static void update_io_tick_disk(struct disk_util *du) in update_io_tick_disk() argument
89 if (!du->users) in update_io_tick_disk()
91 if (get_io_ticks(du, &__dus)) in update_io_tick_disk()
94 dus = &du->dus; in update_io_tick_disk()
95 ldus = &du->last_dus; in update_io_tick_disk()
109 dus->s.msec += mtime_since(&du->time, &t); in update_io_tick_disk()
110 memcpy(&du->time, &t, sizeof(t)); in update_io_tick_disk()
117 struct disk_util *du; in update_io_ticks() local
126 du = flist_entry(entry, struct disk_util, list); in update_io_ticks()
127 update_io_tick_disk(du); in update_io_ticks()
139 struct disk_util *du; in disk_util_exists() local
144 du = flist_entry(entry, struct disk_util, list); in disk_util_exists()
146 if (major == du->major && minor == du->minor) { in disk_util_exists()
148 return du; in disk_util_exists()
286 struct disk_util *du, *__du; in disk_util_add() local
292 du = smalloc(sizeof(*du)); in disk_util_add()
293 if (!du) { in disk_util_add()
298 memset(du, 0, sizeof(*du)); in disk_util_add()
299 INIT_FLIST_HEAD(&du->list); in disk_util_add()
300 l = snprintf(du->path, sizeof(du->path), "%s/stat", path); in disk_util_add()
301 if (l < 0 || l >= sizeof(du->path)) { in disk_util_add()
303 path, sizeof(du->path) - 1); in disk_util_add()
304 sfree(du); in disk_util_add()
307 strncpy((char *) du->dus.name, basename(path), FIO_DU_NAME_SZ - 1); in disk_util_add()
308 du->sysfs_root = path; in disk_util_add()
309 du->major = majdev; in disk_util_add()
310 du->minor = mindev; in disk_util_add()
311 INIT_FLIST_HEAD(&du->slavelist); in disk_util_add()
312 INIT_FLIST_HEAD(&du->slaves); in disk_util_add()
313 du->lock = fio_mutex_init(FIO_MUTEX_UNLOCKED); in disk_util_add()
314 du->users = 0; in disk_util_add()
323 if (!strcmp((char *) du->dus.name, (char *) __du->dus.name)) { in disk_util_add()
324 disk_util_free(du); in disk_util_add()
330 dprint(FD_DISKUTIL, "add %s to list\n", du->dus.name); in disk_util_add()
332 fio_gettime(&du->time, NULL); in disk_util_add()
333 get_io_ticks(du, &du->last_dus); in disk_util_add()
335 flist_add_tail(&du->list, &disk_list); in disk_util_add()
338 find_add_disk_slaves(td, path, du); in disk_util_add()
339 return du; in disk_util_add()
443 struct disk_util *du; in init_per_file_disk_util() local
452 du = disk_util_exists(majdev, mindev); in init_per_file_disk_util()
453 if (du) { in init_per_file_disk_util()
455 td->sysfs_root = strdup(du->sysfs_root); in init_per_file_disk_util()
457 return du; in init_per_file_disk_util()
495 f->du = __init_disk_util(td, f); in init_disk_util()
568 struct disk_util *du; in disk_util_prune_entries() local
570 du = flist_first_entry(&disk_list, struct disk_util, list); in disk_util_prune_entries()
571 flist_del(&du->list); in disk_util_prune_entries()
572 disk_util_free(du); in disk_util_prune_entries()
680 struct disk_util *du; in json_object_add_disk_utils() local
685 du = flist_entry(entry, struct disk_util, list); in json_object_add_disk_utils()
687 aggregate_slaves_stats(du); in json_object_add_disk_utils()
688 json_array_add_disk_util(&du->dus, &du->agg, array); in json_object_add_disk_utils()
695 struct disk_util *du; in show_disk_util() local
717 du = flist_entry(entry, struct disk_util, list); in show_disk_util()
719 aggregate_slaves_stats(du); in show_disk_util()
720 print_disk_util(&du->dus, &du->agg, terse); in show_disk_util()