projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into gfio
[fio.git]
/
diskutil.c
diff --git
a/diskutil.c
b/diskutil.c
index c1524a0b1de3d6e291bfcde29c1e8e48f5ec571c..a3a5b4dd13d767a6430f0156589afcb27965c953 100644
(file)
--- a/
diskutil.c
+++ b/
diskutil.c
@@
-14,6
+14,9
@@
static int last_majdev, last_mindev;
static struct disk_util *last_du;
static int last_majdev, last_mindev;
static struct disk_util *last_du;
+static struct fio_mutex *disk_util_mutex;
+static int disk_util_exit;
+
FLIST_HEAD(disk_list);
static struct disk_util *__init_per_file_disk_util(struct thread_data *td,
FLIST_HEAD(disk_list);
static struct disk_util *__init_per_file_disk_util(struct thread_data *td,
@@
-31,7
+34,7
@@
static void disk_util_free(struct disk_util *du)
flist_del(&slave->slavelist);
slave->users--;
}
flist_del(&slave->slavelist);
slave->users--;
}
-
+
fio_mutex_remove(du->lock);
sfree(du);
}
fio_mutex_remove(du->lock);
sfree(du);
}
@@
-102,17
+105,26
@@
static void update_io_tick_disk(struct disk_util *du)
memcpy(ldus, &__dus, sizeof(__dus));
}
memcpy(ldus, &__dus, sizeof(__dus));
}
-
void
update_io_ticks(void)
+
int
update_io_ticks(void)
{
struct flist_head *entry;
struct disk_util *du;
{
struct flist_head *entry;
struct disk_util *du;
+ int ret = 0;
dprint(FD_DISKUTIL, "update io ticks\n");
dprint(FD_DISKUTIL, "update io ticks\n");
- flist_for_each(entry, &disk_list) {
- du = flist_entry(entry, struct disk_util, list);
- update_io_tick_disk(du);
- }
+ fio_mutex_down(disk_util_mutex);
+
+ if (!disk_util_exit) {
+ flist_for_each(entry, &disk_list) {
+ du = flist_entry(entry, struct disk_util, list);
+ update_io_tick_disk(du);
+ }
+ } else
+ ret = 1;
+
+ fio_mutex_up(disk_util_mutex);
+ return ret;
}
static struct disk_util *disk_util_exists(int major, int minor)
}
static struct disk_util *disk_util_exists(int major, int minor)
@@
-120,13
+132,18
@@
static struct disk_util *disk_util_exists(int major, int minor)
struct flist_head *entry;
struct disk_util *du;
struct flist_head *entry;
struct disk_util *du;
+ fio_mutex_down(disk_util_mutex);
+
flist_for_each(entry, &disk_list) {
du = flist_entry(entry, struct disk_util, list);
flist_for_each(entry, &disk_list) {
du = flist_entry(entry, struct disk_util, list);
- if (major == du->major && minor == du->minor)
+ if (major == du->major && minor == du->minor) {
+ fio_mutex_up(disk_util_mutex);
return du;
return du;
+ }
}
}
+ fio_mutex_up(disk_util_mutex);
return NULL;
}
return NULL;
}
@@
-215,7
+232,7
@@
static void find_add_disk_slaves(struct thread_data *td, char *path,
!strcmp(dirent->d_name, ".."))
continue;
!strcmp(dirent->d_name, ".."))
continue;
- sprintf(temppath, "%s
/%s", slavesdir
, dirent->d_name);
+ sprintf(temppath, "%s
%s%s", slavesdir, FIO_OS_PATH_SEPARATOR
, dirent->d_name);
/* Can we always assume that the slaves device entries
* are links to the real directories for the slave
* devices?
/* Can we always assume that the slaves device entries
* are links to the real directories for the slave
* devices?
@@
-240,7
+257,7
@@
static void find_add_disk_slaves(struct thread_data *td, char *path,
if (slavedu)
continue;
if (slavedu)
continue;
- sprintf(temppath, "%s
/%s", slavesdir
, slavepath);
+ sprintf(temppath, "%s
%s%s", slavesdir, FIO_OS_PATH_SEPARATOR
, slavepath);
__init_per_file_disk_util(td, majdev, mindev, temppath);
slavedu = disk_util_exists(majdev, mindev);
__init_per_file_disk_util(td, majdev, mindev, temppath);
slavedu = disk_util_exists(majdev, mindev);
@@
-273,9
+290,11
@@
static struct disk_util *disk_util_add(struct thread_data *td, int majdev,
du->minor = mindev;
INIT_FLIST_HEAD(&du->slavelist);
INIT_FLIST_HEAD(&du->slaves);
du->minor = mindev;
INIT_FLIST_HEAD(&du->slavelist);
INIT_FLIST_HEAD(&du->slaves);
- du->lock = fio_mutex_init(
1
);
+ du->lock = fio_mutex_init(
FIO_MUTEX_UNLOCKED
);
du->users = 0;
du->users = 0;
+ fio_mutex_down(disk_util_mutex);
+
flist_for_each(entry, &disk_list) {
__du = flist_entry(entry, struct disk_util, list);
flist_for_each(entry, &disk_list) {
__du = flist_entry(entry, struct disk_util, list);
@@
-283,6
+302,7
@@
static struct disk_util *disk_util_add(struct thread_data *td, int majdev,
if (!strcmp((char *) du->dus.name, (char *) __du->dus.name)) {
disk_util_free(du);
if (!strcmp((char *) du->dus.name, (char *) __du->dus.name)) {
disk_util_free(du);
+ fio_mutex_up(disk_util_mutex);
return __du;
}
}
return __du;
}
}
@@
-293,6
+313,8
@@
static struct disk_util *disk_util_add(struct thread_data *td, int majdev,
get_io_ticks(du, &du->last_dus);
flist_add_tail(&du->list, &disk_list);
get_io_ticks(du, &du->last_dus);
flist_add_tail(&du->list, &disk_list);
+ fio_mutex_up(disk_util_mutex);
+
find_add_disk_slaves(td, path, du);
return du;
}
find_add_disk_slaves(td, path, du);
return du;
}
@@
-327,7
+349,7
@@
static int find_block_dir(int majdev, int mindev, char *path, int link_ok)
if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
continue;
if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
continue;
- sprintf(full_path, "%s
/%s", path
, dir->d_name);
+ sprintf(full_path, "%s
%s%s", path, FIO_OS_PATH_SEPARATOR
, dir->d_name);
if (!strcmp(dir->d_name, "dev")) {
if (!check_dev_match(majdev, mindev, full_path)) {
if (!strcmp(dir->d_name, "dev")) {
if (!check_dev_match(majdev, mindev, full_path)) {
@@
-521,6
+543,11
@@
void free_disk_util(void)
{
struct disk_util *du;
{
struct disk_util *du;
+ disk_util_exit = 1;
+ wait_for_disk_thread_exit();
+
+ fio_mutex_down(disk_util_mutex);
+
while (!flist_empty(&disk_list)) {
du = flist_entry(disk_list.next, struct disk_util, list);
flist_del(&du->list);
while (!flist_empty(&disk_list)) {
du = flist_entry(disk_list.next, struct disk_util, list);
flist_del(&du->list);
@@
-528,6
+555,8
@@
void free_disk_util(void)
}
last_majdev = last_mindev = -1;
}
last_majdev = last_mindev = -1;
+ fio_mutex_up(disk_util_mutex);
+ fio_mutex_remove(disk_util_mutex);
}
void print_disk_util(struct disk_util_stat *dus, struct disk_util_agg *agg,
}
void print_disk_util(struct disk_util_stat *dus, struct disk_util_agg *agg,
@@
-540,10
+569,10
@@
void print_disk_util(struct disk_util_stat *dus, struct disk_util_agg *agg,
if (util > 100.0)
util = 100.0;
if (util > 100.0)
util = 100.0;
- if (agg->slavecount)
- log_info(" ");
-
if (!terse) {
if (!terse) {
+ if (agg->slavecount)
+ log_info(" ");
+
log_info(" %s: ios=%u/%u, merge=%u/%u, ticks=%u/%u, "
"in_queue=%u, util=%3.2f%%", dus->name,
dus->ios[0], dus->ios[1],
log_info(" %s: ios=%u/%u, merge=%u/%u, ticks=%u/%u, "
"in_queue=%u, util=%3.2f%%", dus->name,
dus->ios[0], dus->ios[1],
@@
-562,8
+591,7
@@
void print_disk_util(struct disk_util_stat *dus, struct disk_util_agg *agg,
* If the device has slaves, aggregate the stats for
* those slave devices also.
*/
* If the device has slaves, aggregate the stats for
* those slave devices also.
*/
- if (agg->slavecount)
- show_agg_stats(agg, terse);
+ show_agg_stats(agg, terse);
if (!terse)
log_info("\n");
if (!terse)
log_info("\n");
@@
-574,8
+602,12
@@
void show_disk_util(int terse)
struct flist_head *entry;
struct disk_util *du;
struct flist_head *entry;
struct disk_util *du;
- if (flist_empty(&disk_list))
+ fio_mutex_down(disk_util_mutex);
+
+ if (flist_empty(&disk_list)) {
+ fio_mutex_up(disk_util_mutex);
return;
return;
+ }
if (!terse)
log_info("\nDisk stats (read/write):\n");
if (!terse)
log_info("\nDisk stats (read/write):\n");
@@
-586,4
+618,11
@@
void show_disk_util(int terse)
aggregate_slaves_stats(du);
print_disk_util(&du->dus, &du->agg, terse);
}
aggregate_slaves_stats(du);
print_disk_util(&du->dus, &du->agg, terse);
}
+
+ fio_mutex_up(disk_util_mutex);
+}
+
+void setup_disk_util(void)
+{
+ disk_util_mutex = fio_mutex_init(FIO_MUTEX_UNLOCKED);
}
}