Fix sysfs_root assignment with multiple identical devices
authorJens Axboe <jens.axboe@oracle.com>
Tue, 3 Apr 2007 23:33:04 +0000 (16:33 -0700)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 3 Apr 2007 23:33:04 +0000 (16:33 -0700)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diskutil.c
fio.h

index 399aced467e0c855884b3c1ea4d7c09752d1f97d..a87435afc7481ad2eb8652b8a268e2ab53ae7df7 100644 (file)
@@ -79,7 +79,7 @@ void update_io_ticks(void)
        }
 }
 
-static int disk_util_exists(int major, int minor)
+static struct disk_util *disk_util_exists(int major, int minor)
 {
        struct list_head *entry;
        struct disk_util *du;
@@ -88,10 +88,10 @@ static int disk_util_exists(int major, int minor)
                du = list_entry(entry, struct disk_util, list);
 
                if (major == du->major && minor == du->minor)
-                       return 1;
+                       return du;
        }
 
-       return 0;
+       return NULL;
 }
 
 static void disk_util_add(int majdev, int mindev, char *path)
@@ -104,6 +104,7 @@ static void disk_util_add(int majdev, int mindev, char *path)
        INIT_LIST_HEAD(&du->list);
        sprintf(du->path, "%s/stat", path);
        du->name = strdup(basename(path));
+       du->sysfs_root = path;
        du->major = majdev;
        du->minor = mindev;
 
@@ -204,6 +205,7 @@ static void __init_disk_util(struct thread_data *td, struct fio_file *f)
 {
        struct stat st;
        char foo[PATH_MAX], tmp[PATH_MAX];
+       struct disk_util *du;
        int mindev, majdev;
        char *p;
 
@@ -234,8 +236,13 @@ static void __init_disk_util(struct thread_data *td, struct fio_file *f)
                mindev = minor(st.st_dev);
        }
 
-       if (disk_util_exists(majdev, mindev))
+       du = disk_util_exists(majdev, mindev);
+       if (du) {
+               if (td->o.ioscheduler && !td->sysfs_root)
+                       td->sysfs_root = strdup(du->sysfs_root);
+
                return;
+       }
 
        /*
         * for an fs without a device, we will repeatedly stat through
diff --git a/fio.h b/fio.h
index 6b70805966d9d93d66cba25136429d563969b7e6..1a318921c59eb6b7c620559455537e4f8240d52d 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -647,6 +647,7 @@ struct disk_util {
        struct list_head list;
 
        char *name;
+       char *sysfs_root;
        char path[256];
        int major, minor;