Revamp file open/close handling

Some IO engines need special handling for opening and closing
files, and this has complicated the fio filesetup.c file. Instead
have the io engine provide hooks for file open/close. This also
greatly cleans up the flags (we can get rid of SELFOPEN and MMAPIO)
and moves private knowledge into the engines where it belongs.

This potentially destabilizes fio somewhat, so testing is needed.
The new openfiles option that is introduced with this change isn't
verified working yet, hence it isn't documented.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/ioengines.c b/ioengines.c
index a395da1..9d7453b 100644
--- a/ioengines.c
+++ b/ioengines.c
@@ -257,3 +257,20 @@
 
 	return 0;
 }
+
+int td_io_open_file(struct thread_data *td, struct fio_file *f)
+{
+	if (!td->io_ops->open_file(td, f)) {
+		td->nr_open_files++;
+		return 0;
+	}
+
+	return 1;
+}
+
+void td_io_close_file(struct thread_data *td, struct fio_file *f)
+{
+	if (td->io_ops->close_file)
+		td->io_ops->close_file(td, f);
+	td->nr_open_files--;
+}