From 9bf27b4530fca07088ab978aea47be79a3d48879 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 27 Mar 2007 19:49:31 +0200 Subject: [PATCH] Auto limit open files if we get EMFILE Signed-off-by: Jens Axboe --- filesetup.c | 9 ++++++++- fio.h | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/filesetup.c b/filesetup.c index b0a40e57..bf28b41a 100644 --- a/filesetup.c +++ b/filesetup.c @@ -244,8 +244,15 @@ int open_files(struct thread_data *td) for_each_file(td, f, i) { err = td_io_open_file(td, f); - if (err) + if (err) { + if (td->error == EMFILE) { + log_err("fio: limited open files to: %d\n", td->nr_open_files); + td->o.open_files = td->nr_open_files; + err = 0; + clear_error(td); + } break; + } if (td->o.open_files == td->nr_open_files) break; diff --git a/fio.h b/fio.h index 1b8a66d1..76d7ea46 100644 --- a/fio.h +++ b/fio.h @@ -865,4 +865,10 @@ extern void close_ioengine(struct thread_data *); } \ } while (0) +static inline void clear_error(struct thread_data *td) +{ + td->error = 0; + td->verror[0] = '\0'; +} + #endif -- 2.25.1