[PATCH 4/7] harness: Add fallback code for filesystems not supporting O_DIRECT
authorGuillem Jover <guillem@hadrons.org>
Tue, 26 Feb 2019 01:55:40 +0000 (02:55 +0100)
committerGuillem Jover <guillem@debian.org>
Tue, 26 Feb 2019 04:26:21 +0000 (04:26 +0000)
When running the harness on a filesystem such as a tmpfs, which do not
support O_DIRECT, fallback to calls without the flag.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Gbp-Pq: Name 0004-harness-Add-fallback-code-for-filesystems-not-suppor.patch

harness/cases/17.t
harness/cases/18.t
harness/cases/19.t
harness/cases/21.t

index 38ada4d8619bafa3f44e12028b32fef179651848..10c6b9c9f97ab341dd772309da33c3c987b9bc99 100644 (file)
@@ -138,6 +138,8 @@ void run_test(int max_ios, int getevents_type)
 
        unlink(filename);
        fd = open(filename, O_CREAT | O_RDWR | O_DIRECT, 0644);
+       if (fd < 0 && errno == EINVAL)
+               fd = open(filename, O_CREAT | O_RDWR, 0644);
        assert(fd >= 0);
 
        ret = ftruncate(fd, max_ios * io_size);
index daa1d26adcd6f5f66dcd3e77f53637b4ff61fa96..d58f99b6528f88a232798707ad4aa656806e039e 100644 (file)
@@ -53,6 +53,8 @@ aio_worker(void *ptr)
        assert(buffer != NULL);
 
        fd = open(FILENAME, O_DIRECT|O_RDONLY);
+       if (fd < 0 && errno == EINVAL)
+               fd = open(FILENAME, O_RDONLY);
        assert(fd >= 0);
 
        for (i = 0; i < 1000; i++) {
index 5c3e0d68b3682e17c1f3436f25c6c71b3a164e38..aad9bdb5abf4eac3277faff555301f77446c531b 100644 (file)
@@ -43,6 +43,10 @@ open_temp_file(void)
 
        strncpy(template, TEMPLATE, sizeof(template));
        fd = mkostemp(template, O_DIRECT);
+       if (fd < 0 && errno == EINVAL) {
+               strncpy(template, TEMPLATE, sizeof(template));
+               fd = mkstemp(template);
+       }
        if (fd < 0) {
                perror("mkstemp");
                exit(1);
index fe33a9de66c64738eb49d29286b4d6428b4826f6..352bf887d6a64a83999f8b2e3ea557e333e90108 100644 (file)
@@ -92,7 +92,7 @@ test_main()
         */
        flags = fcntl(fd, F_GETFL);
        ret = fcntl(fd, F_SETFL, flags | O_DIRECT);
-       if (ret != 0) {
+       if (ret != 0 && errno != EINVAL) {
                perror("fcntl");
                return 1;
        }