Add file locking hooks

Does nothing so far, but adds locking calls that cover from ->prep()
to after ->queue(). That is the period where we do IO.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index 483226a..188b0ce 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -645,6 +645,14 @@
 	return ret;
 }
 
+void lock_file(struct thread_data *td, struct fio_file *f)
+{
+}
+
+void unlock_file(struct fio_file *f)
+{
+}
+
 static int recurse_dir(struct thread_data *td, const char *dirname)
 {
 	struct dirent *dir;
diff --git a/fio.h b/fio.h
index b0ba0ac..6b8ffe2 100644
--- a/fio.h
+++ b/fio.h
@@ -808,6 +808,8 @@
 extern int add_file(struct thread_data *, const char *);
 extern void get_file(struct fio_file *);
 extern int __must_check put_file(struct thread_data *, struct fio_file *);
+extern void lock_file(struct thread_data *, struct fio_file *);
+extern void unlock_file(struct fio_file *);
 extern int add_dir_files(struct thread_data *, const char *);
 extern int init_random_map(struct thread_data *);
 extern void dup_files(struct thread_data *, struct thread_data *);
diff --git a/io_u.c b/io_u.c
index 5a3157a..04d7dcb 100644
--- a/io_u.c
+++ b/io_u.c
@@ -665,6 +665,7 @@
 		 * td_io_close() does a put_file() as well, so no need to
 		 * do that here.
 		 */
+		unlock_file(io_u->file);
 		io_u->file = NULL;
 		td_io_close_file(td, f);
 		f->flags |= FIO_FILE_DONE;
diff --git a/ioengines.c b/ioengines.c
index 879c5f1..5a2d6b9 100644
--- a/ioengines.c
+++ b/ioengines.c
@@ -168,10 +168,14 @@
 	dprint_io_u(io_u, "prep");
 	fio_ro_check(td, io_u);
 
+	lock_file(td, io_u->file);
+
 	if (td->io_ops->prep) {
 		int ret = td->io_ops->prep(td, io_u);
 
 		dprint(FD_IO, "->prep(%p)=%d\n", io_u, ret);
+		if (ret)
+			unlock_file(io_u->file);
 		return ret;
 	}
 
@@ -228,6 +232,8 @@
 
 	ret = td->io_ops->queue(td, io_u);
 
+	unlock_file(io_u->file);
+
 	if (ret != FIO_Q_BUSY)
 		io_u_mark_depth(td, io_u);