]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test_librbd_fsx: wire up O_DIRECT mode
authorIlya Dryomov <ilya.dryomov@inktank.com>
Wed, 7 May 2014 13:19:53 +0000 (17:19 +0400)
committerIlya Dryomov <ilya.dryomov@inktank.com>
Wed, 7 May 2014 13:30:06 +0000 (17:30 +0400)
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 <ilya.dryomov@inktank.com>
src/test/librbd/fsx.c

index 3cefbc5a1a65c322988a3b76d0011e03914e4079..b83bfb71dec2ac39094c2a565ff57cb436bf10ea 100644 (file)
@@ -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);