ltp/fsx: drop caches if we're doing closeopen
authorJosef Bacik <josef@toxicpanda.com>
Tue, 7 Jan 2020 16:55:41 +0000 (11:55 -0500)
committerEryu Guan <guaneryu@gmail.com>
Sat, 1 Feb 2020 07:56:31 +0000 (15:56 +0800)
fsx has a closeopen option where it will close and then re-open the
file.  This is handy, but what is really more useful is to drop the file
from cache completely, so add a drop_caches into this operation so that
the file is read back completely from disk to be really evil.

[Eryu: fix drop cache failure number to stay within 190]

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
ltp/fsx.c

index c74b13c27b841b88b601def02fce020a5029d8b3..120f4374c95b403d7cce60a761c6334ace85d6f1 100644 (file)
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -1778,10 +1778,14 @@ docloseopen(void)
                prterr("docloseopen: close");
                report_failure(180);
        }
                prterr("docloseopen: close");
                report_failure(180);
        }
+       if (system("echo 3 > /proc/sys/vm/drop_caches")) {
+               prterr("docloseopen: drop_caches");
+               report_failure(181);
+       }
        fd = open(fname, O_RDWR|o_direct, 0);
        if (fd < 0) {
                prterr("docloseopen: open");
        fd = open(fname, O_RDWR|o_direct, 0);
        if (fd < 0) {
                prterr("docloseopen: open");
-               report_failure(181);
+               report_failure(182);
        }
 }
 
        }
 }