From eb704aecfaad2a6256d1e2e48cdfadbabb07e5cb Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Thu, 6 Jan 2022 09:02:24 -0500 Subject: [PATCH] LU-11597 test: Fix sanityn 16a failed on arm 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 Signed-off-by: Xinliang Liu Reviewed-on: https://review.whamcloud.com/37589 Tested-by: jenkins Reviewed-by: James Simmons Reviewed-by: Arshad Hussain Tested-by: Maloo Reviewed-by: James Nunez Reviewed-by: Oleg Drokin --- lustre/tests/fsx.c | 11 +---------- lustre/tests/sanityn.sh | 10 +++++----- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/lustre/tests/fsx.c b/lustre/tests/fsx.c index a013969..5217a906 100644 --- a/lustre/tests/fsx.c +++ b/lustre/tests/fsx.c @@ -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(); diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index c1ead99..dde07fe 100755 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -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" -- 1.8.3.1