summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2005-12-07 11:22:44 +0100
committerJens Axboe <axboe@suse.de>2005-12-07 11:22:44 +0100
commit762d05adb45588b056f29b0e4aaf6402e88ba62e (patch)
tree681660784da768b90f4b8d1b6378dd10558cf191
parentd58fafc4560ae4e82b15b4b139674054c2f71554 (diff)
[PATCH] fio: disk util stats fixes
-rw-r--r--fio-ini.c1
-rw-r--r--fio.c22
2 files changed, 13 insertions, 10 deletions
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");