Add file locking hooks
authorJens Axboe <jens.axboe@oracle.com>
Sat, 1 Mar 2008 17:19:52 +0000 (18:19 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Sat, 1 Mar 2008 17:19:52 +0000 (18:19 +0100)
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>
filesetup.c
fio.h
io_u.c
ioengines.c

index 483226ae56e5d488d4601a14c1ba29b93f91d360..188b0ce88c476633b0a42931ef901dc9000b171c 100644 (file)
@@ -645,6 +645,14 @@ int put_file(struct thread_data *td, struct fio_file *f)
        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 b0ba0ac4c18dd7faf75e842655b2304b2d5c283f..6b8ffe29512bffe563a28263e7bbebb1bd50cd67 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -808,6 +808,8 @@ extern int __must_check generic_close_file(struct thread_data *, struct fio_file
 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 5a3157a24c498e123db83914eb36e904f1890e24..04d7dcbd2fc368397a5e4765e6e702d438cbbc80 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -665,6 +665,7 @@ set_file:
                 * 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;
index 879c5f1c1f438a20a5116bec93968fc0d4e0642f..5a2d6b90fb0c6d73d45d0b6c5ce5307f505691d2 100644 (file)
@@ -168,10 +168,14 @@ int td_io_prep(struct thread_data *td, struct io_u *io_u)
        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 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u)
 
        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);