Auto limit open files if we get EMFILE
authorJens Axboe <jens.axboe@oracle.com>
Tue, 27 Mar 2007 17:49:31 +0000 (19:49 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 27 Mar 2007 17:49:31 +0000 (19:49 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c
fio.h

index b0a40e572b23996ba6f53996a75eb447d2c6ecde..bf28b41ad161c489390382219602e026b8c6b9b2 100644 (file)
@@ -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 1b8a66d1fdac3c0eab6ba2f55efd67f026104880..76d7ea46747d264f6c28cd9474e4fa3a5e41f32f 100644 (file)
--- 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