X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=diskutil.c;h=e90096bee6f5c099c639f0b29ebcd96eb0bfcac8;hb=3098b11a5f6a75153babb63a487b80fa4c2103a1;hp=3cbd6fc3b04e1d2f7dba60375dcf1c5d65683583;hpb=17127517a3ccff19993e36ec3f7bc15044898f2c;p=fio.git diff --git a/diskutil.c b/diskutil.c index 3cbd6fc3..e90096be 100644 --- a/diskutil.c +++ b/diskutil.c @@ -9,12 +9,16 @@ #include "fio.h" #include "smalloc.h" +#include "diskutil.h" static int last_majdev, last_mindev; static struct disk_util *last_du; static struct flist_head disk_list = FLIST_HEAD_INIT(disk_list); +static struct disk_util *__init_per_file_disk_util(struct thread_data *td, + int majdev, int mindev, char *path); + static void disk_util_free(struct disk_util *du) { if (du == last_du) @@ -181,11 +185,8 @@ static int read_block_dev_entry(char *path, int *maj, int *min) return 0; } -static struct disk_util *__init_per_file_disk_util(struct thread_data *td, - int majdev, int mindev, char * path); - static void find_add_disk_slaves(struct thread_data *td, char *path, - struct disk_util *masterdu) + struct disk_util *masterdu) { DIR *dirhandle = NULL; struct dirent *dirent = NULL; @@ -194,13 +195,14 @@ static void find_add_disk_slaves(struct thread_data *td, char *path, int majdev, mindev; ssize_t linklen; - sprintf(slavesdir, "%s/%s",path, "slaves"); + sprintf(slavesdir, "%s/%s", path, "slaves"); dirhandle = opendir(slavesdir); if (!dirhandle) return; while ((dirent = readdir(dirhandle)) != NULL) { - if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, "..")) + if (!strcmp(dirent->d_name, ".") || + !strcmp(dirent->d_name, "..")) continue; sprintf(temppath, "%s/%s", slavesdir, dirent->d_name); @@ -208,11 +210,12 @@ static void find_add_disk_slaves(struct thread_data *td, char *path, * are links to the real directories for the slave * devices? */ - if ((linklen = readlink(temppath, slavepath, PATH_MAX-1)) < 0) { + linklen = readlink(temppath, slavepath, PATH_MAX - 0); + if (linklen < 0) { perror("readlink() for slave device."); return; } - slavepath[linklen]='\0'; + slavepath[linklen] = '\0'; sprintf(temppath, "%s/%s/dev", slavesdir, slavepath); if (read_block_dev_entry(temppath, &majdev, &mindev)) { @@ -220,6 +223,13 @@ static void find_add_disk_slaves(struct thread_data *td, char *path, return; } + /* + * See if this maj,min already exists + */ + slavedu = disk_util_exists(majdev, mindev); + if (slavedu) + continue; + sprintf(temppath, "%s/%s", slavesdir, slavepath); __init_per_file_disk_util(td, majdev, mindev, temppath); slavedu = disk_util_exists(majdev, mindev); @@ -231,7 +241,6 @@ static void find_add_disk_slaves(struct thread_data *td, char *path, } closedir(dirhandle); - return; } static struct disk_util *disk_util_add(struct thread_data * td, int majdev, @@ -276,7 +285,6 @@ static struct disk_util *disk_util_add(struct thread_data * td, int majdev, return du; } - static int check_dev_match(int majdev, int mindev, char *path) { int major, minor; @@ -510,7 +518,7 @@ void show_disk_util(void) * the master's stats line has been displayed in a * previous iteration of this loop. */ - if(!flist_empty(&du->slavelist)) + if (!flist_empty(&du->slavelist)) log_info(" "); log_info(" %s: ios=%u/%u, merge=%u/%u, ticks=%u/%u, " @@ -523,7 +531,7 @@ void show_disk_util(void) /* If the device has slaves, aggregate the stats for * those slave devices also. */ - if(!flist_empty(&du->slaves)) + if (!flist_empty(&du->slaves)) aggregate_slaves_stats(du); log_info("\n");