X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=stat.c;h=f71c5f03a574f4a7d3f1af222527b4ec7a78f7a9;hp=352ba48f4447cf77068b77bae7247ceec8dfa166;hb=7ff1c14bfb97c170c9654c8db5696764779ec4c9;hpb=8abdce6686bfcaa211e7eb75a69ec07e980bd96e diff --git a/stat.c b/stat.c index 352ba48f..f71c5f03 100644 --- a/stat.c +++ b/stat.c @@ -11,9 +11,10 @@ static struct itimerval itimer; static struct list_head disk_list = LIST_HEAD_INIT(disk_list); +static dev_t last_dev; /* - * Cheasy number->string conversion, complete with carry rounding error. + * Cheesy number->string conversion, complete with carry rounding error. */ static char *num2str(unsigned long num, int maxlen, int base) { @@ -245,7 +246,7 @@ void init_disk_util(struct thread_data *td) dev_t dev; char *p; - if (!td->do_disk_util || (td->io_ops->flags & (FIO_NETIO | FIO_NULLIO))) + if (!td->do_disk_util || (td->io_ops->flags & FIO_DISKLESSIO)) return; /* @@ -273,6 +274,17 @@ void init_disk_util(struct thread_data *td) if (disk_util_exists(dev)) return; + + /* + * for an fs without a device, we will repeatedly stat through + * sysfs which can take oodles of time for thousands of files. so + * cache the last lookup and compare with that before going through + * everything again. + */ + if (dev == last_dev) + return; + + last_dev = dev; sprintf(foo, "/sys/block"); if (!find_block_dir(dev, foo)) @@ -454,9 +466,10 @@ static void show_thread_status(struct thread_data *td, else fprintf(f_out, "%s: (groupid=%d): err=%2d (%s): pid=%d\n",td->name, td->groupid, td->error, td->verror, td->pid); - show_ddir_status(td, rs, td->ddir); - if (td->io_bytes[td->ddir ^ 1]) - show_ddir_status(td, rs, td->ddir ^ 1); + if (td_read(td)) + show_ddir_status(td, rs, DDIR_READ); + if (td_write(td)) + show_ddir_status(td, rs, DDIR_WRITE); runtime = mtime_since(&td->epoch, &td->end_time); if (runtime) {