From: Jens Axboe Date: Sat, 1 Mar 2008 17:19:52 +0000 (+0100) Subject: Add file locking hooks X-Git-Tag: fio-1.20-rc1~22 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=b2bd2bd96a09540b3add0ec74db2cdb1c145ca33;hp=f85ac25a7d5c9d5ba4d5c73363a6a2a461a9b013;ds=sidebyside 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 --- diff --git a/filesetup.c b/filesetup.c index 483226ae..188b0ce8 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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 b0ba0ac4..6b8ffe29 100644 --- 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 5a3157a2..04d7dcbd 100644 --- 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; diff --git a/ioengines.c b/ioengines.c index 879c5f1c..5a2d6b90 100644 --- a/ioengines.c +++ b/ioengines.c @@ -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);