Don't allow pre_read on IO engines that cannot seek
authorJens Axboe <jens.axboe@oracle.com>
Wed, 1 Jul 2009 10:26:28 +0000 (12:26 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 1 Jul 2009 10:26:28 +0000 (12:26 +0200)
We cannot pre-read files, if we cannot seek back and read the same
data again. So just disable it with a warning to the user.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
HOWTO
engines/net.c
engines/splice.c
filesetup.c
fio.1
init.c
ioengine.h

diff --git a/HOWTO b/HOWTO
index 3107d3a15e6b4488dcd8626264b791d078459d1e..708eca0037293e80cc681c17f20d6638dc5c4cbd 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -741,7 +741,10 @@ create_on_open=bool        Don't pre-setup the files for IO, just create open()
 pre_read=bool  If this is given, files will be pre-read into memory before
                starting the given IO operation. This will also clear
                the 'invalidate' flag, since it is pointless to pre-read
-               and then drop the cache.
+               and then drop the cache. This will only work for IO engines
+               that are seekable, since they allow you to read the same data
+               multiple times. Thus it will not work on eg network or splice
+               IO.
 
 unlink=bool    Unlink the job files when done. Not the default, as repeated
                runs of that job would then waste time recreating the file
index 4ddacf28b1343e726ad2a860ff5facc308108d3c..c0a793e86cb8d7f38dfff1601ae218b2eb6d387a 100644 (file)
@@ -633,7 +633,7 @@ static struct ioengine_ops ioengine_splice = {
        .open_file      = fio_netio_open_file,
        .close_file     = generic_close_file,
        .flags          = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR |
-                         FIO_SIGQUIT,
+                         FIO_SIGQUIT | FIO_PIPEIO,
 };
 #endif
 
@@ -648,7 +648,7 @@ static struct ioengine_ops ioengine_rw = {
        .open_file      = fio_netio_open_file,
        .close_file     = fio_netio_close_file,
        .flags          = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR |
-                         FIO_SIGQUIT,
+                         FIO_SIGQUIT | FIO_PIPEIO,
 };
 
 static void fio_init fio_netio_register(void)
index 28e1fb04efa79f6d99a695aff0b1fe8fd1b62379..ca43e4343df66f0ddb2e3a10fc4f2f691a7090d7 100644 (file)
@@ -297,7 +297,7 @@ static struct ioengine_ops ioengine = {
        .open_file      = generic_open_file,
        .close_file     = generic_close_file,
        .get_file_size  = generic_get_file_size,
-       .flags          = FIO_SYNCIO,
+       .flags          = FIO_SYNCIO | FIO_PIPEIO,
 };
 
 #else /* FIO_HAVE_SPLICE */
index a0a4b80d33483d70c00db8fe56882ce073136286..1a5a7eccb1b8c95c545c7b94923990d6a005e23c 100644 (file)
@@ -156,6 +156,9 @@ static int pre_read_file(struct thread_data *td, struct fio_file *f)
        unsigned int bs;
        char *b;
 
+       if (td->io_ops->flags & FIO_PIPEIO)
+               return 0;
+
        if (!fio_file_open(f)) {
                if (td->io_ops->open_file(td, f)) {
                        log_err("fio: cannot pre-read, failed to open file\n");
diff --git a/fio.1 b/fio.1
index aa7b9d6767ed9a0136a2282c133878383356d143..32993b61da4bccc9ba633da361bc1e47a68aaa08 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -544,7 +544,9 @@ If true, the files are not created until they are opened for IO by the job.
 .BI pre_read \fR=\fPbool
 If this is given, files will be pre-read into memory before starting the given
 IO operation. This will also clear the \fR \fBinvalidate\fR flag, since it is
-pointless to pre-read and then drop the cache.
+pointless to pre-read and then drop the cache. This will only work for IO
+engines that are seekable, since they allow you to read the same data
+multiple times. Thus it will not work on eg network or splice IO.
 .TP
 .BI unlink \fR=\fPbool
 Unlink job files when done.  Default: false.
diff --git a/init.c b/init.c
index 305f6605f08ab7d749ea415d78a04fa518ba1b03..160bdffc470cfdb1fae61ad30b41fc51ff0cb23d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -350,8 +350,12 @@ static int fixup_options(struct thread_data *td)
        if (td->o.verify != VERIFY_NONE)
                td->o.refill_buffers = 1;
 
-       if (td->o.pre_read)
+       if (td->o.pre_read) {
                td->o.invalidate_cache = 0;
+               if (td->io_ops->flags & FIO_PIPEIO)
+                       log_info("fio: cannot pre-read files with an IO engine"
+                                " that isn't seekable. Pre-read disabled.\n");
+       }
 
        if (td->o.mem_align) {
                if (td->o.odirect && !is_power_of_2(td->o.mem_align)) {
index 6190977d4170fd7632a710c5417ba5661d24ded7..f9777999d0e45aff2849683d1edde5b2b3edb1df 100644 (file)
@@ -112,6 +112,7 @@ enum fio_ioengine_flags {
        FIO_UNIDIR      = 1 << 5,       /* engine is uni-directional */
        FIO_NOIO        = 1 << 6,       /* thread does only pseudo IO */
        FIO_SIGQUIT     = 1 << 7,       /* needs SIGQUIT to exit */
+       FIO_PIPEIO      = 1 << 8,       /* input/output no seekable */
 };
 
 /*