Whamcloud - gitweb
LU-14324 tests: Fix fsx fallocate detection
[fs/lustre-release.git] / lustre / tests / fsx.c
index 36b27f7..66e1de5 100644 (file)
@@ -1526,16 +1526,20 @@ test_fallocate(int mode)
        int fd = get_fd();
 
        if (!lite) {
-               if (fallocate(fd, mode, 0, 1) && errno == EOPNOTSUPP) {
+               /* Must go more than a page away so let's go 4M to be sure */
+               if (fallocate(fd, mode, 0, 4096*1024) && errno == EOPNOTSUPP) {
                        if (!quiet)
                                warn("%s: filesystem does not support fallocate mode 0x%x, disabling!",
                                     __func__, mode);
+               } else {
+                       ret = 1;
                }
 
-               if (ret == 0 && ftruncate(fd, 0) == -1) {
-                       ret = 1;
+               /* Always call ftruncate since file size might be adjusted
+                * by fallocate even on error
+                */
+               if (ftruncate(fd, 0) == -1)
                        warn("ftruncate to 0 size failed");
-               }
        }
        return ret;
 }