From ab9de9c05c2bb2f3cc87c8497ecd6df016c16b96 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Wed, 7 May 2014 17:19:53 +0400 Subject: [PATCH] test_librbd_fsx: wire up O_DIRECT mode Wire up O_DIRECT mode (-Z) for krbd, to have a workaround for possible problems with BLKDISCARD leaving stale entries in the buffer cache in place. Signed-off-by: Ilya Dryomov --- src/test/librbd/fsx.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/test/librbd/fsx.c b/src/test/librbd/fsx.c index 3cefbc5a1a6..b83bfb71dec 100644 --- a/src/test/librbd/fsx.c +++ b/src/test/librbd/fsx.c @@ -151,7 +151,7 @@ int clone_calls = 1; /* -C flag disables */ int randomize_striping = 1; /* -U flag disables */ int mapped_reads = 0; /* -R flag disables it */ int fsxgoodfd = 0; -int o_direct; /* -Z */ +int o_direct = 0; /* -Z flag */ int aio = 0; int num_clones = 0; @@ -501,7 +501,7 @@ krbd_open(const char *name, struct rbd_ctx *ctx) return ret; } - fd = open(devnode, O_RDWR); + fd = open(devnode, O_RDWR | o_direct); if (fd < 0) { ret = -errno; prt("open(%s) failed\n", devnode); @@ -576,6 +576,9 @@ __krbd_flush(struct rbd_ctx *ctx) { int ret; + if (o_direct) + return 0; + /* * fsync(2) on the block device does not sync the filesystem * mounted on top of it, but that's OK - we control the entire @@ -1032,7 +1035,7 @@ doflush(unsigned offset, unsigned size) { int ret; - if (o_direct == O_DIRECT) + if (o_direct) return; ret = ops->flush(&ctx); @@ -1964,6 +1967,8 @@ main(int argc, char **argv) break; case 'R': mapped_reads = 0; + if (!quiet) + fprintf(stdout, "mapped reads DISABLED\n"); break; case 'S': seed = getnum(optarg, &endp); -- 2.47.3