From: Jens Axboe Date: Tue, 27 Mar 2007 17:49:31 +0000 (+0200) Subject: Auto limit open files if we get EMFILE X-Git-Tag: fio-1.15~13 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=9bf27b4530fca07088ab978aea47be79a3d48879;p=fio.git Auto limit open files if we get EMFILE Signed-off-by: Jens Axboe --- 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