Revamp file locking
Get rid of the semaphore implementation, no need to carry both.
Add different locking modes (exclusive and readwrite) to enable
a wider range of testing. Also combine lockfile and lockfile_batch,
the latter is now a postfix option to the former.
So to enable readers-excluding-writers locking mode with a lock batch
count of 4, you would write:
lockfile=readwrite:4
instead.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/ioengines.c b/ioengines.c
index bd2eb4a..87db11c 100644
--- a/ioengines.c
+++ b/ioengines.c
@@ -168,14 +168,14 @@
dprint_io_u(io_u, "prep");
fio_ro_check(td, io_u);
- lock_file(td, io_u->file);
+ lock_file(td, io_u->file, io_u->ddir);
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);
+ unlock_file(td, io_u->file);
return ret;
}
@@ -232,7 +232,7 @@
ret = td->io_ops->queue(td, io_u);
- unlock_file(io_u->file);
+ unlock_file(td, io_u->file);
if (ret != FIO_Q_BUSY)
io_u_mark_depth(td, io_u);
@@ -359,10 +359,7 @@
*/
f->flags |= FIO_FILE_CLOSING;
- if (f->sem_owner == td && f->sem_batch) {
- f->sem_batch = 0;
- unlock_file(f);
- }
+ unlock_file_all(td, f);
return put_file(td, f);
}