From: Jens Axboe Date: Wed, 7 Dec 2005 10:22:44 +0000 (+0100) Subject: [PATCH] fio: disk util stats fixes X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=762d05adb45588b056f29b0e4aaf6402e88ba62e;p=disktools.git [PATCH] fio: disk util stats fixes --- diff --git a/fio-ini.c b/fio-ini.c index d35909d..ab0c0d3 100644 --- a/fio-ini.c +++ b/fio-ini.c @@ -142,6 +142,7 @@ static struct thread_data *get_new_job(int global, struct thread_data *parent) td->stonewall = parent->stonewall; td->numjobs = parent->numjobs; td->use_thread = parent->use_thread; + td->do_disk_util = parent->do_disk_util; memcpy(&td->cpumask, &parent->cpumask, sizeof(td->cpumask)); strcpy(td->io_engine_name, parent->io_engine_name); diff --git a/fio.c b/fio.c index 7d186b0..11a0668 100644 --- a/fio.c +++ b/fio.c @@ -1370,16 +1370,16 @@ static int check_dev_match(dev_t dev, char *path) return 1; } -static char *find_block_dir(dev_t dev, char *path) +static int find_block_dir(dev_t dev, char *path) { struct dirent *dir; - char *found = NULL; struct stat st; + int found = 0; DIR *D; D = opendir(path); if (!D) - return NULL; + return 0; while ((dir = readdir(D)) != NULL) { char full_path[256]; @@ -1393,7 +1393,7 @@ static char *find_block_dir(dev_t dev, char *path) if (!strcmp(dir->d_name, "dev")) { if (!check_dev_match(dev, full_path)) { - found = path; + found = 1; break; } } @@ -1406,8 +1406,11 @@ static char *find_block_dir(dev_t dev, char *path) if (!S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode)) continue; - if ((found = find_block_dir(dev, full_path)) != NULL) + found = find_block_dir(dev, full_path); + if (found) { + strcpy(path, full_path); break; + } } closedir(D); @@ -1515,7 +1518,7 @@ static void init_disk_util(struct thread_data *td) struct stat st; char foo[256], tmp[256]; dev_t dev; - char *p, *dir; + char *p; if (!td->do_disk_util) return; @@ -1543,16 +1546,15 @@ static void init_disk_util(struct thread_data *td) return; sprintf(foo, "/sys/block"); - dir = find_block_dir(dev, foo); - if (!dir) + if (!find_block_dir(dev, foo)) return; /* * if this is inside a partition dir, jump back to parent */ - sprintf(tmp, "%s/queue", dir); + sprintf(tmp, "%s/queue", foo); if (stat(tmp, &st)) { - p = dirname(dir); + p = dirname(foo); sprintf(tmp, "%s/queue", p); if (stat(tmp, &st)) { fprintf(stderr, "unknown sysfs layout\n");