It only measures the read performance.

Signed-off-by: Jaegeuk Kim <[email protected]>
---
 configure.ac            |  1 +
 man/f2fs_io.8           |  3 +++
 tools/f2fs_io/f2fs_io.c | 19 ++++++++++++++++++-
 tools/f2fs_io/f2fs_io.h |  4 ++++
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index ddfc3b0f30e2..4d91605f8106 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,6 +194,7 @@ AC_CHECK_FUNCS_ONCE([
        keyctl
        memset
        pread
+       preadv2
        pwrite
        setmntent
 ])
diff --git a/man/f2fs_io.8 b/man/f2fs_io.8
index 8e54aa644a00..708a5831bba0 100644
--- a/man/f2fs_io.8
+++ b/man/f2fs_io.8
@@ -125,6 +125,9 @@ options can be:
 .B buffered
 buffered I/O
 .TP
+.B dontcache
+buffered I/O with RWF_DONTCACHE
+.TP
 .B dio
 direct I/O
 .TP
diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 028ffe59d0c7..22f9968a35e9 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -24,6 +24,8 @@
 #include <linux/fs.h>
 #include <signal.h>
 #include <stdarg.h>
+#include <sys/uio.h>
+#include <stdarg.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -929,6 +931,7 @@ static void do_write_advice(int argc, char **argv, const 
struct cmd_desc *cmd)
 "Read data in file_path and print nbytes\n"            \
 "IO can be\n"                                          \
 "  buffered : buffered IO\n"                           \
+"  dontcache: buffered IO + dontcache\n"               \
 "  dio      : direct IO\n"                             \
 "  mmap     : mmap IO\n"                               \
 "  mlock    : mmap + mlock\n"                          \
@@ -948,6 +951,7 @@ static void do_read(int argc, char **argv, const struct 
cmd_desc *cmd)
        int flags = 0;
        int do_mmap = 0;
        int do_mlock = 0;
+       int do_dontcache = 0;
        int fd, advice;
 
        if (argc != 8) {
@@ -972,6 +976,12 @@ static void do_read(int argc, char **argv, const struct 
cmd_desc *cmd)
                do_mmap = 1;
        else if (!strcmp(argv[4], "mlock"))
                do_mlock = 1;
+       else if (!strcmp(argv[4], "dontcache"))
+#ifdef HAVE_PREADV2
+               do_dontcache = 1;
+#else
+               die("Not support - preadv2");
+#endif
        else if (strcmp(argv[4], "buffered"))
                die("Wrong IO type");
 
@@ -1016,7 +1026,14 @@ static void do_read(int argc, char **argv, const struct 
cmd_desc *cmd)
                read_cnt = count * buf_size;
        } else {
                for (i = 0; i < count; i++) {
-                       ret = pread(fd, buf, buf_size, offset + buf_size * i);
+                       if (!do_dontcache) {
+                               ret = pread(fd, buf, buf_size, offset + 
buf_size * i);
+                       } else {
+#ifdef HAVE_PREADV2
+                               struct iovec iov = { .iov_base = buf, .iov_len 
= buf_size };
+                               ret = preadv2(fd, &iov, 1, offset + buf_size * 
i, RWF_DONTCACHE);
+#endif
+                       }
                        if (ret != buf_size) {
                                printf("pread expected: %"PRIu64", readed: 
%"PRIu64"\n",
                                                buf_size, ret);
diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h
index 21fd3864a20d..b0d40996f302 100644
--- a/tools/f2fs_io/f2fs_io.h
+++ b/tools/f2fs_io/f2fs_io.h
@@ -226,6 +226,10 @@ enum {
 #define FS_CASEFOLD_FL                 0x40000000 /* Folder is case 
insensitive */
 #endif
 
+#ifndef RWF_DONTCACHE
+#define RWF_DONTCACHE                  0x00000080 /* Uncached buffered IO.  */
+#endif
+
 struct f2fs_gc_range {
        u32 sync;
        u64 start;
-- 
2.51.0.618.g983fd99d29-goog



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to