iolog: don't serialize the writing of all logs
Serialize based on filename, so that independent logs can be
written at the same time. If the logs are big, this can take
a while to flush to disk. It's silly to have all jobs waiting
on each other, when they could write their own logs independently.
Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/iolog.c b/iolog.c
index 7cb633b..8589df6 100644
--- a/iolog.c
+++ b/iolog.c
@@ -10,6 +10,7 @@
#include "fio.h"
#include "verify.h"
#include "trim.h"
+#include "filelock.h"
static const char iolog_ver2[] = "fio version 2 iolog";
@@ -538,22 +539,32 @@
free(log);
}
-void finish_log_named(struct thread_data *td, struct io_log *log,
- const char *prefix, const char *postfix)
+int finish_log_named(struct thread_data *td, struct io_log *log,
+ const char *prefix, const char *postfix, int trylock)
{
char file_name[256];
snprintf(file_name, sizeof(file_name), "%s_%s.log", prefix, postfix);
+ if (trylock) {
+ if (fio_trylock_file(file_name))
+ return 1;
+ } else
+ fio_lock_file(file_name);
+
if (td->client_type == FIO_CLIENT_TYPE_GUI) {
fio_send_iolog(td, log, file_name);
free(log->log);
free(log);
} else
__finish_log(log, file_name);
+
+ fio_unlock_file(file_name);
+ return 0;
}
-void finish_log(struct thread_data *td, struct io_log *log, const char *name)
+int finish_log(struct thread_data *td, struct io_log *log, const char *name,
+ int trylock)
{
- finish_log_named(td, log, td->o.name, name);
+ return finish_log_named(td, log, td->o.name, name, trylock);
}