Add the file sharing bits

When you use the same filename for several jobs now, they will share
the same file structure. Enable locking through two new options:

- lockfile. If set, a semaphore is associated with the file and it is
  held from ->prep() to ->queue() has done its work.
- lockfile_batch. This controls how many IOs the job gets to do per
  semaphore acqusition.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/ioengines.c b/ioengines.c
index 5a2d6b9..bd2eb4a 100644
--- a/ioengines.c
+++ b/ioengines.c
@@ -359,5 +359,10 @@
 	 */
 	f->flags |= FIO_FILE_CLOSING;
 
+	if (f->sem_owner == td && f->sem_batch) {
+		f->sem_batch = 0;
+		unlock_file(f);
+	}
+
 	return put_file(td, f);
 }