Whamcloud - gitweb
LU-11597 test: Fix sanityn 16a failed on arm 89/37589/15
authorWang Shilong <wshilong@ddn.com>
Thu, 6 Jan 2022 14:02:24 +0000 (09:02 -0500)
committerOleg Drokin <green@whamcloud.com>
Tue, 18 Jan 2022 09:08:02 +0000 (09:08 +0000)
As now O_DIRECT expect IO aligned with PAGE SIZE,
x86_64 expect 4K size, but some other platform, it
could be 64K, use PAGE_SIZE here to make the test happy.

And macro O_DIRECT is defined if macro _GNU_SOURCE is defined
according to open man doc[1] and _GNU_SOURCE is defined at the
head of file fsx.c already. So set the value of OP_DIRECT to
O_DIRECT instead of hardcoding its value as O_DIRECT could have
different values for other platforms like Arm64[2].

[1]
https://man7.org/linux/man-pages/man2/open.2.html
"The O_DIRECT, O_NOATIME, O_PATH, and O_TMPFILE flags are Linux-
 specific.  One must define _GNU_SOURCE to obtain their definitions."
[2]
https://code.woboq.org/userspace/glibc/sysdeps/unix/sysv/linux/aarch64/bits/fcntl.h.html#_M/__O_DIRECT

Test-Parameters: testlist=sanityn envdefinitions=ONLY=16a
Fixes: 853d180121a6 ("LU-3606 fsx: Add fallocate operation to fsx")
Change-Id: If72d434adaf91a960dfc50c557d8b50793fda575
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Xinliang Liu <xinliang.liu@linaro.org>
Reviewed-on: https://review.whamcloud.com/37589
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Nunez <jnunez@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/fsx.c
lustre/tests/sanityn.sh

index a013969..5217a90 100644 (file)
@@ -136,8 +136,7 @@ jmp_buf jmpbuf;
 #define OP_MAX_FULL            9
 
 #define OP_SKIPPED 101
-/* _GNU_SOURCE defines O_DIRECT as 14th bit which is 0x4000(16384) */
-#define OP_DIRECT  16384
+#define OP_DIRECT O_DIRECT
 
 #ifndef FALLOC_FL_PUNCH_HOLE
 #define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
@@ -583,9 +582,7 @@ open_test_files(char **argv, int argc)
 
        for (i = 0, tf = test_files; i < num_test_files; i++, tf++) {
                tf->path = argv[i];
-#ifdef O_DIRECT
                tf->o_direct = (random() % (o_direct + 1)) ? OP_DIRECT : 0;
-#endif
                tf->fd = open(tf->path,
                              O_RDWR | (lite ? 0 : O_CREAT | O_TRUNC) |
                              tf->o_direct, 0666);
@@ -1255,9 +1252,7 @@ docloseopen(void)
                return;
 
        tf = get_tf();
-#ifdef O_DIRECT
        direct = (random() % (o_direct + 1)) ? OP_DIRECT : 0;
-#endif
        log4(OP_CLOSEOPEN + direct, file_size, (unsigned int)file_size, 0);
 
        if (fd_policy != FD_SINGLE)
@@ -1475,9 +1470,7 @@ usage(void)
 "      -S seed: for random # generator (default 1) 0 gets timestamp\n"
 /* OSX: -T datasize: atomic data element write size [1,2,4] (default 4)\n\ */
 "      -W: mapped write operations DISabled\n"
-#ifdef O_DIRECT
 "      -Z[P]: O_DIRECT file IO [1 in P chance for each open] (default off)\n"
-#endif
 "      fname: this filename is REQUIRED (no default)\n",
        page_size);
        exit(90);
@@ -1693,12 +1686,10 @@ main(int argc, char **argv)
                                fprintf(stdout, "mapped writes DISABLED\n");
                        break;
                case 'Z':
-#ifdef O_DIRECT
                        if (optarg)
                                o_direct = getnum(optarg, &endp);
                        if (!optarg || o_direct == 0)
                                o_direct = 1;
-#endif
                        break;
                default:
                        usage();
index c1ead99..dde07fe 100755 (executable)
@@ -24,8 +24,8 @@ ALWAYS_EXCEPT+="                28 "
 
 # skip tests for PPC until they are fixed
 if [[ $(uname -m) = ppc64 ]]; then
-       # bug number:    LU-11597 LU-11787
-       ALWAYS_EXCEPT+=" 16a      71a"
+       # bug number:    LU-11787
+       ALWAYS_EXCEPT+=" 71a"
 fi
 
 if [ $mds1_FSTYPE = "zfs" ]; then
@@ -402,9 +402,9 @@ test_16a() {
                error "fsx failed"
        rm -f $file1
 
-       # O_DIRECT reads and writes must be aligned to the device block size.
-       $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
-               -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
+       # O_DIRECT reads and writes must be aligned to the PAGE_SIZE.
+       $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r $PAGE_SIZE \
+               -w $PAGE_SIZE $file1 $file2 || error "fsx with O_DIRECT failed."
 }
 run_test 16a "$FSXNUM iterations of dual-mount fsx"