3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
11 LUSTRE=${LUSTRE:-$(dirname $0)/..}
12 . $LUSTRE/tests/test-framework.sh
16 # bug number for skipped test:
17 ALWAYS_EXCEPT="$SANITY_COMPR_EXCEPT"
23 check_and_setup_lustre
25 # $RUNAS_ID may get set incorrectly somewhere else
26 if [[ $UID -eq 0 && $RUNAS_ID -eq 0 ]]; then
27 skip_env "\$RUNAS_ID set to 0, but \$UID is also 0!" && exit
29 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
31 save_layout_restore_at_exit $MOUNT
32 # Set file system with different layout
33 COMPR_EXTRA_LAYOUT=${COMPR_EXTRA_LAYOUT:-"-E EOF -c 1"}
34 $LFS setstripe $COMPR_EXTRA_LAYOUT $MOUNT
38 always_except LU-16928 56wb
41 SANITY_EXCEPT=$ALWAYS_EXCEPT bash sanity.sh
45 run_test sanity "Run sanity with PFL layout"
55 run_test sanityn "Run sanityn with PFL layout"
59 local dense=$(do_facet ost1 lctl get_param -n \
60 osd*.*OST0000*.extents_dense)
61 [[ -n $dense ]] || skip "no dense writes supported"
63 local osts=$(comma_list $(osts_nodes))
64 do_nodes $osts $LCTL set_param osd*.*.extents_dense=0 ||
65 error "cannot enable dense extent allocation"
66 stack_trap "do_nodes $osts $LCTL set_param osd*.*.extents_dense=$dense"
69 stack_trap "rm -f $tf"
70 log "create file with dense=0"
72 $LFS setstripe -c 1 -i 0 $tf
73 for ((i=0; i<$blocks; i++)); do
74 dd if=/dev/zero of=$tf bs=32k seek=$((i*2)) count=1 \
75 oflag=direct >&/dev/null conv=notrunc ||
76 error "can't dd (sparse)"
80 while read EX LS LE PS PE LEN DEV FLAGS; do
81 [[ "$EX" == "ext:" || "$EX" =~ "File" ]] && continue
82 [[ "$EX" == "0:" ]] && PREV=${PE%:} && ((nonr+=1)) && continue
83 (( ${PS%%.*} == PREV + 1 )) || ((nonr+=1))
85 done < <(filefrag -v $tf)
86 (( nonr > 0 )) || error "no extents?"
90 do_nodes $osts $LCTL set_param osd*.*.extents_dense=1 ||
91 error "cannot enable dense extent allocation"
92 #define OBD_FAIL_OSC_MARK_COMPRESSED 0x419
93 $LCTL set_param fail_loc=0x419
94 log "create file with dense=1"
96 $LFS setstripe -c 1 -i 0 $tf
97 for ((i=0; i<$blocks; i++)); do
98 dd if=/dev/zero of=$tf bs=32k seek=$((i*2)) count=1 \
99 oflag=direct conv=notrunc >&/dev/null ||
100 error "can't dd (dense)"
104 while read EX LS LE PS PE LEN DEV FLAGS; do
105 [[ "$EX" == "ext:" || "$EX" =~ "File" ]] && continue
106 [[ "$EX" == "0:" ]] && PREV=${PE%:} && ((nr+=1)) && continue
107 (( ${PS%%.*} == PREV + 1 )) || ((nr+=1))
109 done < <(filefrag -v $tf)
110 (( nr > 0 )) || error "no extents?"
112 echo "dense ($nr) should have fewer extents ($nonr)"
113 (( (nonr / nr) > 3 )) ||
114 error "dense ($nr) should have less extents ($nonr)"
115 $LCTL set_param fail_loc=0
117 local tmpfile=$(mktemp)
118 stack_trap "rm -f $tmpfile"
119 echo "generate temp file $tmpfile"
120 dd if=/dev/urandom of=$tmpfile bs=32k count=$((blocks*2)) iflag=fullblock ||
121 error "can't generate temporary file"
122 dd if=$tmpfile of=$tf bs=32k conv=notrunc
125 stop ost1 || error "(2) Fail to stop ost1"
126 run_e2fsck $(facet_host ost1) $(ostdevname 1) "-y" ||
127 error "(3) Fail to run e2fsck error"
128 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS ||
129 error "(4) Fail to start ost1"
131 cmp $tmpfile $tf || error "data mismatch"
133 run_test 1000 "compressed vs uncompressed allocation"
136 [[ "$ost1_FSTYPE" == "ldiskfs" ]] || skip "need ldiskfs backend"
137 local osts=$(comma_list $(osts_nodes))
139 local dense=$(do_facet ost1 lctl get_param -n \
140 osd*.*OST0000*.extents_dense)
141 [[ -n $dense ]] || skip "no dense writes supported"
142 do_nodes $osts $LCTL set_param osd*.*.extents_dense=1 ||
143 error "cannot enable dense extent allocation"
144 stack_trap "do_nodes $osts $LCTL set_param osd*.*.extents_dense=$dense"
146 #define OBD_FAIL_OSD_MARK_COMPRESSED 0x2302
147 do_nodes $osts $LCTL set_param fail_loc=0x2302 ||
148 error "cannot force dense writes"
149 stack_trap "do_nodes $osts $LCTL set_param fail_loc=0"
151 fsx_STRIPEPARAMS="-E eof -c -1" ONLY=fsx FSX_COUNT=2500 SLOW=yes bash sanity-benchmark.sh
155 run_test fsx "verify dense writes with fsx on ldiskfs"
157 complete_test $SECONDS
158 check_and_cleanup_lustre
159 declare -a logs=($ONLY)
160 logs=("${logs[@]/#/$TMP/}")
161 exit_status "$(echo "${logs[@]/%/.log}")"