Whamcloud - gitweb
LU-11607 tests: replace version/fstype in sanity-dom/quota
[fs/lustre-release.git] / lustre / tests / sanity-dom.sh
1 #!/bin/bash
2 #
3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
5 #
6
7 set -e
8
9 ONLY=${ONLY:-"$*"}
10
11 LUSTRE=${LUSTRE:-$(dirname $0)/..}
12 . $LUSTRE/tests/test-framework.sh
13 init_test_env $@
14 init_logging
15
16 # bug number for skipped test:
17 ALWAYS_EXCEPT="$SANITY_DOM_EXCEPT"
18 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
19
20 build_test_filter
21
22 [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
23         skip "Need MDS version at least 2.10.56"
24
25 OPENFILE=${OPENFILE:-openfile}
26 MOUNT_2=${MOUNT_2:-"yes"}
27 FAIL_ON_ERROR=false
28
29 check_and_setup_lustre
30
31 # $RUNAS_ID may get set incorrectly somewhere else
32 if [[ $UID -eq 0 && $RUNAS_ID -eq 0 ]]; then
33         skip_env "\$RUNAS_ID set to 0, but \$UID is also 0!" && exit
34 fi
35 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
36
37 DOM="yes"
38 DOM_SIZE=${DOM_SIZE:-"$((1024*1024))"}
39 OSC="mdc"
40
41 save_layout_restore_at_exit $DIR1
42 $LFS setstripe -E $DOM_SIZE -L mdt -E EOF $DIR1
43
44 mkdir -p $MOUNT2
45 mount_client $MOUNT2
46
47 test_1() {
48         dd if=/dev/zero of=$DIR1/$tfile bs=7k count=1 || error "write 1"
49         $TRUNCATE $DIR2/$tfile 1000 || error "truncate"
50         dd if=/dev/zero of=$DIR1/$tfile bs=3k count=1 seek=1 || error "write 2"
51         $CHECKSTAT -t file -s 6144 $DIR2/$tfile || error "stat"
52         rm $DIR1/$tfile
53 }
54 run_test 1 "write a file on one mount, truncate on the other, write again"
55
56 test_2() {
57         SZ1=234852
58         dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4 || return 1
59         dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
60         dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=5 || return 3
61         $CHECKSTAT -t file -s $SZ1 $DIR/${tfile}_left ||
62                 error "Error reading at the end of the file $tfile"
63 }
64 run_test 2 "Write with a seek, append, read from a single mountpoint"
65
66 test_3() {
67         # Write on one node to the DoM stripe and then truncate to over DoM size
68         dd if=/dev/zero of=$DIR1/$tfile bs=$((DOM_SIZE-100)) count=1 ||
69                 return 1
70         truncate $DIR1/$tfile $((DOM_SIZE+700)) || return 2
71         # read on the second node inside DoM stripe to take a lock data from
72         # the first client
73         dd if=$DIR2/$tfile of=/dev/null bs=4096 count=1 seek=1 || return 3
74         $CHECKSTAT -t file -s $((DOM_SIZE+700)) $DIR2/$tfile ||
75                 error "Wrong size after first truncate $tfile on first node"
76         # now do local truncate over DoM size and check size is correct
77         truncate $DIR2/$tfile $((DOM_SIZE+500)) || return 4
78         $CHECKSTAT -t file -s $((DOM_SIZE+500)) $DIR2/$tfile ||
79                 error "Wrong size after second truncate on the same node"
80         $CHECKSTAT -t file -s $((DOM_SIZE+500)) $DIR1/$tfile ||
81                 error "Wrong size after second truncate on other node"
82 }
83 run_test 3 "Truncate over DoM size on different nodes"
84
85 test_4() {
86         local before=0
87         local after=0
88
89         dd if=/dev/zero of=$DIR1/$tfile bs=2M count=1
90         cancel_lru_locks mdc
91
92         #define OBD_FAIL_MDC_GLIMPSE_DDOS 0x808
93         $LCTL set_param fail_loc=0x80000808
94         before=$(lctl get_param -n ldlm.namespaces.*mdc*.lock_count |
95                 gawk '{cnt=cnt+$1}  END{print cnt}')
96         for ((i=1; i < 100; i++))
97         do
98                 tail -n100 $DIR1/$tfile > /dev/null
99                 stat -f $DIR2/$tfile > /dev/null
100         done
101         after=$(lctl get_param -n ldlm.namespaces.*mdc*.lock_count |
102                 gawk '{cnt=cnt+$1}  END{print cnt}')
103         [[ $((after - before)) -ge 20 ]] &&
104                 error "Too many locks found $((after - before))"
105         return 0
106 }
107 run_test 4 "DoM: glimpse doesn't produce duplicated locks"
108
109 test_5() {
110         local before=$(date +%s)
111         local evict
112
113         dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 || return 1
114
115         multiop_bg_pause $DIR/$tfile O_Ac || return 1
116         setxattr=$!
117
118         multiop_bg_pause $DIR/$tfile O_Tc || return 1
119         truncate=$!
120
121         multiop $DIR2/$tfile Ow10 || return 1
122
123         getfattr -d $DIR2/$tfile
124
125 #define OBD_FAIL_LLITE_TRUNCATE_INODE_PAUSE        0x1415
126         $LCTL set_param fail_loc=0x80001415 fail_val=5
127         kill -USR1 $truncate
128         sleep 1
129         multiop $DIR2/$tfile Ow10 &
130         sleep 1
131         kill -USR1 $setxattr
132
133         wait
134
135         evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
136           awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
137
138         [ -z "$evict" ] || [[ $evict -le $before ]] ||
139                 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
140                         error "eviction happened: $evict before:$before")
141 }
142 run_test 5 "DoM truncate deadlock"
143
144 test_6() {
145         $MULTIOP $DIR1/$tfile Oz40960w100_z200w100c &
146         MULTIPID=$!
147
148         # let MULTIPID to create the file
149         sleep 1
150         $MULTIOP $DIR2/$tfile oO_RDWR:Tw100c
151         kill -USR1 $MULTIPID
152         wait
153         $MULTIOP $DIR2/$tfile oO_RDWR:z400w100c
154         $CHECKSTAT -s 500 $DIR2/$tfile || error "wrong size"
155 }
156 run_test 6 "Race two writes, check file size"
157
158 test_fsx() {
159         local file1=$DIR1/$tfile
160         local file2=$DIR2/$tfile
161
162         touch $file1
163         fsx -c 50 -p 100 -N 1000 -l $((DOM_SIZE*2)) -S 0 -d -d $file1 $file2
164 }
165 run_test fsx "Dual-mount fsx with DoM files"
166
167 test_sanity()
168 {
169         # XXX: to fix 45. Add 42a, c when LU-9693 fixed.
170         # Add 42b when LU-6493 fixed
171         # Enable 39k when LU-10496 fixed
172         ONLY="36 39 40 41 42d 42e 43 46 56r 101e 119a 131 150 155a 155b 155c \
173                 155d 207 241 251" \
174                 EXCEPT=39k OSC="mdc" DOM="yes" bash sanity.sh
175 }
176 run_test sanity "Run sanity with Data-on-MDT files"
177
178 test_sanityn()
179 {
180         # XXX: to fix 60
181         ONLY="1 2 4 5 6 7 8 9 10 11 12 14 17 19 20 23 27 39 51a 51c 51d" \
182                 OSC="mdc" DOM="yes" bash sanityn.sh
183 }
184 run_test sanityn "Run sanityn with Data-on-MDT files"
185
186 complete $SECONDS
187 check_and_cleanup_lustre
188 exit_status