projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Split mutex.c and .h each into three files
[fio.git]
/
diskutil.c
diff --git
a/diskutil.c
b/diskutil.c
index 294d2d3d084a371fb3b1b47a4fb2087046d9f262..789071d197fcd2a4bd2abd9dfc01c1ae4235e954 100644
(file)
--- a/
diskutil.c
+++ b/
diskutil.c
@@
-3,6
+3,7
@@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#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>
#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;
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);
static struct disk_util *__init_per_file_disk_util(struct thread_data *td,
int majdev, int mindev, char *path);
@@
-37,6
+36,7
@@
static void disk_util_free(struct disk_util *du)
}
fio_mutex_remove(du->lock);
}
fio_mutex_remove(du->lock);
+ free(du->sysfs_root);
sfree(du);
}
sfree(du);
}
@@
-85,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;
static void update_io_tick_disk(struct disk_util *du)
{
struct disk_util_stat __dus, *dus, *ldus;
- struct time
val
t;
+ struct time
spec
t;
if (!du->users)
return;
if (!du->users)
return;
@@
-179,6
+179,7
@@
static int get_device_numbers(char *file_name, int *maj, int *min)
/*
* must be a file, open "." in that path
*/
/*
* must be a file, open "." in that path
*/
+ tempname[PATH_MAX - 1] = '\0';
strncpy(tempname, file_name, PATH_MAX - 1);
p = dirname(tempname);
if (stat(p, &st)) {
strncpy(tempname, file_name, PATH_MAX - 1);
p = dirname(tempname);
if (stat(p, &st)) {
@@
-245,7
+246,7
@@
static void find_add_disk_slaves(struct thread_data *td, char *path,
* devices?
*/
linklen = readlink(temppath, slavepath, PATH_MAX - 1);
* devices?
*/
linklen = readlink(temppath, slavepath, PATH_MAX - 1);
- if (linklen
< 0) {
+ if (linklen < 0) {
perror("readlink() for slave device.");
closedir(dirhandle);
return;
perror("readlink() for slave device.");
closedir(dirhandle);
return;
@@
-253,8
+254,10
@@
static void find_add_disk_slaves(struct thread_data *td, char *path,
slavepath[linklen] = '\0';
sprintf(temppath, "%s/%s/dev", slavesdir, slavepath);
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)) {
if (read_block_dev_entry(temppath, &majdev, &mindev)) {
- perror("Error getting slave device numbers
.
");
+ perror("Error getting slave device numbers");
closedir(dirhandle);
return;
}
closedir(dirhandle);
return;
}
@@
-291,10
+294,8
@@
static struct disk_util *disk_util_add(struct thread_data *td, int majdev,
dprint(FD_DISKUTIL, "add maj/min %d/%d: %s\n", majdev, mindev, path);
du = smalloc(sizeof(*du));
dprint(FD_DISKUTIL, "add maj/min %d/%d: %s\n", majdev, mindev, path);
du = smalloc(sizeof(*du));
- if (!du) {
- log_err("fio: smalloc() pool exhausted\n");
+ if (!du)
return NULL;
return NULL;
- }
memset(du, 0, sizeof(*du));
INIT_FLIST_HEAD(&du->list);
memset(du, 0, sizeof(*du));
INIT_FLIST_HEAD(&du->list);
@@
-306,7
+307,7
@@
static struct disk_util *disk_util_add(struct thread_data *td, int majdev,
return NULL;
}
strncpy((char *) du->dus.name, basename(path), FIO_DU_NAME_SZ - 1);
return NULL;
}
strncpy((char *) du->dus.name, basename(path), FIO_DU_NAME_SZ - 1);
- du->sysfs_root =
path
;
+ du->sysfs_root =
strdup(path)
;
du->major = majdev;
du->minor = mindev;
INIT_FLIST_HEAD(&du->slavelist);
du->major = majdev;
du->minor = mindev;
INIT_FLIST_HEAD(&du->slavelist);
@@
-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) {
return 0;
while ((dir = readdir(D)) != NULL) {
- char full_path[25
6
];
+ char full_path[25
7
];
if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
continue;
if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
continue;
@@
-426,13
+427,11
@@
static struct disk_util *__init_per_file_disk_util(struct thread_data *td,
log_err("unknown sysfs layout\n");
return NULL;
}
log_err("unknown sysfs layout\n");
return NULL;
}
+ tmp[PATH_MAX - 1] = '\0';
strncpy(tmp, p, PATH_MAX - 1);
sprintf(path, "%s", tmp);
}
strncpy(tmp, p, PATH_MAX - 1);
sprintf(path, "%s", tmp);
}
- if (td->o.ioscheduler && !td->sysfs_root)
- td->sysfs_root = strdup(path);
-
return disk_util_add(td, majdev, mindev, path);
}
return disk_util_add(td, majdev, mindev, path);
}
@@
-451,12
+450,8
@@
static struct disk_util *init_per_file_disk_util(struct thread_data *td,
mindev);
du = disk_util_exists(majdev, mindev);
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;
return du;
- }
/*
* for an fs without a device, we will repeatedly stat through
/*
* for an fs without a device, we will repeatedly stat through
@@
-489,7
+484,7
@@
void init_disk_util(struct thread_data *td)
unsigned int i;
if (!td->o.do_disk_util ||
unsigned int i;
if (!td->o.do_disk_util ||
-
(td->io_ops->flags & (FIO_DISKLESSIO | FIO_NODISKUTIL)
))
+
td_ioengine_flagged(td, FIO_DISKLESSIO | FIO_NODISKUTIL
))
return;
for_each_file(td, f, i)
return;
for_each_file(td, f, i)