Skip to content

Commit f71a48a

Browse files
author
Jaegeuk Kim
committed
f2fs_io: add dontcache to measure RWF_DONTCACHE speed
It only measures the read performance. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 2a624e6 commit f71a48a

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ AC_CHECK_FUNCS_ONCE([
194194
keyctl
195195
memset
196196
pread
197+
preadv2
197198
pwrite
198199
setmntent
199200
])

tools/f2fs_io/f2fs_io.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <linux/fs.h>
2525
#include <signal.h>
2626
#include <stdarg.h>
27+
#include <sys/uio.h>
28+
#include <stdarg.h>
2729
#include <stdbool.h>
2830
#include <stdio.h>
2931
#include <stdlib.h>
@@ -929,6 +931,7 @@ static void do_write_advice(int argc, char **argv, const struct cmd_desc *cmd)
929931
"Read data in file_path and print nbytes\n" \
930932
"IO can be\n" \
931933
" buffered : buffered IO\n" \
934+
" dontcache: buffered IO + dontcache\n" \
932935
" dio : direct IO\n" \
933936
" mmap : mmap IO\n" \
934937
" mlock : mmap + mlock\n" \
@@ -948,6 +951,7 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
948951
int flags = 0;
949952
int do_mmap = 0;
950953
int do_mlock = 0;
954+
int do_dontcache = 0;
951955
int fd, advice;
952956

953957
if (argc != 8) {
@@ -972,6 +976,12 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
972976
do_mmap = 1;
973977
else if (!strcmp(argv[4], "mlock"))
974978
do_mlock = 1;
979+
else if (!strcmp(argv[4], "dontcache"))
980+
#ifdef HAVE_PREADV2
981+
do_dontcache = 1;
982+
#else
983+
die("Not support - preadv2");
984+
#endif
975985
else if (strcmp(argv[4], "buffered"))
976986
die("Wrong IO type");
977987

@@ -1016,7 +1026,14 @@ static void do_read(int argc, char **argv, const struct cmd_desc *cmd)
10161026
read_cnt = count * buf_size;
10171027
} else {
10181028
for (i = 0; i < count; i++) {
1019-
ret = pread(fd, buf, buf_size, offset + buf_size * i);
1029+
if (!do_dontcache) {
1030+
ret = pread(fd, buf, buf_size, offset + buf_size * i);
1031+
} else {
1032+
#ifdef HAVE_PREADV2
1033+
struct iovec iov = { .iov_base = buf, .iov_len = buf_size };
1034+
ret = preadv2(fd, &iov, 1, offset + buf_size * i, RWF_DONTCACHE);
1035+
#endif
1036+
}
10201037
if (ret != buf_size) {
10211038
printf("pread expected: %"PRIu64", readed: %"PRIu64"\n",
10221039
buf_size, ret);

tools/f2fs_io/f2fs_io.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ enum {
226226
#define FS_CASEFOLD_FL 0x40000000 /* Folder is case insensitive */
227227
#endif
228228

229+
#ifndef RWF_DONTCACHE
230+
#define RWF_DONTCACHE 0x00000080 /* Uncached buffered IO. */
231+
#endif
232+
229233
struct f2fs_gc_range {
230234
u32 sync;
231235
u64 start;

0 commit comments

Comments
 (0)