diskutil: try additional slave device path if first fails
[fio.git] / diskutil.c
index c34841a2af2c379b10b47b162ef79e99fd88a040..af2fa3bdc57860755685999be12d5aba2dc83aa7 100644 (file)
@@ -3,6 +3,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>
 #include <dirent.h>
 #include <libgen.h>
 #include <math.h>
@@ -18,8 +19,6 @@ static struct disk_util *last_du;
 
 static struct fio_mutex *disk_util_mutex;
 
-FLIST_HEAD(disk_list);
-
 static struct disk_util *__init_per_file_disk_util(struct thread_data *td,
                int majdev, int mindev, char *path);
 
@@ -86,7 +85,7 @@ static int get_io_ticks(struct disk_util *du, struct disk_util_stat *dus)
 static void update_io_tick_disk(struct disk_util *du)
 {
        struct disk_util_stat __dus, *dus, *ldus;
-       struct timeval t;
+       struct timespec t;
 
        if (!du->users)
                return;
@@ -255,6 +254,8 @@ static void find_add_disk_slaves(struct thread_data *td, char *path,
                slavepath[linklen] = '\0';
 
                sprintf(temppath, "%s/%s/dev", slavesdir, slavepath);
+               if (access(temppath, F_OK) != 0)
+                       sprintf(temppath, "%s/%s/device/dev", slavesdir, slavepath);
                if (read_block_dev_entry(temppath, &majdev, &mindev)) {
                        perror("Error getting slave device numbers.");
                        closedir(dirhandle);
@@ -365,7 +366,7 @@ static int find_block_dir(int majdev, int mindev, char *path, int link_ok)
                return 0;
 
        while ((dir = readdir(D)) != NULL) {
-               char full_path[256];
+               char full_path[257];
 
                if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
                        continue;
@@ -431,9 +432,6 @@ static struct disk_util *__init_per_file_disk_util(struct thread_data *td,
                sprintf(path, "%s", tmp);
        }
 
-       if (td->o.ioscheduler && !td->sysfs_root)
-               td->sysfs_root = strdup(path);
-
        return disk_util_add(td, majdev, mindev, path);
 }
 
@@ -452,12 +450,8 @@ static struct disk_util *init_per_file_disk_util(struct thread_data *td,
                        mindev);
 
        du = disk_util_exists(majdev, mindev);
-       if (du) {
-               if (td->o.ioscheduler && !td->sysfs_root)
-                       td->sysfs_root = strdup(du->sysfs_root);
-
+       if (du)
                return du;
-       }
 
        /*
         * for an fs without a device, we will repeatedly stat through