static struct disk_util *last_du;
static struct fio_mutex *disk_util_mutex;
-static int disk_util_exit;
FLIST_HEAD(disk_list);
{
struct disk_util *du, *__du;
struct flist_head *entry;
+ int l;
dprint(FD_DISKUTIL, "add maj/min %d/%d: %s\n", majdev, mindev, path);
du = smalloc(sizeof(*du));
+ if (!du) {
+ log_err("fio: smalloc() pool exhausted\n");
+ return NULL;
+ }
+
memset(du, 0, sizeof(*du));
INIT_FLIST_HEAD(&du->list);
- sprintf(du->path, "%s/stat", path);
+ l = snprintf(du->path, sizeof(du->path), "%s/stat", path);
+ if (l < 0 || l >= sizeof(du->path)) {
+ log_err("constructed path \"%.100s[...]/stat\" larger than buffer (%zu bytes)\n",
+ path, sizeof(du->path) - 1);
+ sfree(du);
+ return NULL;
+ }
strncpy((char *) du->dus.name, basename(path), FIO_DU_NAME_SZ);
du->sysfs_root = path;
du->major = majdev;
agg->max_util.u.f = 100.0;
}
-void free_disk_util(void)
+void disk_util_prune_entries(void)
{
- struct disk_util *du;
-
- disk_util_exit = 1;
- wait_for_disk_thread_exit();
-
fio_mutex_down(disk_util_mutex);
while (!flist_empty(&disk_list)) {
+ struct disk_util *du;
+
du = flist_entry(disk_list.next, struct disk_util, list);
flist_del(&du->list);
disk_util_free(du);
if (!terse)
log_info("\nDisk stats (read/write):\n");
- if (terse && terse_version == 4) {
+ if (output_format == FIO_OUTPUT_JSON) {
array = json_create_array();
json_object_add_value_array(parent, "disk_util", array);
}
du = flist_entry(entry, struct disk_util, list);
aggregate_slaves_stats(du);
- if (terse && terse_version == 4)
+ if (output_format == FIO_OUTPUT_JSON)
print_disk_util_json(du, array);
else
print_disk_util(&du->dus, &du->agg, terse);