2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
19 SRCDIR=$(cd $(dirname $0); echo $PWD)
20 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 OPENFILE=${OPENFILE:-openfile}
32 OPENUNLINK=${OPENUNLINK:-openunlink}
33 export MULTIOP=${MULTIOP:-multiop}
34 READS=${READS:-"reads"}
35 MUNLINK=${MUNLINK:-munlink}
36 SOCKETSERVER=${SOCKETSERVER:-socketserver}
37 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
38 MEMHOG=${MEMHOG:-memhog}
39 DIRECTIO=${DIRECTIO:-directio}
40 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
41 UMOUNT=${UMOUNT:-"umount -d"}
43 CHECK_GRANT=${CHECK_GRANT:-"yes"}
44 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
45 export PARALLEL=${PARALLEL:-"no"}
47 export NAME=${NAME:-local}
54 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
55 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24D 27m 64b 68 71 77f 78 115 124b"
63 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
64 # bug number for skipped test: LU-4536 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 65ic 180 184c"
66 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
73 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
74 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
83 check_swap_layouts_support()
85 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
86 { skip "Does not support layout lock."; return 0; }
90 check_and_setup_lustre
95 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
96 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
97 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
98 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
99 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
100 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
101 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
102 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
104 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
105 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
106 rm -rf $DIR/[Rdfs][0-9]*
108 # $RUNAS_ID may get set incorrectly somewhere else
109 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
111 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
115 if [ "${ONLY}" = "MOUNT" ] ; then
116 echo "Lustre is up, please go on"
120 echo "preparing for tests involving mounts"
121 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
123 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
124 echo # add a newline after mke2fs.
128 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
129 lctl set_param debug=-1 2> /dev/null || true
132 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
134 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
136 run_test 0a "touch; rm ====================="
139 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
140 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
142 run_test 0b "chmod 0755 $DIR ============================="
145 $LCTL get_param mdc.*.import | grep "state: FULL" ||
146 error "import not FULL"
147 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
150 run_test 0c "check import proc ============================="
153 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
154 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
155 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
156 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
159 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
161 run_test 1 "mkdir; remkdir; rmdir =============================="
164 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
165 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
166 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
168 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
170 run_test 2 "mkdir; touch; rmdir; check file ===================="
173 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
174 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
175 touch $DIR/$tdir/$tfile
176 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
178 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
180 run_test 3 "mkdir; touch; rmdir; check dir ====================="
182 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
186 test_mkdir $DIR/$tdir ||
187 error "Create remote directory failed"
189 touch $DIR/$tdir/$tfile ||
190 error "Create file under remote directory failed"
193 error "Expect error removing in-use dir $DIR/$tdir"
195 test -d $DIR/$tdir || error "Remote directory disappeared"
197 rm -rf $DIR/$tdir || error "remove remote dir error"
199 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
202 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
203 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
204 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
205 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
206 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
208 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
211 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
212 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
213 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
214 error "$tfile does not have perm 0666 or UID $UID"
215 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
216 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
217 error "$tfile should be 0666 and owned by UID $UID"
219 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
222 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
224 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
225 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
226 error "$tfile should be owned by UID $RUNAS_ID"
227 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
228 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
229 error "$tfile should be owned by UID $RUNAS_ID"
231 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
234 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
236 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
237 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
238 error "$tfile should be owned by GID $UID"
239 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
240 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
241 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
243 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
246 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
247 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
248 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
249 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
250 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
251 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
252 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
253 error "$tdir/d/subdir should be GID $RUNAS_GID"
255 run_test 6g "Is new dir in sgid dir inheriting group?"
257 test_6h() { # bug 7331
258 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
259 touch $DIR/$tfile || error "touch failed"
260 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
261 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
262 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
263 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
264 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
266 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
269 test_mkdir $DIR/$tdir
270 $MCREATE $DIR/$tdir/$tfile
271 chmod 0666 $DIR/$tdir/$tfile
272 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
273 error "$tdir/$tfile should be mode 0666"
275 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
278 if [ ! -d $DIR/$tdir ]; then
279 test_mkdir $DIR/$tdir
281 $MCREATE $DIR/$tdir/$tfile
282 echo -n foo > $DIR/$tdir/$tfile
283 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
284 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
286 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
289 test_mkdir $DIR/$tdir
290 touch $DIR/$tdir/$tfile
291 chmod 0666 $DIR/$tdir/$tfile
292 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
293 error "$tfile mode not 0666"
295 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
298 test_mkdir $DIR/$tdir
299 test_mkdir $DIR/$tdir/d2
300 test_mkdir $DIR/$tdir/d2/d3
301 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
303 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
306 test_mkdir $DIR/$tdir
307 test_mkdir $DIR/$tdir/d2
308 touch $DIR/$tdir/d2/$tfile
309 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
310 error "$tdir/d2/$tfile not a file"
312 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
315 test_mkdir $DIR/$tdir
316 test_mkdir $DIR/$tdir/d2
317 chmod 0666 $DIR/$tdir/d2
318 chmod 0705 $DIR/$tdir/d2
319 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
320 error "$tdir/d2 mode not 0705"
322 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
325 test_mkdir $DIR/$tdir
326 touch $DIR/$tdir/$tfile
327 chmod 0666 $DIR/$tdir/$tfile
328 chmod 0654 $DIR/$tdir/$tfile
329 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
330 error "$tdir/d2 mode not 0654"
332 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
335 test_mkdir $DIR/$tdir
336 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
338 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
339 error "$tdir/$tfile size not 0 after truncate"
341 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
344 test_mkdir $DIR/$tdir
345 touch $DIR/$tdir/$tfile
347 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
349 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
352 test_mkdir $DIR/$tdir
353 touch $DIR/$tdir/$tfile
354 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
355 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
356 error "$tdir/${tfile_2} not a file after rename"
357 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
359 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
362 test_mkdir $DIR/$tdir
363 touch $DIR/$tdir/$tfile
364 rm -rf $DIR/$tdir/$tfile
365 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
367 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
370 test_mkdir -p $DIR/$tdir
371 touch $DIR/$tdir/$tfile
372 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
374 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
375 error "$tdir/l-exist not a symlink"
376 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
377 error "$tdir/l-exist not referencing a file"
378 rm -f $DIR/$tdir/l-exist
379 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
381 run_test 17a "symlinks: create, remove (real) =================="
384 test_mkdir -p $DIR/$tdir
385 ln -s no-such-file $DIR/$tdir/l-dangle
387 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
388 error "$tdir/l-dangle not referencing no-such-file"
389 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
390 error "$tdir/l-dangle not referencing non-existent file"
391 rm -f $DIR/$tdir/l-dangle
392 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
394 run_test 17b "symlinks: create, remove (dangling) =============="
396 test_17c() { # bug 3440 - don't save failed open RPC for replay
397 test_mkdir -p $DIR/$tdir
398 ln -s foo $DIR/$tdir/$tfile
399 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
401 run_test 17c "symlinks: open dangling (should return error) ===="
404 test_mkdir -p $DIR/$tdir
405 ln -s foo $DIR/$tdir/$tfile
406 touch $DIR/$tdir/$tfile || error "creating to new symlink"
408 run_test 17d "symlinks: create dangling ========================"
411 test_mkdir -p $DIR/$tdir
412 local foo=$DIR/$tdir/$tfile
413 ln -s $foo $foo || error "create symlink failed"
414 ls -l $foo || error "ls -l failed"
415 ls $foo && error "ls not failed" || true
417 run_test 17e "symlinks: create recursive symlink (should return error) ===="
420 test_mkdir -p $DIR/$tdir
421 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
422 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
423 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
424 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
425 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
426 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
429 run_test 17f "symlinks: long and very long symlink name ========================"
431 # str_repeat(S, N) generate a string that is string S repeated N times
436 while [ $((n -= 1)) -ge 0 ]; do
442 # Long symlinks and LU-2241
444 test_mkdir -p $DIR/$tdir
445 local TESTS="59 60 61 4094 4095"
447 # Fix for inode size boundary in 2.1.4
448 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
451 # Patch not applied to 2.2 or 2.3 branches
452 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
453 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
456 # skip long symlink name for rhel6.5.
457 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
458 grep -q '6.5' /etc/redhat-release &>/dev/null &&
459 TESTS="59 60 61 4062 4063"
462 local SYMNAME=$(str_repeat 'x' $i)
463 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
464 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
467 run_test 17g "symlinks: really long symlink name and inode boundaries"
469 test_17h() { #bug 17378
470 remote_mds_nodsh && skip "remote MDS with nodsh" && return
471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
473 test_mkdir -p $DIR/$tdir
474 if [[ $MDSCOUNT -gt 1 ]]; then
475 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
479 $SETSTRIPE -c -1 $DIR/$tdir
480 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
481 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
482 touch $DIR/$tdir/$tfile || true
484 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
486 test_17i() { #bug 20018
487 remote_mds_nodsh && skip "remote MDS with nodsh" && return
488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
489 test_mkdir -c1 $DIR/$tdir
490 local foo=$DIR/$tdir/$tfile
492 if [[ $MDSCOUNT -gt 1 ]]; then
493 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
497 ln -s $foo $foo || error "create symlink failed"
498 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
499 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
500 ls -l $foo && error "error not detected"
503 run_test 17i "don't panic on short symlink"
505 test_17k() { #bug 22301
506 [[ -z "$(which rsync 2>/dev/null)" ]] &&
507 skip "no rsync command" && return 0
508 rsync --help | grep -q xattr ||
509 skip_env "$(rsync --version | head -n1) does not support xattrs"
510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
511 test_mkdir -p $DIR/$tdir
512 test_mkdir -p $DIR/$tdir.new
513 touch $DIR/$tdir/$tfile
514 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
515 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
516 error "rsync failed with xattrs enabled"
518 run_test 17k "symlinks: rsync with xattrs enabled ========================="
520 test_17l() { # LU-279
521 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
522 skip "no getfattr command" && return 0
523 test_mkdir -p $DIR/$tdir
524 touch $DIR/$tdir/$tfile
525 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
526 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
527 # -h to not follow symlinks. -m '' to list all the xattrs.
528 # grep to remove first line: '# file: $path'.
529 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
531 lgetxattr_size_check $path $xattr ||
532 error "lgetxattr_size_check $path $xattr failed"
536 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
540 local short_sym="0123456789"
541 local WDIR=$DIR/${tdir}m
548 remote_mds_nodsh && skip "remote MDS with nodsh" && return
549 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
550 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
551 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
553 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
554 skip "only for ldiskfs MDT" && return 0
556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
560 # create a long symlink file
561 for ((i = 0; i < 4; ++i)); do
562 long_sym=${long_sym}${long_sym}
565 echo "create 512 short and long symlink files under $WDIR"
566 for ((i = 0; i < 256; ++i)); do
567 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
568 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
574 wait_delete_completed
576 echo "recreate the 512 symlink files with a shorter string"
577 for ((i = 0; i < 512; ++i)); do
578 # rewrite the symlink file with a shorter string
579 ln -sf ${long_sym} $WDIR/long-$i
580 ln -sf ${short_sym} $WDIR/short-$i
583 mds_index=$($LFS getstripe -M $WDIR)
584 mds_index=$((mds_index+1))
585 devname=$(mdsdevname $mds_index)
586 cmd="$E2FSCK -fnvd $devname"
588 echo "stop and checking mds${mds_index}: $cmd"
589 # e2fsck should not return error
591 do_facet mds${mds_index} $cmd || rc=$?
593 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
594 df $MOUNT > /dev/null 2>&1
595 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
596 "short/long symlink MDT: rc=$rc"
599 run_test 17m "run e2fsck against MDT which contains short/long symlink"
601 check_fs_consistency_17n() {
607 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
608 # so it only check MDT1/MDT2 instead of all of MDTs.
609 for mdt_index in $(seq 1 2); do
610 devname=$(mdsdevname $mdt_index)
611 cmd="$E2FSCK -fnvd $devname"
613 echo "stop and checking mds${mdt_index}: $cmd"
614 # e2fsck should not return error
616 do_facet mds${mdt_index} $cmd || rc=$?
618 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
619 error "mount mds${mdt_index} failed"
620 df $MOUNT > /dev/null 2>&1
621 [ $rc -ne 0 ] && break
629 remote_mds_nodsh && skip "remote MDS with nodsh" && return
630 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
631 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
632 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
634 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
635 skip "only for ldiskfs MDT" && return 0
637 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
641 test_mkdir $DIR/$tdir
642 for ((i=0; i<10; i++)); do
643 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
644 error "create remote dir error $i"
645 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
646 error "create files under remote dir failed $i"
649 check_fs_consistency_17n ||
650 error "e2fsck report error after create files under remote dir"
652 for ((i = 0; i < 10; i++)); do
653 rm -rf $DIR/$tdir/remote_dir_${i} ||
654 error "destroy remote dir error $i"
657 check_fs_consistency_17n ||
658 error "e2fsck report error after unlink files under remote dir"
660 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
661 skip "lustre < 2.4.50 does not support migrate mv " && return
663 for ((i = 0; i < 10; i++)); do
664 mkdir -p $DIR/$tdir/remote_dir_${i}
665 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
666 error "create files under remote dir failed $i"
667 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
668 error "migrate remote dir error $i"
670 check_fs_consistency_17n || error "e2fsck report error after migration"
672 for ((i = 0; i < 10; i++)); do
673 rm -rf $DIR/$tdir/remote_dir_${i} ||
674 error "destroy remote dir error $i"
677 check_fs_consistency_17n || error "e2fsck report error after unlink"
679 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
682 remote_mds_nodsh && skip "remote MDS with nodsh" && return
683 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
684 skip "Need MDS version at least 2.3.64" && return
686 local WDIR=$DIR/${tdir}o
691 mdt_index=$($LFS getstripe -M $WDIR)
692 mdt_index=$((mdt_index+1))
696 #fail mds will wait the failover finish then set
697 #following fail_loc to avoid interfer the recovery process.
700 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
701 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
702 ls -l $WDIR/$tfile && rc=1
703 do_facet mds${mdt_index} lctl set_param fail_loc=0
704 [[ $rc -ne 0 ]] && error "stat file should fail"
707 run_test 17o "stat file with incompat LMA feature"
710 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
711 ls $DIR || error "Failed to ls $DIR: $?"
713 run_test 18 "touch .../f ; ls ... =============================="
719 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
721 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
724 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
726 run_test 19b "ls -l .../f19 (should return error) =============="
729 [ $RUNAS_ID -eq $UID ] &&
730 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
731 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
733 run_test 19c "$RUNAS touch .../f19 (should return error) =="
736 cat $DIR/f19 && error || true
738 run_test 19d "cat .../f19 (should return error) =============="
750 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
752 run_test 20 "touch .../f ; ls -l ... ==========================="
755 test_mkdir -p $DIR/$tdir
756 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
757 ln -s dangle $DIR/$tdir/link
758 echo foo >> $DIR/$tdir/link
759 cat $DIR/$tdir/dangle
760 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
761 $CHECKSTAT -f -t file $DIR/$tdir/link ||
762 error "$tdir/link not linked to a file"
764 run_test 21 "write to dangling link ============================"
768 test_mkdir -p $DIR/$tdir
769 chown $RUNAS_ID:$RUNAS_GID $WDIR
770 (cd $WDIR || error "cd $WDIR failed";
771 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
773 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
774 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
775 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
777 run_test 22 "unpack tar archive as non-root user ==============="
781 test_mkdir -p $DIR/$tdir
782 local file=$DIR/$tdir/$tfile
784 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
785 openfile -f O_CREAT:O_EXCL $file &&
786 error "$file recreate succeeded" || true
788 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
790 test_23b() { # bug 18988
791 test_mkdir -p $DIR/$tdir
792 local file=$DIR/$tdir/$tfile
795 echo foo > $file || error "write filed"
796 echo bar >> $file || error "append filed"
797 $CHECKSTAT -s 8 $file || error "wrong size"
800 run_test 23b "O_APPEND check =========================="
804 echo '-- same directory rename'
805 test_mkdir $DIR/$tdir
806 touch $DIR/$tdir/$tfile.1
807 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
808 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
810 run_test 24a "rename file to non-existent target"
813 test_mkdir $DIR/$tdir
814 touch $DIR/$tdir/$tfile.{1,2}
815 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
816 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
817 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
819 run_test 24b "rename file to existing target"
822 test_mkdir $DIR/$tdir
823 test_mkdir $DIR/$tdir/d$testnum.1
824 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
825 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
826 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
828 run_test 24c "rename directory to non-existent target"
831 test_mkdir -c1 $DIR/$tdir
832 test_mkdir -c1 $DIR/$tdir/d$testnum.1
833 test_mkdir -c1 $DIR/$tdir/d$testnum.2
834 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
835 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
836 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
838 run_test 24d "rename directory to existing target"
841 echo '-- cross directory renames --'
845 mv $DIR/R5a/f $DIR/R5b/g
846 $CHECKSTAT -a $DIR/R5a/f || error
847 $CHECKSTAT -t file $DIR/R5b/g || error
849 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
854 touch $DIR/R6a/f $DIR/R6b/g
855 mv $DIR/R6a/f $DIR/R6b/g
856 $CHECKSTAT -a $DIR/R6a/f || error
857 $CHECKSTAT -t file $DIR/R6b/g || error
859 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
864 test_mkdir $DIR/R7a/d
865 mv $DIR/R7a/d $DIR/R7b/e
866 $CHECKSTAT -a $DIR/R7a/d || error
867 $CHECKSTAT -t dir $DIR/R7b/e || error
869 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
872 test_mkdir -c1 $DIR/R8a
873 test_mkdir -c1 $DIR/R8b
874 test_mkdir -c1 $DIR/R8a/d
875 test_mkdir -c1 $DIR/R8b/e
876 mrename $DIR/R8a/d $DIR/R8b/e
877 $CHECKSTAT -a $DIR/R8a/d || error
878 $CHECKSTAT -t dir $DIR/R8b/e || error
880 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
883 echo "-- rename error cases"
887 mrename $DIR/R9/f $DIR/R9/a
888 $CHECKSTAT -t file $DIR/R9/f || error
889 $CHECKSTAT -t dir $DIR/R9/a || error
890 $CHECKSTAT -a $DIR/R9/a/f || error
892 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
896 mrename $DIR/R10/f $DIR/R10/g
897 $CHECKSTAT -t dir $DIR/R10 || error
898 $CHECKSTAT -a $DIR/R10/f || error
899 $CHECKSTAT -a $DIR/R10/g || error
901 run_test 24j "source does not exist ============================"
905 test_mkdir $DIR/R11a/d
907 mv $DIR/R11a/f $DIR/R11a/d
908 $CHECKSTAT -a $DIR/R11a/f || error
909 $CHECKSTAT -t file $DIR/R11a/d/f || error
911 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
913 # bug 2429 - rename foo foo foo creates invalid file
916 $MULTIOP $f OcNs || error
918 run_test 24l "Renaming a file to itself ========================"
922 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
923 # on ext3 this does not remove either the source or target files
924 # though the "expected" operation would be to remove the source
925 $CHECKSTAT -t file ${f} || error "${f} missing"
926 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
928 run_test 24m "Renaming a file to a hard link to itself ========="
932 # this stats the old file after it was renamed, so it should fail
936 $CHECKSTAT ${f}.rename
939 run_test 24n "Statting the old file after renaming (Posix rename 2)"
942 test_mkdir -p $DIR/d24o
943 rename_many -s random -v -n 10 $DIR/d24o
945 run_test 24o "rename of files during htree split ==============="
950 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
951 mrename $DIR/R12a $DIR/R12b
952 $CHECKSTAT -a $DIR/R12a || error
953 $CHECKSTAT -t dir $DIR/R12b || error
954 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
955 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
957 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
959 cleanup_multiop_pause() {
965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
968 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
969 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
972 trap cleanup_multiop_pause EXIT
973 mrename $DIR/R13a $DIR/R13b
974 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
975 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
976 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
977 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
978 cleanup_multiop_pause
979 wait $MULTIPID || error "multiop close failed"
981 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
983 test_24r() { #bug 3789
985 test_mkdir $DIR/R14a/b
986 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
987 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
988 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
990 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
994 test_mkdir $DIR/R15a/b
995 test_mkdir $DIR/R15a/b/c
996 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
997 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
998 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1000 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1002 test_mkdir $DIR/R16a
1003 test_mkdir $DIR/R16a/b
1004 test_mkdir $DIR/R16a/b/c
1005 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1006 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1007 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1009 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1011 test_24u() { # bug12192
1012 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1013 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1015 run_test 24u "create stripe file"
1021 simple_cleanup_common() {
1024 wait_delete_completed
1027 max_pages_per_rpc() {
1028 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1032 local NRFILES=100000
1033 local FREE_INODES=$(mdt_free_inodes 0)
1034 [[ $FREE_INODES -lt $NRFILES ]] &&
1035 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1039 trap simple_cleanup_common EXIT
1041 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1042 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1044 test_mkdir -p $DIR/$tdir
1045 createmany -m $DIR/$tdir/$tfile $NRFILES
1047 cancel_lru_locks mdc
1048 lctl set_param mdc.*.stats clear
1050 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1052 # LU-5 large readdir
1053 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1054 # 8 bytes for name(filename is mostly 5 in this test) +
1055 # 8 bytes for luda_type
1056 # take into account of overhead in lu_dirpage header and end mark in
1057 # each page, plus one in RPC_NUM calculation.
1059 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1060 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1061 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1062 awk '/^mds_readpage/ {print $2}')
1063 [[ $mds_readpage -gt $RPC_NUM ]] &&
1064 error "large readdir doesn't take effect"
1066 simple_cleanup_common
1068 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1070 test_24w() { # bug21506
1072 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1073 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1074 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1075 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1076 [[ "$SZ1" -eq "$SZ2" ]] ||
1077 error "Error reading at the end of the file $tfile"
1079 run_test 24w "Reading a file larger than 4Gb"
1082 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1085 local remote_dir=$DIR/$tdir/remote_dir
1087 test_mkdir -p $DIR/$tdir
1088 $LFS mkdir -i $MDTIDX $remote_dir ||
1089 error "create remote directory failed"
1091 test_mkdir -p $DIR/$tdir/src_dir
1092 touch $DIR/$tdir/src_file
1093 test_mkdir -p $remote_dir/tgt_dir
1094 touch $remote_dir/tgt_file
1096 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1097 error "rename dir cross MDT failed!"
1099 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1100 error "rename file cross MDT failed!"
1102 touch $DIR/$tdir/ln_file
1103 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1104 error "ln file cross MDT failed"
1106 rm -rf $DIR/$tdir || error "Can not delete directories"
1108 run_test 24x "cross MDT rename/link"
1111 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1114 local remote_dir=$DIR/$tdir/remote_dir
1116 test_mkdir -p $DIR/$tdir
1117 $LFS mkdir -i $MDTIDX $remote_dir ||
1118 error "create remote directory failed"
1120 test_mkdir -p $remote_dir/src_dir
1121 touch $remote_dir/src_file
1122 test_mkdir -p $remote_dir/tgt_dir
1123 touch $remote_dir/tgt_file
1125 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1126 error "rename subdir in the same remote dir failed!"
1128 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1129 error "rename files in the same remote dir failed!"
1131 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1132 error "link files in the same remote dir failed!"
1134 rm -rf $DIR/$tdir || error "Can not delete directories"
1136 run_test 24y "rename/link on the same dir should succeed"
1138 test_24A() { # LU-3182
1142 test_mkdir -p $DIR/$tdir
1143 createmany -m $DIR/$tdir/$tfile $NFILES
1144 local t=$(ls $DIR/$tdir | wc -l)
1145 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1146 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1147 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1148 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1151 rm -rf $DIR/$tdir || error "Can not delete directories"
1153 run_test 24A "readdir() returns correct number of entries."
1155 test_24B() { # LU-4805
1156 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1159 test_mkdir $DIR/$tdir
1160 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1161 error "create striped dir failed"
1163 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1164 [ $count -eq 2 ] || error "Expected 2, got $count"
1166 touch $DIR/$tdir/striped_dir/a
1168 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1169 [ $count -eq 3 ] || error "Expected 3, got $count"
1171 touch $DIR/$tdir/striped_dir/.f
1173 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1174 [ $count -eq 4 ] || error "Expected 4, got $count"
1176 rm -rf $DIR/$tdir || error "Can not delete directories"
1178 run_test 24B "readdir for striped dir return correct number of entries"
1181 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1187 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1188 error "create striped dir failed"
1190 cd $DIR/$tdir/d0/striped_dir
1192 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1193 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1194 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1196 [ "$d0_ino" = "$parent_ino" ] ||
1197 error ".. wrong, expect $d0_ino, get $parent_ino"
1199 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1200 error "mv striped dir failed"
1202 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1204 [ "$d1_ino" = "$parent_ino" ] ||
1205 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1207 run_test 24C "check .. in striped dir"
1209 test_24D() { # LU-6101
1214 createmany -m $DIR/$tdir/$tfile $NFILES
1215 local t=$(ls $DIR/$tdir | wc -l)
1216 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1217 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1218 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1219 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1222 rm -rf $DIR/$tdir || error "Can not delete directories"
1224 run_test 24D "readdir() returns correct number of entries after cursor reload"
1227 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
1228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1231 mkdir $DIR/$tdir/src_dir
1232 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1233 error "create remote source failed"
1235 touch $DIR/$tdir/src_dir/src_child/a
1237 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1238 error "create remote target dir failed"
1240 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1241 error "create remote target child failed"
1243 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1244 error "rename dir cross MDT failed!"
1248 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1249 error "src_child still exists after rename"
1251 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1252 error "missing file(a) after rename"
1254 rm -rf $DIR/$tdir || error "Can not delete directories"
1256 run_test 24E "cross MDT rename/link"
1259 echo '== symlink sanity ============================================='
1263 touch $DIR/s25/foo || error
1265 run_test 25a "create file in symlinked directory ==============="
1268 [ ! -d $DIR/d25 ] && test_25a
1269 $CHECKSTAT -t file $DIR/s25/foo || error
1271 run_test 25b "lookup file in symlinked directory ==============="
1275 test_mkdir $DIR/d26/d26-2
1276 ln -s d26/d26-2 $DIR/s26
1277 touch $DIR/s26/foo || error
1279 run_test 26a "multiple component symlink ======================="
1282 test_mkdir -p $DIR/d26b/d26-2
1283 ln -s d26b/d26-2/foo $DIR/s26-2
1284 touch $DIR/s26-2 || error
1286 run_test 26b "multiple component symlink at end of lookup ======"
1289 test_mkdir $DIR/d26.2
1290 touch $DIR/d26.2/foo
1291 ln -s d26.2 $DIR/s26.2-1
1292 ln -s s26.2-1 $DIR/s26.2-2
1293 ln -s s26.2-2 $DIR/s26.2-3
1294 chmod 0666 $DIR/s26.2-3/foo
1296 run_test 26c "chain of symlinks ================================"
1298 # recursive symlinks (bug 439)
1300 ln -s d26-3/foo $DIR/d26-3
1302 run_test 26d "create multiple component recursive symlink ======"
1305 [ ! -h $DIR/d26-3 ] && test_26d
1308 run_test 26e "unlink multiple component recursive symlink ======"
1310 # recursive symlinks (bug 7022)
1312 test_mkdir -p $DIR/$tdir
1313 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1314 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1315 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1316 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1317 cd $tfile || error "cd $tfile failed"
1318 ln -s .. dotdot || error "ln dotdot failed"
1319 ln -s dotdot/lndir lndir || error "ln lndir failed"
1320 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1321 output=`ls $tfile/$tfile/lndir/bar1`
1322 [ "$output" = bar1 ] && error "unexpected output"
1323 rm -r $tfile || error "rm $tfile failed"
1324 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1326 run_test 26f "rm -r of a directory which has recursive symlink ="
1329 echo '== stripe sanity =============================================='
1330 test_mkdir -p $DIR/d27 || error "mkdir failed"
1332 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1333 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1334 log "== test_27a: write to one stripe file ========================="
1335 cp /etc/hosts $DIR/d27/f0 || error
1337 run_test 27a "one stripe file =================================="
1340 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1341 test_mkdir -p $DIR/d27
1342 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1343 $GETSTRIPE -c $DIR/d27/f01
1344 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1345 error "two-stripe file doesn't have two stripes"
1347 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1349 run_test 27b "create and write to two stripe file"
1352 test_mkdir -p $DIR/d27
1353 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1354 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1355 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1357 run_test 27d "create file with default settings ================"
1360 # LU-5839 adds check for existed layout before setting it
1361 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1362 skip "Need MDS version at least 2.7.56" && return
1363 test_mkdir -p $DIR/d27
1364 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1365 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1366 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1368 run_test 27e "setstripe existing file (should return error) ======"
1371 test_mkdir $DIR/$tdir
1372 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1373 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1374 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1375 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1376 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1377 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1379 run_test 27f "setstripe with bad stripe size (should return error)"
1382 test_mkdir -p $DIR/d27
1383 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1384 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1385 error "$DIR/d27/fnone has object"
1387 run_test 27g "$GETSTRIPE with no objects"
1390 test_mkdir $DIR/$tdir
1391 touch $DIR/$tdir/$tfile || error "touch failed"
1392 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1393 error "missing objects"
1395 run_test 27i "$GETSTRIPE with some objects"
1398 test_mkdir -p $DIR/d27
1399 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1401 run_test 27j "setstripe with bad stripe offset (should return error)"
1403 test_27k() { # bug 2844
1404 test_mkdir -p $DIR/d27
1406 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1407 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1408 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1409 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1410 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1411 dd if=/dev/zero of=$FILE bs=4k count=1
1412 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1413 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1415 run_test 27k "limit i_blksize for broken user apps ============="
1418 test_mkdir -p $DIR/d27
1419 mcreate $DIR/f27l || error "creating file"
1420 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1421 error "setstripe should have failed" || true
1423 run_test 27l "check setstripe permissions (should return error)"
1426 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1428 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1429 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1432 trap simple_cleanup_common EXIT
1433 test_mkdir -p $DIR/$tdir
1434 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1435 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1436 error "dd should fill OST0"
1438 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1440 [ $i -gt 256 ] && break
1443 touch $DIR/$tdir/f27m_$i
1444 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1445 error "OST0 was full but new created file still use it"
1447 touch $DIR/$tdir/f27m_$i
1448 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1449 error "OST0 was full but new created file still use it"
1450 simple_cleanup_common
1452 run_test 27m "create file while OST0 was full =================="
1455 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1459 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1460 # if the OST isn't full anymore.
1462 local OSTIDX=${1:-""}
1464 local list=$(comma_list $(osts_nodes))
1465 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1467 do_nodes $list lctl set_param fail_loc=0
1468 sync # initiate all OST_DESTROYs from MDS to OST
1472 exhaust_precreations() {
1475 local FAILIDX=${3:-$OSTIDX}
1476 local ofacet=ost$((OSTIDX + 1))
1478 test_mkdir -p -c1 $DIR/$tdir
1479 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1480 local mfacet=mds$((mdtidx + 1))
1481 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1483 local OST=$(ostname_from_index $OSTIDX)
1486 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1487 local last_id=$(do_facet $mfacet lctl get_param -n \
1488 osc.$mdtosc_proc1.prealloc_last_id)
1489 local next_id=$(do_facet $mfacet lctl get_param -n \
1490 osc.$mdtosc_proc1.prealloc_next_id)
1492 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1493 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1495 test_mkdir -p $DIR/$tdir/${OST}
1496 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1497 #define OBD_FAIL_OST_ENOSPC 0x215
1498 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1499 echo "Creating to objid $last_id on ost $OST..."
1500 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1501 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1502 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1506 exhaust_all_precreations() {
1508 for (( i=0; i < OSTCOUNT; i++ )) ; do
1509 exhaust_precreations $i $1 -1
1514 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1516 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1517 remote_ost_nodsh && skip "remote OST with nodsh" && return
1520 rm -f $DIR/$tdir/$tfile
1521 exhaust_precreations 0 0x80000215
1522 $SETSTRIPE -c -1 $DIR/$tdir
1523 touch $DIR/$tdir/$tfile || error
1524 $GETSTRIPE $DIR/$tdir/$tfile
1527 run_test 27n "create file with some full OSTs =================="
1530 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1532 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1533 remote_ost_nodsh && skip "remote OST with nodsh" && return
1536 rm -f $DIR/$tdir/$tfile
1537 exhaust_all_precreations 0x215
1539 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1544 run_test 27o "create file with all full OSTs (should error) ===="
1547 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1550 remote_ost_nodsh && skip "remote OST with nodsh" && return
1553 rm -f $DIR/$tdir/$tfile
1554 test_mkdir -p $DIR/$tdir
1556 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1557 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1558 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1560 exhaust_precreations 0 0x80000215
1561 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1562 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1563 $GETSTRIPE $DIR/$tdir/$tfile
1567 run_test 27p "append to a truncated file with some full OSTs ==="
1570 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1572 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1573 remote_ost_nodsh && skip "remote OST with nodsh" && return
1576 rm -f $DIR/$tdir/$tfile
1578 test_mkdir -p $DIR/$tdir
1579 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1580 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1581 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1583 exhaust_all_precreations 0x215
1585 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1586 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1590 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1593 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1595 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1596 remote_ost_nodsh && skip "remote OST with nodsh" && return
1599 rm -f $DIR/$tdir/$tfile
1600 exhaust_precreations 0 0x80000215
1602 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1606 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1608 test_27s() { # bug 10725
1609 test_mkdir -p $DIR/$tdir
1610 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1611 local stripe_count=0
1612 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1613 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1614 error "stripe width >= 2^32 succeeded" || true
1617 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1619 test_27t() { # bug 10864
1624 $WLFS getstripe $tfile
1627 run_test 27t "check that utils parse path correctly"
1629 test_27u() { # bug 4900
1630 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1631 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1633 local list=$(comma_list $(mdts_nodes))
1635 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1636 do_nodes $list $LCTL set_param fail_loc=0x139
1637 test_mkdir -p $DIR/$tdir
1639 createmany -o $DIR/$tdir/t- 1000
1640 do_nodes $list $LCTL set_param fail_loc=0
1642 TLOG=$DIR/$tfile.getstripe
1643 $GETSTRIPE $DIR/$tdir > $TLOG
1644 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1645 unlinkmany $DIR/$tdir/t- 1000
1646 [[ $OBJS -gt 0 ]] &&
1647 error "$OBJS objects created on OST-0. See $TLOG" || pass
1649 run_test 27u "skip object creation on OSC w/o objects =========="
1651 test_27v() { # bug 4900
1652 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1654 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1655 remote_ost_nodsh && skip "remote OST with nodsh" && return
1657 exhaust_all_precreations 0x215
1660 test_mkdir -p $DIR/$tdir
1661 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1663 touch $DIR/$tdir/$tfile
1664 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1666 for (( i=1; i < OSTCOUNT; i++ )); do
1667 do_facet ost$i lctl set_param fail_loc=0x705
1669 local START=`date +%s`
1670 createmany -o $DIR/$tdir/$tfile 32
1672 local FINISH=`date +%s`
1673 local TIMEOUT=`lctl get_param -n timeout`
1674 local PROCESS=$((FINISH - START))
1675 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1676 error "$FINISH - $START >= $TIMEOUT / 2"
1677 sleep $((TIMEOUT / 2 - PROCESS))
1680 run_test 27v "skip object creation on slow OST ================="
1682 test_27w() { # bug 10997
1683 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1684 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1685 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1686 error "stripe size $size != 65536" || true
1687 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1688 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1690 run_test 27w "check $SETSTRIPE -S option"
1693 [[ $OSTCOUNT -lt 2 ]] &&
1694 skip_env "skipping multiple stripe count/offset test" && return
1696 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1697 for i in $(seq 1 $OSTCOUNT); do
1699 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1700 error "setstripe -c $i -i $offset failed"
1701 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1702 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1703 [ $count -ne $i ] && error "stripe count $count != $i" || true
1704 [ $index -ne $offset ] &&
1705 error "stripe offset $index != $offset" || true
1708 run_test 27wa "check $SETSTRIPE -c -i options"
1711 remote_ost_nodsh && skip "remote OST with nodsh" && return
1712 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1714 OFFSET=$(($OSTCOUNT - 1))
1716 local OST=$(ostname_from_index $OSTIDX)
1718 test_mkdir -p $DIR/$tdir
1719 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1720 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1722 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1723 for i in `seq 0 $OFFSET`; do
1724 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1725 error "OST0 was degraded but new created file still use it"
1727 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1729 run_test 27x "create files while OST0 is degraded"
1732 [[ $OSTCOUNT -lt 2 ]] &&
1733 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1735 remote_ost_nodsh && skip "remote OST with nodsh" && return
1736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1738 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1739 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1740 osc.$mdtosc.prealloc_last_id)
1741 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1742 osc.$mdtosc.prealloc_next_id)
1743 local fcount=$((last_id - next_id))
1744 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1745 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1747 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1748 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1749 local OST_DEACTIVE_IDX=-1
1754 for OSC in $MDS_OSCS; do
1755 OST=$(osc_to_ost $OSC)
1756 OSTIDX=$(index_from_ostuuid $OST)
1757 if [ $OST_DEACTIVE_IDX == -1 ]; then
1758 OST_DEACTIVE_IDX=$OSTIDX
1760 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1761 echo $OSC "is Deactivated:"
1762 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1766 OSTIDX=$(index_from_ostuuid $OST)
1767 test_mkdir -p $DIR/$tdir
1768 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1770 for OSC in $MDS_OSCS; do
1771 OST=$(osc_to_ost $OSC)
1772 OSTIDX=$(index_from_ostuuid $OST)
1773 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1774 echo $OST "is degraded:"
1775 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1776 obdfilter.$OST.degraded=1
1781 createmany -o $DIR/$tdir/$tfile $fcount
1783 for OSC in $MDS_OSCS; do
1784 OST=$(osc_to_ost $OSC)
1785 OSTIDX=$(index_from_ostuuid $OST)
1786 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1787 echo $OST "is recovered from degraded:"
1788 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1789 obdfilter.$OST.degraded=0
1791 do_facet $SINGLEMDS lctl --device %$OSC activate
1795 # all osp devices get activated, hence -1 stripe count restored
1798 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1799 # devices get activated.
1801 $SETSTRIPE -c -1 $DIR/$tfile
1802 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1804 [ $stripecnt -ne $OSTCOUNT ] &&
1805 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1808 run_test 27y "create files while OST0 is degraded and the rest inactive"
1814 lmm_count=$($GETSTRIPE -c $1)
1815 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1816 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1818 local old_ifs="$IFS"
1820 fid=($($LFS path2fid $1))
1823 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1824 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1826 # compare lmm_seq and lu_fid->f_seq
1827 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1828 # compare lmm_object_id and lu_fid->oid
1829 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1831 # check the trusted.fid attribute of the OST objects of the file
1832 local have_obdidx=false
1834 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1835 # skip lines up to and including "obdidx"
1836 [ -z "$obdidx" ] && break
1837 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1838 $have_obdidx || continue
1840 local ost=$((obdidx + 1))
1841 local dev=$(ostdevname $ost)
1844 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1846 seq=$(echo $seq | sed -e "s/^0x//g")
1847 if [ $seq == 0 ]; then
1848 oid_hex=$(echo $oid)
1850 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1852 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1856 # Don't unmount/remount the OSTs if we don't need to do that.
1857 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1858 # update too, until that use mount/ll_decode_filter_fid/mount.
1859 # Re-enable when debugfs will understand new filter_fid.
1861 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1862 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1863 $dev 2>/dev/null" | grep "parent=")
1866 mount_fstype ost$ost
1867 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1868 $(facet_mntpt ost$ost)/$obj_file)
1869 unmount_fstype ost$ost
1870 start ost$ost $dev $OST_MOUNT_OPTS
1873 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1875 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1877 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1878 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1879 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1880 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1881 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1883 if echo $ff_parent | grep -q 'stripe='; then
1884 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1887 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1888 # into f_ver in this case. See the comment on
1891 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1895 # compare lmm_seq and filter_fid->ff_parent.f_seq
1896 [ $ff_pseq = $lmm_seq ] ||
1897 error "FF parent SEQ $ff_pseq != $lmm_seq"
1898 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1899 [ $ff_poid = $lmm_oid ] ||
1900 error "FF parent OID $ff_poid != $lmm_oid"
1901 (($ff_pstripe == $stripe_nr)) ||
1902 error "FF stripe $ff_pstripe != $stripe_nr"
1904 stripe_nr=$((stripe_nr + 1))
1909 remote_ost_nodsh && skip "remote OST with nodsh" && return
1910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1911 test_mkdir -p $DIR/$tdir
1913 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1914 { error "setstripe -c -1 failed"; return 1; }
1915 # We need to send a write to every object to get parent FID info set.
1916 # This _should_ also work for setattr, but does not currently.
1917 # touch $DIR/$tdir/$tfile-1 ||
1918 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1919 { error "dd $tfile-1 failed"; return 2; }
1920 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1921 { error "setstripe -c -1 failed"; return 3; }
1922 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1923 { error "dd $tfile-2 failed"; return 4; }
1925 # make sure write RPCs have been sent to OSTs
1928 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1929 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1931 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1933 test_27A() { # b=19102
1934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1935 local restore_size=$($GETSTRIPE -S $MOUNT)
1936 local restore_count=$($GETSTRIPE -c $MOUNT)
1937 local restore_offset=$($GETSTRIPE -i $MOUNT)
1938 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1939 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1940 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1941 local default_size=$($GETSTRIPE -S $MOUNT)
1942 local default_offset=$($GETSTRIPE -i $MOUNT)
1943 local dsize=$((1024 * 1024))
1944 [ $default_size -eq $dsize ] ||
1945 error "stripe size $default_size != $dsize"
1946 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1947 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1949 run_test 27A "check filesystem-wide default LOV EA values"
1951 test_27B() { # LU-2523
1952 test_mkdir -p $DIR/$tdir
1953 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1955 # open f1 with O_LOV_DELAY_CREATE
1957 # call setstripe ioctl on open file descriptor for f1
1959 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1963 # open f1 with O_LOV_DELAY_CREATE
1965 # call setstripe ioctl on open file descriptor for f1
1967 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1969 # Allow multiop to fail in imitation of NFS's busted semantics.
1972 run_test 27B "call setstripe on open unlinked file/rename victim"
1974 test_27C() { #LU-2871
1975 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1983 test_mkdir -p $DIR/$tdir
1985 for i in $(seq 0 $((OSTCOUNT - 1))); do
1986 # set stripe across all OSTs starting from OST$i
1987 $SETSTRIPE -i $i -c -1 $tfile$i
1988 # get striping information
1989 ost_idx=($($GETSTRIPE $tfile$i |
1990 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1994 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1995 error "${#ost_idx[@]} != $OSTCOUNT"
1997 for index in $(seq 0 $((OSTCOUNT - 1))); do
1999 for j in $(echo ${ost_idx[@]}); do
2000 if [ $index -eq $j ]; then
2006 error "Can not find $index in ${ost_idx[@]}"
2010 run_test 27C "check full striping across all OSTs"
2013 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2014 local POOL=${POOL:-testpool}
2016 local last_ost=$(($OSTCOUNT - 1))
2018 local ost_list=$(seq $first_ost $ost_step $last_ost)
2019 local ost_range="$first_ost $last_ost $ost_step"
2021 test_mkdir -p $DIR/$tdir
2022 pool_add $POOL || error "pool_add failed"
2023 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2024 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2025 error "llapi_layout_test failed"
2026 cleanup_pools || error "cleanup_pools failed"
2028 run_test 27D "validate llapi_layout API"
2030 # Verify that default_easize is increased from its initial value after
2031 # accessing a widely striped file.
2033 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2035 # 72 bytes is the minimum space required to store striping
2036 # information for a file striped across one OST:
2037 # (sizeof(struct lov_user_md_v3) +
2038 # sizeof(struct lov_user_ost_data_v1))
2040 $LCTL set_param -n llite.*.default_easize $min_easize ||
2041 error "lctl set_param failed"
2042 local easize=$($LCTL get_param -n llite.*.default_easize)
2044 [ $easize -eq $min_easize ] ||
2045 error "failed to set default_easize"
2047 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2048 error "setstripe failed"
2052 easize=$($LCTL get_param -n llite.*.default_easize)
2054 [ $easize -gt $min_easize ] ||
2055 error "default_easize not updated"
2057 run_test 27E "check that default extended attribute size properly increases"
2059 # createtest also checks that device nodes are created and
2060 # then visible correctly (#2091)
2061 test_28() { # bug 2091
2063 $CREATETEST $DIR/d28/ct || error
2065 run_test 28 "create/mknod/mkdir with bad file types ============"
2068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2069 cancel_lru_locks mdc
2075 declare -i LOCKCOUNTORIG=0
2076 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2077 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2079 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2081 declare -i LOCKUNUSEDCOUNTORIG=0
2082 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2083 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2090 declare -i LOCKCOUNTCURRENT=0
2091 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2092 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2095 declare -i LOCKUNUSEDCOUNTCURRENT=0
2096 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2097 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2100 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2101 $LCTL set_param -n ldlm.dump_namespaces ""
2102 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2103 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2104 log "dumped log to $TMP/test_29.dk (bug 5793)"
2107 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2108 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2109 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2110 log "dumped log to $TMP/test_29.dk (bug 5793)"
2114 run_test 29 "IT_GETATTR regression ============================"
2116 test_30a() { # was test_30
2117 cp $(which ls) $DIR || cp /bin/ls $DIR
2121 run_test 30a "execute binary from Lustre (execve) =============="
2124 cp `which ls` $DIR || cp /bin/ls $DIR
2126 $RUNAS $DIR/ls / || error
2129 run_test 30b "execute binary from Lustre as non-root ==========="
2131 test_30c() { # b=22376
2132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2133 cp `which ls` $DIR || cp /bin/ls $DIR
2135 cancel_lru_locks mdc
2136 cancel_lru_locks osc
2137 $RUNAS $DIR/ls / || error
2140 run_test 30c "execute binary from Lustre without read perms ===="
2143 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2144 $CHECKSTAT -a $DIR/f31 || error
2146 run_test 31a "open-unlink file =================================="
2149 touch $DIR/f31 || error
2150 ln $DIR/f31 $DIR/f31b || error
2151 $MULTIOP $DIR/f31b Ouc || error
2152 $CHECKSTAT -t file $DIR/f31 || error
2154 run_test 31b "unlink file with multiple links while open ======="
2157 touch $DIR/f31 || error
2158 ln $DIR/f31 $DIR/f31c || error
2159 multiop_bg_pause $DIR/f31 O_uc || return 1
2161 $MULTIOP $DIR/f31c Ouc
2162 kill -USR1 $MULTIPID
2165 run_test 31c "open-unlink file with multiple links ============="
2168 opendirunlink $DIR/d31d $DIR/d31d || error
2169 $CHECKSTAT -a $DIR/d31d || error
2171 run_test 31d "remove of open directory ========================="
2173 test_31e() { # bug 2904
2174 openfilleddirunlink $DIR/d31e || error
2176 run_test 31e "remove of open non-empty directory ==============="
2178 test_31f() { # bug 4554
2179 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2181 test_mkdir $DIR/d31f
2182 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2183 cp /etc/hosts $DIR/d31f
2185 $GETSTRIPE $DIR/d31f/hosts
2186 multiop_bg_pause $DIR/d31f D_c || return 1
2189 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2190 test_mkdir $DIR/d31f
2191 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2192 cp /etc/hosts $DIR/d31f
2194 $GETSTRIPE $DIR/d31f/hosts
2195 multiop_bg_pause $DIR/d31f D_c || return 1
2198 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2199 wait $MULTIPID || error "first opendir $MULTIPID failed"
2203 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2204 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2207 run_test 31f "remove of open directory with open-unlink file ==="
2210 echo "-- cross directory link --"
2211 test_mkdir -c1 $DIR/${tdir}ga
2212 test_mkdir -c1 $DIR/${tdir}gb
2213 touch $DIR/${tdir}ga/f
2214 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2215 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2216 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2217 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2218 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2220 run_test 31g "cross directory link==============="
2223 echo "-- cross directory link --"
2224 test_mkdir -c1 $DIR/${tdir}
2225 test_mkdir -c1 $DIR/${tdir}/dir
2226 touch $DIR/${tdir}/f
2227 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2228 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2229 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2230 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2231 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2233 run_test 31h "cross directory link under child==============="
2236 echo "-- cross directory link --"
2237 test_mkdir -c1 $DIR/$tdir
2238 test_mkdir -c1 $DIR/$tdir/dir
2239 touch $DIR/$tdir/dir/f
2240 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2241 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2242 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2243 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2244 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2246 run_test 31i "cross directory link under parent==============="
2249 test_mkdir -c1 -p $DIR/$tdir
2250 test_mkdir -c1 -p $DIR/$tdir/dir1
2251 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2252 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2253 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2254 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2257 run_test 31j "link for directory==============="
2260 test_mkdir -c1 -p $DIR/$tdir
2262 touch $DIR/$tdir/exist
2263 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2264 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2265 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2266 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2267 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2268 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2269 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2272 run_test 31k "link to file: the same, non-existing, dir==============="
2278 touch $DIR/d31m2/exist
2279 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2280 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2281 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2282 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2283 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2284 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2287 run_test 31m "link to file: the same, non-existing, dir==============="
2290 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2291 nlink=$(stat --format=%h $DIR/$tfile)
2292 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2294 local cmd="exec $fd<$DIR/$tfile"
2297 trap "eval $cmd" EXIT
2298 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2299 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2300 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2301 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2302 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2305 run_test 31n "check link count of unlinked file"
2308 local TEMPNAME=$(mktemp $1_XXXXXX)
2309 mlink $TEMPNAME $1 2> /dev/null &&
2310 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2314 test_31o() { # LU-2901
2315 test_mkdir -p $DIR/$tdir
2316 for LOOP in $(seq 100); do
2317 rm -f $DIR/$tdir/$tfile*
2318 for THREAD in $(seq 8); do
2319 link_one $DIR/$tdir/$tfile.$LOOP &
2322 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2323 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2324 error "$LINKS duplicate links to $tfile.$LOOP" &&
2328 run_test 31o "duplicate hard links with same filename"
2331 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2333 test_mkdir $DIR/$tdir
2334 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2335 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2337 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2338 error "open unlink test1 failed"
2339 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2340 error "open unlink test2 failed"
2342 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2343 error "test1 still exists"
2344 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2345 error "test2 still exists"
2347 run_test 31p "remove of open striped directory"
2349 cleanup_test32_mount() {
2351 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2356 echo "== more mountpoints and symlinks ================="
2357 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2358 trap cleanup_test32_mount EXIT
2359 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2360 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2361 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2362 cleanup_test32_mount
2364 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2368 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2369 trap cleanup_test32_mount EXIT
2370 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2371 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2372 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2373 cleanup_test32_mount
2375 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2379 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2380 trap cleanup_test32_mount EXIT
2381 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2382 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2383 test_mkdir -p $DIR/$tdir/d2/test_dir
2384 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2385 cleanup_test32_mount
2387 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2391 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2392 trap cleanup_test32_mount EXIT
2393 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2394 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2395 test_mkdir -p $DIR/$tdir/d2/test_dir
2396 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2397 cleanup_test32_mount
2399 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2402 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2403 test_mkdir -p $DIR/d32e/tmp
2404 TMP_DIR=$DIR/d32e/tmp
2405 ln -s $DIR/d32e $TMP_DIR/symlink11
2406 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2407 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2408 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2410 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2413 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2414 test_mkdir -p $DIR/d32f/tmp
2415 TMP_DIR=$DIR/d32f/tmp
2416 ln -s $DIR/d32f $TMP_DIR/symlink11
2417 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2418 ls $DIR/d32f/tmp/symlink11 || error
2419 ls $DIR/d32f/symlink01 || error
2421 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2424 TMP_DIR=$DIR/$tdir/tmp
2425 test_mkdir -p $DIR/$tdir/tmp
2426 test_mkdir $DIR/${tdir}2
2427 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2428 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2429 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2430 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2431 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2432 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2434 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2437 rm -fr $DIR/$tdir $DIR/${tdir}2
2438 TMP_DIR=$DIR/$tdir/tmp
2439 test_mkdir -p $DIR/$tdir/tmp
2440 test_mkdir $DIR/${tdir}2
2441 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2442 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2443 ls $TMP_DIR/symlink12 || error
2444 ls $DIR/$tdir/symlink02 || error
2446 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2449 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2450 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2451 trap cleanup_test32_mount EXIT
2452 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2453 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2454 touch $DIR/$tdir/test_file
2455 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2456 cleanup_test32_mount
2458 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2462 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2463 trap cleanup_test32_mount EXIT
2464 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2465 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2466 touch $DIR/$tdir/test_file
2467 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2468 cleanup_test32_mount
2470 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2473 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2475 trap cleanup_test32_mount EXIT
2476 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2477 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2478 test_mkdir -p $DIR/$tdir/d2
2479 touch $DIR/$tdir/d2/test_file || error
2480 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2481 cleanup_test32_mount
2483 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2488 trap cleanup_test32_mount EXIT
2489 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2490 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2491 test_mkdir -p $DIR/$tdir/d2
2492 touch $DIR/$tdir/d2/test_file
2493 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2494 cleanup_test32_mount
2496 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2500 test_mkdir -p $DIR/d32m/tmp
2501 TMP_DIR=$DIR/d32m/tmp
2502 ln -s $DIR $TMP_DIR/symlink11
2503 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2504 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2505 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2507 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2511 test_mkdir -p $DIR/d32n/tmp
2512 TMP_DIR=$DIR/d32n/tmp
2513 ln -s $DIR $TMP_DIR/symlink11
2514 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2515 ls -l $DIR/d32n/tmp/symlink11 || error
2516 ls -l $DIR/d32n/symlink01 || error
2518 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2522 test_mkdir -p $DIR/d32o/tmp
2523 TMP_DIR=$DIR/d32o/tmp
2524 ln -s $DIR/$tfile $TMP_DIR/symlink12
2525 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2526 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2527 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2528 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2529 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2531 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2541 test_mkdir -p $DIR/d32p/tmp
2543 TMP_DIR=$DIR/d32p/tmp
2545 ln -s $DIR/$tfile $TMP_DIR/symlink12
2547 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2549 cat $DIR/d32p/tmp/symlink12 || error
2551 cat $DIR/d32p/symlink02 || error
2554 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2556 cleanup_testdir_mount() {
2558 $UMOUNT -d $DIR/$tdir
2562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2563 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2564 trap cleanup_testdir_mount EXIT
2565 test_mkdir -p $DIR/$tdir
2566 touch $DIR/$tdir/under_the_mount
2567 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2568 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2569 cleanup_testdir_mount
2571 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2575 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2576 trap cleanup_testdir_mount EXIT
2577 test_mkdir -p $DIR/$tdir
2578 touch $DIR/$tdir/under_the_mount
2579 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2580 ls $DIR/$tdir | grep -q under_the_mount && error || true
2581 cleanup_testdir_mount
2583 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2588 chmod 444 $DIR/$tfile
2589 chown $RUNAS_ID $DIR/$tfile
2591 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2594 run_test 33aa "write file with mode 444 (should return error) ===="
2598 test_mkdir -p $DIR/d33
2599 chown $RUNAS_ID $DIR/d33
2600 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2601 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2602 error "open RDWR" || true
2604 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2608 test_mkdir -p $DIR/d33
2609 chown $RUNAS_ID $DIR/d33
2610 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2612 run_test 33b "test open file with malformed flags (No panic)"
2615 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2621 remote_ost_nodsh && skip "remote OST with nodsh" && return
2624 test_mkdir -p $DIR/d33
2625 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2628 for ostnum in $(seq $OSTCOUNT); do
2629 # test-framework's OST numbering is one-based, while Lustre's
2631 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2632 # Parsing llobdstat's output sucks; we could grep the /proc
2633 # path, but that's likely to not be as portable as using the
2634 # llobdstat utility. So we parse lctl output instead.
2635 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2636 obdfilter/$ostname/stats |
2637 awk '/^write_bytes/ {print $7}' )
2638 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2639 if (( ${write_bytes:-0} > 0 ))
2646 $all_zeros || return 0
2649 echo foo > $DIR/d33/bar
2653 # Total up write_bytes after writing. We'd better find non-zeros.
2654 for ostnum in $(seq $OSTCOUNT); do
2655 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2656 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2657 obdfilter/$ostname/stats |
2658 awk '/^write_bytes/ {print $7}' )
2659 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2660 if (( ${write_bytes:-0} > 0 ))
2669 for ostnum in $(seq $OSTCOUNT); do
2670 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2671 echo "Check that write_bytes is present in obdfilter/*/stats:"
2672 do_facet ost$ostnum lctl get_param -n \
2673 obdfilter/$ostname/stats
2675 error "OST not keeping write_bytes stats (b22312)"
2678 run_test 33c "test llobdstat and write_bytes"
2681 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2684 local remote_dir=$DIR/$tdir/remote_dir
2686 test_mkdir -p $DIR/$tdir
2687 $LFS mkdir -i $MDTIDX $remote_dir ||
2688 error "create remote directory failed"
2690 touch $remote_dir/$tfile
2691 chmod 444 $remote_dir/$tfile
2692 chown $RUNAS_ID $remote_dir/$tfile
2694 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2696 chown $RUNAS_ID $remote_dir
2697 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2698 error "create" || true
2699 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2700 error "open RDWR" || true
2701 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2702 error "create" || true
2704 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2707 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2711 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2712 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2713 mkdir $DIR/$tdir/local_dir
2715 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2716 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2717 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2719 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2720 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2722 rmdir $DIR/$tdir/* || error "rmdir failed"
2725 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2726 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2727 mkdir $DIR/$tdir/local_dir
2729 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2730 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2731 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2733 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2734 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2736 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2739 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2740 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2741 mkdir $DIR/$tdir/local_dir
2743 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2744 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2745 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2747 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2748 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2750 run_test 33e "mkdir and striped directory should have same mode"
2754 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2758 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2761 chmod go+rwx $DIR/$tdir
2762 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2763 trap cleanup_33f EXIT
2765 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2766 error "cannot create striped directory"
2768 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2769 error "cannot create files in striped directory"
2771 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2772 error "cannot remove files in striped directory"
2774 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2775 error "cannot remove striped directory"
2779 run_test 33f "nonroot user can create, access, and remove a striped directory"
2781 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2784 $MCREATE $DIR/f34 || error
2785 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2786 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2787 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2788 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2790 run_test 34a "truncate file that has not been opened ==========="
2793 [ ! -f $DIR/f34 ] && test_34a
2794 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2795 $OPENFILE -f O_RDONLY $DIR/f34
2796 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2797 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2799 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2802 [ ! -f $DIR/f34 ] && test_34a
2803 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2804 $OPENFILE -f O_RDWR $DIR/f34
2805 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2806 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2808 run_test 34c "O_RDWR opening file-with-size works =============="
2811 [ ! -f $DIR/f34 ] && test_34a
2812 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2813 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2816 run_test 34d "write to sparse file ============================="
2820 $MCREATE $DIR/f34e || error
2821 $TRUNCATE $DIR/f34e 1000 || error
2822 $CHECKSTAT -s 1000 $DIR/f34e || error
2823 $OPENFILE -f O_RDWR $DIR/f34e
2824 $CHECKSTAT -s 1000 $DIR/f34e || error
2826 run_test 34e "create objects, some with size and some without =="
2828 test_34f() { # bug 6242, 6243
2829 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2832 $MCREATE $DIR/f34f || error
2833 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2834 dd if=$DIR/f34f of=$TMP/f34f
2835 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2836 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2837 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2838 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2839 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2841 run_test 34f "read from a file with no objects until EOF ======="
2844 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2845 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2846 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2847 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2848 cancel_lru_locks osc
2849 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2850 error "wrong size after lock cancel"
2852 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2853 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2854 error "expanding truncate failed"
2855 cancel_lru_locks osc
2856 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2857 error "wrong expanded size after lock cancel"
2859 run_test 34g "truncate long file ==============================="
2862 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2866 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2867 sync # Flush the cache so that multiop below does not block on cache
2868 # flush when getting the group lock
2869 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2872 # Since just timed wait is not good enough, let's do a sync write
2873 # that way we are sure enough time for a roundtrip + processing
2874 # passed + 2 seconds of extra margin.
2875 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2879 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2880 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2884 local nsz=`stat -c %s $DIR/$tfile`
2885 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2887 run_test 34h "ftruncate file under grouplock should not block"
2890 cp /bin/sh $DIR/f35a
2892 chown $RUNAS_ID $DIR/f35a
2893 $RUNAS $DIR/f35a && error || true
2896 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2900 utime $DIR/f36 || error
2902 run_test 36a "MDS utime check (mknod, utime) ==================="
2906 utime $DIR/f36 || error
2908 run_test 36b "OST utime check (open, utime) ===================="
2913 chown $RUNAS_ID $DIR/d36
2914 $RUNAS utime $DIR/d36/f36 || error
2916 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2919 [ ! -d $DIR/d36 ] && test_36c
2920 echo "" > $DIR/d36/f36
2921 $RUNAS utime $DIR/d36/f36 || error
2923 run_test 36d "non-root OST utime check (open, utime) ==========="
2926 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2927 test_mkdir -p $DIR/$tdir
2928 touch $DIR/$tdir/$tfile
2929 $RUNAS utime $DIR/$tdir/$tfile && \
2930 error "utime worked, expected failure" || true
2932 run_test 36e "utime on non-owned file (should return error) ===="
2936 local LANG_SAVE=$LANG
2937 local LC_LANG_SAVE=$LC_LANG
2938 export LANG=C LC_LANG=C # for date language
2940 DATESTR="Dec 20 2000"
2941 test_mkdir -p $DIR/$tdir
2942 lctl set_param fail_loc=$fl
2944 cp /etc/hosts $DIR/$tdir/$tfile
2945 sync & # write RPC generated with "current" inode timestamp, but delayed
2947 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2948 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2949 cancel_lru_locks osc
2950 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2952 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2953 echo "BEFORE: $LS_BEFORE" && \
2954 echo "AFTER : $LS_AFTER" && \
2955 echo "WANT : $DATESTR" && \
2956 error "$DIR/$tdir/$tfile timestamps changed" || true
2958 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2963 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2964 subr_36fh "0x80000214"
2966 run_test 36f "utime on file racing with OST BRW write =========="
2969 remote_ost_nodsh && skip "remote OST with nodsh" && return
2970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2975 test_mkdir -p $DIR/$tdir
2976 fmd_max_age=$(do_facet ost1 \
2977 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2980 fmd_before=$(do_facet ost1 \
2981 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2982 touch $DIR/$tdir/$tfile
2983 sleep $((fmd_max_age + 12))
2984 fmd_after=$(do_facet ost1 \
2985 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2987 echo "fmd_before: $fmd_before"
2988 echo "fmd_after: $fmd_after"
2989 [[ $fmd_after -gt $fmd_before ]] &&
2990 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2991 error "fmd didn't expire after ping" || true
2993 run_test 36g "filter mod data cache expiry ====================="
2996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2997 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2998 subr_36fh "0x80000227"
3000 run_test 36h "utime on file racing with OST BRW write =========="
3003 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3005 test_mkdir $DIR/$tdir
3006 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3008 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3009 local new_mtime=$((mtime + 200))
3011 #change Modify time of striped dir
3012 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3013 error "change mtime failed"
3015 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3017 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3019 run_test 36i "change mtime on striped directory"
3021 # test_37 - duplicate with tests 32q 32r
3024 local file=$DIR/$tfile
3026 openfile -f O_DIRECTORY $file
3029 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3030 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3032 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3036 touch $DIR/${tfile}2
3037 # ls -l $DIR/$tfile $DIR/${tfile}2
3038 # ls -lu $DIR/$tfile $DIR/${tfile}2
3039 # ls -lc $DIR/$tfile $DIR/${tfile}2
3041 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3042 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3044 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3046 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3048 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3049 error "O_TRUNC didn't change timestamps"
3052 run_test 39 "mtime changed on create ==========================="
3055 test_mkdir -p -c1 $DIR/$tdir
3056 cp -p /etc/passwd $DIR/$tdir/fopen
3057 cp -p /etc/passwd $DIR/$tdir/flink
3058 cp -p /etc/passwd $DIR/$tdir/funlink
3059 cp -p /etc/passwd $DIR/$tdir/frename
3060 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3063 echo "aaaaaa" >> $DIR/$tdir/fopen
3064 echo "aaaaaa" >> $DIR/$tdir/flink
3065 echo "aaaaaa" >> $DIR/$tdir/funlink
3066 echo "aaaaaa" >> $DIR/$tdir/frename
3068 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3069 local link_new=`stat -c %Y $DIR/$tdir/flink`
3070 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3071 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3073 cat $DIR/$tdir/fopen > /dev/null
3074 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3075 rm -f $DIR/$tdir/funlink2
3076 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3078 for (( i=0; i < 2; i++ )) ; do
3079 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3080 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3081 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3082 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3084 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3085 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3086 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3087 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3089 cancel_lru_locks osc
3090 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3093 run_test 39b "mtime change on open, link, unlink, rename ======"
3095 # this should be set to past
3096 TEST_39_MTIME=`date -d "1 year ago" +%s`
3102 local mtime0=`stat -c %Y $DIR1/$tfile`
3104 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3105 local mtime1=`stat -c %Y $DIR1/$tfile`
3106 [ "$mtime1" = $TEST_39_MTIME ] || \
3107 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3110 echo hello >> $DIR1/$tfile
3112 local mtime2=`stat -c %Y $DIR1/$tfile`
3113 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3114 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3116 mv $DIR1/$tfile $DIR1/$tfile-1
3118 for (( i=0; i < 2; i++ )) ; do
3119 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3120 [ "$mtime2" = "$mtime3" ] || \
3121 error "mtime ($mtime2) changed (to $mtime3) on rename"
3123 cancel_lru_locks osc
3124 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3127 run_test 39c "mtime change on rename ==========================="
3131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3134 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3136 for (( i=0; i < 2; i++ )) ; do
3137 local mtime=`stat -c %Y $DIR1/$tfile`
3138 [ $mtime = $TEST_39_MTIME ] || \
3139 error "mtime($mtime) is not set to $TEST_39_MTIME"
3141 cancel_lru_locks osc
3142 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3145 run_test 39d "create, utime, stat =============================="
3149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3151 local mtime1=`stat -c %Y $DIR1/$tfile`
3153 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3155 for (( i=0; i < 2; i++ )) ; do
3156 local mtime2=`stat -c %Y $DIR1/$tfile`
3157 [ $mtime2 = $TEST_39_MTIME ] || \
3158 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3160 cancel_lru_locks osc
3161 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3164 run_test 39e "create, stat, utime, stat ========================"
3168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3170 mtime1=`stat -c %Y $DIR1/$tfile`
3173 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3175 for (( i=0; i < 2; i++ )) ; do
3176 local mtime2=`stat -c %Y $DIR1/$tfile`
3177 [ $mtime2 = $TEST_39_MTIME ] || \
3178 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3180 cancel_lru_locks osc
3181 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3184 run_test 39f "create, stat, sleep, utime, stat ================="
3188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3189 echo hello >> $DIR1/$tfile
3190 local mtime1=`stat -c %Y $DIR1/$tfile`
3193 chmod o+r $DIR1/$tfile
3195 for (( i=0; i < 2; i++ )) ; do
3196 local mtime2=`stat -c %Y $DIR1/$tfile`
3197 [ "$mtime1" = "$mtime2" ] || \
3198 error "lost mtime: $mtime2, should be $mtime1"
3200 cancel_lru_locks osc
3201 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3204 run_test 39g "write, chmod, stat ==============================="
3208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3213 echo hello >> $DIR1/$tfile
3214 local mtime1=`stat -c %Y $DIR1/$tfile`
3216 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3218 if [ "$d1" != "$d2" ]; then
3219 echo "write and touch not within one second"
3221 for (( i=0; i < 2; i++ )) ; do
3222 local mtime2=`stat -c %Y $DIR1/$tfile`
3223 [ "$mtime2" = $TEST_39_MTIME ] || \
3224 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3226 cancel_lru_locks osc
3227 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3231 run_test 39h "write, utime within one second, stat ============="
3234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3238 echo hello >> $DIR1/$tfile
3239 local mtime1=`stat -c %Y $DIR1/$tfile`
3241 mv $DIR1/$tfile $DIR1/$tfile-1
3243 for (( i=0; i < 2; i++ )) ; do
3244 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3246 [ "$mtime1" = "$mtime2" ] || \
3247 error "lost mtime: $mtime2, should be $mtime1"
3249 cancel_lru_locks osc
3250 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3253 run_test 39i "write, rename, stat =============================="
3256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3257 start_full_debug_logging
3261 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3262 lctl set_param fail_loc=0x80000412
3263 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3264 error "multiop failed"
3266 local mtime1=`stat -c %Y $DIR1/$tfile`
3268 mv $DIR1/$tfile $DIR1/$tfile-1
3270 kill -USR1 $multipid
3271 wait $multipid || error "multiop close failed"
3273 for (( i=0; i < 2; i++ )) ; do
3274 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3275 [ "$mtime1" = "$mtime2" ] ||
3276 error "mtime is lost on close: $mtime2, " \
3279 cancel_lru_locks osc
3280 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3282 lctl set_param fail_loc=0
3283 stop_full_debug_logging
3285 run_test 39j "write, rename, close, stat ======================="
3288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3292 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3294 local mtime1=`stat -c %Y $DIR1/$tfile`
3296 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3298 kill -USR1 $multipid
3299 wait $multipid || error "multiop close failed"
3301 for (( i=0; i < 2; i++ )) ; do
3302 local mtime2=`stat -c %Y $DIR1/$tfile`
3304 [ "$mtime2" = $TEST_39_MTIME ] || \
3305 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3307 cancel_lru_locks osc
3308 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3311 run_test 39k "write, utime, close, stat ========================"
3313 # this should be set to future
3314 TEST_39_ATIME=`date -d "1 year" +%s`
3317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3318 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3319 local atime_diff=$(do_facet $SINGLEMDS \
3320 lctl get_param -n mdd.*MDT0000*.atime_diff)
3324 # test setting directory atime to future
3325 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3326 local atime=$(stat -c %X $DIR/$tdir)
3327 [ "$atime" = $TEST_39_ATIME ] || \
3328 error "atime is not set to future: $atime, $TEST_39_ATIME"
3330 # test setting directory atime from future to now
3331 local d1=$(date +%s)
3333 local d2=$(date +%s)
3335 cancel_lru_locks mdc
3336 atime=$(stat -c %X $DIR/$tdir)
3337 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3338 error "atime is not updated from future: $atime, $d1<atime<$d2"
3340 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3343 # test setting directory atime when now > dir atime + atime_diff
3347 cancel_lru_locks mdc
3348 atime=$(stat -c %X $DIR/$tdir)
3349 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3350 error "atime is not updated : $atime, should be $d2"
3352 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3355 # test not setting directory atime when now < dir atime + atime_diff
3357 cancel_lru_locks mdc
3358 atime=$(stat -c %X $DIR/$tdir)
3359 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3360 error "atime is updated to $atime, should remain $d1<atime<$d2"
3362 do_facet $SINGLEMDS \
3363 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3365 run_test 39l "directory atime update ==========================="
3368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3371 local far_past_mtime=$(date -d "May 29 1953" +%s)
3372 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3374 touch -m -d @$far_past_mtime $DIR1/$tfile
3375 touch -a -d @$far_past_atime $DIR1/$tfile
3377 for (( i=0; i < 2; i++ )) ; do
3378 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3379 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3380 error "atime or mtime set incorrectly"
3382 cancel_lru_locks osc
3383 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3386 run_test 39m "test atime and mtime before 1970"
3388 test_39n() { # LU-3832
3389 local atime_diff=$(do_facet $SINGLEMDS \
3390 lctl get_param -n mdd.*MDT0000*.atime_diff)
3395 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3398 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3399 atime0=$(stat -c %X $DIR/$tfile)
3402 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3403 atime1=$(stat -c %X $DIR/$tfile)
3406 cancel_lru_locks mdc
3407 cancel_lru_locks osc
3408 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3409 atime2=$(stat -c %X $DIR/$tfile)
3411 do_facet $SINGLEMDS \
3412 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3414 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3415 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3417 run_test 39n "check that O_NOATIME is honored"
3420 TESTDIR=$DIR/$tdir/$tfile
3421 [ -e $TESTDIR ] && rm -rf $TESTDIR
3428 links2=$(stat -c %h .)
3429 [ $(($links1 + 2)) != $links2 ] &&
3430 error "wrong links count $(($links1 + 2)) != $links2"
3432 links3=$(stat -c %h .)
3433 [ $(($links1 + 1)) != $links3 ] &&
3434 error "wrong links count $links1 != $links3"
3437 run_test 39o "directory cached attributes updated after create ========"
3440 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3442 TESTDIR=$DIR/$tdir/$tfile
3443 [ -e $TESTDIR ] && rm -rf $TESTDIR
3444 test_mkdir -p $TESTDIR
3448 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3449 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3451 links2=$(stat -c %h .)
3452 [ $(($links1 + 2)) != $links2 ] &&
3453 error "wrong links count $(($links1 + 2)) != $links2"
3455 links3=$(stat -c %h .)
3456 [ $(($links1 + 1)) != $links3 ] &&
3457 error "wrong links count $links1 != $links3"
3460 run_test 39p "remote directory cached attributes updated after create ========"
3464 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3465 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3466 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3467 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3468 error "$tfile is not 4096 bytes in size"
3470 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3474 small_write $DIR/f41 18
3476 run_test 41 "test small file write + fstat ====================="
3478 count_ost_writes() {
3479 lctl get_param -n osc.*.stats |
3480 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3481 END { printf("%0.0f", writes) }'
3488 BG_DIRTY_RATIO_SAVE=10
3489 MAX_BG_DIRTY_RATIO=25
3493 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3494 # dirty_ratio, dirty_background_ratio
3495 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3496 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3497 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3498 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3500 # if file not here, we are a 2.4 kernel
3501 kill -CONT `pidof kupdated`
3506 # setup the trap first, so someone cannot exit the test at the
3507 # exact wrong time and mess up a machine
3508 trap start_writeback EXIT
3509 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3510 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3511 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3512 sysctl -w vm.dirty_writeback_centisecs=0
3513 sysctl -w vm.dirty_writeback_centisecs=0
3514 # save and increase /proc/sys/vm/dirty_ratio
3515 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3516 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3517 # save and increase /proc/sys/vm/dirty_background_ratio
3518 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3519 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3521 # if file not here, we are a 2.4 kernel
3522 kill -STOP `pidof kupdated`
3526 # ensure that all stripes have some grant before we test client-side cache
3528 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3529 dd if=/dev/zero of=$i bs=4k count=1
3534 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3535 # file truncation, and file removal.
3537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3539 cancel_lru_locks osc
3541 sync; sleep 1; sync # just to be safe
3542 BEFOREWRITES=`count_ost_writes`
3543 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3544 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3545 AFTERWRITES=`count_ost_writes`
3546 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3547 error "$BEFOREWRITES < $AFTERWRITES"
3550 run_test 42a "ensure that we don't flush on close =============="
3553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3555 cancel_lru_locks osc
3558 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3559 BEFOREWRITES=$(count_ost_writes)
3560 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3561 AFTERWRITES=$(count_ost_writes)
3562 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3563 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3565 BEFOREWRITES=$(count_ost_writes)
3566 sync || error "sync: $?"
3567 AFTERWRITES=$(count_ost_writes)
3568 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3569 error "$BEFOREWRITES < $AFTERWRITES on sync"
3571 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3575 run_test 42b "test destroy of file with cached dirty data ======"
3577 # if these tests just want to test the effect of truncation,
3578 # they have to be very careful. consider:
3579 # - the first open gets a {0,EOF}PR lock
3580 # - the first write conflicts and gets a {0, count-1}PW
3581 # - the rest of the writes are under {count,EOF}PW
3582 # - the open for truncate tries to match a {0,EOF}PR
3583 # for the filesize and cancels the PWs.
3584 # any number of fixes (don't get {0,EOF} on open, match
3585 # composite locks, do smarter file size management) fix
3586 # this, but for now we want these tests to verify that
3587 # the cancellation with truncate intent works, so we
3588 # start the file with a full-file pw lock to match against
3589 # until the truncate.
3594 cancel_lru_locks osc
3596 # prime the file with 0,EOF PW to match
3600 # now the real test..
3601 dd if=/dev/zero of=$file bs=1024 count=100
3602 BEFOREWRITES=`count_ost_writes`
3603 $TRUNCATE $file $offset
3604 cancel_lru_locks osc
3605 AFTERWRITES=`count_ost_writes`
3610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3612 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3613 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3616 run_test 42c "test partial truncate of file with cached dirty data"
3619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3621 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3622 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3625 run_test 42d "test complete truncate of file with cached dirty data"
3627 test_42e() { # bug22074
3628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3629 local TDIR=$DIR/${tdir}e
3630 local pagesz=$(page_size)
3631 local pages=16 # hardcoded 16 pages, don't change it.
3632 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3633 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3637 test_mkdir -p $DIR/${tdir}e
3638 $SETSTRIPE -c 1 $TDIR
3639 createmany -o $TDIR/f $files
3641 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3643 # we assume that with $OSTCOUNT files, at least one of them will
3644 # be allocated on OST0.
3645 warmup_files=$((OSTCOUNT * max_dirty_mb))
3646 createmany -o $TDIR/w $warmup_files
3648 # write a large amount of data into one file and sync, to get good
3649 # avail_grant number from OST.
3650 for ((i=0; i<$warmup_files; i++)); do
3651 idx=$($GETSTRIPE -i $TDIR/w$i)
3652 [ $idx -ne 0 ] && continue
3653 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3656 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3658 $LCTL get_param $proc_osc0/cur_dirty_bytes
3659 $LCTL get_param $proc_osc0/cur_grant_bytes
3661 # create as much dirty pages as we can while not to trigger the actual
3662 # RPCs directly. but depends on the env, VFS may trigger flush during this
3663 # period, hopefully we are good.
3664 for ((i=0; i<$warmup_files; i++)); do
3665 idx=$($GETSTRIPE -i $TDIR/w$i)
3666 [ $idx -ne 0 ] && continue
3667 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3669 $LCTL get_param $proc_osc0/cur_dirty_bytes
3670 $LCTL get_param $proc_osc0/cur_grant_bytes
3672 # perform the real test
3673 $LCTL set_param $proc_osc0/rpc_stats 0
3674 for ((;i<$files; i++)); do
3675 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3676 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3679 $LCTL get_param $proc_osc0/rpc_stats
3682 local have_ppr=false
3683 $LCTL get_param $proc_osc0/rpc_stats |
3684 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3685 # skip lines until we are at the RPC histogram data
3686 [ "$PPR" == "pages" ] && have_ppr=true && continue
3687 $have_ppr || continue
3689 # we only want the percent stat for < 16 pages
3690 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3692 percent=$((percent + WPCT))
3693 if [[ $percent -gt 15 ]]; then
3694 error "less than 16-pages write RPCs" \
3701 run_test 42e "verify sub-RPC writes are not done synchronously"
3704 test_mkdir -p $DIR/$tdir
3705 cp -p /bin/ls $DIR/$tdir/$tfile
3706 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3708 # give multiop a chance to open
3711 $DIR/$tdir/$tfile && error || true
3714 run_test 43 "execution of file opened for write should return -ETXTBSY"
3717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3718 test_mkdir -p $DIR/$tdir
3719 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3720 cp -p multiop $DIR/$tdir/multiop
3721 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3724 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3725 kill -USR1 $MULTIOP_PID || return 2
3726 wait $MULTIOP_PID || return 3
3727 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3729 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3733 test_mkdir -p $DIR/$tdir
3734 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3735 cp -p multiop $DIR/$tdir/multiop
3736 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3739 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3740 kill -USR1 $MULTIOP_PID || return 2
3741 wait $MULTIOP_PID || return 3
3742 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3744 run_test 43b "truncate of file being executed should return -ETXTBSY"
3747 local testdir="$DIR/$tdir"
3748 test_mkdir -p $DIR/$tdir
3750 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3751 ( cd $testdir && md5sum -c)
3753 run_test 43c "md5sum of copy into lustre========================"
3756 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3757 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3758 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3760 run_test 44 "zero length read from a sparse stripe ============="
3763 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3765 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3766 [[ $nstripe -gt $OSTCOUNT ]] &&
3767 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3769 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3771 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3772 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3776 OFFSETS="0 $((stride/2)) $((stride-1))"
3777 for offset in $OFFSETS; do
3778 for i in $(seq 0 $((nstripe-1))); do
3779 local GLOBALOFFSETS=""
3781 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3782 local myfn=$DIR/d44a-$size
3783 echo "--------writing $myfn at $size"
3784 ll_sparseness_write $myfn $size ||
3785 error "ll_sparseness_write"
3786 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3787 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3788 error "ll_sparseness_verify $GLOBALOFFSETS"
3790 for j in $(seq 0 $((nstripe-1))); do
3792 size=$((((j + $nstripe )*$stride + $offset)))
3793 ll_sparseness_write $myfn $size ||
3794 error "ll_sparseness_write"
3795 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3797 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3798 error "ll_sparseness_verify $GLOBALOFFSETS"
3803 run_test 44a "test sparse pwrite ==============================="
3807 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3813 before=`dirty_osc_total`
3814 echo executing "\"$*\""
3816 after=`dirty_osc_total`
3817 echo before $before, after $after
3820 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3822 # Obtain grants from OST if it supports it
3823 echo blah > ${f}_grant
3826 do_dirty_record "echo blah > $f"
3827 [[ $before -eq $after ]] && error "write wasn't cached"
3828 do_dirty_record "> $f"
3829 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3830 do_dirty_record "echo blah > $f"
3831 [[ $before -eq $after ]] && error "write wasn't cached"
3832 do_dirty_record "sync"
3833 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3834 do_dirty_record "echo blah > $f"
3835 [[ $before -eq $after ]] && error "write wasn't cached"
3836 do_dirty_record "cancel_lru_locks osc"
3837 [[ $before -gt $after ]] ||
3838 error "lock cancellation didn't lower dirty count"
3841 run_test 45 "osc io page accounting ============================"
3843 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3844 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3845 # objects offset and an assert hit when an rpc was built with 1023's mapped
3846 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3852 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3854 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3855 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3859 run_test 46 "dirtying a previously written page ================"
3861 # test_47 is removed "Device nodes check" is moved to test_28
3863 test_48a() { # bug 2399
3864 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3865 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3866 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3868 test_mkdir $DIR/$tdir
3870 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
3871 test_mkdir $DIR/$tdir || error "recreate directory failed"
3872 touch foo || error "'touch foo' failed after recreating cwd"
3873 test_mkdir bar || error "'mkdir foo' failed after recreating cwd"
3874 touch .foo || error "'touch .foo' failed after recreating cwd"
3875 test_mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3876 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3877 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3878 cd . || error "'cd .' failed after recreating cwd"
3879 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3880 rmdir . && error "'rmdir .' worked after recreating cwd"
3881 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3882 cd .. || error "'cd ..' failed after recreating cwd"
3884 run_test 48a "Access renamed working dir (should return errors)="
3886 test_48b() { # bug 2399
3888 test_mkdir $DIR/$tdir
3890 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3891 touch foo && error "'touch foo' worked after removing cwd"
3892 test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3893 touch .foo && error "'touch .foo' worked after removing cwd"
3894 test_mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3895 ls . > /dev/null && error "'ls .' worked after removing cwd"
3896 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3897 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3898 test_mkdir . && error "'mkdir .' worked after removing cwd"
3899 rmdir . && error "'rmdir .' worked after removing cwd"
3900 ln -s . foo && error "'ln -s .' worked after removing cwd"
3901 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3903 run_test 48b "Access removed working dir (should return errors)="
3905 test_48c() { # bug 2350
3906 #lctl set_param debug=-1
3909 test_mkdir -p $DIR/$tdir/dir
3911 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3912 $TRACE touch foo && error "touch foo worked after removing cwd"
3913 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3914 touch .foo && error "touch .foo worked after removing cwd"
3915 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3916 $TRACE ls . && error "'ls .' worked after removing cwd"
3917 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3918 is_patchless || ( $TRACE cd . &&
3919 error "'cd .' worked after removing cwd" )
3920 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3921 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3922 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3923 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3925 run_test 48c "Access removed working subdir (should return errors)"
3927 test_48d() { # bug 2350
3928 #lctl set_param debug=-1
3931 test_mkdir -p $DIR/$tdir/dir
3933 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3934 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3935 $TRACE touch foo && error "'touch foo' worked after removing parent"
3936 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3937 touch .foo && error "'touch .foo' worked after removing parent"
3938 test_mkdir .foo && error "mkdir .foo worked after removing parent"
3939 $TRACE ls . && error "'ls .' worked after removing parent"
3940 $TRACE ls .. && error "'ls ..' worked after removing parent"
3941 is_patchless || ( $TRACE cd . &&
3942 error "'cd .' worked after recreate parent" )
3943 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3944 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3945 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3946 is_patchless || ( $TRACE cd .. &&
3947 error "'cd ..' worked after removing parent" || true )
3949 run_test 48d "Access removed parent subdir (should return errors)"
3951 test_48e() { # bug 4134
3952 #lctl set_param debug=-1
3955 test_mkdir -p $DIR/$tdir/dir
3957 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3958 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3959 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3960 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3961 # On a buggy kernel addition of "touch foo" after cd .. will
3962 # produce kernel oops in lookup_hash_it
3963 touch ../foo && error "'cd ..' worked after recreate parent"
3965 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3967 run_test 48e "Access to recreated parent subdir (should return errors)"
3969 test_49() { # LU-1030
3970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3971 # get ost1 size - lustre-OST0000
3972 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3974 # write 800M at maximum
3975 [[ $ost1_size -lt 2 ]] && ost1_size=2
3976 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3978 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3979 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3982 # change max_pages_per_rpc while writing the file
3983 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3984 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3985 # loop until dd process exits
3986 while ps ax -opid | grep -wq $dd_pid; do
3987 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3988 sleep $((RANDOM % 5 + 1))
3990 # restore original max_pages_per_rpc
3991 $LCTL set_param $osc1_mppc=$orig_mppc
3992 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3994 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3998 test_mkdir $DIR/$tdir
4000 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4002 run_test 50 "special situations: /proc symlinks ==============="
4004 test_51a() { # was test_51
4005 # bug 1516 - create an empty entry right after ".." then split dir
4006 test_mkdir -c1 $DIR/$tdir
4007 touch $DIR/$tdir/foo
4008 $MCREATE $DIR/$tdir/bar
4010 createmany -m $DIR/$tdir/longfile 201
4012 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4013 $MCREATE $DIR/$tdir/longfile$FNUM
4018 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4020 run_test 51a "special situations: split htree with empty entry =="
4022 export NUMTEST=70000
4024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4025 local BASE=$DIR/d${base}.${TESTSUITE}
4027 # cleanup the directory
4030 test_mkdir -p -c1 $BASE
4034 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4035 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4036 [[ $numfree -lt 21000 ]] &&
4037 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4040 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4041 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4043 # need to check free space for the directories as well
4044 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4045 numfree=$((blkfree / 4))
4046 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4047 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4049 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4053 echo "failed" > $BASE/fnum
4054 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4057 run_test 51b "exceed 64k subdirectory nlink limit"
4059 test_51ba() { # LU-993
4060 local BASE=$DIR/d${base}.${TESTSUITE}
4061 # unlink all but 100 subdirectories, then check it still works
4063 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4065 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4066 local DELETE=$((NUMTEST - LEFT))
4068 # continue on to run this test even if 51b didn't finish,
4069 # just to delete the many subdirectories created.
4070 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4072 # for ldiskfs the nlink count should be 1, but this is OSD specific
4073 # and so this is listed for informational purposes only
4074 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4075 unlinkmany -d $BASE/d $DELETE
4078 if [ $RC -ne 0 ]; then
4079 if [ "$NUMPREV" == "failed" ]; then
4080 skip "previous setup failed"
4083 error "unlink of first $DELETE subdirs failed"
4088 echo "nlink between: $(stat -c %h $BASE)"
4089 # trim the first line of ls output
4090 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4091 [ $FOUND -ne $LEFT ] &&
4092 error "can't find subdirs: found only $FOUND/$LEFT"
4094 unlinkmany -d $BASE/d $DELETE $LEFT ||
4095 error "unlink of second $LEFT subdirs failed"
4096 # regardless of whether the backing filesystem tracks nlink accurately
4097 # or not, the nlink count shouldn't be more than "." and ".." here
4098 local AFTER=$(stat -c %h $BASE)
4099 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4100 echo "nlink after: $AFTER"
4102 run_test 51ba "verify nlink for many subdirectory cleanup"
4105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4106 [[ $OSTCOUNT -lt 3 ]] &&
4107 skip_env "skipping test with few OSTs" && return
4108 test_mkdir -p $DIR/$tdir
4109 createmany -o $DIR/$tdir/t- 1000
4110 $GETSTRIPE $DIR/$tdir > $TMP/files
4111 for N in $(seq 0 $((OSTCOUNT - 1))); do
4112 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4113 END { printf("%0.0f", objs) }' $TMP/files)
4114 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4115 '($1 == '$N') { objs += 1 } \
4116 END { printf("%0.0f", objs) }')
4117 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4119 unlinkmany $DIR/$tdir/t- 1000
4122 for N in $(seq 1 $((OSTCOUNT - 1))); do
4123 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4124 error "OST $N has less objects vs OST $NLAST" \
4125 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4126 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4127 error "OST $N has less objects vs OST $NLAST" \
4128 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4130 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4131 error "OST $N has less #0 objects vs OST $NLAST" \
4132 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4133 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4134 error "OST $N has less #0 objects vs OST $NLAST" \
4135 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4139 run_test 51d "check object distribution ===================="
4142 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4143 skip "Only applicable to ldiskfs-based MDTs"
4147 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4148 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4150 touch $DIR/$tdir/d0/foo
4151 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4152 error "file exceed 65000 nlink limit!"
4153 unlinkmany $DIR/$tdir/d0/f- 65001
4156 run_test 51e "check file nlink limit"
4159 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4160 test_mkdir -p $DIR/$tdir
4161 touch $DIR/$tdir/foo
4162 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4163 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4164 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4165 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4166 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4168 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4169 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4170 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4172 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4173 cp -r $DIR/$tdir /tmp/
4174 rm -fr $DIR/$tdir || error "cleanup rm failed"
4176 run_test 52a "append-only flag test (should return errors) ====="
4179 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4180 test_mkdir -p $DIR/$tdir
4181 touch $DIR/$tdir/foo
4182 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4183 cat test > $DIR/$tdir/foo && error "cat test worked"
4184 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4185 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4186 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4188 echo foo >> $DIR/$tdir/foo && error "echo worked"
4189 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4190 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4191 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4192 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4194 chattr -i $DIR/$tdir/foo || error "chattr failed"
4196 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4198 run_test 52b "immutable flag test (should return errors) ======="
4201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4202 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4203 remote_ost_nodsh && skip "remote OST with nodsh" && return
4216 local support_last_seq=true
4218 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4219 support_last_seq=false
4222 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4224 for value in $(do_facet $SINGLEMDS \
4225 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4226 param=$(echo ${value[0]} | cut -d "=" -f1)
4227 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4229 if $support_last_seq; then
4230 param_seq=$(echo $param |
4231 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4232 mds_last_seq=$(do_facet $SINGLEMDS \
4233 $LCTL get_param -n $param_seq)
4235 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4237 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4238 node=$(facet_active_host ost$((ostnum+1)))
4239 param="obdfilter.$ostname.last_id"
4240 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4241 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4242 ost_last_id=$ost_last
4244 if $support_last_seq; then
4245 ost_last_id=$(echo $ost_last |
4246 awk -F':' '{print $2}' |
4248 ost_last_seq=$(echo $ost_last |
4249 awk -F':' '{print $1}')
4250 [[ $ost_last_seq = $mds_last_seq ]] || continue
4253 if [[ $ost_last_id != $mds_last ]]; then
4254 error "$ost_last_id != $mds_last"
4261 $found || error "can not match last_seq/last_id for $mdtosc"
4264 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4267 $SOCKETSERVER $DIR/socket ||
4268 error "$SOCKETSERVER $DIR/socket failed: $?"
4269 $SOCKETCLIENT $DIR/socket ||
4270 error "$SOCKETCLIENT $DIR/socket failed: $?"
4271 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4273 run_test 54a "unix domain socket test =========================="
4279 dd if=/dev/zero of=$f bs=$(page_size) count=1
4281 run_test 54b "char device works in lustre ======================"
4284 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4285 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4286 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4288 for i in $(seq 3 7); do
4289 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4297 loopdev="$DIR/loop54c"
4300 $UMOUNT -d $DIR/$tdir || rc=$?
4301 losetup -d $loopdev || true
4302 losetup -d $LOOPDEV || true
4303 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4309 loopdev="$DIR/loop54c"
4312 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4313 trap cleanup_54c EXIT
4314 mknod $loopdev b 7 $LOOPNUM
4315 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4316 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4317 losetup $loopdev $DIR/$tfile ||
4318 error "can't set up $loopdev for $DIR/$tfile"
4319 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4320 test_mkdir -p $DIR/$tdir
4321 mount -t ext2 $loopdev $DIR/$tdir ||
4322 error "error mounting $loopdev on $DIR/$tdir"
4323 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4326 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4330 run_test 54c "block device works in lustre ====================="
4336 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4338 run_test 54d "fifo device works in lustre ======================"
4343 cp -aL /dev/console $f
4344 echo $string > $f || error "echo $string to $f failed"
4346 run_test 54e "console/tty device works in lustre ======================"
4348 #The test_55 used to be iopen test and it was removed by bz#24037.
4349 #run_test 55 "check iopen_connect_dentry() ======================"
4351 test_56a() { # was test_56
4354 test_mkdir -p $DIR/$tdir/dir
4356 NUMFILESx2=$(($NUMFILES * 2))
4357 for i in $(seq 1 $NUMFILES); do
4358 touch $DIR/$tdir/file$i
4359 touch $DIR/$tdir/dir/file$i
4362 # test lfs getstripe with --recursive
4363 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4364 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4365 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4366 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4367 [[ $FILENUM -eq $NUMFILES ]] ||
4368 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4369 echo "$GETSTRIPE --recursive passed."
4371 # test lfs getstripe with file instead of dir
4372 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4373 [[ $FILENUM -eq 1 ]] ||
4374 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4375 echo "$GETSTRIPE file1 passed."
4377 #test lfs getstripe with --verbose
4378 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4379 grep -c lmm_magic) -eq $NUMFILES ]] ||
4380 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4381 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4382 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4383 echo "$GETSTRIPE --verbose passed."
4385 #test lfs getstripe with --obd
4386 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4387 grep -q "unknown obduuid" ||
4388 error "$GETSTRIPE --obd wrong_uuid should return error message"
4390 [[ $OSTCOUNT -lt 2 ]] &&
4391 skip_env "skipping other $GETSTRIPE --obd test" && return
4394 OBDUUID=$(ostuuid_from_index $OSTIDX)
4395 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4396 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4397 [[ $FOUND -eq $FILENUM ]] ||
4398 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4399 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4400 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4401 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4402 error "$GETSTRIPE --obd: should not show file on other obd"
4403 echo "$GETSTRIPE --obd passed"
4405 run_test 56a "check $GETSTRIPE"
4410 local LOCAL_NUMFILES="$1"
4411 local LOCAL_NUMDIRS="$2"
4412 local MKDIR_PARAMS="$3"
4413 local DIR_STRIPE_PARAMS="$4"
4415 if [ ! -d "$TDIR" ] ; then
4416 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4417 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4418 for i in `seq 1 $LOCAL_NUMFILES` ; do
4421 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4422 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4423 for j in `seq 1 $LOCAL_NUMFILES` ; do
4424 touch $TDIR/dir$i/file$j
4430 setup_56_special() {
4434 if [ ! -e "$TDIR/loop1b" ] ; then
4435 for i in `seq 1 $LOCAL_NUMFILES` ; do
4436 mknod $TDIR/loop${i}b b 7 $i
4437 mknod $TDIR/null${i}c c 1 3
4438 ln -s $TDIR/file1 $TDIR/link${i}l
4440 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4441 mknod $TDIR/dir$i/loop${i}b b 7 $i
4442 mknod $TDIR/dir$i/null${i}c c 1 3
4443 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4452 setup_56 $NUMFILES $NUMDIRS
4454 EXPECTED=$(($NUMDIRS + 2))
4455 # test lfs find with -name
4456 for i in $(seq 1 $NUMFILES) ; do
4457 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4458 [ $NUMS -eq $EXPECTED ] ||
4459 error "lfs find -name \"*$i\" $TDIR wrong: "\
4460 "found $NUMS, expected $EXPECTED"
4463 run_test 56g "check lfs find -name ============================="
4469 setup_56 $NUMFILES $NUMDIRS
4471 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4472 # test lfs find with ! -name
4473 for i in $(seq 1 $NUMFILES) ; do
4474 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4475 [ $NUMS -eq $EXPECTED ] ||
4476 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4477 "found $NUMS, expected $EXPECTED"
4480 run_test 56h "check lfs find ! -name ============================="
4484 test_mkdir -p $DIR/$tdir
4485 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4486 CMD="$LFIND -ost $UUID $DIR/$tdir"
4488 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4490 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4494 setup_56_special $NUMFILES $NUMDIRS
4496 EXPECTED=$((NUMDIRS + 1))
4497 CMD="$LFIND -type d $TDIR"
4498 NUMS=$($CMD | wc -l)
4499 [ $NUMS -eq $EXPECTED ] ||
4500 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4502 run_test 56j "check lfs find -type d ============================="
4506 setup_56_special $NUMFILES $NUMDIRS
4508 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4509 CMD="$LFIND -type f $TDIR"
4510 NUMS=$($CMD | wc -l)
4511 [ $NUMS -eq $EXPECTED ] ||
4512 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4514 run_test 56k "check lfs find -type f ============================="
4518 setup_56_special $NUMFILES $NUMDIRS
4520 EXPECTED=$((NUMDIRS + NUMFILES))
4521 CMD="$LFIND -type b $TDIR"
4522 NUMS=$($CMD | wc -l)
4523 [ $NUMS -eq $EXPECTED ] ||
4524 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4526 run_test 56l "check lfs find -type b ============================="
4530 setup_56_special $NUMFILES $NUMDIRS
4532 EXPECTED=$((NUMDIRS + NUMFILES))
4533 CMD="$LFIND -type c $TDIR"
4534 NUMS=$($CMD | wc -l)
4535 [ $NUMS -eq $EXPECTED ] ||
4536 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4538 run_test 56m "check lfs find -type c ============================="
4542 setup_56_special $NUMFILES $NUMDIRS
4544 EXPECTED=$((NUMDIRS + NUMFILES))
4545 CMD="$LFIND -type l $TDIR"
4546 NUMS=$($CMD | wc -l)
4547 [ $NUMS -eq $EXPECTED ] ||
4548 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4550 run_test 56n "check lfs find -type l ============================="
4554 setup_56 $NUMFILES $NUMDIRS
4555 utime $TDIR/file1 > /dev/null || error "utime (1)"
4556 utime $TDIR/file2 > /dev/null || error "utime (2)"
4557 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4558 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4559 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4560 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4563 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4564 [ $NUMS -eq $EXPECTED ] || \
4565 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4568 CMD="$LFIND -mtime 0 $TDIR"
4569 NUMS=$($CMD | wc -l)
4570 [ $NUMS -eq $EXPECTED ] ||
4571 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4573 run_test 56o "check lfs find -mtime for old files =========================="
4576 [ $RUNAS_ID -eq $UID ] &&
4577 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4580 setup_56 $NUMFILES $NUMDIRS
4582 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4584 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4585 NUMS=$($CMD | wc -l)
4586 [ $NUMS -eq $EXPECTED ] || \
4587 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4589 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4590 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4591 NUMS=$($CMD | wc -l)
4592 [ $NUMS -eq $EXPECTED ] || \
4593 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4595 run_test 56p "check lfs find -uid and ! -uid ==============================="
4598 [ $RUNAS_ID -eq $UID ] &&
4599 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4602 setup_56 $NUMFILES $NUMDIRS
4604 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4607 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4608 NUMS=$($CMD | wc -l)
4609 [ $NUMS -eq $EXPECTED ] ||
4610 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4612 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4613 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4614 NUMS=$($CMD | wc -l)
4615 [ $NUMS -eq $EXPECTED ] ||
4616 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4618 run_test 56q "check lfs find -gid and ! -gid ==============================="
4622 setup_56 $NUMFILES $NUMDIRS
4625 CMD="$LFIND -size 0 -type f $TDIR"
4626 NUMS=$($CMD | wc -l)
4627 [ $NUMS -eq $EXPECTED ] ||
4628 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4630 CMD="$LFIND ! -size 0 -type f $TDIR"
4631 NUMS=$($CMD | wc -l)
4632 [ $NUMS -eq $EXPECTED ] ||
4633 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4634 echo "test" > $TDIR/$tfile
4635 echo "test2" > $TDIR/$tfile.2 && sync
4637 CMD="$LFIND -size 5 -type f $TDIR"
4638 NUMS=$($CMD | wc -l)
4639 [ $NUMS -eq $EXPECTED ] ||
4640 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4642 CMD="$LFIND -size +5 -type f $TDIR"
4643 NUMS=$($CMD | wc -l)
4644 [ $NUMS -eq $EXPECTED ] ||
4645 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4647 CMD="$LFIND -size +0 -type f $TDIR"
4648 NUMS=$($CMD | wc -l)
4649 [ $NUMS -eq $EXPECTED ] ||
4650 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4652 CMD="$LFIND ! -size -5 -type f $TDIR"
4653 NUMS=$($CMD | wc -l)
4654 [ $NUMS -eq $EXPECTED ] ||
4655 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4657 CMD="$LFIND -size -5 -type f $TDIR"
4658 NUMS=$($CMD | wc -l)
4659 [ $NUMS -eq $EXPECTED ] ||
4660 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4662 run_test 56r "check lfs find -size works =========================="
4664 test_56s() { # LU-611
4666 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4668 if [[ $OSTCOUNT -gt 1 ]]; then
4669 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4673 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4677 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4678 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4679 NUMS=$($CMD | wc -l)
4680 [ $NUMS -eq $EXPECTED ] || {
4682 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4685 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4686 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4687 NUMS=$($CMD | wc -l)
4688 [ $NUMS -eq $EXPECTED ] || {
4690 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4694 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4695 NUMS=$($CMD | wc -l)
4696 [ $NUMS -eq $EXPECTED ] || {
4698 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4701 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4702 NUMS=$($CMD | wc -l)
4703 [ $NUMS -eq $EXPECTED ] || {
4705 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4709 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4710 NUMS=$($CMD | wc -l)
4711 [ $NUMS -eq $EXPECTED ] || {
4713 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4716 run_test 56s "check lfs find -stripe-count works"
4718 test_56t() { # LU-611
4720 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4722 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4724 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4725 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4726 NUMS=$($CMD | wc -l)
4727 [ $NUMS -eq $EXPECTED ] ||
4728 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4730 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4731 NUMS=$($CMD | wc -l)
4732 [ $NUMS -eq $EXPECTED ] ||
4733 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4735 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4736 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4737 NUMS=$($CMD | wc -l)
4738 [ $NUMS -eq $EXPECTED ] ||
4739 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4741 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4742 NUMS=$($CMD | wc -l)
4743 [ $NUMS -eq $EXPECTED ] ||
4744 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4747 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4748 NUMS=$($CMD | wc -l)
4749 [ $NUMS -eq $EXPECTED ] ||
4750 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4752 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4753 NUMS=$($CMD | wc -l)
4754 [ $NUMS -eq $EXPECTED ] ||
4755 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4758 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4759 NUMS=$($CMD | wc -l)
4760 [ $NUMS -eq $EXPECTED ] ||
4761 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4763 run_test 56t "check lfs find -stripe-size works"
4765 test_56u() { # LU-611
4767 setup_56 $NUMFILES $NUMDIRS "-i 0"
4769 if [[ $OSTCOUNT -gt 1 ]]; then
4770 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4776 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4777 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4778 NUMS=$($CMD | wc -l)
4779 [ $NUMS -eq $EXPECTED ] ||
4780 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4783 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4784 NUMS=$($CMD | wc -l)
4785 [ $NUMS -eq $EXPECTED ] ||
4786 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4788 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4789 NUMS=$($CMD | wc -l)
4790 [ $NUMS -eq $EXPECTED ] ||
4791 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4794 # This should produce an error and not return any files
4795 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4796 NUMS=$($CMD 2>/dev/null | wc -l)
4797 [ $NUMS -eq $EXPECTED ] ||
4798 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4800 if [[ $OSTCOUNT -gt 1 ]]; then
4801 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4802 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4803 NUMS=$($CMD | wc -l)
4804 [ $NUMS -eq $EXPECTED ] ||
4805 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4808 run_test 56u "check lfs find -stripe-index works"
4815 setup_56 $NUMFILES $NUMDIRS
4817 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4818 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4820 for file in $($LFIND -mdt $UUID $TDIR); do
4821 file_mdt_idx=$($GETSTRIPE -M $file)
4822 [ $file_mdt_idx -eq $MDT_IDX ] ||
4823 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4826 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4829 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4834 rm -rf $TDIR || error "remove $TDIR failed"
4835 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4838 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4839 error "$GETSTRIPE -S -d $TDIR failed"
4840 stripe_size=${stripe_size%% *}
4842 local file_size=$((stripe_size * OSTCOUNT))
4843 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4844 local required_space=$((file_num * file_size))
4845 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4846 [[ $free_space -le $((required_space / 1024)) ]] &&
4847 skip_env "need at least $required_space bytes free space," \
4848 "have $free_space kbytes" && return
4851 local dd_count=$((file_size / dd_bs))
4853 # write data into the files
4857 for i in $(seq 1 $NUMFILES); do
4859 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4860 error "write data into $file failed"
4862 for i in $(seq 1 $NUMDIRS); do
4863 for j in $(seq 1 $NUMFILES); do
4864 file=$TDIR/dir$i/file$j
4865 yes | dd bs=$dd_bs count=$dd_count of=$file \
4867 error "write data into $file failed"
4872 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4875 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4877 eval $cmd || error "$cmd failed"
4879 check_stripe_count $TDIR/file1 $expected
4881 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4883 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4884 # OST 1 if it is on OST 0. This file is small enough to
4885 # be on only one stripe.
4886 file=$TDIR/migr_1_ost
4887 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4888 error "write data into $file failed"
4889 local obdidx=$($LFS getstripe -i $file)
4890 local oldmd5=$(md5sum $file)
4892 [[ $obdidx -eq 0 ]] && newobdidx=1
4893 cmd="$LFS migrate -i $newobdidx $file"
4895 eval $cmd || error "$cmd failed"
4896 local realobdix=$($LFS getstripe -i $file)
4897 local newmd5=$(md5sum $file)
4898 [[ $newobdidx -ne $realobdix ]] &&
4899 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4900 [[ "$oldmd5" != "$newmd5" ]] &&
4901 error "md5sum differ: $oldmd5, $newmd5"
4905 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4907 eval $cmd || error "$cmd failed"
4909 for j in $(seq 1 $NUMFILES); do
4910 check_stripe_count $TDIR/dir1/file$j $expected
4913 # lfs_migrate works with lfs find
4914 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4915 $LFS_MIGRATE -y -c $expected"
4917 eval $cmd || error "$cmd failed"
4919 for i in $(seq 2 $NUMFILES); do
4920 check_stripe_count $TDIR/file$i $expected
4922 for i in $(seq 2 $NUMDIRS); do
4923 for j in $(seq 1 $NUMFILES); do
4924 check_stripe_count $TDIR/dir$i/file$j $expected
4928 run_test 56w "check lfs_migrate -c stripe_count works"
4931 check_swap_layouts_support && return 0
4932 [[ $OSTCOUNT -lt 2 ]] &&
4933 skip_env "need 2 OST, skipping test" && return
4935 local dir0=$DIR/$tdir/$testnum
4936 test_mkdir -p $dir0 || error "creating dir $dir0"
4938 local ref1=/etc/passwd
4939 local file1=$dir0/file1
4941 $SETSTRIPE -c 2 $file1
4943 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4944 stripe=$($GETSTRIPE -c $file1)
4945 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4946 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4951 run_test 56x "lfs migration support"
4954 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4955 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
4959 local dir0=$DIR/$tdir/$testnum
4960 test_mkdir -p $dir0 || error "creating dir $dir0"
4961 local f1=$dir0/file1
4962 local f2=$dir0/file2
4964 touch $f1 || error "creating std file $f1"
4965 $MULTIOP $f2 H2c || error "creating released file $f2"
4967 # a directory can be raid0, so ask only for files
4968 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4969 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4971 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4972 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4974 # only files can be released, so no need to force file search
4975 res=$($LFIND $dir0 -L released)
4976 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4978 res=$($LFIND $dir0 \! -L released)
4979 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4982 run_test 56y "lfs find -L raid0|released"
4984 test_56z() { # LU-4824
4985 # This checks to make sure 'lfs find' continues after errors
4986 # There are two classes of errors that should be caught:
4987 # - If multiple paths are provided, all should be searched even if one
4989 # - If errors are encountered during the search, it should not terminate
4992 test_mkdir $DIR/$tdir
4993 for i in d{0..9}; do
4994 test_mkdir $DIR/$tdir/$i
4996 touch $DIR/$tdir/d{0..9}/$tfile
4997 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
4998 error "$LFS find did not return an error"
4999 # Make a directory unsearchable. This should NOT be the last entry in
5000 # directory order. Arbitrarily pick the 6th entry
5001 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5002 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5003 # The user should be able to see 10 directories and 9 files
5004 [ $count == 19 ] || error "$LFS find did not continue after error"
5006 run_test 56z "lfs find should continue after an error"
5008 test_56aa() { # LU-5937
5009 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5012 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5014 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5015 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5017 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5019 run_test 56aa "lfs find --size under striped dir"
5022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5023 # note test will not do anything if MDS is not local
5024 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5025 skip "Only applicable to ldiskfs-based MDTs"
5029 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5030 local MNTDEV="osd*.*MDT*.mntdev"
5031 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5032 [ -z "$DEV" ] && error "can't access $MNTDEV"
5033 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5034 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5035 error "can't access $DEV"
5036 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5037 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5041 run_test 57a "verify MDS filesystem created with large inodes =="
5044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5045 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5046 skip "Only applicable to ldiskfs-based MDTs"
5050 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5051 local dir=$DIR/$tdir
5055 local FILEN=$dir/f$FILECOUNT
5057 rm -rf $dir || error "removing $dir"
5058 test_mkdir -p -c1 $dir || error "creating $dir"
5059 local mdtidx=$($LFS getstripe -M $dir)
5060 local mdtname=MDT$(printf %04x $mdtidx)
5061 local facet=mds$((mdtidx + 1))
5063 echo "mcreating $FILECOUNT files"
5064 createmany -m $dir/f 1 $FILECOUNT || \
5065 error "creating files in $dir"
5067 # verify that files do not have EAs yet
5068 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5069 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5073 df $dir #make sure we get new statfs data
5074 local MDSFREE=$(do_facet $facet \
5075 lctl get_param -n osd*.*$mdtname.kbytesfree)
5076 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5077 echo "opening files to create objects/EAs"
5079 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5080 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5083 # verify that files have EAs now
5084 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5085 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5087 sleep 1 #make sure we get new statfs data
5089 local MDSFREE2=$(do_facet $facet \
5090 lctl get_param -n osd*.*$mdtname.kbytesfree)
5091 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5092 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5093 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5094 error "MDC before $MDCFREE != after $MDCFREE2"
5096 echo "MDC before $MDCFREE != after $MDCFREE2"
5097 echo "unable to confirm if MDS has large inodes"
5102 run_test 57b "default LOV EAs are stored inside large inodes ==="
5105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5106 [ -z "$(which wiretest 2>/dev/null)" ] &&
5107 skip_env "could not find wiretest" && return
5110 run_test 58 "verify cross-platform wire constants =============="
5113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5114 echo "touch 130 files"
5115 createmany -o $DIR/f59- 130
5117 unlinkmany $DIR/f59- 130
5119 # wait for commitment of removal
5120 wait_delete_completed
5122 run_test 59 "verify cancellation of llog records async ========="
5124 TEST60_HEAD="test_60 run $RANDOM"
5126 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5127 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5128 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5129 skip_env "missing subtest run-llog.sh" && return
5130 log "$TEST60_HEAD - from kernel mode"
5131 do_facet mgs sh run-llog.sh
5133 run_test 60a "llog sanity tests run from kernel module =========="
5135 test_60b() { # bug 6411
5136 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5138 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5150 [[ $LLOG_COUNT -gt 50 ]] &&
5151 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5153 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5156 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5157 echo "create 5000 files"
5158 createmany -o $DIR/f60c- 5000
5159 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5160 lctl set_param fail_loc=0x80000137
5161 unlinkmany $DIR/f60c- 5000
5162 lctl set_param fail_loc=0
5164 run_test 60c "unlink file when mds full"
5167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5168 SAVEPRINTK=$(lctl get_param -n printk)
5170 # verify "lctl mark" is even working"
5171 MESSAGE="test message ID $RANDOM $$"
5172 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5173 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5175 lctl set_param printk=0 || error "set lnet.printk failed"
5176 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5177 MESSAGE="new test message ID $RANDOM $$"
5178 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5179 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5180 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5182 lctl set_param -n printk="$SAVEPRINTK"
5184 run_test 60d "test printk console message masking"
5187 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5189 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5190 cancel_lru_locks osc
5191 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5194 run_test 61 "mmap() writes don't make sync hang ================"
5196 # bug 2330 - insufficient obd_match error checking causes LBUG
5198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5201 cancel_lru_locks osc
5202 lctl set_param fail_loc=0x405
5203 cat $f && error "cat succeeded, expect -EIO"
5204 lctl set_param fail_loc=0
5206 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5207 # match every page all of the time.
5208 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5210 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5211 # Though this test is irrelevant anymore, it helped to reveal some
5212 # other grant bugs (LU-4482), let's keep it.
5213 test_63a() { # was test_63
5214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5215 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5216 for i in `seq 10` ; do
5217 dd if=/dev/zero of=$DIR/f63 bs=8k &
5223 rm -f $DIR/f63 || true
5225 run_test 63a "Verify oig_wait interruption does not crash ======="
5227 # bug 2248 - async write errors didn't return to application on sync
5228 # bug 3677 - async write errors left page locked
5230 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5232 lctl set_param debug=-1
5234 # ensure we have a grant to do async writes
5235 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5238 sync # sync lest earlier test intercept the fail_loc
5240 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5241 lctl set_param fail_loc=0x80000406
5242 $MULTIOP $DIR/$tfile Owy && \
5243 error "sync didn't return ENOMEM"
5244 sync; sleep 2; sync # do a real sync this time to flush page
5245 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5246 error "locked page left in cache after async error" || true
5249 run_test 63b "async write errors should be returned to fsync ==="
5252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5254 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5256 run_test 64a "verify filter grant calculations (in kernel) ====="
5259 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5260 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5262 run_test 64b "check out-of-space detection on client ==========="
5265 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5267 run_test 64c "verify grant shrink ========================------"
5269 # bug 1414 - set/get directories' stripe info
5271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5272 test_mkdir -p $DIR/$tdir
5274 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5276 run_test 65a "directory with no stripe info ===================="
5279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5280 test_mkdir -p $DIR/$tdir
5281 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5284 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5286 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5289 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5290 if [[ $OSTCOUNT -gt 1 ]]; then
5291 test_mkdir -p $DIR/$tdir
5292 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5293 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5295 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5298 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5302 test_mkdir -p $DIR/$tdir
5303 if [[ $STRIPECOUNT -le 0 ]]; then
5305 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5306 #LOV_MAX_STRIPE_COUNT is 2000
5307 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5309 sc=$(($STRIPECOUNT - 1))
5311 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5312 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5313 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5314 error "lverify failed"
5316 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5320 test_mkdir -p $DIR/$tdir
5322 $SETSTRIPE $DIR/$tdir || error "setstripe"
5323 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5324 error "no stripe info failed"
5326 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5328 run_test 65e "directory setstripe defaults ======================="
5331 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5332 test_mkdir -p $DIR/${tdir}f
5333 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5335 run_test 65f "dir setstripe permission (should return error) ==="
5338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5339 test_mkdir -p $DIR/$tdir
5340 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5342 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5343 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5344 error "delete default stripe failed"
5346 run_test 65g "directory setstripe -d ==========================="
5349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5350 test_mkdir -p $DIR/$tdir
5351 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5353 test_mkdir -p $DIR/$tdir/dd1
5354 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5355 error "stripe info inherit failed"
5357 run_test 65h "directory stripe info inherit ===================="
5359 test_65i() { # bug6367
5360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5361 $SETSTRIPE -S 65536 -c -1 $MOUNT
5363 run_test 65i "set non-default striping on root directory (bug 6367)="
5365 test_65ia() { # bug12836
5366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5367 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5369 run_test 65ia "getstripe on -1 default directory striping"
5371 test_65ib() { # bug12836
5372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5373 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5375 run_test 65ib "getstripe -v on -1 default directory striping"
5377 test_65ic() { # bug12836
5378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5379 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5381 run_test 65ic "new find on -1 default directory striping"
5383 test_65j() { # bug6367
5384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5386 # if we aren't already remounting for each test, do so for this test
5387 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5388 cleanup || error "failed to unmount"
5391 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5393 run_test 65j "set default striping on root directory (bug 6367)="
5395 test_65k() { # bug11679
5396 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5397 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5398 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5400 echo "Check OST status: "
5401 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5402 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5404 for OSC in $MDS_OSCS; do
5405 echo $OSC "is activate"
5406 do_facet $SINGLEMDS lctl --device %$OSC activate
5410 for INACTIVE_OSC in $MDS_OSCS; do
5411 echo "Deactivate: " $INACTIVE_OSC
5412 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5413 for STRIPE_OSC in $MDS_OSCS; do
5414 OST=`osc_to_ost $STRIPE_OSC`
5415 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5416 awk -F: /$OST/'{ print $1 }' | head -n 1`
5418 [ -f $DIR/$tdir/$IDX ] && continue
5419 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5420 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5422 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5425 echo $INACTIVE_OSC "is Activate."
5426 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5429 run_test 65k "validate manual striping works properly with deactivated OSCs"
5431 test_65l() { # bug 12836
5432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5433 test_mkdir -p $DIR/$tdir/test_dir
5434 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5435 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5437 run_test 65l "lfs find on -1 stripe dir ========================"
5439 # bug 2543 - update blocks count on client
5441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5443 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5444 sync; sync_all_data; sync; sync_all_data
5445 cancel_lru_locks osc
5446 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5447 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5449 run_test 66 "update inode blocks count on client ==============="
5454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5456 if [ ! -z "$LLOOP" ]; then
5457 if swapon -s | grep -q $LLOOP; then
5458 swapoff $LLOOP || error "swapoff failed"
5461 $LCTL blockdev_detach $LLOOP || error "detach failed"
5465 if [ ! -z "$LLITELOOPLOAD" ]; then
5473 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5477 swapon -s | awk '($1 == "'$1'") { print $4 }'
5480 # test case for lloop driver, basic function
5482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5483 [ "$UID" != 0 ] && skip_env "must run as root" && return
5484 llite_lloop_enabled || \
5485 { skip_env "llite_lloop module disabled" && return; }
5487 trap cleanup_68 EXIT
5489 if ! module_loaded llite_lloop; then
5490 if load_module llite/llite_lloop; then
5493 skip_env "can't find module llite_lloop"
5498 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5499 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5500 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5502 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5503 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5507 run_test 68a "lloop driver - basic test ========================"
5509 # excercise swapping to lustre by adding a high priority swapfile entry
5510 # and then consuming memory until it is used.
5511 test_68b() { # was test_68
5512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5513 [ "$UID" != 0 ] && skip_env "must run as root" && return
5514 lctl get_param -n devices | grep -q obdfilter && \
5515 skip "local OST" && return
5517 grep -q llite_lloop /proc/modules
5518 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5520 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5521 skip "can't reliably test swap with TCP" && return
5523 MEMTOTAL=`meminfo MemTotal`
5524 NR_BLOCKS=$((MEMTOTAL>>8))
5525 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5527 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5528 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5531 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5533 trap cleanup_68 EXIT
5535 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5537 echo "before: `swapon -s | grep $LLOOP`"
5538 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5539 echo "after: `swapon -s | grep $LLOOP`"
5540 SWAPUSED=`swap_used $LLOOP`
5544 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5546 run_test 68b "support swapping to Lustre ========================"
5548 # bug5265, obdfilter oa2dentry return -ENOENT
5549 # #define OBD_FAIL_OST_ENOENT 0x217
5551 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5552 remote_ost_nodsh && skip "remote OST with nodsh" && return
5555 $SETSTRIPE -c 1 -i 0 $f
5557 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5559 do_facet ost1 lctl set_param fail_loc=0x217
5560 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5561 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5563 do_facet ost1 lctl set_param fail_loc=0
5564 $DIRECTIO write $f 0 2 || error "write error"
5566 cancel_lru_locks osc
5567 $DIRECTIO read $f 0 1 || error "read error"
5569 do_facet ost1 lctl set_param fail_loc=0x217
5570 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5572 do_facet ost1 lctl set_param fail_loc=0
5575 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5578 test_mkdir -p $DIR/$tdir
5579 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
5580 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5582 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5584 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5586 [ "$RUNAS_ID" = "$UID" ] &&
5587 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5589 # Check that testing environment is properly set up. Skip if not
5590 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5591 skip_env "User $RUNAS_ID does not exist - skipping"
5595 chmod 777 $DIR/$tfile
5596 chmod ug+s $DIR/$tfile
5597 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5598 error "$RUNAS dd $DIR/$tfile failed"
5599 # See if we are still setuid/sgid
5600 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5601 error "S/gid is not dropped on write"
5602 # Now test that MDS is updated too
5603 cancel_lru_locks mdc
5604 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5605 error "S/gid is not dropped on MDS"
5608 run_test 72a "Test that remove suid works properly (bug5695) ===="
5610 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5613 [ "$RUNAS_ID" = "$UID" ] && \
5614 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5615 [ "$RUNAS_ID" -eq 0 ] && \
5616 skip_env "RUNAS_ID = 0 -- skipping" && return
5618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5619 # Check that testing environment is properly set up. Skip if not
5620 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5621 skip_env "User $RUNAS_ID does not exist - skipping"
5624 touch $DIR/${tfile}-f{g,u}
5625 test_mkdir $DIR/${tfile}-dg
5626 test_mkdir $DIR/${tfile}-du
5627 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5628 chmod g+s $DIR/${tfile}-{f,d}g
5629 chmod u+s $DIR/${tfile}-{f,d}u
5630 for perm in 777 2777 4777; do
5631 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5632 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5633 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5634 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5638 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5640 # bug 3462 - multiple simultaneous MDC requests
5642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5643 test_mkdir $DIR/d73-1
5644 test_mkdir $DIR/d73-2
5645 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5648 lctl set_param fail_loc=0x80000129
5649 $MULTIOP $DIR/d73-1/f73-2 Oc &
5651 lctl set_param fail_loc=0
5653 $MULTIOP $DIR/d73-2/f73-3 Oc &
5657 wait $pid1 || return 1
5661 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5662 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5663 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5667 run_test 73 "multiple MDC requests (should not deadlock)"
5669 test_74a() { # bug 6149, 6184
5670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5671 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5673 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5674 # will spin in a tight reconnection loop
5676 $LCTL set_param fail_loc=0x8000030e
5677 # get any lock that won't be difficult - lookup works.
5679 $LCTL set_param fail_loc=0
5683 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5685 test_74b() { # bug 13310
5686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5687 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5689 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5690 # will spin in a tight reconnection loop
5691 $LCTL set_param fail_loc=0x8000030e
5692 # get a "difficult" lock
5694 $LCTL set_param fail_loc=0
5698 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5702 #define OBD_FAIL_LDLM_NEW_LOCK
5703 $LCTL set_param fail_loc=0x319
5704 touch $DIR/$tfile && error "touch successful"
5705 $LCTL set_param fail_loc=0
5708 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5711 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5714 get_inode_slab_tunables() {
5715 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5718 set_inode_slab_tunables() {
5719 echo "lustre_inode_cache $1" > /proc/slabinfo
5722 test_76() { # Now for bug 20433, added originally in bug 1443
5723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5724 local SLAB_SETTINGS=`get_inode_slab_tunables`
5725 local CPUS=`getconf _NPROCESSORS_ONLN`
5726 # we cannot set limit below 1 which means 1 inode in each
5727 # per-cpu cache is still allowed
5728 set_inode_slab_tunables "1 1 0"
5729 cancel_lru_locks osc
5730 BEFORE_INODES=$(num_inodes)
5731 echo "before inodes: $BEFORE_INODES"
5733 [ "$SLOW" = "no" ] && COUNT=100
5734 for i in $(seq $COUNT); do
5738 cancel_lru_locks osc
5739 AFTER_INODES=$(num_inodes)
5740 echo "after inodes: $AFTER_INODES"
5742 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5744 AFTER_INODES=$(num_inodes)
5746 echo "wait $wait seconds inodes: $AFTER_INODES"
5747 if [ $wait -gt 30 ]; then
5748 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5751 set_inode_slab_tunables "$SLAB_SETTINGS"
5753 run_test 76 "confirm clients recycle inodes properly ===="
5759 # Note: in sptlrpc modes which enable its own bulk checksum, the
5760 # original crc32_le bulk checksum will be automatically disabled,
5761 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5762 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5763 # In this case set_checksums() will not be no-op, because sptlrpc
5764 # bulk checksum will be enabled all through the test.
5766 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5767 lctl set_param -n osc.*.checksums $1
5771 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5772 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5773 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5774 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5777 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5778 log "set checksum type to $1"
5781 F77_TMP=$TMP/f77-temp
5784 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5785 error "error writing to $F77_TMP"
5788 test_77a() { # bug 10889
5789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5790 $GSS && skip "could not run with gss" && return
5791 [ ! -f $F77_TMP ] && setup_f77
5793 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5797 run_test 77a "normal checksum read/write operation"
5799 test_77b() { # bug 10889
5800 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5801 $GSS && skip "could not run with gss" && return
5802 [ ! -f $F77_TMP ] && setup_f77
5803 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5804 $LCTL set_param fail_loc=0x80000409
5807 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5808 error "dd error: $?"
5809 $LCTL set_param fail_loc=0
5811 for algo in $CKSUM_TYPES; do
5812 cancel_lru_locks osc
5813 set_checksum_type $algo
5814 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5815 $LCTL set_param fail_loc=0x80000408
5816 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5817 $LCTL set_param fail_loc=0
5820 set_checksum_type $ORIG_CSUM_TYPE
5823 run_test 77b "checksum error on client write, read"
5825 test_77d() { # bug 10889
5826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5827 $GSS && skip "could not run with gss" && return
5828 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5829 $LCTL set_param fail_loc=0x80000409
5831 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5832 error "direct write: rc=$?"
5833 $LCTL set_param fail_loc=0
5836 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5837 $LCTL set_param fail_loc=0x80000408
5839 cancel_lru_locks osc
5840 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5841 error "direct read: rc=$?"
5842 $LCTL set_param fail_loc=0
5845 run_test 77d "checksum error on OST direct write, read"
5847 test_77f() { # bug 10889
5848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5849 $GSS && skip "could not run with gss" && return
5851 for algo in $CKSUM_TYPES; do
5852 cancel_lru_locks osc
5853 set_checksum_type $algo
5854 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5855 $LCTL set_param fail_loc=0x409
5856 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5857 error "direct write succeeded"
5858 $LCTL set_param fail_loc=0
5860 set_checksum_type $ORIG_CSUM_TYPE
5863 run_test 77f "repeat checksum error on write (expect error)"
5865 test_77g() { # bug 10889
5866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5867 $GSS && skip "could not run with gss" && return
5868 remote_ost_nodsh && skip "remote OST with nodsh" && return
5870 [ ! -f $F77_TMP ] && setup_f77
5872 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5873 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5874 do_facet ost1 lctl set_param fail_loc=0x8000021a
5876 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5877 error "write error: rc=$?"
5878 do_facet ost1 lctl set_param fail_loc=0
5881 cancel_lru_locks osc
5882 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5883 do_facet ost1 lctl set_param fail_loc=0x8000021b
5885 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5886 do_facet ost1 lctl set_param fail_loc=0
5889 run_test 77g "checksum error on OST write, read"
5891 test_77i() { # bug 13805
5892 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5893 $GSS && skip "could not run with gss" && return
5894 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5895 lctl set_param fail_loc=0x40b
5896 remount_client $MOUNT
5897 lctl set_param fail_loc=0
5898 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5899 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5900 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5901 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5903 remount_client $MOUNT
5905 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5907 test_77j() { # bug 13805
5908 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5909 $GSS && skip "could not run with gss" && return
5910 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5911 lctl set_param fail_loc=0x40c
5912 remount_client $MOUNT
5913 lctl set_param fail_loc=0
5914 sleep 2 # wait async osc connect to finish
5915 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5916 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5917 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5918 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5920 remount_client $MOUNT
5922 run_test 77j "client only supporting ADLER32"
5924 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5928 test_78() { # bug 10901
5929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5930 remote_ost || { skip_env "local OST" && return; }
5933 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5934 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5935 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5936 echo "MemTotal: $MEMTOTAL"
5938 # reserve 256MB of memory for the kernel and other running processes,
5939 # and then take 1/2 of the remaining memory for the read/write buffers.
5940 if [ $MEMTOTAL -gt 512 ] ;then
5941 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5943 # for those poor memory-starved high-end clusters...
5944 MEMTOTAL=$((MEMTOTAL / 2))
5946 echo "Mem to use for directio: $MEMTOTAL"
5948 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5949 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5950 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5951 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5953 echo "Smallest OST: $SMALLESTOST"
5954 [[ $SMALLESTOST -lt 10240 ]] &&
5955 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5957 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5958 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5960 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5961 echo "File size: $F78SIZE"
5962 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5963 for i in $(seq 1 $NSEQ); do
5964 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5965 echo directIO rdwr round $i of $NSEQ
5966 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5971 run_test 78 "handle large O_DIRECT writes correctly ============"
5973 test_79() { # bug 12743
5974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5975 wait_delete_completed
5977 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5978 BKFREE=$(calc_osc_kbytes kbytesfree)
5979 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5981 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5982 DFTOTAL=`echo $STRING | cut -d, -f1`
5983 DFUSED=`echo $STRING | cut -d, -f2`
5984 DFAVAIL=`echo $STRING | cut -d, -f3`
5985 DFFREE=$(($DFTOTAL - $DFUSED))
5987 ALLOWANCE=$((64 * $OSTCOUNT))
5989 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5990 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5991 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5993 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5994 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5995 error "df free($DFFREE) mismatch OST free($BKFREE)"
5997 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5998 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5999 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6002 run_test 79 "df report consistency check ======================="
6004 test_80() { # bug 10718
6005 remote_ost_nodsh && skip "remote OST with nodsh" && return
6006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6007 # relax strong synchronous semantics for slow backends like ZFS
6008 local soc="obdfilter.*.sync_on_lock_cancel"
6009 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6011 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6012 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6013 facet_active_host $host; done | sort -u)
6014 do_nodes $hosts lctl set_param $soc=never
6017 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6019 local BEFORE=`date +%s`
6020 cancel_lru_locks osc
6021 local AFTER=`date +%s`
6022 local DIFF=$((AFTER-BEFORE))
6023 if [ $DIFF -gt 1 ] ; then
6024 error "elapsed for 1M@1T = $DIFF"
6027 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6031 run_test 80 "Page eviction is equally fast at high offsets too ===="
6033 test_81a() { # LU-456
6034 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6035 remote_ost_nodsh && skip "remote OST with nodsh" && return
6036 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6037 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6038 do_facet ost1 lctl set_param fail_loc=0x80000228
6040 # write should trigger a retry and success
6041 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6042 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6044 if [ $RC -ne 0 ] ; then
6045 error "write should success, but failed for $RC"
6048 run_test 81a "OST should retry write when get -ENOSPC ==============="
6050 test_81b() { # LU-456
6051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6052 remote_ost_nodsh && skip "remote OST with nodsh" && return
6053 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6054 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6055 do_facet ost1 lctl set_param fail_loc=0x228
6057 # write should retry several times and return -ENOSPC finally
6058 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6059 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6062 if [ $RC -ne $ENOSPC ] ; then
6063 error "dd should fail for -ENOSPC, but succeed."
6066 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6068 test_82() { # LU-1031
6069 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6073 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6075 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6077 kill -USR1 $MULTIPID2
6079 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6080 error "First grouplock does not block second one"
6082 echo "Second grouplock blocks first one"
6084 kill -USR1 $MULTIPID1
6088 run_test 82 "Basic grouplock test ==============================="
6091 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6093 test_mkdir -p $DIR/d99cvsroot
6094 chown $RUNAS_ID $DIR/d99cvsroot
6095 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6098 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6101 run_test 99a "cvs init ========================================="
6104 [ -z "$(which cvs 2>/dev/null)" ] &&
6105 skip_env "could not find cvs" && return
6106 [ ! -d $DIR/d99cvsroot ] && test_99a
6108 # some versions of cvs import exit(1) when asked to import links or
6109 # files they can't read. ignore those files.
6110 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6111 ! -perm +4 -printf '-I %f\n')
6112 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6113 d99reposname vtag rtag
6115 run_test 99b "cvs import ======================================="
6118 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6119 [ ! -d $DIR/d99cvsroot ] && test_99b
6121 test_mkdir -p $DIR/d99reposname
6122 chown $RUNAS_ID $DIR/d99reposname
6123 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6125 run_test 99c "cvs checkout ====================================="
6128 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6129 [ ! -d $DIR/d99cvsroot ] && test_99c
6130 cd $DIR/d99reposname
6132 $RUNAS cvs add -m 'addmsg' foo99
6134 run_test 99d "cvs add =========================================="
6137 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6138 [ ! -d $DIR/d99cvsroot ] && test_99c
6139 cd $DIR/d99reposname
6142 run_test 99e "cvs update ======================================="
6145 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6146 [ ! -d $DIR/d99cvsroot ] && test_99d
6147 cd $DIR/d99reposname
6148 $RUNAS cvs commit -m 'nomsg' foo99
6149 rm -fr $DIR/d99cvsroot
6151 run_test 99f "cvs commit ======================================="
6154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6155 [ "$NETTYPE" = tcp ] || \
6156 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6159 remote_ost_nodsh && skip "remote OST with nodsh" && return
6160 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6162 { skip "useless for local single node setup" && return; }
6164 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6165 [ "$PROT" != "tcp" ] && continue
6166 RPORT=$(echo $REMOTE | cut -d: -f2)
6167 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6170 LPORT=`echo $LOCAL | cut -d: -f2`
6171 if [ $LPORT -ge 1024 ]; then
6172 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6174 error_exit "local: $LPORT > 1024, remote: $RPORT"
6177 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6179 run_test 100 "check local port using privileged port ==========="
6181 function get_named_value()
6190 echo $line | sed "s/^$tag[ ]*//"
6197 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6198 awk '/^max_cached_mb/ { print $2 }')
6201 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6206 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6207 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6211 local cache_limit=32
6213 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6214 trap cleanup_101a EXIT
6215 $LCTL set_param -n llite.*.read_ahead_stats 0
6216 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6219 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6221 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6222 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6225 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6226 get_named_value 'read but discarded' | cut -d" " -f1); do
6227 discard=$(($discard + $s))
6231 if [[ $(($discard * 10)) -gt $nreads ]]; then
6232 $LCTL get_param osc.*-osc*.rpc_stats
6233 $LCTL get_param llite.*.read_ahead_stats
6234 error "too many ($discard) discarded pages"
6236 rm -f $DIR/$tfile || true
6238 run_test 101a "check read-ahead for random reads ================"
6241 test_mkdir -p $DIR/$tdir
6242 local STRIPE_SIZE=$1
6243 local FILE_LENGTH=$2
6246 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6248 local list=$(comma_list $(osts_nodes))
6249 set_osd_param $list '' read_cache_enable 0
6250 set_osd_param $list '' writethrough_cache_enable 0
6252 trap cleanup_test101bc EXIT
6253 # prepare the read-ahead file
6254 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6256 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6257 count=$FILE_SIZE_MB 2> /dev/null
6261 cleanup_test101bc() {
6266 local list=$(comma_list $(osts_nodes))
6267 set_osd_param $list '' read_cache_enable 1
6268 set_osd_param $list '' writethrough_cache_enable 1
6272 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6277 local STRIPE_SIZE=$2
6278 local FILE_LENGTH=$3
6279 local RA_INC=1048576
6280 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6281 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6282 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6283 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6284 get_named_value 'read but discarded' |
6285 cut -d" " -f1 | calc_total)
6286 if [[ $DISCARD -gt $discard_limit ]]; then
6287 $LCTL get_param llite.*.read_ahead_stats
6288 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6290 echo "Read-ahead success for size ${READ_SIZE}"
6295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6296 [[ $OSTCOUNT -lt 2 ]] &&
6297 skip_env "skipping stride IO stride-ahead test" && return
6298 local STRIPE_SIZE=1048576
6299 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6300 if [ $SLOW == "yes" ]; then
6301 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6303 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6306 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6308 # prepare the read-ahead file
6309 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6310 cancel_lru_locks osc
6311 for BIDX in 2 4 8 16 32 64 128 256
6313 local BSIZE=$((BIDX*4096))
6314 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6315 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6316 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6317 $LCTL set_param -n llite.*.read_ahead_stats 0
6318 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6319 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6320 cancel_lru_locks osc
6321 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6326 run_test 101b "check stride-io mode read-ahead ================="
6329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6330 local STRIPE_SIZE=1048576
6331 local FILE_LENGTH=$((STRIPE_SIZE*100))
6335 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6337 cancel_lru_locks osc
6338 $LCTL set_param osc.*.rpc_stats 0
6339 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6340 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6341 local stats=$($LCTL get_param -n $osc_rpc_stats)
6342 local lines=$(echo "$stats" | awk 'END {print NR;}')
6345 if [ $lines -le 20 ]; then
6348 for size in 1 2 4 8; do
6349 local rpc=$(echo "$stats" |
6350 awk '($1 == "'$size':") {print $2; exit; }')
6352 error "Small $((size*4))k read IO $rpc !"
6354 echo "$osc_rpc_stats check passed!"
6359 run_test 101c "check stripe_size aligned read-ahead ================="
6362 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6363 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6368 local file=$DIR/$tfile
6369 local sz_MB=${FILESIZE_101d:-500}
6370 local ra_MB=${READAHEAD_MB:-40}
6372 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6373 [ $free_MB -lt $sz_MB ] &&
6374 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6376 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6377 $SETSTRIPE -c -1 $file || error "setstripe failed"
6379 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6380 echo Cancel LRU locks on lustre client to flush the client cache
6381 cancel_lru_locks osc
6383 echo Disable read-ahead
6384 local old_READAHEAD=$(set_read_ahead 0)
6386 echo Reading the test file $file with read-ahead disabled
6387 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6389 echo Cancel LRU locks on lustre client to flush the client cache
6390 cancel_lru_locks osc
6391 echo Enable read-ahead with ${ra_MB}MB
6392 set_read_ahead $ra_MB
6394 echo Reading the test file $file with read-ahead enabled
6395 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6397 echo "read-ahead disabled time read $raOFF"
6398 echo "read-ahead enabled time read $raON"
6400 set_read_ahead $old_READAHEAD
6402 wait_delete_completed
6404 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6405 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6407 run_test 101d "file read with and without read-ahead enabled"
6410 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6411 local file=$DIR/$tfile
6412 local size_KB=500 #KB
6416 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6417 local need_KB=$((count * size_KB))
6418 [[ $free_KB -le $need_KB ]] &&
6419 skip_env "Need free space $need_KB, have $free_KB" && return
6421 echo "Creating $count ${size_KB}K test files"
6422 for ((i = 0; i < $count; i++)); do
6423 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6426 echo "Cancel LRU locks on lustre client to flush the client cache"
6427 cancel_lru_locks osc
6429 echo "Reset readahead stats"
6430 $LCTL set_param -n llite.*.read_ahead_stats 0
6432 for ((i = 0; i < $count; i++)); do
6433 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6436 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6437 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6439 for ((i = 0; i < $count; i++)); do
6440 rm -rf $file.$i 2>/dev/null
6443 #10000 means 20% reads are missing in readahead
6444 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6446 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6448 cleanup_test101f() {
6450 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6451 rm -rf $DIR/$tfile 2>/dev/null
6455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6456 local file=$DIR/$tfile
6459 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6460 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6461 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6462 trap cleanup_test101f EXIT
6464 echo Cancel LRU locks on lustre client to flush the client cache
6465 cancel_lru_locks osc
6467 echo Reset readahead stats
6468 $LCTL set_param -n llite.*.read_ahead_stats 0
6469 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6470 # readahead should read in 2M file on second read, so only miss
6472 echo Random 4K reads on 2M file for 1000 times
6473 $READS -f $file -s 2097152 -b 4096 -n $nreads
6475 echo checking missing pages
6476 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6477 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6479 [ $miss -lt 3 ] || error "misses too much pages!"
6482 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6485 test_mkdir -p $DIR/$tdir
6486 chown $RUNAS_ID $DIR/$tdir
6489 STRIPE_COUNT=$OSTCOUNT
6490 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6492 trap cleanup_test102 EXIT
6494 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6496 for num in 1 2 3 4; do
6497 for count in $(seq 1 $STRIPE_COUNT); do
6498 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6499 local size=`expr $STRIPE_SIZE \* $num`
6500 local file=file"$num-$idx-$count"
6501 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6507 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6513 rm -rf $DIR/d0.sanity/d102
6517 local testfile=$DIR/$tfile
6521 [ "$UID" != 0 ] && skip_env "must run as root" && return
6522 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6523 skip_env "must have user_xattr" && return
6525 [ -z "$(which setfattr 2>/dev/null)" ] &&
6526 skip_env "could not find setfattr" && return
6528 echo "set/get xattr..."
6529 setfattr -n trusted.name1 -v value1 $testfile ||
6530 error "setfattr -n trusted.name1=value1 $testfile failed"
6531 getfattr -n trusted.name1 $testfile 2> /dev/null |
6532 grep "trusted.name1=.value1" ||
6533 error "$testfile missing trusted.name1=value1"
6535 setfattr -n user.author1 -v author1 $testfile ||
6536 error "setfattr -n user.author1=author1 $testfile failed"
6537 getfattr -n user.author1 $testfile 2> /dev/null |
6538 grep "user.author1=.author1" ||
6539 error "$testfile missing trusted.author1=author1"
6542 setfattr -n trusted.name2 -v value2 $testfile ||
6543 error "$testfile unable to set trusted.name2"
6544 setfattr -n trusted.name3 -v value3 $testfile ||
6545 error "$testfile unable to set trusted.name3"
6546 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6547 grep "trusted.name" | wc -l) -eq 3 ] ||
6548 error "$testfile missing 3 trusted.name xattrs"
6550 setfattr -n user.author2 -v author2 $testfile ||
6551 error "$testfile unable to set user.author2"
6552 setfattr -n user.author3 -v author3 $testfile ||
6553 error "$testfile unable to set user.author3"
6554 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6555 grep "user.author" | wc -l) -eq 3 ] ||
6556 error "$testfile missing 3 user.author xattrs"
6558 echo "remove xattr..."
6559 setfattr -x trusted.name1 $testfile ||
6560 error "$testfile error deleting trusted.name1"
6561 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6562 error "$testfile did not delete trusted.name1 xattr"
6564 setfattr -x user.author1 $testfile ||
6565 error "$testfile error deleting user.author1"
6566 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6567 error "$testfile did not delete trusted.name1 xattr"
6569 # b10667: setting lustre special xattr be silently discarded
6570 echo "set lustre special xattr ..."
6571 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6572 error "$testfile allowed setting trusted.lov"
6574 run_test 102a "user xattr test =================================="
6577 [ -z "$(which setfattr 2>/dev/null)" ] &&
6578 skip_env "could not find setfattr" && return
6580 # b10930: get/set/list trusted.lov xattr
6581 echo "get/set/list trusted.lov xattr ..."
6582 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6583 local testfile=$DIR/$tfile
6584 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6585 error "setstripe failed"
6586 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6587 error "getstripe failed"
6588 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6589 error "can't get trusted.lov from $testfile"
6591 local testfile2=${testfile}2
6592 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6593 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6596 setfattr -n trusted.lov -v $value $testfile2
6597 local stripe_size=$($GETSTRIPE -S $testfile2)
6598 local stripe_count=$($GETSTRIPE -c $testfile2)
6599 [[ $stripe_size -eq 65536 ]] ||
6600 error "stripe size $stripe_size != 65536"
6601 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6602 error "stripe count $stripe_count != $STRIPECOUNT"
6605 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6608 [ -z "$(which setfattr 2>/dev/null)" ] &&
6609 skip_env "could not find setfattr" && return
6611 # b10930: get/set/list lustre.lov xattr
6612 echo "get/set/list lustre.lov xattr ..."
6613 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6614 test_mkdir -p $DIR/$tdir
6615 chown $RUNAS_ID $DIR/$tdir
6616 local testfile=$DIR/$tdir/$tfile
6617 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6618 error "setstripe failed"
6619 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6620 error "getstripe failed"
6621 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6622 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6624 local testfile2=${testfile}2
6625 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6626 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6628 $RUNAS $MCREATE $testfile2
6629 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6630 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6631 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6632 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6633 [ $stripe_count -eq $STRIPECOUNT ] ||
6634 error "stripe count $stripe_count != $STRIPECOUNT"
6636 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6638 compare_stripe_info1() {
6639 local stripe_index_all_zero=true
6641 for num in 1 2 3 4; do
6642 for count in $(seq 1 $STRIPE_COUNT); do
6643 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6644 local size=$((STRIPE_SIZE * num))
6645 local file=file"$num-$offset-$count"
6646 stripe_size=$($LFS getstripe -S $PWD/$file)
6647 [[ $stripe_size -ne $size ]] &&
6648 error "$file: size $stripe_size != $size"
6649 stripe_count=$($LFS getstripe -c $PWD/$file)
6650 # allow fewer stripes to be created, ORI-601
6651 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6652 error "$file: count $stripe_count != $count"
6653 stripe_index=$($LFS getstripe -i $PWD/$file)
6654 [[ $stripe_index -ne 0 ]] &&
6655 stripe_index_all_zero=false
6659 $stripe_index_all_zero &&
6660 error "all files are being extracted starting from OST index 0"
6665 [ -n "$(which tar 2>/dev/null)" ] &&
6666 strings $(which tar) | grep -q "lustre" && echo tar
6670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6671 # b10930: tar test for trusted.lov xattr
6672 TAR=$(find_lustre_tar)
6673 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6674 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6676 test_mkdir -p $DIR/d102d
6677 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6679 compare_stripe_info1
6681 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6684 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6685 # b10930: tar test for trusted.lov xattr
6686 TAR=$(find_lustre_tar)
6687 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6688 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6690 test_mkdir -p $DIR/d102f
6692 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6694 compare_stripe_info1
6696 run_test 102f "tar copy files, not keep osts ==========="
6699 local xsize=${1:-1024} # in bytes
6700 local file=$DIR/$tfile
6702 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
6703 skip "must have user_xattr" && return 0
6704 [ -z "$(which setfattr 2>/dev/null)" ] &&
6705 skip_env "could not find setfattr" && return 0
6706 [ -z "$(which getfattr 2>/dev/null)" ] &&
6707 skip_env "could not find getfattr" && return 0
6711 local value="$(generate_string $xsize)"
6713 local xbig=trusted.big
6714 log "save $xbig on $file"
6715 setfattr -n $xbig -v $value $file ||
6716 error "saving $xbig on $file failed"
6718 local orig=$(get_xattr_value $xbig $file)
6719 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6721 local xsml=trusted.sml
6722 log "save $xsml on $file"
6723 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6725 local new=$(get_xattr_value $xbig $file)
6726 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6728 log "grow $xsml on $file"
6729 setfattr -n $xsml -v "$value" $file ||
6730 error "growing $xsml on $file failed"
6732 new=$(get_xattr_value $xbig $file)
6733 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6734 log "$xbig still valid after growing $xsml"
6739 test_102h() { # bug 15777
6742 run_test 102h "grow xattr from inside inode to external block"
6745 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6746 grow_xattr $(max_xattr_size)
6748 run_test 102ha "grow xattr from inside inode to external inode"
6750 test_102i() { # bug 17038
6751 [ -z "$(which getfattr 2>/dev/null)" ] &&
6752 skip "could not find getfattr" && return
6754 ln -s $DIR/$tfile $DIR/${tfile}link
6755 getfattr -n trusted.lov $DIR/$tfile ||
6756 error "lgetxattr on $DIR/$tfile failed"
6757 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6758 grep -i "no such attr" ||
6759 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6760 rm -f $DIR/$tfile $DIR/${tfile}link
6762 run_test 102i "lgetxattr test on symbolic link ============"
6765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6766 TAR=$(find_lustre_tar)
6767 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6768 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6769 setup_test102 "$RUNAS"
6770 test_mkdir -p $DIR/d102j
6771 chown $RUNAS_ID $DIR/d102j
6772 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6774 compare_stripe_info1 "$RUNAS"
6776 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6779 [ -z "$(which setfattr 2>/dev/null)" ] &&
6780 skip "could not find setfattr" && return
6782 # b22187 just check that does not crash for regular file.
6783 setfattr -n trusted.lov $DIR/$tfile
6784 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6785 local test_kdir=$DIR/d102k
6786 test_mkdir $test_kdir
6787 local default_size=`$GETSTRIPE -S $test_kdir`
6788 local default_count=`$GETSTRIPE -c $test_kdir`
6789 local default_offset=`$GETSTRIPE -i $test_kdir`
6790 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6791 error 'dir setstripe failed'
6792 setfattr -n trusted.lov $test_kdir
6793 local stripe_size=`$GETSTRIPE -S $test_kdir`
6794 local stripe_count=`$GETSTRIPE -c $test_kdir`
6795 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6796 [ $stripe_size -eq $default_size ] ||
6797 error "stripe size $stripe_size != $default_size"
6798 [ $stripe_count -eq $default_count ] ||
6799 error "stripe count $stripe_count != $default_count"
6800 [ $stripe_offset -eq $default_offset ] ||
6801 error "stripe offset $stripe_offset != $default_offset"
6802 rm -rf $DIR/$tfile $test_kdir
6804 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6807 [ -z "$(which getfattr 2>/dev/null)" ] &&
6808 skip "could not find getfattr" && return
6810 # LU-532 trusted. xattr is invisible to non-root
6811 local testfile=$DIR/$tfile
6815 echo "listxattr as user..."
6816 chown $RUNAS_ID $testfile
6817 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6818 grep -q "trusted" &&
6819 error "$testfile trusted xattrs are user visible"
6823 run_test 102l "listxattr size test =================================="
6825 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6826 local path=$DIR/$tfile
6829 listxattr_size_check $path || error "listattr_size_check $path failed"
6831 run_test 102m "Ensure listxattr fails on small bufffer ========"
6835 getxattr() { # getxattr path name
6836 # Return the base64 encoding of the value of xattr name on path.
6840 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6842 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6844 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6846 getfattr --absolute-names --encoding=base64 --name=$name $path |
6847 awk -F= -v name=$name '$1 == name {
6848 print substr($0, index($0, "=") + 1);
6852 test_102n() { # LU-4101 mdt: protect internal xattrs
6853 local file0=$DIR/$tfile.0
6854 local file1=$DIR/$tfile.1
6855 local xattr0=$TMP/$tfile.0
6856 local xattr1=$TMP/$tfile.1
6860 [ -z "$(which setfattr 2>/dev/null)" ] &&
6861 skip "could not find setfattr" && return
6863 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6865 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6869 rm -rf $file0 $file1 $xattr0 $xattr1
6872 # Get 'before' xattrs of $file1.
6873 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6875 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6876 # Try to copy xattr from $file0 to $file1.
6877 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6879 setfattr --name=trusted.$name --value="$value" $file1 ||
6880 error "setxattr 'trusted.$name' failed"
6882 # Try to set a garbage xattr.
6883 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6885 setfattr --name=trusted.$name --value="$value" $file1 ||
6886 error "setxattr 'trusted.$name' failed"
6888 # Try to remove the xattr from $file1. We don't care if this
6889 # appears to succeed or fail, we just don't want there to be
6890 # any changes or crashes.
6891 setfattr --remove=$trusted.$name $file1 2> /dev/null
6894 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6897 # Try to copy xattr from $file0 to $file1.
6898 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6900 setfattr --name=trusted.$name --value="$value" $file1 ||
6901 error "setxattr 'trusted.$name' failed"
6903 # Try to set a garbage xattr.
6904 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6906 setfattr --name=trusted.$name --value="$value" $file1 ||
6907 error "setxattr 'trusted.$name' failed"
6909 # Try to remove the xattr from $file1. We don't care if this
6910 # appears to succeed or fail, we just don't want there to be
6911 # any changes or crashes.
6912 setfattr --remove=$trusted.$name $file1 2> /dev/null
6915 # Get 'after' xattrs of file1.
6916 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6918 if ! diff $xattr0 $xattr1; then
6919 error "before and after xattrs of '$file1' differ"
6922 rm -rf $file0 $file1 $xattr0 $xattr1
6926 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6928 test_102p() { # LU-4703 setxattr did not check ownership
6929 local testfile=$DIR/$tfile
6931 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6932 skip "MDS needs to be at least 2.5.56" && return
6936 echo "setfacl as user..."
6937 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6938 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6940 echo "setfattr as user..."
6941 setfacl -m "u:$RUNAS_ID:---" $testfile
6942 $RUNAS setfattr -x system.posix_acl_access $testfile
6943 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6945 run_test 102p "check setxattr(2) correctly fails without permission"
6948 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
6949 skip "MDS needs to be at least 2.6.92" && return
6950 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
6952 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
6955 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
6956 skip "MDS needs to be at least 2.6.93" && return
6957 touch $DIR/$tfile || error "touch"
6958 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
6959 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
6960 rm $DIR/$tfile || error "rm"
6963 mkdir -p $DIR/$tdir || error "mkdir"
6964 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
6965 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
6966 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
6967 error "$testfile error deleting user.author1"
6968 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
6969 grep "user.$(basename $tdir)" &&
6970 error "$tdir did not delete user.$(basename $tdir)"
6971 rmdir $DIR/$tdir || error "rmdir"
6974 test_mkdir -p $DIR/$tdir || error "make striped dir"
6975 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
6976 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
6977 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
6978 error "$testfile error deleting user.author1"
6979 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
6980 grep "user.$(basename $tdir)" &&
6981 error "$tdir did not delete user.$(basename $tdir)"
6982 rmdir $DIR/$tdir || error "rm striped dir"
6984 run_test 102r "set EAs with empty values"
6988 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6993 [ "$UID" != 0 ] && skip_env "must run as root" && return
6994 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6995 skip "must have acl enabled" && return
6996 [ -z "$(which setfacl 2>/dev/null)" ] &&
6997 skip_env "could not find setfacl" && return
6998 $GSS && skip "could not run under gss" && return
7000 gpasswd -a daemon bin # LU-5641
7001 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7003 declare -a identity_old
7005 for num in $(seq $MDSCOUNT); do
7006 switch_identity $num true || identity_old[$num]=$?
7013 echo "performing cp ..."
7014 run_acl_subtest cp || error "run_acl_subtest cp failed"
7015 echo "performing getfacl-noacl..."
7016 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7017 echo "performing misc..."
7018 run_acl_subtest misc || error "misc test failed"
7019 echo "performing permissions..."
7020 run_acl_subtest permissions || error "permissions failed"
7021 echo "performing setfacl..."
7022 run_acl_subtest setfacl || error "setfacl test failed"
7024 # inheritance test got from HP
7025 echo "performing inheritance..."
7026 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7027 chmod +x make-tree || error "chmod +x failed"
7028 run_acl_subtest inheritance || error "inheritance test failed"
7031 echo "LU-974 ignore umask when acl is enabled..."
7032 run_acl_subtest 974 || error "LU-974 umask test failed"
7033 if [ $MDSCOUNT -ge 2 ]; then
7034 run_acl_subtest 974_remote ||
7035 error "LU-974 umask test failed under remote dir"
7038 echo "LU-2561 newly created file is same size as directory..."
7039 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7040 run_acl_subtest 2561 || error "LU-2561 test failed"
7042 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7045 run_acl_subtest 4924 || error "LU-4924 test failed"
7050 for num in $(seq $MDSCOUNT); do
7051 if [ "${identity_old[$num]}" = 1 ]; then
7052 switch_identity $num false || identity_old[$num]=$?
7056 run_test 103a "acl test ========================================="
7060 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7061 local mountopts=$MDS_MOUNT_OPTS
7063 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7067 stop $SINGLEMDS || error "failed to stop MDT."
7069 if [ -z "$MDS_MOUNT_OPTS" ]; then
7070 MDS_MOUNT_OPTS="-o noacl"
7072 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7074 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7075 error "failed to start MDT."
7076 MDS_MOUNT_OPTS=$mountopts
7080 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7084 stop $SINGLEMDS || error "failed to stop MDT."
7086 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7087 error "failed to start MDT."
7092 run_test 103b "MDS mount option 'noacl'"
7096 cp -rp $DIR/$tdir $DIR/$tdir.bak
7098 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7099 error "$DIR/$tdir shouldn't contain default ACL"
7100 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7101 error "$DIR/$tdir.bak shouldn't contain default ACL"
7104 run_test 103c "'cp -rp' won't set empty acl"
7107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7109 lfs df || error "lfs df failed"
7110 lfs df -ih || error "lfs df -ih failed"
7111 lfs df -h $DIR || error "lfs df -h $DIR failed"
7112 lfs df -i $DIR || error "lfs df -i $DIR failed"
7113 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7114 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7116 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7117 lctl --device %$OSC deactivate
7118 lfs df || error "lfs df with deactivated OSC failed"
7119 lctl --device %$OSC activate
7120 # wait the osc back to normal
7121 wait_osc_import_state client ost FULL
7123 lfs df || error "lfs df with reactivated OSC failed"
7126 run_test 104a "lfs df [-ih] [path] test ========================="
7129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7130 [ $RUNAS_ID -eq $UID ] &&
7131 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7133 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7134 grep "Permission denied" | wc -l)))
7135 if [ $denied_cnt -ne 0 ]; then
7136 error "lfs check servers test failed"
7139 run_test 104b "$RUNAS lfs check servers test ===================="
7142 # doesn't work on 2.4 kernels
7144 if $(flock_is_enabled); then
7145 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7147 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7151 run_test 105a "flock when mounted without -o flock test ========"
7155 if $(flock_is_enabled); then
7156 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7158 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7162 run_test 105b "fcntl when mounted without -o flock test ========"
7166 if $(flock_is_enabled); then
7167 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7169 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7173 run_test 105c "lockf when mounted without -o flock test ========"
7175 test_105d() { # bug 15924
7176 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7177 test_mkdir -p $DIR/$tdir
7178 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7179 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7180 $LCTL set_param fail_loc=0x80000315
7181 flocks_test 2 $DIR/$tdir
7183 run_test 105d "flock race (should not freeze) ========"
7185 test_105e() { # bug 22660 && 22040
7186 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7188 flocks_test 3 $DIR/$tfile
7190 run_test 105e "Two conflicting flocks from same process ======="
7192 test_106() { #bug 10921
7193 test_mkdir -p $DIR/$tdir
7194 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7195 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7197 run_test 106 "attempt exec of dir followed by chown of that dir"
7200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7207 local save_pattern=$(sysctl -n kernel.core_pattern)
7208 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7209 sysctl -w kernel.core_pattern=$file
7210 sysctl -w kernel.core_uses_pid=0
7218 kill -s 11 $SLEEPPID
7220 if [ -e $file ]; then
7221 size=`stat -c%s $file`
7222 [ $size -eq 0 ] && error "Fail to create core file $file"
7224 error "Fail to create core file $file"
7227 sysctl -w kernel.core_pattern=$save_pattern
7228 sysctl -w kernel.core_uses_pid=$save_uses_pid
7231 run_test 107 "Coredump on SIG"
7234 test_mkdir -p $DIR/$tdir
7235 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7236 error "mkdir with 255 char failed"
7237 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7238 error "mkdir with 256 char should fail, but did not"
7239 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7240 error "create with 255 char failed"
7241 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7242 error "create with 256 char should fail, but did not"
7247 run_test 110 "filename length checking"
7250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7251 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7252 tail -1 | cut -c11-20)
7253 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7254 echo "Starting with $OSTIO_pre threads"
7257 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7258 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7259 echo "$NUMTEST creates/unlinks"
7260 test_mkdir -p $DIR/$tdir
7261 createmany -o $DIR/$tdir/$tfile $NUMTEST
7262 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7264 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7265 tail -1 | cut -c11-20)
7267 # don't return an error
7268 [ $OSTIO_post == $OSTIO_pre ] && echo \
7269 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7270 echo "This may be fine, depending on what ran before this test" &&
7271 echo "and how fast this system is." && return
7273 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7275 run_test 115 "verify dynamic thread creation===================="
7278 wait_delete_completed
7279 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7280 echo OST kbytes available: ${AVAIL[@]}
7281 MAXI=0; MAXV=${AVAIL[0]}
7282 MINI=0; MINV=${AVAIL[0]}
7283 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7284 #echo OST $i: ${AVAIL[i]}kb
7285 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7286 MAXV=${AVAIL[i]}; MAXI=$i
7288 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7289 MINV=${AVAIL[i]}; MINI=$i
7292 echo Min free space: OST $MINI: $MINV
7293 echo Max free space: OST $MAXI: $MAXV
7296 test_116a() { # was previously test_116()
7297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7298 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7300 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7302 echo -n "Free space priority "
7303 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7308 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7309 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7311 trap simple_cleanup_common EXIT
7314 # Check if we need to generate uneven OSTs
7315 test_mkdir -p $DIR/$tdir/OST${MINI}
7316 local FILL=$(($MINV / 4))
7317 local DIFF=$(($MAXV - $MINV))
7318 local DIFF2=$(($DIFF * 100 / $MINV))
7320 local threshold=$(do_facet $SINGLEMDS \
7321 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7322 threshold=${threshold%%%}
7323 echo -n "Check for uneven OSTs: "
7324 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7326 if [[ $DIFF2 -gt $threshold ]]; then
7328 echo "Don't need to fill OST$MINI"
7330 # generate uneven OSTs. Write 2% over the QOS threshold value
7332 DIFF=$(($threshold - $DIFF2 + 2))
7333 DIFF2=$(( ($MINV * $DIFF)/100 ))
7334 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7335 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7336 error "setstripe failed"
7337 DIFF=$(($DIFF2 / 2048))
7339 while [ $i -lt $DIFF ]; do
7341 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7342 bs=2M count=1 2>/dev/null
7351 DIFF=$(($MAXV - $MINV))
7352 DIFF2=$(($DIFF * 100 / $MINV))
7353 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7354 if [[ $DIFF2 -gt $threshold ]]; then
7357 echo "failed - QOS mode won't be used"
7358 skip "QOS imbalance criteria not met"
7359 simple_cleanup_common
7363 MINI1=$MINI; MINV1=$MINV
7364 MAXI1=$MAXI; MAXV1=$MAXV
7366 # now fill using QOS
7367 $SETSTRIPE -c 1 $DIR/$tdir
7368 FILL=$(($FILL / 200))
7369 if [ $FILL -gt 600 ]; then
7372 echo "writing $FILL files to QOS-assigned OSTs"
7374 while [ $i -lt $FILL ]; do
7376 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7380 echo "wrote $i 200k files"
7384 echo "Note: free space may not be updated, so measurements might be off"
7386 DIFF2=$(($MAXV - $MINV))
7387 echo "free space delta: orig $DIFF final $DIFF2"
7388 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7389 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7390 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7391 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7392 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7393 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7395 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7397 # Figure out which files were written where
7398 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7399 awk '/'$MINI1': / {print $2; exit}')
7401 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7402 echo "$MINC files created on smaller OST $MINI1"
7403 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7404 awk '/'$MAXI1': / {print $2; exit}')
7406 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7407 echo "$MAXC files created on larger OST $MAXI1"
7408 FILL=$(($MAXC * 100 / $MINC - 100))
7409 [[ $MINC -gt 0 ]] &&
7410 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7411 [[ $MAXC -gt $MINC ]] ||
7412 error_ignore LU-9 "stripe QOS didn't balance free space"
7413 simple_cleanup_common
7415 run_test 116a "stripe QOS: free space balance ==================="
7417 test_116b() { # LU-2093
7418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7419 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7421 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7422 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7423 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7424 [ -z "$old_rr" ] && skip "no QOS" && return 0
7425 do_facet $SINGLEMDS lctl set_param \
7426 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7428 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7429 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7430 do_facet $SINGLEMDS lctl set_param fail_loc=0
7432 do_facet $SINGLEMDS lctl set_param \
7433 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7435 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7437 test_117() # bug 10891
7439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7440 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7441 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7442 lctl set_param fail_loc=0x21e
7443 > $DIR/$tfile || error "truncate failed"
7444 lctl set_param fail_loc=0
7445 echo "Truncate succeeded."
7448 run_test 117 "verify osd extend =========="
7450 NO_SLOW_RESENDCOUNT=4
7451 export OLD_RESENDCOUNT=""
7452 set_resend_count () {
7453 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7454 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7455 lctl set_param -n $PROC_RESENDCOUNT $1
7456 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7459 # for reduce test_118* time (b=14842)
7460 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7462 # Reset async IO behavior after error case
7464 FILE=$DIR/reset_async
7466 # Ensure all OSCs are cleared
7467 $SETSTRIPE -c -1 $FILE
7468 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7473 test_118a() #bug 11710
7475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7478 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7479 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7480 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7482 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7483 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7488 run_test 118a "verify O_SYNC works =========="
7492 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7493 remote_ost_nodsh && skip "remote OST with nodsh" && return
7497 #define OBD_FAIL_OST_ENOENT 0x217
7498 set_nodes_failloc "$(osts_nodes)" 0x217
7499 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7501 set_nodes_failloc "$(osts_nodes)" 0
7502 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7503 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7506 if [[ $RC -eq 0 ]]; then
7507 error "Must return error due to dropped pages, rc=$RC"
7511 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7512 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7516 echo "Dirty pages not leaked on ENOENT"
7518 # Due to the above error the OSC will issue all RPCs syncronously
7519 # until a subsequent RPC completes successfully without error.
7520 $MULTIOP $DIR/$tfile Ow4096yc
7525 run_test 118b "Reclaim dirty pages on fatal error =========="
7529 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7531 # for 118c, restore the original resend count, LU-1940
7532 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7533 set_resend_count $OLD_RESENDCOUNT
7534 remote_ost_nodsh && skip "remote OST with nodsh" && return
7538 #define OBD_FAIL_OST_EROFS 0x216
7539 set_nodes_failloc "$(osts_nodes)" 0x216
7541 # multiop should block due to fsync until pages are written
7542 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7546 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7547 error "Multiop failed to block on fsync, pid=$MULTIPID"
7550 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7552 if [[ $WRITEBACK -eq 0 ]]; then
7553 error "No page in writeback, writeback=$WRITEBACK"
7556 set_nodes_failloc "$(osts_nodes)" 0
7559 if [[ $RC -ne 0 ]]; then
7560 error "Multiop fsync failed, rc=$RC"
7563 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7564 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7566 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7567 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7571 echo "Dirty pages flushed via fsync on EROFS"
7574 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7576 # continue to use small resend count to reduce test_118* time (b=14842)
7577 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7581 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7582 remote_ost_nodsh && skip "remote OST with nodsh" && return
7586 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7587 set_nodes_failloc "$(osts_nodes)" 0x214
7588 # multiop should block due to fsync until pages are written
7589 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7593 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7594 error "Multiop failed to block on fsync, pid=$MULTIPID"
7597 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7599 if [[ $WRITEBACK -eq 0 ]]; then
7600 error "No page in writeback, writeback=$WRITEBACK"
7603 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7604 set_nodes_failloc "$(osts_nodes)" 0
7606 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7607 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7609 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7610 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7614 echo "Dirty pages gaurenteed flushed via fsync"
7617 run_test 118d "Fsync validation inject a delay of the bulk =========="
7620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7623 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7624 lctl set_param fail_loc=0x8000040a
7626 # Should simulate EINVAL error which is fatal
7627 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7629 if [[ $RC -eq 0 ]]; then
7630 error "Must return error due to dropped pages, rc=$RC"
7633 lctl set_param fail_loc=0x0
7635 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7636 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7637 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7639 if [[ $LOCKED -ne 0 ]]; then
7640 error "Locked pages remain in cache, locked=$LOCKED"
7643 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7644 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7648 echo "No pages locked after fsync"
7653 run_test 118f "Simulate unrecoverable OSC side error =========="
7656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7659 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7660 lctl set_param fail_loc=0x406
7662 # simulate local -ENOMEM
7663 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7666 lctl set_param fail_loc=0
7667 if [[ $RC -eq 0 ]]; then
7668 error "Must return error due to dropped pages, rc=$RC"
7671 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7672 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7673 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7675 if [[ $LOCKED -ne 0 ]]; then
7676 error "Locked pages remain in cache, locked=$LOCKED"
7679 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7680 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7684 echo "No pages locked after fsync"
7689 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7692 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7693 remote_ost_nodsh && skip "remote OST with nodsh" && return
7697 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7698 set_nodes_failloc "$(osts_nodes)" 0x20e
7699 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7700 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7703 set_nodes_failloc "$(osts_nodes)" 0
7704 if [[ $RC -eq 0 ]]; then
7705 error "Must return error due to dropped pages, rc=$RC"
7708 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7709 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7710 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7712 if [[ $LOCKED -ne 0 ]]; then
7713 error "Locked pages remain in cache, locked=$LOCKED"
7716 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7717 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7721 echo "No pages locked after fsync"
7725 run_test 118h "Verify timeout in handling recoverables errors =========="
7727 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7731 remote_ost_nodsh && skip "remote OST with nodsh" && return
7735 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7736 set_nodes_failloc "$(osts_nodes)" 0x20e
7738 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7739 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7742 set_nodes_failloc "$(osts_nodes)" 0
7746 if [[ $RC -ne 0 ]]; then
7747 error "got error, but should be not, rc=$RC"
7750 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7751 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7752 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7753 if [[ $LOCKED -ne 0 ]]; then
7754 error "Locked pages remain in cache, locked=$LOCKED"
7757 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7758 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7762 echo "No pages locked after fsync"
7766 run_test 118i "Fix error before timeout in recoverable error =========="
7768 [ "$SLOW" = "no" ] && set_resend_count 4
7771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7772 remote_ost_nodsh && skip "remote OST with nodsh" && return
7776 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7777 set_nodes_failloc "$(osts_nodes)" 0x220
7779 # return -EIO from OST
7780 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7782 set_nodes_failloc "$(osts_nodes)" 0x0
7783 if [[ $RC -eq 0 ]]; then
7784 error "Must return error due to dropped pages, rc=$RC"
7787 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7788 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7789 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7790 if [[ $LOCKED -ne 0 ]]; then
7791 error "Locked pages remain in cache, locked=$LOCKED"
7794 # in recoverable error on OST we want resend and stay until it finished
7795 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7796 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7800 echo "No pages locked after fsync"
7804 run_test 118j "Simulate unrecoverable OST side error =========="
7808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7809 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7811 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7812 set_nodes_failloc "$(osts_nodes)" 0x20e
7813 test_mkdir -p $DIR/$tdir
7815 for ((i=0;i<10;i++)); do
7816 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7817 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7824 set_nodes_failloc "$(osts_nodes)" 0
7827 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7833 test_mkdir -p $DIR/$tdir
7834 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7837 run_test 118l "fsync dir ========="
7839 test_118m() # LU-3066
7841 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7842 test_mkdir -p $DIR/$tdir
7843 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7846 run_test 118m "fdatasync dir ========="
7848 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7850 test_119a() # bug 11737
7852 BSIZE=$((512 * 1024))
7853 directio write $DIR/$tfile 0 1 $BSIZE
7854 # We ask to read two blocks, which is more than a file size.
7855 # directio will indicate an error when requested and actual
7856 # sizes aren't equeal (a normal situation in this case) and
7857 # print actual read amount.
7858 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7859 if [ "$NOB" != "$BSIZE" ]; then
7860 error "read $NOB bytes instead of $BSIZE"
7864 run_test 119a "Short directIO read must return actual read amount"
7866 test_119b() # bug 11737
7868 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7870 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7871 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7873 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7874 error "direct read failed"
7877 run_test 119b "Sparse directIO read must return actual read amount"
7879 test_119c() # bug 13099
7882 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7883 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7886 run_test 119c "Testing for direct read hitting hole"
7888 test_119d() # bug 15950
7890 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7891 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7892 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7894 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7895 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7896 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7897 lctl set_param fail_loc=0x40d
7898 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7901 cat $DIR/$tfile > /dev/null &
7902 lctl set_param fail_loc=0
7905 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7907 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7908 error "the read rpcs have not completed in 2s"
7910 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7912 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7916 test_mkdir -p $DIR/$tdir
7917 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7918 skip "no early lock cancel on server" && return 0
7920 lru_resize_disable mdc
7921 lru_resize_disable osc
7922 cancel_lru_locks mdc
7923 # asynchronous object destroy at MDT could cause bl ast to client
7924 cancel_lru_locks osc
7926 stat $DIR/$tdir > /dev/null
7927 can1=$(do_facet $SINGLEMDS \
7928 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7929 awk '/ldlm_cancel/ {print $2}')
7930 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7931 awk '/ldlm_bl_callback/ {print $2}')
7932 test_mkdir -c1 $DIR/$tdir/d1
7933 can2=$(do_facet $SINGLEMDS \
7934 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7935 awk '/ldlm_cancel/ {print $2}')
7936 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7937 awk '/ldlm_bl_callback/ {print $2}')
7938 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7939 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7940 lru_resize_enable mdc
7941 lru_resize_enable osc
7943 run_test 120a "Early Lock Cancel: mkdir test"
7946 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7947 test_mkdir $DIR/$tdir
7948 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7949 skip "no early lock cancel on server" && return 0
7950 lru_resize_disable mdc
7951 lru_resize_disable osc
7952 cancel_lru_locks mdc
7953 stat $DIR/$tdir > /dev/null
7954 can1=$(do_facet $SINGLEMDS \
7955 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7956 awk '/ldlm_cancel/ {print $2}')
7957 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7958 awk '/ldlm_bl_callback/ {print $2}')
7960 can2=$(do_facet $SINGLEMDS \
7961 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7962 awk '/ldlm_cancel/ {print $2}')
7963 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7964 awk '/ldlm_bl_callback/ {print $2}')
7965 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7966 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7967 lru_resize_enable mdc
7968 lru_resize_enable osc
7970 run_test 120b "Early Lock Cancel: create test"
7973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7974 test_mkdir -c1 $DIR/$tdir
7975 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7976 skip "no early lock cancel on server" && return 0
7977 lru_resize_disable mdc
7978 lru_resize_disable osc
7979 test_mkdir -p -c1 $DIR/$tdir/d1
7980 test_mkdir -p -c1 $DIR/$tdir/d2
7981 touch $DIR/$tdir/d1/f1
7982 cancel_lru_locks mdc
7983 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7984 can1=$(do_facet $SINGLEMDS \
7985 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7986 awk '/ldlm_cancel/ {print $2}')
7987 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7988 awk '/ldlm_bl_callback/ {print $2}')
7989 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7990 can2=$(do_facet $SINGLEMDS \
7991 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7992 awk '/ldlm_cancel/ {print $2}')
7993 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7994 awk '/ldlm_bl_callback/ {print $2}')
7995 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7996 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7997 lru_resize_enable mdc
7998 lru_resize_enable osc
8000 run_test 120c "Early Lock Cancel: link test"
8003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8004 test_mkdir -p -c1 $DIR/$tdir
8005 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8006 skip "no early lock cancel on server" && return 0
8007 lru_resize_disable mdc
8008 lru_resize_disable osc
8010 cancel_lru_locks mdc
8011 stat $DIR/$tdir > /dev/null
8012 can1=$(do_facet $SINGLEMDS \
8013 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8014 awk '/ldlm_cancel/ {print $2}')
8015 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8016 awk '/ldlm_bl_callback/ {print $2}')
8017 chmod a+x $DIR/$tdir
8018 can2=$(do_facet $SINGLEMDS \
8019 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8020 awk '/ldlm_cancel/ {print $2}')
8021 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8022 awk '/ldlm_bl_callback/ {print $2}')
8023 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8024 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8025 lru_resize_enable mdc
8026 lru_resize_enable osc
8028 run_test 120d "Early Lock Cancel: setattr test"
8031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8032 test_mkdir -p -c1 $DIR/$tdir
8033 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8034 skip "no early lock cancel on server" && return 0
8035 lru_resize_disable mdc
8036 lru_resize_disable osc
8037 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8038 cancel_lru_locks mdc
8039 cancel_lru_locks osc
8040 dd if=$DIR/$tdir/f1 of=/dev/null
8041 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8042 # XXX client can not do early lock cancel of OST lock
8043 # during unlink (LU-4206), so cancel osc lock now.
8044 cancel_lru_locks osc
8045 can1=$(do_facet $SINGLEMDS \
8046 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8047 awk '/ldlm_cancel/ {print $2}')
8048 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8049 awk '/ldlm_bl_callback/ {print $2}')
8050 unlink $DIR/$tdir/f1
8052 can2=$(do_facet $SINGLEMDS \
8053 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8054 awk '/ldlm_cancel/ {print $2}')
8055 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8056 awk '/ldlm_bl_callback/ {print $2}')
8057 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8058 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8059 lru_resize_enable mdc
8060 lru_resize_enable osc
8062 run_test 120e "Early Lock Cancel: unlink test"
8065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8066 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8067 skip "no early lock cancel on server" && return 0
8068 test_mkdir -p -c1 $DIR/$tdir
8069 lru_resize_disable mdc
8070 lru_resize_disable osc
8071 test_mkdir -p -c1 $DIR/$tdir/d1
8072 test_mkdir -p -c1 $DIR/$tdir/d2
8073 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8074 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8075 cancel_lru_locks mdc
8076 cancel_lru_locks osc
8077 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8078 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8079 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8080 # XXX client can not do early lock cancel of OST lock
8081 # during rename (LU-4206), so cancel osc lock now.
8082 cancel_lru_locks osc
8083 can1=$(do_facet $SINGLEMDS \
8084 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8085 awk '/ldlm_cancel/ {print $2}')
8086 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8087 awk '/ldlm_bl_callback/ {print $2}')
8088 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8090 can2=$(do_facet $SINGLEMDS \
8091 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8092 awk '/ldlm_cancel/ {print $2}')
8093 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8094 awk '/ldlm_bl_callback/ {print $2}')
8095 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8096 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8097 lru_resize_enable mdc
8098 lru_resize_enable osc
8100 run_test 120f "Early Lock Cancel: rename test"
8103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8104 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8105 skip "no early lock cancel on server" && return 0
8106 lru_resize_disable mdc
8107 lru_resize_disable osc
8109 echo create $count files
8110 test_mkdir -p $DIR/$tdir
8111 cancel_lru_locks mdc
8112 cancel_lru_locks osc
8115 can0=$(do_facet $SINGLEMDS \
8116 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8117 awk '/ldlm_cancel/ {print $2}')
8118 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8119 awk '/ldlm_bl_callback/ {print $2}')
8120 createmany -o $DIR/$tdir/f $count
8122 can1=$(do_facet $SINGLEMDS \
8123 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8124 awk '/ldlm_cancel/ {print $2}')
8125 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8126 awk '/ldlm_bl_callback/ {print $2}')
8128 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8129 echo rm $count files
8132 can2=$(do_facet $SINGLEMDS \
8133 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8134 awk '/ldlm_cancel/ {print $2}')
8135 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8136 awk '/ldlm_bl_callback/ {print $2}')
8138 echo total: $count removes in $((t2-t1))
8139 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8141 # wait for commitment of removal
8142 lru_resize_enable mdc
8143 lru_resize_enable osc
8145 run_test 120g "Early Lock Cancel: performance test"
8147 test_121() { #bug #10589
8148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8150 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8151 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8152 lctl set_param fail_loc=0x310
8153 cancel_lru_locks osc > /dev/null
8154 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8155 lctl set_param fail_loc=0
8156 [[ $reads -eq $writes ]] ||
8157 error "read $reads blocks, must be $writes blocks"
8159 run_test 121 "read cancel race ========="
8161 test_123a() { # was test 123, statahead(bug 11401)
8162 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8164 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8165 log "testing on UP system. Performance may be not as good as expected."
8170 test_mkdir -p $DIR/$tdir
8171 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8172 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8174 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8175 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8177 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8178 lctl set_param -n llite.*.statahead_max 0
8179 lctl get_param llite.*.statahead_max
8180 cancel_lru_locks mdc
8181 cancel_lru_locks osc
8183 time ls -l $DIR/$tdir | wc -l
8185 delta=$((etime - stime))
8186 log "ls $i files without statahead: $delta sec"
8187 lctl set_param llite.*.statahead_max=$max
8189 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8190 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8191 cancel_lru_locks mdc
8192 cancel_lru_locks osc
8194 time ls -l $DIR/$tdir | wc -l
8196 delta_sa=$((etime - stime))
8197 log "ls $i files with statahead: $delta_sa sec"
8198 lctl get_param -n llite.*.statahead_stats
8199 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8201 [[ $swrong -lt $ewrong ]] &&
8202 log "statahead was stopped, maybe too many locks held!"
8203 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8205 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8206 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8207 lctl set_param -n llite.*.statahead_max 0
8208 lctl get_param llite.*.statahead_max
8209 cancel_lru_locks mdc
8210 cancel_lru_locks osc
8212 time ls -l $DIR/$tdir | wc -l
8214 delta=$((etime - stime))
8215 log "ls $i files again without statahead: $delta sec"
8216 lctl set_param llite.*.statahead_max=$max
8217 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8218 if [ $SLOWOK -eq 0 ]; then
8219 error "ls $i files is slower with statahead!"
8221 log "ls $i files is slower with statahead!"
8227 [ $delta -gt 20 ] && break
8228 [ $delta -gt 8 ] && MULT=$((50 / delta))
8229 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8237 delta=$((etime - stime))
8238 log "rm -r $DIR/$tdir/: $delta seconds"
8240 lctl get_param -n llite.*.statahead_stats
8242 run_test 123a "verify statahead work"
8244 test_123b () { # statahead(bug 15027)
8245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8246 test_mkdir -p $DIR/$tdir
8247 createmany -o $DIR/$tdir/$tfile-%d 1000
8249 cancel_lru_locks mdc
8250 cancel_lru_locks osc
8252 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8253 lctl set_param fail_loc=0x80000803
8254 ls -lR $DIR/$tdir > /dev/null
8256 lctl set_param fail_loc=0x0
8257 lctl get_param -n llite.*.statahead_stats
8262 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8265 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8266 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8267 skip "no lru resize on server" && return 0
8269 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8271 log "create $NR files at $DIR/$tdir"
8272 createmany -o $DIR/$tdir/f $NR ||
8273 error "failed to create $NR files in $DIR/$tdir"
8275 cancel_lru_locks mdc
8276 ls -l $DIR/$tdir > /dev/null
8280 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8281 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8282 LRU_SIZE=$($LCTL get_param -n $PARAM)
8283 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8284 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8286 log "NS=$(basename $NSDIR)"
8291 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8292 skip "Not enough cached locks created!"
8299 # We know that lru resize allows one client to hold $LIMIT locks
8300 # for 10h. After that locks begin to be killed by client.
8302 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8304 if [ $LIMIT -lt $LRU_SIZE ]; then
8305 skip "Limit is too small $LIMIT"
8309 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8310 # killing locks. Some time was spent for creating locks. This means
8311 # that up to the moment of sleep finish we must have killed some of
8312 # them (10-100 locks). This depends on how fast ther were created.
8313 # Many of them were touched in almost the same moment and thus will
8314 # be killed in groups.
8315 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8317 # Use $LRU_SIZE_B here to take into account real number of locks
8318 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8319 local LRU_SIZE_B=$LRU_SIZE
8321 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8322 log "OLD_LVF=$OLD_LVF"
8323 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8325 # Let's make sure that we really have some margin. Client checks
8326 # cached locks every 10 sec.
8328 log "Sleep ${SLEEP} sec"
8330 while ((SEC<$SLEEP)); do
8334 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8338 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8339 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8341 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8342 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8343 unlinkmany $DIR/$tdir/f $NR
8347 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8348 log "unlink $NR files at $DIR/$tdir"
8349 unlinkmany $DIR/$tdir/f $NR
8351 run_test 124a "lru resize ======================================="
8353 get_max_pool_limit()
8355 local limit=$($LCTL get_param \
8356 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8359 if [[ $l -gt $max ]]; then
8367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8368 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8369 skip "no lru resize on server" && return 0
8371 LIMIT=$(get_max_pool_limit)
8373 NR=$(($(default_lru_size)*20))
8374 if [[ $NR -gt $LIMIT ]]; then
8375 log "Limit lock number by $LIMIT locks"
8378 lru_resize_disable mdc
8379 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8380 error "failed to create $DIR/$tdir/disable_lru_resize"
8382 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8383 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8384 cancel_lru_locks mdc
8387 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8390 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8393 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8397 nolruresize_delta=$((etime-stime))
8398 log "ls -la time: $nolruresize_delta seconds"
8399 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8400 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8402 lru_resize_enable mdc
8403 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8404 error "failed to create $DIR/$tdir/enable_lru_resize"
8406 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8407 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8408 cancel_lru_locks mdc
8411 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8414 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8417 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8421 lruresize_delta=$((etime-stime))
8422 log "ls -la time: $lruresize_delta seconds"
8423 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8425 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8426 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8427 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8428 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8430 log "lru resize performs the same with no lru resize"
8432 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8434 run_test 124b "lru resize (performance test) ======================="
8437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8438 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8439 skip "no lru resize on server" && return 0
8441 # cache ununsed locks on client
8443 cancel_lru_locks mdc
8444 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8445 createmany -o $DIR/$tdir/f $nr ||
8446 error "failed to create $nr files in $DIR/$tdir"
8447 ls -l $DIR/$tdir > /dev/null
8449 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
8450 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
8451 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
8452 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
8453 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
8455 # set lru_max_age to 1 sec
8456 $LCTL set_param $nsdir.lru_max_age=1000 # jiffies
8457 echo "sleep $((recalc_p * 2)) seconds..."
8458 sleep $((recalc_p * 2))
8460 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
8461 # restore lru_max_age
8462 $LCTL set_param -n $nsdir.lru_max_age $max_age
8463 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
8464 unlinkmany $DIR/$tdir/f $nr
8466 run_test 124c "LRUR cancel very aged locks"
8468 test_125() { # 13358
8469 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8470 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8471 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8472 test_mkdir -p $DIR/d125 || error "mkdir failed"
8473 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8474 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8475 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8477 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8479 test_126() { # bug 12829/13455
8480 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8481 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8482 $GSS && skip "must run as gss disabled" && return
8484 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8485 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8487 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8489 run_test 126 "check that the fsgid provided by the client is taken into account"
8491 test_127a() { # bug 15521
8492 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8493 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8494 $LCTL set_param osc.*.stats=0
8495 FSIZE=$((2048 * 1024))
8496 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8497 cancel_lru_locks osc
8498 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8500 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8501 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8502 echo "got $COUNT $NAME"
8503 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8504 eval $NAME=$COUNT || error "Wrong proc format"
8507 read_bytes|write_bytes)
8508 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8509 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8510 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8511 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8512 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8513 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8514 error "sumsquare is too small: $SUMSQ"
8515 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8516 error "sumsquare is too big: $SUMSQ"
8520 done < $DIR/${tfile}.tmp
8522 #check that we actually got some stats
8523 [ "$read_bytes" ] || error "Missing read_bytes stats"
8524 [ "$write_bytes" ] || error "Missing write_bytes stats"
8525 [ "$read_bytes" != 0 ] || error "no read done"
8526 [ "$write_bytes" != 0 ] || error "no write done"
8528 run_test 127a "verify the client stats are sane"
8530 test_127b() { # bug LU-333
8531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8532 $LCTL set_param llite.*.stats=0
8533 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8534 # perform 2 reads and writes so MAX is different from SUM.
8535 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8536 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8537 cancel_lru_locks osc
8538 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8539 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8541 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8542 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8543 echo "got $COUNT $NAME"
8544 eval $NAME=$COUNT || error "Wrong proc format"
8548 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8549 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8550 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8551 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8554 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8555 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8556 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8557 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8561 done < $TMP/${tfile}.tmp
8563 #check that we actually got some stats
8564 [ "$read_bytes" ] || error "Missing read_bytes stats"
8565 [ "$write_bytes" ] || error "Missing write_bytes stats"
8566 [ "$read_bytes" != 0 ] || error "no read done"
8567 [ "$write_bytes" != 0 ] || error "no write done"
8569 run_test 127b "verify the llite client stats are sane"
8571 test_128() { # bug 15212
8573 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8578 result=$(grep error $TMP/$tfile.log)
8580 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8582 run_test 128 "interactive lfs for 2 consecutive find's"
8589 local LDPROC=/proc/fs/ldiskfs
8590 local facets=$(get_facets MDS)
8592 for facet in ${facets//,/ }; do
8593 canondev=$(ldiskfs_canon \
8594 *.$(convert_facet2label $facet).mntdev $facet)
8595 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8596 LDPROC=/sys/fs/ldiskfs
8597 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8603 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8604 skip "Only applicable to ldiskfs-based MDTs"
8607 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8612 test_mkdir -p $DIR/$tdir
8614 # block size of mds1
8615 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8616 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8617 local MAX=$((MDSBLOCKSIZE * 3))
8619 local I=$(stat -c%s "$DIR/$tdir")
8621 local STRIPE_COUNT=1
8622 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8623 MAX=$((MAX*STRIPE_COUNT))
8624 while [[ $I -le $MAX ]]; do
8625 $MULTIOP $DIR/$tdir/$J Oc
8627 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8628 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8629 #and EFBIG for previous versions
8630 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8632 echo "return code $rc received as expected"
8633 multiop $DIR/$tdir/$J Oc ||
8634 error_exit "multiop failed w/o dir size limit"
8636 I=$(stat -c%s "$DIR/$tdir")
8638 if [ $(lustre_version_code $SINGLEMDS) -lt \
8639 $(version_code 2.4.51) ]
8641 [[ $I -eq $MAX ]] && return 0
8643 [[ $I -gt $MAX ]] && return 0
8645 error_exit "current dir size $I, previous limit $MAX"
8646 elif [ $rc -ne 0 ]; then
8648 error_exit "return code $rc received instead of expected " \
8649 "$EFBIG or $ENOSPC, files in dir $I"
8652 I=$(stat -c%s "$DIR/$tdir")
8656 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8658 run_test 129 "test directory size limit ========================"
8667 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8668 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8671 trap cleanup_130 EXIT RETURN
8673 local fm_file=$DIR/$tfile
8674 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8675 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8676 error "dd failed for $fm_file"
8678 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8679 filefrag -ves $fm_file
8681 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8682 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8683 [ $RC != 0 ] && error "filefrag $fm_file failed"
8685 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8686 grep -v "ext:" | grep -v "found")
8687 lun=$($GETSTRIPE -i $fm_file)
8689 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8692 for line in $filefrag_op
8694 frag_lun=`echo $line | cut -d: -f5`
8695 ext_len=`echo $line | cut -d: -f4`
8696 if (( $frag_lun != $lun )); then
8698 error "FIEMAP on 1-stripe file($fm_file) failed"
8701 (( tot_len += ext_len ))
8704 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8706 error "FIEMAP on 1-stripe file($fm_file) failed;"
8712 echo "FIEMAP on single striped file succeeded"
8714 run_test 130a "FIEMAP (1-stripe file)"
8717 [ "$OSTCOUNT" -lt "2" ] &&
8718 skip_env "skipping FIEMAP on 2-stripe file test" && return
8720 [ "$OSTCOUNT" -ge "10" ] &&
8721 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8723 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8724 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8727 trap cleanup_130 EXIT RETURN
8729 local fm_file=$DIR/$tfile
8730 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8731 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8732 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8734 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8735 error "dd failed on $fm_file"
8737 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8738 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8739 grep -v "ext:" | grep -v "found")
8741 last_lun=$(echo $filefrag_op | cut -d: -f5)
8746 for line in $filefrag_op
8748 frag_lun=`echo $line | cut -d: -f5`
8749 ext_len=`echo $line | cut -d: -f4`
8750 if (( $frag_lun != $last_lun )); then
8751 if (( tot_len != 1024 )); then
8753 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8760 (( tot_len += ext_len ))
8763 if (( num_luns != 2 || tot_len != 1024 )); then
8765 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8771 echo "FIEMAP on 2-stripe file succeeded"
8773 run_test 130b "FIEMAP (2-stripe file)"
8776 [ "$OSTCOUNT" -lt "2" ] &&
8777 skip_env "skipping FIEMAP on 2-stripe file" && return
8779 [ "$OSTCOUNT" -ge "10" ] &&
8780 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8782 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8783 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8786 trap cleanup_130 EXIT RETURN
8788 local fm_file=$DIR/$tfile
8789 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8790 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8791 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8793 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8795 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8796 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8798 last_lun=`echo $filefrag_op | cut -d: -f5`
8803 for line in $filefrag_op
8805 frag_lun=`echo $line | cut -d: -f5`
8806 ext_len=`echo $line | cut -d: -f4`
8807 if (( $frag_lun != $last_lun )); then
8808 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8809 if (( logical != 512 )); then
8811 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8814 if (( tot_len != 512 )); then
8816 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8823 (( tot_len += ext_len ))
8826 if (( num_luns != 2 || tot_len != 512 )); then
8828 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8834 echo "FIEMAP on 2-stripe file with hole succeeded"
8836 run_test 130c "FIEMAP (2-stripe file with hole)"
8839 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8841 [ "$OSTCOUNT" -ge "10" ] &&
8842 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8844 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8845 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8847 trap cleanup_130 EXIT RETURN
8849 local fm_file=$DIR/$tfile
8850 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8851 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8852 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8854 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8855 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8856 error "dd failed on $fm_file"
8858 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8859 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8860 grep -v "ext:" | grep -v "found"`
8862 last_lun=`echo $filefrag_op | cut -d: -f5`
8867 for line in $filefrag_op
8869 frag_lun=`echo $line | cut -d: -f5`
8870 ext_len=`echo $line | cut -d: -f4`
8871 if (( $frag_lun != $last_lun )); then
8872 if (( tot_len != 1024 )); then
8874 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8881 (( tot_len += ext_len ))
8884 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8886 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8892 echo "FIEMAP on N-stripe file succeeded"
8894 run_test 130d "FIEMAP (N-stripe file)"
8897 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8899 [ "$OSTCOUNT" -ge "10" ] &&
8900 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8902 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8903 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8905 trap cleanup_130 EXIT RETURN
8907 local fm_file=$DIR/$tfile
8908 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8909 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8910 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8913 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8914 for ((i = 0; i < $NUM_BLKS; i++))
8916 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8919 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8920 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8922 last_lun=`echo $filefrag_op | cut -d: -f5`
8927 for line in $filefrag_op
8929 frag_lun=`echo $line | cut -d: -f5`
8930 ext_len=`echo $line | cut -d: -f4`
8931 if (( $frag_lun != $last_lun )); then
8932 if (( tot_len != $EXPECTED_LEN )); then
8934 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8941 (( tot_len += ext_len ))
8944 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8946 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8952 echo "FIEMAP with continuation calls succeeded"
8954 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8956 # Test for writev/readv
8958 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8959 error "writev test failed"
8960 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8961 error "readv failed"
8964 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8967 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8968 error "append writev test failed"
8969 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8970 error "append writev test failed"
8973 run_test 131b "test append writev"
8976 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8979 run_test 131c "test read/write on file w/o objects"
8982 rwv -f $DIR/$tfile -w -n 1 1572864
8983 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8984 if [ "$NOB" != 1572864 ]; then
8985 error "Short read filed: read $NOB bytes instead of 1572864"
8989 run_test 131d "test short read"
8992 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8993 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8994 error "read hitting hole failed"
8997 run_test 131e "test read hitting hole"
9003 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9005 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9007 *) error "Wrong argument $1" ;;
9010 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9011 # if the argument $3 is zero, it means any stat increment is ok.
9012 if [[ $3 -gt 0 ]]; then
9013 count=$(echo $res | awk '{ print $2 }')
9014 [[ $count -ne $3 ]] &&
9015 error "The $2 counter on $1 is wrong - expected $3"
9020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9021 remote_ost_nodsh && skip "remote OST with nodsh" && return
9022 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9024 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9025 { skip "MDS doesn't support rename stats"; return; }
9026 local testdir=$DIR/${tdir}/stats_testdir
9027 mkdir -p $DIR/${tdir}
9030 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9031 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9033 # verify mdt stats first.
9034 mkdir ${testdir} || error "mkdir failed"
9035 check_stats $SINGLEMDS "mkdir" 1
9036 touch ${testdir}/${tfile} || "touch failed"
9037 check_stats $SINGLEMDS "open" 1
9038 check_stats $SINGLEMDS "close" 1
9039 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9040 check_stats $SINGLEMDS "mknod" 1
9041 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9042 check_stats $SINGLEMDS "unlink" 1
9043 rm -f ${testdir}/${tfile} || error "file remove failed"
9044 check_stats $SINGLEMDS "unlink" 2
9046 # remove working dir and check mdt stats again.
9047 rmdir ${testdir} || error "rmdir failed"
9048 check_stats $SINGLEMDS "rmdir" 1
9050 local testdir1=$DIR/${tdir}/stats_testdir1
9052 mkdir -p ${testdir1}
9053 touch ${testdir1}/test1
9054 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9055 check_stats $SINGLEMDS "crossdir_rename" 1
9057 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9058 check_stats $SINGLEMDS "samedir_rename" 1
9062 run_test 133a "Verifying MDT stats ========================================"
9065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9066 remote_ost_nodsh && skip "remote OST with nodsh" && return
9067 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9068 local testdir=$DIR/${tdir}/stats_testdir
9069 mkdir -p ${testdir} || error "mkdir failed"
9070 touch ${testdir}/${tfile} || "touch failed"
9071 cancel_lru_locks mdc
9074 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9075 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9077 # extra mdt stats verification.
9078 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9079 check_stats $SINGLEMDS "setattr" 1
9080 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9081 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9083 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9084 check_stats $SINGLEMDS "getattr" 1
9086 $LFS df || error "lfs failed"
9087 check_stats $SINGLEMDS "statfs" 1
9091 run_test 133b "Verifying extra MDT stats =================================="
9094 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9095 remote_ost_nodsh && skip "remote OST with nodsh" && return
9096 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9097 local testdir=$DIR/${tdir}/stats_testdir
9098 test_mkdir -p ${testdir} || error "mkdir failed"
9100 # verify obdfilter stats.
9101 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9103 cancel_lru_locks osc
9104 wait_delete_completed
9107 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9108 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9110 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9112 cancel_lru_locks osc
9113 check_stats ost "write" 1
9115 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9116 check_stats ost "read" 1
9118 > ${testdir}/${tfile} || error "truncate failed"
9119 check_stats ost "punch" 1
9121 rm -f ${testdir}/${tfile} || error "file remove failed"
9122 wait_delete_completed
9123 check_stats ost "destroy" 1
9127 run_test 133c "Verifying OST stats ========================================"
9134 while [ $value -ge 2 ]; do
9139 if [ $orig -gt $order ]; then
9147 local size=('K' 'M' 'G' 'T');
9149 local size_string=$value
9151 while [ $value -ge 1024 ]; do
9152 if [ $i -gt 3 ]; then
9153 #T is the biggest unit we get here, if that is bigger,
9155 size_string=${value}T
9158 value=$((value >> 10))
9159 if [ $value -lt 1024 ]; then
9160 size_string=${value}${size[$i]}
9171 local context=${2:-.}
9172 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9174 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9179 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9180 remote_ost_nodsh && skip "remote OST with nodsh" && return
9181 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9182 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9183 { skip "MDS doesn't support rename stats"; return; }
9185 local testdir1=$DIR/${tdir}/stats_testdir1
9186 local testdir2=$DIR/${tdir}/stats_testdir2
9188 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9190 mkdir -p ${testdir1} || error "mkdir failed"
9191 mkdir -p ${testdir2} || error "mkdir failed"
9193 createmany -o $testdir1/test 512 || error "createmany failed"
9195 # check samedir rename size
9196 mv ${testdir1}/test0 ${testdir1}/test_0
9198 local testdir1_size=$(ls -l $DIR/${tdir} |
9199 awk '/stats_testdir1/ {print $5}')
9200 local testdir2_size=$(ls -l $DIR/${tdir} |
9201 awk '/stats_testdir2/ {print $5}')
9203 testdir1_size=$(order_2 $testdir1_size)
9204 testdir2_size=$(order_2 $testdir2_size)
9206 testdir1_size=$(size_in_KMGT $testdir1_size)
9207 testdir2_size=$(size_in_KMGT $testdir2_size)
9209 echo "source rename dir size: ${testdir1_size}"
9210 echo "target rename dir size: ${testdir2_size}"
9212 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9213 eval $cmd || error "$cmd failed"
9214 local samedir=$($cmd | grep 'same_dir')
9215 local same_sample=$(get_rename_size $testdir1_size)
9216 [ -z "$samedir" ] && error "samedir_rename_size count error"
9217 [[ $same_sample -eq 1 ]] ||
9218 error "samedir_rename_size error $same_sample"
9219 echo "Check same dir rename stats success"
9221 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9223 # check crossdir rename size
9224 mv ${testdir1}/test_0 ${testdir2}/test_0
9226 testdir1_size=$(ls -l $DIR/${tdir} |
9227 awk '/stats_testdir1/ {print $5}')
9228 testdir2_size=$(ls -l $DIR/${tdir} |
9229 awk '/stats_testdir2/ {print $5}')
9231 testdir1_size=$(order_2 $testdir1_size)
9232 testdir2_size=$(order_2 $testdir2_size)
9234 testdir1_size=$(size_in_KMGT $testdir1_size)
9235 testdir2_size=$(size_in_KMGT $testdir2_size)
9237 echo "source rename dir size: ${testdir1_size}"
9238 echo "target rename dir size: ${testdir2_size}"
9240 eval $cmd || error "$cmd failed"
9241 local crossdir=$($cmd | grep 'crossdir')
9242 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9243 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9244 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9245 [[ $src_sample -eq 1 ]] ||
9246 error "crossdir_rename_size error $src_sample"
9247 [[ $tgt_sample -eq 1 ]] ||
9248 error "crossdir_rename_size error $tgt_sample"
9249 echo "Check cross dir rename stats success"
9252 run_test 133d "Verifying rename_stats ========================================"
9255 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9256 remote_ost_nodsh && skip "remote OST with nodsh" && return
9257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9258 local testdir=$DIR/${tdir}/stats_testdir
9259 local ctr f0 f1 bs=32768 count=42 sum
9261 mkdir -p ${testdir} || error "mkdir failed"
9263 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9265 for ctr in {write,read}_bytes; do
9267 cancel_lru_locks osc
9269 do_facet ost1 $LCTL set_param -n \
9270 "obdfilter.*.exports.clear=clear"
9272 if [ $ctr = write_bytes ]; then
9274 f1=${testdir}/${tfile}
9276 f0=${testdir}/${tfile}
9280 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9283 cancel_lru_locks osc
9285 sum=$(do_facet ost1 $LCTL get_param \
9286 "obdfilter.*.exports.*.stats" |
9287 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9288 $1 == ctr { sum += $7 }
9289 END { printf("%0.0f", sum) }')
9291 if ((sum != bs * count)); then
9292 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9298 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9303 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9304 /sys/fs/lustre/ /sys/fs/lnet/"
9306 for dir in $dirs; do
9307 if [ -d $dir ]; then
9308 proc_dirs="$proc_dirs $dir"
9314 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9315 remote_ost_nodsh && skip "remote OST with nodsh" && return
9316 # First without trusting modes.
9317 find $proc_dirs -exec cat '{}' \; &> /dev/null
9319 # Second verifying readability.
9322 -exec cat '{}' \; &> /dev/null ||
9323 error "proc file read failed"
9325 for facet in $SINGLEMDS ost1; do
9326 do_facet $facet find $proc_dirs \
9327 ! -name req_history \
9328 -exec cat '{}' \\\; &> /dev/null
9330 do_facet $facet find $proc_dirs \
9331 ! -name req_history \
9333 -exec cat '{}' \\\; &> /dev/null ||
9334 error "proc file read failed"
9337 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9342 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9343 /sys/fs/lustre/ /sys/fs/lnet/"
9345 for dir in $dirs; do
9346 if [ -d $dir ]; then
9347 proc_dirs="$proc_dirs $dir"
9353 # Second verifying readability.
9356 -not -name force_lbug \
9357 -not -name changelog_mask \
9358 -exec badarea_io '{}' \; &> /dev/null ||
9359 error "find $proc_dirs failed"
9361 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9362 skip "Too old lustre on MDS" && return
9364 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9365 skip "Too old lustre on ost1" && return
9367 for facet in $SINGLEMDS ost1; do
9368 do_facet $facet find $proc_dirs \
9370 -not -name force_lbug \
9371 -not -name changelog_mask \
9372 -exec badarea_io '{}' \\\; &> /dev/null ||
9373 error "$facet find $proc_dirs failed"
9377 # remount the FS in case writes/reads /proc break the FS
9378 cleanup || error "failed to unmount"
9379 setup || error "failed to setup"
9382 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9385 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9386 skip "Need MDS version at least 2.7.54" && return
9388 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9389 cancel_lru_locks mdc
9391 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
9392 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9393 [ $unused -eq 0 ] || "$unused locks are not cleared"
9396 createmany -o $DIR/$tdir/f $nr ||
9397 error "failed to create $nr files in $DIR/$tdir"
9398 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
9400 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
9401 do_facet mds1 $LCTL set_param fail_loc=0x327
9402 do_facet mds1 $LCTL set_param fail_val=500
9405 echo "sleep 10 seconds ..."
9407 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
9409 do_facet mds1 $LCTL set_param fail_loc=0
9410 do_facet mds1 $LCTL set_param fail_val=0
9411 [ $lck_cnt -lt $unused ] ||
9412 error "No locks reclaimed, before:$unused, after:$lck_cnt"
9415 unlinkmany $DIR/$tdir/f $nr
9417 run_test 134a "Server reclaims locks when reaching low watermark"
9420 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
9421 skip "Need MDS version at least 2.7.54" && return
9423 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
9424 cancel_lru_locks mdc
9426 local low_wm=$(do_facet mds1 $LCTL get_param -n ldlm.watermark_mb_low)
9427 # disable reclaim temporarily
9428 do_facet mds1 $LCTL set_param ldlm.watermark_mb_low=0
9430 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
9431 do_facet mds1 $LCTL set_param fail_loc=0x328
9432 do_facet mds1 $LCTL set_param fail_val=500
9434 $LCTL set_param debug=+trace
9437 createmany -o $DIR/$tdir/f $nr &
9440 echo "Sleep $TIMEOUT seconds ..."
9442 if ! ps -p $create_pid > /dev/null 2>&1; then
9443 do_facet mds1 $LCTL set_param fail_loc=0
9444 do_facet mds1 $LCTL set_param fail_val=0
9445 do_facet mds1 $LCTL set_param ldlm.watermark_mb_low=$low_wm
9446 error "createmany finished incorrectly!"
9448 do_facet mds1 $LCTL set_param fail_loc=0
9449 do_facet mds1 $LCTL set_param fail_val=0
9450 do_facet mds1 $LCTL set_param ldlm.watermark_mb_low=$low_wm
9451 wait $create_pid || return 1
9453 unlinkmany $DIR/$tdir/f $nr
9455 run_test 134b "Server rejects lock request when reaching high watermark"
9457 test_140() { #bug-17379
9458 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9459 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9460 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9461 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9463 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9464 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9466 while i=`expr $i + 1`; do
9467 test_mkdir -p $i || error "Creating dir $i"
9468 cd $i || error "Changing to $i"
9469 ln -s ../stat stat || error "Creating stat symlink"
9470 # Read the symlink until ELOOP present,
9471 # not LBUGing the system is considered success,
9472 # we didn't overrun the stack.
9473 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9475 if [ $ret -eq 40 ]; then
9478 error "Open stat symlink"
9484 echo "The symlink depth = $i"
9485 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9486 error "Invalid symlink depth"
9488 # Test recursive symlink
9489 ln -s symlink_self symlink_self
9490 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9491 echo "open symlink_self returns $ret"
9492 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9494 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9498 local TF="$TMP/$tfile"
9500 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9502 cancel_lru_locks osc
9503 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9504 remount_client $MOUNT
9506 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9509 $TRUNCATE $DIR/$tfile 6000
9510 cancel_lru_locks osc
9511 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9514 echo "12345" >>$DIR/$tfile
9515 cancel_lru_locks osc
9516 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9519 echo "12345" >>$DIR/$tfile
9520 cancel_lru_locks osc
9521 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9526 run_test 150 "truncate/append tests"
9528 #LU-2902 roc_hit was not able to read all values from lproc
9529 function roc_hit_init() {
9530 local list=$(comma_list $(osts_nodes))
9531 local dir=$DIR/$tdir-check
9532 local file=$dir/file
9538 #use setstripe to do a write to every ost
9539 for i in $(seq 0 $((OSTCOUNT-1))); do
9540 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9541 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9542 idx=$(printf %04x $i)
9543 BEFORE=$(get_osd_param $list *OST*$idx stats |
9544 awk '$1 == "cache_access" {sum += $7}
9545 END { printf("%0.0f", sum) }')
9547 cancel_lru_locks osc
9548 cat $file >/dev/null
9550 AFTER=$(get_osd_param $list *OST*$idx stats |
9551 awk '$1 == "cache_access" {sum += $7}
9552 END { printf("%0.0f", sum) }')
9554 echo BEFORE:$BEFORE AFTER:$AFTER
9555 if ! let "AFTER - BEFORE == 4"; then
9557 error "roc_hit is not safe to use"
9565 function roc_hit() {
9566 local list=$(comma_list $(osts_nodes))
9567 echo $(get_osd_param $list '' stats |
9568 awk '$1 == "cache_hit" {sum += $7}
9569 END { printf("%0.0f", sum) }')
9572 function set_cache() {
9575 if [ "$2" == "off" ]; then
9578 local list=$(comma_list $(osts_nodes))
9579 set_osd_param $list '' $1_cache_enable $on
9581 cancel_lru_locks osc
9585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9586 remote_ost_nodsh && skip "remote OST with nodsh" && return
9589 local list=$(comma_list $(osts_nodes))
9591 # check whether obdfilter is cache capable at all
9592 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9593 echo "not cache-capable obdfilter"
9597 # check cache is enabled on all obdfilters
9598 if get_osd_param $list '' read_cache_enable | grep 0; then
9599 echo "oss cache is disabled"
9603 set_osd_param $list '' writethrough_cache_enable 1
9605 # check write cache is enabled on all obdfilters
9606 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9607 echo "oss write cache is NOT enabled"
9613 #define OBD_FAIL_OBD_NO_LRU 0x609
9614 do_nodes $list $LCTL set_param fail_loc=0x609
9616 # pages should be in the case right after write
9617 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9620 local BEFORE=$(roc_hit)
9621 cancel_lru_locks osc
9622 cat $DIR/$tfile >/dev/null
9623 local AFTER=$(roc_hit)
9625 do_nodes $list $LCTL set_param fail_loc=0
9627 if ! let "AFTER - BEFORE == CPAGES"; then
9628 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9631 # the following read invalidates the cache
9632 cancel_lru_locks osc
9633 set_osd_param $list '' read_cache_enable 0
9634 cat $DIR/$tfile >/dev/null
9636 # now data shouldn't be found in the cache
9638 cancel_lru_locks osc
9639 cat $DIR/$tfile >/dev/null
9641 if let "AFTER - BEFORE != 0"; then
9642 error "IN CACHE: before: $BEFORE, after: $AFTER"
9645 set_osd_param $list '' read_cache_enable 1
9648 run_test 151 "test cache on oss and controls ==============================="
9651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9652 local TF="$TMP/$tfile"
9654 # simulate ENOMEM during write
9655 #define OBD_FAIL_OST_NOMEM 0x226
9656 lctl set_param fail_loc=0x80000226
9657 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9659 sync || error "sync failed"
9660 lctl set_param fail_loc=0
9662 # discard client's cache
9663 cancel_lru_locks osc
9665 # simulate ENOMEM during read
9666 lctl set_param fail_loc=0x80000226
9667 cmp $TF $DIR/$tfile || error "cmp failed"
9668 lctl set_param fail_loc=0
9672 run_test 152 "test read/write with enomem ============================"
9675 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9677 run_test 153 "test if fdatasync does not crash ======================="
9679 dot_lustre_fid_permission_check() {
9681 local ffid=$MOUNT/.lustre/fid/$fid
9684 echo "stat fid $fid"
9685 stat $ffid > /dev/null || error "stat $ffid failed."
9686 echo "touch fid $fid"
9687 touch $ffid || error "touch $ffid failed."
9688 echo "write to fid $fid"
9689 cat /etc/hosts > $ffid || error "write $ffid failed."
9690 echo "read fid $fid"
9691 diff /etc/hosts $ffid || error "read $ffid failed."
9692 echo "append write to fid $fid"
9693 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9694 echo "rename fid $fid"
9695 mv $ffid $test_dir/$tfile.1 &&
9696 error "rename $ffid to $tfile.1 should fail."
9697 touch $test_dir/$tfile.1
9698 mv $test_dir/$tfile.1 $ffid &&
9699 error "rename $tfile.1 to $ffid should fail."
9700 rm -f $test_dir/$tfile.1
9701 echo "truncate fid $fid"
9702 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9703 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9704 echo "link fid $fid"
9705 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9707 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9708 echo "setfacl fid $fid"
9709 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9710 echo "getfacl fid $fid"
9711 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9713 echo "unlink fid $fid"
9714 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9715 echo "mknod fid $fid"
9716 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9718 fid=[0xf00000400:0x1:0x0]
9719 ffid=$MOUNT/.lustre/fid/$fid
9721 echo "stat non-exist fid $fid"
9722 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9723 echo "write to non-exist fid $fid"
9724 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9725 echo "link new fid $fid"
9726 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9728 mkdir -p $test_dir/$tdir
9729 touch $test_dir/$tdir/$tfile
9730 fid=$($LFS path2fid $test_dir/$tdir)
9733 error "error: could not get fid for $test_dir/$dir/$tfile."
9735 ffid=$MOUNT/.lustre/fid/$fid
9738 ls $ffid > /dev/null || error "ls $ffid failed."
9739 echo "touch $fid/$tfile.1"
9740 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9742 echo "touch $MOUNT/.lustre/fid/$tfile"
9743 touch $MOUNT/.lustre/fid/$tfile && \
9744 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9746 echo "setxattr to $MOUNT/.lustre/fid"
9747 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9749 echo "listxattr for $MOUNT/.lustre/fid"
9750 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9752 echo "delxattr from $MOUNT/.lustre/fid"
9753 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9755 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9756 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9757 error "touch invalid fid should fail."
9759 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9760 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9761 error "touch non-normal fid should fail."
9763 echo "rename $tdir to $MOUNT/.lustre/fid"
9764 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9765 error "rename to $MOUNT/.lustre/fid should fail."
9767 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9769 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9770 local new_obf_mode=777
9772 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9773 chmod $new_obf_mode $DIR/.lustre/fid ||
9774 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9776 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9777 [ $obf_mode -eq $new_obf_mode ] ||
9778 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9780 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9781 chmod $old_obf_mode $DIR/.lustre/fid ||
9782 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9785 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9786 fid=$($LFS path2fid $test_dir/$tfile-2)
9788 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9790 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9791 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9792 error "create lov data thru .lustre failed"
9794 echo "cp /etc/passwd $test_dir/$tfile-2"
9795 cp /etc/passwd $test_dir/$tfile-2 ||
9796 error "copy to $test_dir/$tfile-2 failed."
9797 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9798 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9799 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9801 rm -rf $test_dir/tfile.lnk
9802 rm -rf $test_dir/$tfile-2
9806 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9807 skip "Need MDS version at least 2.4.1" && return
9810 local FID=$($LFS path2fid $DIR/$tfile)
9811 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9813 # check that we get the same pathname back
9814 local FOUND=$($LFS fid2path $MOUNT "$FID")
9815 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9816 [ "$FOUND" != "$DIR/$tfile" ] &&
9817 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9821 run_test 154A "lfs path2fid and fid2path basic checks"
9824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9825 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9826 { skip "Need MDS version at least 2.2.51"; return 0; }
9827 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9829 cp /etc/hosts $DIR/$tfile
9831 fid=$($LFS path2fid $DIR/$tfile)
9833 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9835 dot_lustre_fid_permission_check "$fid" $DIR ||
9836 error "dot lustre permission check $fid failed"
9838 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9840 touch $MOUNT/.lustre/file &&
9841 error "creation is not allowed under .lustre"
9843 mkdir $MOUNT/.lustre/dir &&
9844 error "mkdir is not allowed under .lustre"
9848 run_test 154a "Open-by-FID"
9851 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9852 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9853 { skip "Need MDS version at least 2.2.51"; return 0; }
9855 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9857 local remote_dir=$DIR/$tdir/remote_dir
9862 $LFS mkdir -i $MDTIDX $remote_dir ||
9863 error "create remote directory failed"
9865 cp /etc/hosts $remote_dir/$tfile
9867 fid=$($LFS path2fid $remote_dir/$tfile)
9869 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9871 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9872 error "dot lustre permission check $fid failed"
9875 run_test 154b "Open-by-FID for remote directory"
9878 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9879 skip "Need MDS version at least 2.4.1" && return
9881 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9882 local FID1=$($LFS path2fid $DIR/$tfile.1)
9883 local FID2=$($LFS path2fid $DIR/$tfile.2)
9884 local FID3=$($LFS path2fid $DIR/$tfile.3)
9887 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9888 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9889 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9891 [ "$FID" = "${!want}" ] ||
9892 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9896 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
9898 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9899 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9903 run_test 154c "lfs path2fid and fid2path multiple arguments"
9906 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9907 skip "Need MDS version at least 2.5.53" && return
9910 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9914 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9921 local fid=$($LFS path2fid $DIR/$tfile)
9924 cmd="exec $fd<$DIR/$tfile"
9926 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9927 echo "$fid_list" | grep "$fid"
9930 cmd="exec $fd>/dev/null"
9932 if [ $rc -ne 0 ]; then
9933 error "FID $fid not found in open files list $fid_list"
9936 run_test 154d "Verify open file fid"
9940 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9941 skip "Need MDS version at least 2.6.50" && return
9943 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9944 error ".lustre returned by readdir"
9947 run_test 154e ".lustre is not returned by readdir"
9950 # create parent directory on a single MDT to avoid cross-MDT hardlinks
9951 test_mkdir -p -c1 $DIR/$tdir/d
9952 # test dirs inherit from its stripe
9953 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
9954 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
9955 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
9956 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
9959 # get fid of parents
9960 local FID0=$($LFS path2fid $DIR/$tdir/d)
9961 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
9962 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
9963 local FID3=$($LFS path2fid $DIR)
9965 # check that path2fid --parents returns expected <parent_fid>/name
9966 # 1) test for a directory (single parent)
9967 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
9968 [ "$parent" == "$FID0/foo1" ] ||
9969 error "expected parent: $FID0/foo1, got: $parent"
9971 # 2) test for a file with nlink > 1 (multiple parents)
9972 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
9973 echo "$parent" | grep -F "$FID1/$tfile" ||
9974 error "$FID1/$tfile not returned in parent list"
9975 echo "$parent" | grep -F "$FID2/link" ||
9976 error "$FID2/link not returned in parent list"
9978 # 3) get parent by fid
9979 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
9980 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9981 echo "$parent" | grep -F "$FID1/$tfile" ||
9982 error "$FID1/$tfile not returned in parent list (by fid)"
9983 echo "$parent" | grep -F "$FID2/link" ||
9984 error "$FID2/link not returned in parent list (by fid)"
9986 # 4) test for entry in root directory
9987 parent=$($LFS path2fid --parents $DIR/f)
9988 echo "$parent" | grep -F "$FID3/f" ||
9989 error "$FID3/f not returned in parent list"
9991 # 5) test it on root directory
9992 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
9993 error "$MOUNT should not have parents"
9995 # enable xattr caching and check that linkea is correctly updated
9996 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9997 save_lustre_params client "llite.*.xattr_cache" > $save
9998 lctl set_param llite.*.xattr_cache 1
10000 # 6.1) linkea update on rename
10001 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
10003 # get parents by fid
10004 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10005 # foo1 should no longer be returned in parent list
10006 echo "$parent" | grep -F "$FID1" &&
10007 error "$FID1 should no longer be in parent list"
10008 # the new path should appear
10009 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
10010 error "$FID2/$tfile.moved is not in parent list"
10012 # 6.2) linkea update on unlink
10013 rm -f $DIR/$tdir/d/foo2/link
10014 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
10015 # foo2/link should no longer be returned in parent list
10016 echo "$parent" | grep -F "$FID2/link" &&
10017 error "$FID2/link should no longer be in parent list"
10021 restore_lustre_params < $save
10023 run_test 154f "get parent fids by reading link ea"
10027 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
10028 { skip "Need MDS version at least 2.6.92"; return 0; }
10030 mkdir -p $DIR/$tdir
10031 llapi_fid_test -d $DIR/$tdir
10033 run_test 154g "various llapi FID tests"
10035 test_155_small_load() {
10036 local temp=$TMP/$tfile
10037 local file=$DIR/$tfile
10039 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
10040 error "dd of=$temp bs=6096 count=1 failed"
10042 cancel_lru_locks osc
10043 cmp $temp $file || error "$temp $file differ"
10045 $TRUNCATE $temp 6000
10046 $TRUNCATE $file 6000
10047 cmp $temp $file || error "$temp $file differ (truncate1)"
10049 echo "12345" >>$temp
10050 echo "12345" >>$file
10051 cmp $temp $file || error "$temp $file differ (append1)"
10053 echo "12345" >>$temp
10054 echo "12345" >>$file
10055 cmp $temp $file || error "$temp $file differ (append2)"
10061 test_155_big_load() {
10062 remote_ost_nodsh && skip "remote OST with nodsh" && return
10063 local temp=$TMP/$tfile
10064 local file=$DIR/$tfile
10067 local cache_size=$(do_facet ost$((MAXI+1)) \
10068 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
10069 local large_file_size=$((cache_size * 2))
10071 echo "OSS cache size: $cache_size KB"
10072 echo "Large file size: $large_file_size KB"
10074 [ $MAXV -le $large_file_size ] && \
10075 skip_env "max available OST size needs > $large_file_size KB" && \
10078 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
10080 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
10081 error "dd of=$temp bs=$large_file_size count=1k failed"
10084 cancel_lru_locks osc
10085 cmp $temp $file || error "$temp $file differ"
10092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10094 set_cache writethrough on
10095 test_155_small_load
10097 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10102 set_cache writethrough off
10103 test_155_small_load
10105 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10110 set_cache writethrough on
10111 test_155_small_load
10113 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10118 set_cache writethrough off
10119 test_155_small_load
10121 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10126 set_cache writethrough on
10129 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10134 set_cache writethrough off
10137 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10140 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10142 set_cache writethrough on
10145 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10150 set_cache writethrough off
10153 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10156 remote_ost_nodsh && skip "remote OST with nodsh" && return
10157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10161 local file="$DIR/$tfile"
10163 [ "$(facet_fstype ost1)" = "zfs" -a \
10164 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
10165 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
10170 log "Turn on read and write cache"
10172 set_cache writethrough on
10174 log "Write data and read it back."
10175 log "Read should be satisfied from the cache."
10176 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10178 cancel_lru_locks osc
10179 cat $file >/dev/null
10181 if ! let "AFTER - BEFORE == CPAGES"; then
10182 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10184 log "cache hits:: before: $BEFORE, after: $AFTER"
10187 log "Read again; it should be satisfied from the cache."
10189 cancel_lru_locks osc
10190 cat $file >/dev/null
10192 if ! let "AFTER - BEFORE == CPAGES"; then
10193 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10195 log "cache hits:: before: $BEFORE, after: $AFTER"
10198 log "Turn off the read cache and turn on the write cache"
10200 set_cache writethrough on
10202 log "Read again; it should be satisfied from the cache."
10204 cancel_lru_locks osc
10205 cat $file >/dev/null
10207 if ! let "AFTER - BEFORE == CPAGES"; then
10208 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10210 log "cache hits:: before: $BEFORE, after: $AFTER"
10213 log "Read again; it should not be satisfied from the cache."
10215 cancel_lru_locks osc
10216 cat $file >/dev/null
10218 if ! let "AFTER - BEFORE == 0"; then
10219 error "IN CACHE: before: $BEFORE, after: $AFTER"
10221 log "cache hits:: before: $BEFORE, after: $AFTER"
10224 log "Write data and read it back."
10225 log "Read should be satisfied from the cache."
10226 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10228 cancel_lru_locks osc
10229 cat $file >/dev/null
10231 if ! let "AFTER - BEFORE == CPAGES"; then
10232 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10234 log "cache hits:: before: $BEFORE, after: $AFTER"
10237 log "Read again; it should not be satisfied from the cache."
10239 cancel_lru_locks osc
10240 cat $file >/dev/null
10242 if ! let "AFTER - BEFORE == 0"; then
10243 error "IN CACHE: before: $BEFORE, after: $AFTER"
10245 log "cache hits:: before: $BEFORE, after: $AFTER"
10248 log "Turn off read and write cache"
10250 set_cache writethrough off
10252 log "Write data and read it back"
10253 log "It should not be satisfied from the cache."
10255 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10256 cancel_lru_locks osc
10258 cat $file >/dev/null
10260 if ! let "AFTER - BEFORE == 0"; then
10261 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10263 log "cache hits:: before: $BEFORE, after: $AFTER"
10266 log "Turn on the read cache and turn off the write cache"
10268 set_cache writethrough off
10270 log "Write data and read it back"
10271 log "It should not be satisfied from the cache."
10273 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10275 cancel_lru_locks osc
10276 cat $file >/dev/null
10278 if ! let "AFTER - BEFORE == 0"; then
10279 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10281 log "cache hits:: before: $BEFORE, after: $AFTER"
10284 log "Read again; it should be satisfied from the cache."
10286 cancel_lru_locks osc
10287 cat $file >/dev/null
10289 if ! let "AFTER - BEFORE == CPAGES"; then
10290 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10292 log "cache hits:: before: $BEFORE, after: $AFTER"
10297 run_test 156 "Verification of tunables"
10301 if [[ $MDSCOUNT -gt 1 ]]; then
10302 error_ignore bz17935 $*
10310 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10312 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10314 if [ $MASK -eq 1 ]; then
10315 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10317 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10321 changelog_extract_field() {
10325 local identifier=$4
10327 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10328 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10334 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10335 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10336 { skip "Need MDS version at least 2.2.0"; return; }
10338 local CL_USERS="mdd.$MDT0.changelog_users"
10339 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10340 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10341 echo "Registered as changelog user $USER"
10342 $GET_CL_USERS | grep -q $USER ||
10343 error "User $USER not found in changelog_users"
10346 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10347 touch $DIR/$tdir/pics/2008/zachy/timestamp
10348 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10349 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10350 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10351 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10352 rm $DIR/$tdir/pics/desktop.jpg
10354 $LFS changelog $MDT0 | tail -5
10356 echo "verifying changelog mask"
10357 changelog_chmask "MKDIR"
10358 changelog_chmask "CLOSE"
10360 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10361 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10363 changelog_chmask "MKDIR"
10364 changelog_chmask "CLOSE"
10366 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10367 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10369 $LFS changelog $MDT0
10370 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10371 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10372 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10373 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10376 echo "verifying target fid"
10377 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10378 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10379 [ "$fidc" == "$fidf" ] ||
10380 err17935 "fid in changelog $fidc != file fid $fidf"
10381 echo "verifying parent fid"
10382 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10383 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10384 [ "$fidc" == "$fidf" ] ||
10385 err17935 "pfid in changelog $fidc != dir fid $fidf"
10387 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10388 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10389 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10390 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10391 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10392 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10394 MIN_REC=$($GET_CL_USERS |
10395 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10396 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10397 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10398 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10399 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10401 # LU-3446 changelog index reset on MDT restart
10402 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10403 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10404 $LFS changelog_clear $MDT0 $USER 0
10405 stop $SINGLEMDS || error "Fail to stop MDT."
10406 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10407 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10408 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10409 [ $CUR_REC1 == $CUR_REC2 ] ||
10410 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10412 echo "verifying user deregister"
10413 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10414 $GET_CL_USERS | grep -q $USER &&
10415 error "User $USER still in changelog_users"
10417 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10418 if [ $USERS -eq 0 ]; then
10419 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10420 touch $DIR/$tdir/chloe
10421 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10422 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10423 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10425 echo "$USERS other changelog users; can't verify off"
10428 run_test 160a "changelog sanity"
10430 test_160b() { # LU-3587
10431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10432 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10433 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10434 { skip "Need MDS version at least 2.2.0"; return; }
10436 local CL_USERS="mdd.$MDT0.changelog_users"
10437 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10438 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10439 echo "Registered as changelog user $USER"
10440 $GET_CL_USERS | grep -q $USER ||
10441 error "User $USER not found in changelog_users"
10443 local LONGNAME1=$(str_repeat a 255)
10444 local LONGNAME2=$(str_repeat b 255)
10447 echo "creating very long named file"
10448 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10449 echo "moving very long named file"
10450 mv $LONGNAME1 $LONGNAME2
10452 $LFS changelog $MDT0 | grep RENME
10454 echo "deregistering $USER"
10455 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10459 run_test 160b "Verify that very long rename doesn't crash in changelog"
10462 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10465 local server_version=$(lustre_version_code $SINGLEMDS)
10467 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10468 [[ $server_version -gt $(version_code 2.5.1) &&
10469 $server_version -lt $(version_code 2.5.50) ]] ||
10470 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10473 # Registration step
10474 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10475 changelog_register -n)
10478 mkdir -p $DIR/$tdir
10479 $MCREATE $DIR/$tdir/foo_160c
10480 changelog_chmask "TRUNC"
10481 $TRUNCATE $DIR/$tdir/foo_160c 200
10482 changelog_chmask "TRUNC"
10483 $TRUNCATE $DIR/$tdir/foo_160c 199
10484 $LFS changelog $MDT0
10485 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10486 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10487 $LFS changelog_clear $MDT0 $USER 0
10489 # Deregistration step
10490 echo "deregistering $USER"
10491 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10493 run_test 160c "verify that changelog log catch the truncate event"
10496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10497 test_mkdir -p -c1 $DIR/$tdir
10498 cp /etc/hosts $DIR/$tdir/$tfile
10499 test_mkdir -c1 $DIR/$tdir/foo1
10500 test_mkdir -c1 $DIR/$tdir/foo2
10501 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10502 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10503 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10504 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10505 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10506 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10507 $LFS fid2path $DIR $FID
10508 err17935 "bad link ea"
10511 rm $DIR/$tdir/foo2/zachary
10513 rm $DIR/$tdir/foo2/thor
10515 rm $DIR/$tdir/$tfile
10517 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10518 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10520 $LFS fid2path $DIR $FID
10521 err17935 "bad link rename"
10523 rm $DIR/$tdir/foo2/maggie
10526 local longname=filename_avg_len_is_thirty_two_
10527 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10528 error "failed to hardlink many files"
10529 links=$($LFS fid2path $DIR $FID | wc -l)
10530 echo -n "${links}/1000 links in link EA"
10531 [[ $links -gt 60 ]] ||
10532 err17935 "expected at least 60 links in link EA"
10533 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10534 error "failed to unlink many hardlinks"
10536 run_test 161a "link ea sanity"
10539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10540 [ $MDSCOUNT -lt 2 ] &&
10541 skip "skipping remote directory test" && return
10543 local remote_dir=$DIR/$tdir/remote_dir
10545 mkdir -p $DIR/$tdir
10546 $LFS mkdir -i $MDTIDX $remote_dir ||
10547 error "create remote directory failed"
10549 cp /etc/hosts $remote_dir/$tfile
10550 mkdir -p $remote_dir/foo1
10551 mkdir -p $remote_dir/foo2
10552 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10553 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10554 ln $remote_dir/$tfile $remote_dir/foo1/luna
10555 ln $remote_dir/$tfile $remote_dir/foo2/thor
10557 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10559 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10560 $LFS fid2path $DIR $FID
10561 err17935 "bad link ea"
10564 rm $remote_dir/foo2/zachary
10566 rm $remote_dir/foo2/thor
10568 rm $remote_dir/$tfile
10570 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10571 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10572 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10573 $LFS fid2path $DIR $FID
10574 err17935 "bad link rename"
10576 rm $remote_dir/foo2/maggie
10579 local longname=filename_avg_len_is_thirty_two_
10580 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10581 error "failed to hardlink many files"
10582 links=$($LFS fid2path $DIR $FID | wc -l)
10583 echo -n "${links}/1000 links in link EA"
10584 [[ ${links} -gt 60 ]] ||
10585 err17935 "expected at least 60 links in link EA"
10586 unlinkmany $remote_dir/foo2/$longname 1000 ||
10587 error "failed to unlink many hardlinks"
10589 run_test 161b "link ea sanity under remote directory"
10592 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10594 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10595 skip "Need MDS version at least 2.1.5" && return
10597 # define CLF_RENAME_LAST 0x0001
10598 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10599 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10600 changelog_register -n)
10602 mkdir -p $DIR/$tdir
10603 touch $DIR/$tdir/foo_161c
10604 touch $DIR/$tdir/bar_161c
10605 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10606 $LFS changelog $MDT0 | grep RENME
10607 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10609 $LFS changelog_clear $MDT0 $USER 0
10610 if [ x$flags != "x0x1" ]; then
10611 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10613 error "flag $flags is not 0x1"
10615 echo "rename overwrite a target having nlink = 1," \
10616 "changelog record has flags of $flags"
10618 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10619 touch $DIR/$tdir/foo_161c
10620 touch $DIR/$tdir/bar_161c
10621 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10622 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10623 $LFS changelog $MDT0 | grep RENME
10624 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10625 $LFS changelog_clear $MDT0 $USER 0
10626 if [ x$flags != "x0x0" ]; then
10627 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10629 error "flag $flags is not 0x0"
10631 echo "rename overwrite a target having nlink > 1," \
10632 "changelog record has flags of $flags"
10634 # rename doesn't overwrite a target (changelog flag 0x0)
10635 touch $DIR/$tdir/foo_161c
10636 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10637 $LFS changelog $MDT0 | grep RENME
10638 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10639 $LFS changelog_clear $MDT0 $USER 0
10640 if [ x$flags != "x0x0" ]; then
10641 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10643 error "flag $flags is not 0x0"
10645 echo "rename doesn't overwrite a target," \
10646 "changelog record has flags of $flags"
10648 # define CLF_UNLINK_LAST 0x0001
10649 # unlink a file having nlink = 1 (changelog flag 0x1)
10650 rm -f $DIR/$tdir/foo2_161c
10651 $LFS changelog $MDT0 | grep UNLNK
10652 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10653 $LFS changelog_clear $MDT0 $USER 0
10654 if [ x$flags != "x0x1" ]; then
10655 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10657 error "flag $flags is not 0x1"
10659 echo "unlink a file having nlink = 1," \
10660 "changelog record has flags of $flags"
10662 # unlink a file having nlink > 1 (changelog flag 0x0)
10663 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10664 rm -f $DIR/$tdir/foobar_161c
10665 $LFS changelog $MDT0 | grep UNLNK
10666 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10667 $LFS changelog_clear $MDT0 $USER 0
10668 if [ x$flags != "x0x0" ]; then
10669 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10671 error "flag $flags is not 0x0"
10673 echo "unlink a file having nlink > 1," \
10674 "changelog record has flags of $flags"
10675 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10677 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10684 local path=$(${LFS} fid2path $*)
10685 # Remove the '//' indicating a remote directory
10686 path=$(echo $path | sed 's#//#/#g')
10689 if [ $RC -ne 0 ]; then
10690 err17935 "path looked up of $expected failed. Error $RC"
10692 elif [ "${path}" != "${expected}" ]; then
10693 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10696 echo "fid $fid resolves to path $path (expected $expected)"
10700 # Make changes to filesystem
10701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10702 test_mkdir -p -c1 $DIR/$tdir/d2
10703 touch $DIR/$tdir/d2/$tfile
10704 touch $DIR/$tdir/d2/x1
10705 touch $DIR/$tdir/d2/x2
10706 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10707 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10709 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10710 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10711 error "check path $tdir/d2/$tfile failed"
10714 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10715 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10716 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10717 error "check path $tdir/d2/p/q/r/slink failed"
10719 # softlink to wrong file
10720 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10721 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10722 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10723 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10726 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10727 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10728 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10729 # fid2path dir/fsname should both work
10730 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10731 error "check path $tdir/d2/a/b/c/new_file failed"
10732 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10733 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10735 # hardlink count: check that there are 2 links
10736 # Doesnt work with CMD yet: 17935
10737 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10738 err17935 "expected 2 links"
10740 # hardlink indexing: remove the first link
10741 rm $DIR/$tdir/d2/p/q/r/hlink
10742 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10743 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10747 run_test 162 "path lookup sanity"
10750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10751 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10754 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10755 error "create striped dir failed"
10757 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10758 tail -n 1 | awk '{print $2}')
10759 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10761 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10762 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10765 for ((i=0;i<5;i++)); do
10766 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10767 error "get fid for f$i failed"
10768 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10769 error "check path $tdir/striped_dir/f$i failed"
10771 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10772 error "get fid for d$i failed"
10773 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10774 error "check path $tdir/striped_dir/d$i failed"
10779 run_test 162b "striped directory path lookup sanity"
10781 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10783 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
10784 skip "Need MDS version at least 2.7.51" && return
10785 test_mkdir $DIR/$tdir.local
10786 test_mkdir $DIR/$tdir.remote
10787 local lpath=$tdir.local
10788 local rpath=$tdir.remote
10790 for ((i = 0; i <= 101; i++)); do
10793 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10794 error "get fid for local directory $DIR/$lpath failed"
10795 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10796 error "check path for local directory $DIR/$lpath failed"
10799 test_mkdir $DIR/$rpath
10800 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10801 error "get fid for remote directory $DIR/$rpath failed"
10802 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10803 error "check path for remote directory $DIR/$rpath failed"
10808 run_test 162c "fid2path works with paths 100 or more directories deep"
10811 # do directio so as not to populate the page cache
10812 log "creating a 10 Mb file"
10813 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10814 log "starting reads"
10815 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10816 log "truncating the file"
10817 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10819 kill %+ || true # reads might have finished
10820 echo "wait until dd is finished"
10822 log "removing the temporary file"
10823 rm -rf $DIR/$tfile || error "tmp file removal failed"
10825 run_test 169 "parallel read and truncate should not deadlock"
10828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10829 $LCTL clear # bug 18514
10830 $LCTL debug_daemon start $TMP/${tfile}_log_good
10832 $LCTL debug_daemon stop
10833 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10834 error "sed failed to read log_good"
10836 $LCTL debug_daemon start $TMP/${tfile}_log_good
10838 $LCTL debug_daemon stop
10840 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10841 error "lctl df log_bad failed"
10843 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10844 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10846 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10847 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10849 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10850 error "bad_line good_line1 good_line2 are empty"
10852 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10853 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10854 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10856 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10857 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10858 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10860 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10861 error "bad_line_new good_line_new are empty"
10863 local expected_good=$((good_line1 + good_line2*2))
10865 rm -f $TMP/${tfile}*
10866 # LU-231, short malformed line may not be counted into bad lines
10867 if [ $bad_line -ne $bad_line_new ] &&
10868 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10869 error "expected $bad_line bad lines, but got $bad_line_new"
10873 if [ $expected_good -ne $good_line_new ]; then
10874 error "expected $expected_good good lines, but got $good_line_new"
10879 run_test 170 "test lctl df to handle corrupted log ====================="
10881 test_171() { # bug20592
10882 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10883 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10884 $LCTL set_param fail_loc=0x50e
10885 $LCTL set_param fail_val=3000
10886 multiop_bg_pause $DIR/$tfile O_s || true
10888 kill -USR1 $MULTIPID
10892 if dmesg | grep "recursive fault"; then
10893 error "caught a recursive fault"
10895 $LCTL set_param fail_loc=0
10898 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10900 # it would be good to share it with obdfilter-survey/iokit-libecho code
10901 setup_obdecho_osc () {
10904 local obdfilter_name=$2
10905 echo "Creating new osc for $obdfilter_name on $ost_nid"
10906 # make sure we can find loopback nid
10907 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10909 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10910 ${obdfilter_name}_osc_UUID || rc=2; }
10911 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10912 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10916 cleanup_obdecho_osc () {
10917 local obdfilter_name=$1
10918 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10919 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10926 local pages=${3:-64}
10931 local obd_size=$(get_obd_size $node $OBD)
10932 local page_size=$(get_page_size $node)
10933 if [[ -n "$obd_size" ]]; then
10934 local new_count=$((obd_size / (pages * page_size / 1024)))
10935 [[ $new_count -ge $count ]] || count=$new_count
10938 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10939 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10941 if [ $rc -eq 0 ]; then
10942 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10943 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10945 echo "New object id is $id"
10946 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10948 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10949 "test_brw $count w v $pages $id" || rc=4; }
10950 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10952 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10953 "cleanup" || rc=5; }
10954 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10955 "detach" || rc=6; }
10956 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10962 remote_ost_nodsh && skip "remote OST with nodsh" && return
10964 local rmmod_local=0
10966 if ! module_loaded obdecho; then
10967 load_module obdecho/obdecho
10971 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10972 local host=$(lctl get_param -n osc.$osc.import |
10973 awk '/current_connection:/ {print $2}' )
10974 local target=$(lctl get_param -n osc.$osc.import |
10975 awk '/target:/ {print $2}' )
10976 target=${target%_UUID}
10978 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10979 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10980 [[ -n $target ]] && cleanup_obdecho_osc $target
10981 [ $rmmod_local -eq 1 ] && rmmod obdecho
10984 run_test 180a "test obdecho on osc"
10987 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10988 remote_ost_nodsh && skip "remote OST with nodsh" && return
10990 local rmmod_remote=0
10992 do_facet ost1 "lsmod | grep -q obdecho || " \
10993 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10994 "modprobe obdecho; }" && rmmod_remote=1
10995 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10996 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10997 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
11000 run_test 180b "test obdecho directly on obdfilter"
11002 test_180c() { # LU-2598
11003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11004 remote_ost_nodsh && skip "remote OST with nodsh" && return
11005 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
11006 skip "Need MDS version at least 2.4.0" && return
11009 local rmmod_remote=false
11010 local pages=16384 # 64MB bulk I/O RPC size
11013 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
11014 rmmod_remote=true || error "failed to load module obdecho"
11016 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
11018 if [ -n "$target" ]; then
11019 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
11021 echo "there is no obdfilter target on ost1"
11024 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
11027 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
11029 test_181() { # bug 22177
11030 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11031 # create enough files to index the directory
11032 createmany -o $DIR/$tdir/foobar 4000
11033 # print attributes for debug purpose
11036 multiop_bg_pause $DIR/$tdir D_Sc || return 1
11038 # remove the files & current working dir
11039 unlinkmany $DIR/$tdir/foobar 4000
11041 kill -USR1 $MULTIPID
11043 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
11046 run_test 181 "Test open-unlinked dir ========================"
11052 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11054 $LCTL set_param mdc.*.rpc_stats=clear
11056 for (( i = 0; i < $tcount; i++ )) ; do
11057 mkdir $DIR/$tdir/$i
11060 for (( i = 0; i < $tcount; i++ )) ; do
11061 createmany -o $DIR/$tdir/$i/f- $fcount &
11065 for (( i = 0; i < $tcount; i++ )) ; do
11066 unlinkmany $DIR/$tdir/$i/f- $fcount &
11070 $LCTL get_param mdc.*.rpc_stats
11074 run_test 182 "Test parallel modify metadata operations ================"
11076 test_183() { # LU-2275
11077 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11078 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
11079 skip "Need MDS version at least 2.3.56" && return
11081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11082 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11083 echo aaa > $DIR/$tdir/$tfile
11085 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
11086 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
11088 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
11089 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11091 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11093 # Flush negative dentry cache
11094 touch $DIR/$tdir/$tfile
11096 # We are not checking for any leaked references here, they'll
11097 # become evident next time we do cleanup with module unload.
11100 run_test 183 "No crash or request leak in case of strange dispositions ========"
11102 # test suite 184 is for LU-2016, LU-2017
11104 check_swap_layouts_support && return 0
11106 dir0=$DIR/$tdir/$testnum
11107 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11112 $SETSTRIPE -c1 $file1
11114 $SETSTRIPE -c2 $file2
11116 gen1=$($GETSTRIPE -g $file1)
11117 gen2=$($GETSTRIPE -g $file2)
11119 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11120 gen=$($GETSTRIPE -g $file1)
11121 [[ $gen1 != $gen ]] ||
11122 "Layout generation on $file1 does not change"
11123 gen=$($GETSTRIPE -g $file2)
11124 [[ $gen2 != $gen ]] ||
11125 "Layout generation on $file2 does not change"
11127 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11128 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11130 run_test 184a "Basic layout swap"
11133 check_swap_layouts_support && return 0
11135 dir0=$DIR/$tdir/$testnum
11136 mkdir -p $dir0 || error "creating dir $dir0"
11143 $SETSTRIPE -c1 $file1
11144 $SETSTRIPE -c2 $file2
11145 $SETSTRIPE -c1 $file3
11146 chown $RUNAS_ID $file3
11147 gen1=$($GETSTRIPE -g $file1)
11148 gen2=$($GETSTRIPE -g $file2)
11150 $LFS swap_layouts $dir1 $dir2 &&
11151 error "swap of directories layouts should fail"
11152 $LFS swap_layouts $dir1 $file1 &&
11153 error "swap of directory and file layouts should fail"
11154 $RUNAS $LFS swap_layouts $file1 $file2 &&
11155 error "swap of file we cannot write should fail"
11156 $LFS swap_layouts $file1 $file3 &&
11157 error "swap of file with different owner should fail"
11158 /bin/true # to clear error code
11160 run_test 184b "Forbidden layout swap (will generate errors)"
11163 check_swap_layouts_support && return 0
11165 local dir0=$DIR/$tdir/$testnum
11166 mkdir -p $dir0 || error "creating dir $dir0"
11168 local ref1=$dir0/ref1
11169 local ref2=$dir0/ref2
11170 local file1=$dir0/file1
11171 local file2=$dir0/file2
11172 # create a file large enough for the concurrent test
11173 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11174 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11175 echo "ref file size: ref1($(stat -c %s $ref1))," \
11176 "ref2($(stat -c %s $ref2))"
11179 dd if=$ref1 of=$file1 bs=16k &
11182 # Make sure dd starts to copy file
11183 while [ ! -f $file1 ]; do sleep 0.1; done
11185 $LFS swap_layouts $file1 $file2
11188 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11189 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11191 # how many bytes copied before swapping layout
11192 local copied=$(stat -c %s $file2)
11193 local remaining=$(stat -c %s $ref1)
11194 remaining=$((remaining - copied))
11195 echo "Copied $copied bytes before swapping layout..."
11197 cmp -n $copied $file1 $ref2 | grep differ &&
11198 error "Content mismatch [0, $copied) of ref2 and file1"
11199 cmp -n $copied $file2 $ref1 ||
11200 error "Content mismatch [0, $copied) of ref1 and file2"
11201 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11202 error "Content mismatch [$copied, EOF) of ref1 and file1"
11205 rm -f $ref1 $ref2 $file1 $file2
11207 run_test 184c "Concurrent write and layout swap"
11210 check_swap_layouts_support && return 0
11211 [ -z "$(which getfattr 2>/dev/null)" ] &&
11212 skip "no getfattr command" && return 0
11214 local file1=$DIR/$tdir/$tfile-1
11215 local file2=$DIR/$tdir/$tfile-2
11216 local file3=$DIR/$tdir/$tfile-3
11220 mkdir -p $DIR/$tdir
11221 touch $file1 || error "create $file1 failed"
11222 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11223 error "create $file2 failed"
11224 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11225 error "create $file3 failed"
11226 lovea1=$($LFS getstripe $file1 | sed 1d)
11228 $LFS swap_layouts $file2 $file3 ||
11229 error "swap $file2 $file3 layouts failed"
11230 $LFS swap_layouts $file1 $file2 ||
11231 error "swap $file1 $file2 layouts failed"
11233 lovea2=$($LFS getstripe $file2 | sed 1d)
11234 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11236 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11237 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11239 run_test 184d "allow stripeless layouts swap"
11242 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11243 { skip "Need MDS version at least 2.6.94"; return 0; }
11244 check_swap_layouts_support && return 0
11245 [ -z "$(which getfattr 2>/dev/null)" ] &&
11246 skip "no getfattr command" && return 0
11248 local file1=$DIR/$tdir/$tfile-1
11249 local file2=$DIR/$tdir/$tfile-2
11250 local file3=$DIR/$tdir/$tfile-3
11253 mkdir -p $DIR/$tdir
11254 touch $file1 || error "create $file1 failed"
11255 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11256 error "create $file2 failed"
11257 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11258 error "create $file3 failed"
11260 $LFS swap_layouts $file1 $file2 ||
11261 error "swap $file1 $file2 layouts failed"
11263 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11264 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11266 echo 123 > $file1 || error "Should be able to write into $file1"
11268 $LFS swap_layouts $file1 $file3 ||
11269 error "swap $file1 $file3 layouts failed"
11271 echo 123 > $file1 || error "Should be able to write into $file1"
11273 rm -rf $file1 $file2 $file3
11275 run_test 184e "Recreate layout after stripeless layout swaps"
11277 test_185() { # LU-2441
11278 # LU-3553 - no volatile file support in old servers
11279 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11280 { skip "Need MDS version at least 2.3.60"; return 0; }
11282 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11283 touch $DIR/$tdir/spoo
11284 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11285 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11286 error "cannot create/write a volatile file"
11287 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11288 error "FID is still valid after close"
11290 multiop_bg_pause $DIR/$tdir vVw4096_c
11297 # assume that the next FID for this client is sequential, since stdout
11298 # is unfortunately eaten by multiop_bg_pause
11299 local n=$((${fidv[1]} + 1))
11300 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11301 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11302 error "FID is missing before close"
11303 kill -USR1 $multi_pid
11304 # 1 second delay, so if mtime change we will see it
11306 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11307 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11309 run_test 185 "Volatile file support"
11312 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11313 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11314 skip "Need MDS version at least 2.3.0" && return
11316 local dir0=$DIR/$tdir/$testnum
11317 mkdir -p $dir0 || error "creating dir $dir0"
11319 local file=$dir0/file1
11320 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11321 local dv1=$($LFS data_version $file)
11322 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11323 local dv2=$($LFS data_version $file)
11324 [[ $dv1 != $dv2 ]] ||
11325 error "data version did not change on write $dv1 == $dv2"
11330 run_test 187a "Test data version change"
11333 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11334 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
11335 skip "Need MDS version at least 2.3.0" && return
11337 local dir0=$DIR/$tdir/$testnum
11338 mkdir -p $dir0 || error "creating dir $dir0"
11340 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11341 [[ ${DV[0]} != ${DV[1]} ]] ||
11342 error "data version did not change on write"\
11343 " ${DV[0]} == ${DV[1]}"
11348 run_test 187b "Test data version change on volatile file"
11351 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11352 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11354 local POOL=${POOL:-cea1}
11355 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11356 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11359 local last_ost=$(($OSTCOUNT - 1))
11361 local ost_list=$(seq $first_ost $ost_step $last_ost)
11362 local ost_range="$first_ost $last_ost $ost_step"
11363 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11364 local file_dir=$POOL_ROOT/file_tst
11365 local subdir=$test_path/subdir
11369 # former test_200a test_200b
11370 pool_add $POOL || { rc=$? ; break; }
11371 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11372 # former test_200c test_200d
11373 mkdir -p $test_path
11374 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11375 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11377 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11378 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11379 || { rc=$? ; break; }
11380 # former test_200e test_200f
11381 local files=$((OSTCOUNT*3))
11382 pool_alloc_files $POOL $test_path $files "$ost_list" \
11383 || { rc=$? ; break; }
11384 pool_create_files $POOL $file_dir $files "$ost_list" \
11385 || { rc=$? ; break; }
11386 # former test_200g test_200h
11387 pool_lfs_df $POOL || { rc=$? ; break; }
11388 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11390 # former test_201a test_201b test_201c
11391 pool_remove_first_target $POOL || { rc=$? ; break; }
11393 local f=$test_path/$tfile
11394 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11395 pool_remove $POOL $f || { rc=$? ; break; }
11402 run_test 200 "OST pools"
11404 # usage: default_attr <count | size | offset>
11406 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11409 # usage: check_default_stripe_attr
11410 check_default_stripe_attr() {
11411 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11413 --stripe-count|--count)
11414 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11415 --stripe-size|--size)
11416 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11417 --stripe-index|--index)
11420 error "unknown getstripe attr '$1'"
11423 [ $ACTUAL != $EXPECTED ] &&
11424 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11428 test_mkdir -p $DIR/$tdir
11429 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11431 check_default_stripe_attr --stripe-count
11432 check_default_stripe_attr --stripe-size
11433 check_default_stripe_attr --stripe-index
11437 run_test 204a "Print default stripe attributes ================="
11440 test_mkdir -p $DIR/$tdir
11441 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11443 check_default_stripe_attr --stripe-size
11444 check_default_stripe_attr --stripe-index
11448 run_test 204b "Print default stripe size and offset ==========="
11451 test_mkdir -p $DIR/$tdir
11452 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11454 check_default_stripe_attr --stripe-count
11455 check_default_stripe_attr --stripe-index
11459 run_test 204c "Print default stripe count and offset ==========="
11462 test_mkdir -p $DIR/$tdir
11463 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11465 check_default_stripe_attr --stripe-count
11466 check_default_stripe_attr --stripe-size
11470 run_test 204d "Print default stripe count and size ============="
11473 test_mkdir -p $DIR/$tdir
11474 $SETSTRIPE -d $DIR/$tdir
11476 check_default_stripe_attr --stripe-count --raw
11477 check_default_stripe_attr --stripe-size --raw
11478 check_default_stripe_attr --stripe-index --raw
11482 run_test 204e "Print raw stripe attributes ================="
11485 test_mkdir -p $DIR/$tdir
11486 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11488 check_default_stripe_attr --stripe-size --raw
11489 check_default_stripe_attr --stripe-index --raw
11493 run_test 204f "Print raw stripe size and offset ==========="
11496 test_mkdir -p $DIR/$tdir
11497 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11499 check_default_stripe_attr --stripe-count --raw
11500 check_default_stripe_attr --stripe-index --raw
11504 run_test 204g "Print raw stripe count and offset ==========="
11507 test_mkdir -p $DIR/$tdir
11508 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11510 check_default_stripe_attr --stripe-count --raw
11511 check_default_stripe_attr --stripe-size --raw
11515 run_test 204h "Print raw stripe count and size ============="
11517 # Figure out which job scheduler is being used, if any,
11518 # or use a fake one
11519 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11520 JOBENV=SLURM_JOB_ID
11521 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11523 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11525 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11526 JOBENV=LOADL_STEP_ID
11527 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11533 verify_jobstats() {
11538 # we don't really need to clear the stats for this test to work, since each
11539 # command has a unique jobid, but it makes debugging easier if needed.
11540 # for facet in $facets; do
11541 # local dev=$(convert_facet2label $facet)
11542 # # clear old jobstats
11543 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
11546 # use a new JobID for each test, or we might see an old one
11547 [ "$JOBENV" = "FAKE_JOBID" ] &&
11548 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
11551 log "Test: ${cmd[*]}"
11552 log "Using JobID environment variable $JOBENV=$JOBVAL"
11554 if [ $JOBENV = "FAKE_JOBID" ]; then
11555 FAKE_JOBID=$JOBVAL ${cmd[*]}
11560 # all files are created on OST0000
11561 for facet in $facets; do
11562 local stats="*.$(convert_facet2label $facet).job_stats"
11563 if [ $(do_facet $facet lctl get_param $stats |
11564 grep -c $JOBVAL) -ne 1 ]; then
11565 do_facet $facet lctl get_param $stats
11566 error "No jobstats for $JOBVAL found on $facet::$stats"
11573 NEW_JOBENV=${1:-$OLD_JOBENV}
11574 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11575 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11579 do_facet $SINGLEMDS \
11580 $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
11581 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11582 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
11585 test_205() { # Job stats
11586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11587 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11588 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11589 remote_ost_nodsh && skip "remote OST with nodsh" && return
11591 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11592 skip "Server doesn't support jobstats" && return 0
11593 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11595 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11596 if [ $OLD_JOBENV != $JOBENV ]; then
11597 jobstats_set $JOBENV
11598 trap cleanup_205 EXIT
11601 CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
11602 echo "Registered as changelog user $CL_USER"
11604 OLD_INTERVAL=$(do_facet $SINGLEMDS \
11605 lctl get_param -n mdt.*.job_cleanup_interval)
11606 local interval_new=5
11607 do_facet $SINGLEMDS \
11608 $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
11609 local start=$SECONDS
11613 cmd="mkdir $DIR/$tdir"
11614 verify_jobstats "$cmd" "$SINGLEMDS"
11616 cmd="rmdir $DIR/$tdir"
11617 verify_jobstats "$cmd" "$SINGLEMDS"
11618 # mkdir on secondary MDT
11619 if [ $MDSCOUNT -gt 1 ]; then
11620 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
11621 verify_jobstats "$cmd" "mds2"
11624 cmd="mknod $DIR/$tfile c 1 3"
11625 verify_jobstats "$cmd" "$SINGLEMDS"
11627 cmd="rm -f $DIR/$tfile"
11628 verify_jobstats "$cmd" "$SINGLEMDS"
11629 # create all files on OST0000 so verify_jobstats can find OST stats
11631 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11632 verify_jobstats "$cmd" "$SINGLEMDS"
11634 cmd="touch $DIR/$tfile"
11635 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11637 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11638 verify_jobstats "$cmd" "ost1"
11640 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11641 verify_jobstats "$cmd" "ost1"
11643 cmd="$TRUNCATE $DIR/$tfile 0"
11644 verify_jobstats "$cmd" "$SINGLEMDS ost1"
11646 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
11647 verify_jobstats "$cmd" "$SINGLEMDS"
11648 # jobstats expiry - sleep until old stats should be expired
11649 local left=$((interval_new - (SECONDS - start)))
11650 [ $left -ge 0 ] && echo "sleep $left for expiry" && sleep $((left + 1))
11651 cmd="mkdir $DIR/$tdir.expire"
11652 verify_jobstats "$cmd" "$SINGLEMDS"
11653 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
11654 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
11656 # Ensure that jobid are present in changelog (if supported by MDS)
11657 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11659 $LFS changelog $MDT0 | tail -9
11660 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11661 [ $jobids -eq 9 ] ||
11662 error "Wrong changelog jobid count $jobids != 9"
11666 jobstats_set $JOBENV
11668 $LFS changelog $MDT0 | tail -1
11669 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11670 [ $jobids -eq 0 ] ||
11671 error "Unexpected jobids when jobid_var=$JOBENV"
11676 run_test 205 "Verify job stats"
11678 # LU-1480, LU-1773 and LU-1657
11680 mkdir -p $DIR/$tdir
11681 $SETSTRIPE -c -1 $DIR/$tdir
11682 #define OBD_FAIL_LOV_INIT 0x1403
11683 $LCTL set_param fail_loc=0xa0001403
11684 $LCTL set_param fail_val=1
11685 touch $DIR/$tdir/$tfile || true
11687 run_test 206 "fail lov_init_raid0() doesn't lbug"
11690 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11691 local fsz=`stat -c %s $DIR/$tfile`
11692 cancel_lru_locks mdc
11694 # do not return layout in getattr intent
11695 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11696 $LCTL set_param fail_loc=0x170
11697 local sz=`stat -c %s $DIR/$tfile`
11699 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11703 run_test 207a "can refresh layout at glimpse"
11706 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11707 local cksum=`md5sum $DIR/$tfile`
11708 local fsz=`stat -c %s $DIR/$tfile`
11709 cancel_lru_locks mdc
11710 cancel_lru_locks osc
11712 # do not return layout in getattr intent
11713 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11714 $LCTL set_param fail_loc=0x171
11716 # it will refresh layout after the file is opened but before read issues
11717 echo checksum is "$cksum"
11718 echo "$cksum" |md5sum -c --quiet || error "file differs"
11722 run_test 207b "can refresh layout at open"
11725 # FIXME: in this test suite, only RD lease is used. This is okay
11726 # for now as only exclusive open is supported. After generic lease
11727 # is done, this test suite should be revised. - Jinshan
11729 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11730 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11731 { skip "Need MDS version at least 2.4.52"; return 0; }
11733 echo "==== test 1: verify get lease work"
11734 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11736 echo "==== test 2: verify lease can be broken by upcoming open"
11737 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11741 $MULTIOP $DIR/$tfile oO_RDONLY:c
11742 kill -USR1 $PID && wait $PID || error "break lease error"
11744 echo "==== test 3: verify lease can't be granted if an open already exists"
11745 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11749 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11750 kill -USR1 $PID && wait $PID || error "open file error"
11752 echo "==== test 4: lease can sustain over recovery"
11753 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11759 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11761 echo "==== test 5: lease broken can't be regained by replay"
11762 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11766 # open file to break lease and then recovery
11767 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11770 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11774 run_test 208 "Exclusive open"
11777 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11778 skip_env "must have disp_stripe" && return
11781 sync; sleep 5; sync;
11783 echo 3 > /proc/sys/vm/drop_caches
11784 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11786 # open/close 500 times
11787 for i in $(seq 500); do
11791 echo 3 > /proc/sys/vm/drop_caches
11792 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11794 echo "before: $req_before, after: $req_after"
11795 [ $((req_after - req_before)) -ge 300 ] &&
11796 error "open/close requests are not freed"
11799 run_test 209 "read-only open/close requests should be freed promptly"
11803 size=$((size % 8192 + 1))
11804 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11805 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11806 rm -f $DIR/f212 $DIR/f212.xyz
11808 run_test 212 "Sendfile test ============================================"
11811 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11812 cancel_lru_locks osc
11813 lctl set_param fail_loc=0x8000040f
11814 # generate a read lock
11815 cat $DIR/$tfile > /dev/null
11816 # write to the file, it will try to cancel the above read lock.
11817 cat /etc/hosts >> $DIR/$tfile
11819 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11821 test_214() { # for bug 20133
11822 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11823 for (( i=0; i < 340; i++ )) ; do
11824 touch $DIR/$tdir/d214c/a$i
11827 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11828 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11829 ls $DIR/d214c || error "ls $DIR/d214c failed"
11830 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11831 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11833 run_test 214 "hash-indexed directory test - bug 20133"
11835 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11836 create_lnet_proc_files() {
11837 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11838 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11840 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11841 rm -f "$TMP/lnet_$1.sys_tmp"
11844 # counterpart of create_lnet_proc_files
11845 remove_lnet_proc_files() {
11846 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11849 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11850 # 3rd arg as regexp for body
11851 check_lnet_proc_stats() {
11852 local l=$(cat "$TMP/lnet_$1" |wc -l)
11853 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11855 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11858 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11859 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11860 # optional and can be regexp for 2nd line (lnet.routes case)
11861 check_lnet_proc_entry() {
11862 local blp=2 # blp stands for 'position of 1st line of body'
11863 [ -z "$5" ] || blp=3 # lnet.routes case
11865 local l=$(cat "$TMP/lnet_$1" |wc -l)
11866 # subtracting one from $blp because the body can be empty
11867 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11869 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11870 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11872 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11873 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11875 # bail out if any unexpected line happened
11876 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11877 [ "$?" != 0 ] || error "$2 misformatted"
11880 test_215() { # for bugs 18102, 21079, 21517
11881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11882 local N='(0|[1-9][0-9]*)' # non-negative numeric
11883 local P='[1-9][0-9]*' # positive numeric
11884 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11885 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11886 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11887 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11889 local L1 # regexp for 1st line
11890 local L2 # regexp for 2nd line (optional)
11891 local BR # regexp for the rest (body)
11893 # lnet.stats should look as 11 space-separated non-negative numerics
11894 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11895 create_lnet_proc_files "stats"
11896 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11897 remove_lnet_proc_files "stats"
11899 # lnet.routes should look like this:
11900 # Routing disabled/enabled
11901 # net hops priority state router
11902 # where net is a string like tcp0, hops > 0, priority >= 0,
11903 # state is up/down,
11904 # router is a string like 192.168.1.1@tcp2
11905 L1="^Routing (disabled|enabled)$"
11906 L2="^net +hops +priority +state +router$"
11907 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11908 create_lnet_proc_files "routes"
11909 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11910 remove_lnet_proc_files "routes"
11912 # lnet.routers should look like this:
11913 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11914 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11915 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11916 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11917 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11918 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11919 create_lnet_proc_files "routers"
11920 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11921 remove_lnet_proc_files "routers"
11923 # lnet.peers should look like this:
11924 # nid refs state last max rtr min tx min queue
11925 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11926 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11927 # numeric (0 or >0 or <0), queue >= 0.
11928 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11929 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11930 create_lnet_proc_files "peers"
11931 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11932 remove_lnet_proc_files "peers"
11934 # lnet.buffers should look like this:
11935 # pages count credits min
11936 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11937 L1="^pages +count +credits +min$"
11938 BR="^ +$N +$N +$I +$I$"
11939 create_lnet_proc_files "buffers"
11940 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11941 remove_lnet_proc_files "buffers"
11943 # lnet.nis should look like this:
11944 # nid status alive refs peer rtr max tx min
11945 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11946 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11947 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11948 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11949 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11950 create_lnet_proc_files "nis"
11951 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11952 remove_lnet_proc_files "nis"
11954 # can we successfully write to lnet.stats?
11955 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
11956 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11958 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
11960 test_216() { # bug 20317
11961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11962 remote_ost_nodsh && skip "remote OST with nodsh" && return
11965 local facets=$(get_facets OST)
11966 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11968 save_lustre_params client "osc.*.contention_seconds" > $p
11969 save_lustre_params $facets \
11970 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11971 save_lustre_params $facets \
11972 "ldlm.namespaces.filter-*.contended_locks" >> $p
11973 save_lustre_params $facets \
11974 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11977 # agressive lockless i/o settings
11978 for node in $(osts_nodes); do
11979 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
11981 lctl set_param -n osc.*.contention_seconds 60
11983 $DIRECTIO write $DIR/$tfile 0 10 4096
11984 $CHECKSTAT -s 40960 $DIR/$tfile
11986 # disable lockless i/o
11987 for node in $(osts_nodes); do
11988 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
11990 lctl set_param -n osc.*.contention_seconds 0
11993 dd if=/dev/zero of=$DIR/$tfile count=0
11994 $CHECKSTAT -s 0 $DIR/$tfile
11996 restore_lustre_params <$p
12000 run_test 216 "check lockless direct write works and updates file size and kms correctly"
12002 test_217() { # bug 22430
12003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12007 for node in $(nodes_list); do
12008 nid=$(host_nids_address $node $NETTYPE)
12009 if [[ $nid = *-* ]] ; then
12010 echo "lctl ping $nid@$NETTYPE"
12011 lctl ping $nid@$NETTYPE
12013 echo "skipping $node (no hyphen detected)"
12017 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
12020 # do directio so as not to populate the page cache
12021 log "creating a 10 Mb file"
12022 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
12023 log "starting reads"
12024 dd if=$DIR/$tfile of=/dev/null bs=4096 &
12025 log "truncating the file"
12026 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
12028 kill %+ || true # reads might have finished
12029 echo "wait until dd is finished"
12031 log "removing the temporary file"
12032 rm -rf $DIR/$tfile || error "tmp file removal failed"
12034 run_test 218 "parallel read and truncate should not deadlock ======================="
12037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12038 # write one partial page
12039 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
12040 # set no grant so vvp_io_commit_write will do sync write
12041 $LCTL set_param fail_loc=0x411
12042 # write a full page at the end of file
12043 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
12045 $LCTL set_param fail_loc=0
12046 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
12047 $LCTL set_param fail_loc=0x411
12048 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
12051 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
12052 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
12054 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
12056 test_220() { #LU-325
12057 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12058 remote_ost_nodsh && skip "remote OST with nodsh" && return
12059 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12060 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
12063 # create on MDT0000 so the last_id and next_id are correct
12065 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
12069 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
12070 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
12071 osc.$mdtosc_proc1.prealloc_last_id)
12072 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
12073 osc.$mdtosc_proc1.prealloc_next_id)
12077 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
12078 #define OBD_FAIL_OST_ENOINO 0x229
12079 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
12080 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
12081 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
12083 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
12085 MDSOBJS=$((last_id - next_id))
12086 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
12088 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
12089 echo "OST still has $count kbytes free"
12091 echo "create $MDSOBJS files @next_id..."
12092 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
12094 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12095 osc.$mdtosc_proc1.prealloc_last_id)
12096 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
12097 osc.$mdtosc_proc1.prealloc_next_id)
12099 echo "after creation, last_id=$last_id2, next_id=$next_id2"
12104 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
12105 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
12107 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
12108 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
12109 echo "unlink $MDSOBJS files @$next_id..."
12110 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
12112 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
12115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12116 dd if=`which date` of=$MOUNT/date oflag=sync
12117 chmod +x $MOUNT/date
12119 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
12120 $LCTL set_param fail_loc=0x80001401
12122 $MOUNT/date > /dev/null
12125 run_test 221 "make sure fault and truncate race to not cause OOM"
12128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12130 test_mkdir -p $DIR/$tdir
12131 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12132 createmany -o $DIR/$tdir/$tfile 10
12133 cancel_lru_locks mdc
12134 cancel_lru_locks osc
12135 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12136 $LCTL set_param fail_loc=0x31a
12137 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12138 $LCTL set_param fail_loc=0
12141 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12146 test_mkdir -p $DIR/$tdir
12147 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12148 createmany -o $DIR/$tdir/$tfile 10
12149 cancel_lru_locks mdc
12150 cancel_lru_locks osc
12151 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12152 $LCTL set_param fail_loc=0x31a
12153 rm -r $DIR/$tdir || "AGL for rmdir failed"
12154 $LCTL set_param fail_loc=0
12156 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12161 test_mkdir -p $DIR/$tdir
12162 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12163 createmany -o $DIR/$tdir/$tfile 10
12164 cancel_lru_locks mdc
12165 cancel_lru_locks osc
12166 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12167 $LCTL set_param fail_loc=0x31b
12168 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12169 $LCTL set_param fail_loc=0
12172 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12174 test_224a() { # LU-1039, MRP-303
12175 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12176 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12177 $LCTL set_param fail_loc=0x508
12178 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12179 $LCTL set_param fail_loc=0
12182 run_test 224a "Don't panic on bulk IO failure"
12184 test_224b() { # LU-1039, MRP-303
12185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12186 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12187 cancel_lru_locks osc
12188 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12189 $LCTL set_param fail_loc=0x515
12190 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12191 $LCTL set_param fail_loc=0
12194 run_test 224b "Don't panic on bulk IO failure"
12196 test_224c() { # LU-6441
12197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12198 local pages_per_rpc=$($LCTL get_param \
12199 osc.*.max_pages_per_rpc)
12200 local at_max=$($LCTL get_param -n at_max)
12201 local timeout=$($LCTL get_param -n timeout)
12202 local test_at="$LCTL get_param -n at_max"
12203 local param_at="$FSNAME.sys.at_max"
12204 local test_timeout="$LCTL get_param -n timeout"
12205 local param_timeout="$FSNAME.sys.timeout"
12207 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
12209 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
12210 error "conf_param at_max=0 failed"
12211 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
12212 error "conf_param timeout=5 failed"
12214 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
12215 $LCTL set_param fail_loc=0x520
12216 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
12218 $LCTL set_param fail_loc=0
12220 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
12221 error "conf_param at_max=$at_max failed"
12222 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
12223 $timeout || error "conf_param timeout=$timeout failed"
12225 $LCTL set_param -n $pages_per_rpc
12227 run_test 224c "Don't hang if one of md lost during large bulk RPC"
12229 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12232 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12233 if [ -z ${MDSSURVEY} ]; then
12234 skip_env "mds-survey not found" && return
12237 [ $MDSCOUNT -ge 2 ] &&
12238 skip "skipping now for more than one MDT" && return
12240 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12241 { skip "Need MDS version at least 2.2.51"; return; }
12243 local mds=$(facet_host $SINGLEMDS)
12244 local target=$(do_nodes $mds 'lctl dl' | \
12245 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12247 local cmd1="file_count=1000 thrhi=4"
12248 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12249 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12250 local cmd="$cmd1 $cmd2 $cmd3"
12252 rm -f ${TMP}/mds_survey*
12254 eval $cmd || error "mds-survey with zero-stripe failed"
12255 cat ${TMP}/mds_survey*
12256 rm -f ${TMP}/mds_survey*
12258 run_test 225a "Metadata survey sanity with zero-stripe"
12261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12262 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12263 if [ -z ${MDSSURVEY} ]; then
12264 skip_env "mds-survey not found" && return
12266 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12267 { skip "Need MDS version at least 2.2.51"; return; }
12269 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12270 skip_env "Need to mount OST to test" && return
12273 [ $MDSCOUNT -ge 2 ] &&
12274 skip "skipping now for more than one MDT" && return
12275 local mds=$(facet_host $SINGLEMDS)
12276 local target=$(do_nodes $mds 'lctl dl' | \
12277 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12279 local cmd1="file_count=1000 thrhi=4"
12280 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12281 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12282 local cmd="$cmd1 $cmd2 $cmd3"
12284 rm -f ${TMP}/mds_survey*
12286 eval $cmd || error "mds-survey with stripe_count failed"
12287 cat ${TMP}/mds_survey*
12288 rm -f ${TMP}/mds_survey*
12290 run_test 225b "Metadata survey sanity with stripe_count = 1"
12292 mcreate_path2fid () {
12298 local path=$DIR/$tdir/$name
12303 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12304 error "cannot create $desc"
12306 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12308 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12310 fid_path=$($LFS fid2path $MOUNT $fid)
12312 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12314 [ "$path" == "$fid_path" ] ||
12315 error "fid2path returned $fid_path, expected $path"
12317 echo "pass with $path and $fid"
12322 mkdir -p $DIR/$tdir
12324 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12325 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12326 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12327 mcreate_path2fid 0040666 0 0 dir "directory"
12328 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12329 mcreate_path2fid 0100666 0 0 file "regular file"
12330 mcreate_path2fid 0120666 0 0 link "symbolic link"
12331 mcreate_path2fid 0140666 0 0 sock "socket"
12333 run_test 226a "call path2fid and fid2path on files of all type"
12336 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12340 mkdir -p $DIR/$tdir
12341 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12342 error "create remote directory failed"
12343 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12344 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12345 "character special file (null)"
12346 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12347 "character special file (no device)"
12348 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12349 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12350 "block special file (loop)"
12351 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12352 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12353 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12355 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12357 # LU-1299 Executing or running ldd on a truncated executable does not
12358 # cause an out-of-memory condition.
12360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12361 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12362 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12363 chmod +x $MOUNT/date
12365 $MOUNT/date > /dev/null
12366 ldd $MOUNT/date > /dev/null
12369 run_test 227 "running truncated executable does not cause OOM"
12371 # LU-1512 try to reuse idle OI blocks
12373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12374 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12375 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12376 skip "non-ldiskfs backend" && return
12378 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12379 local myDIR=$DIR/$tdir
12382 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12383 $LCTL set_param fail_loc=0x80001002
12384 createmany -o $myDIR/t- 10000
12385 $LCTL set_param fail_loc=0
12386 # The guard is current the largest FID holder
12388 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12390 local IDX=$(($SEQ % 64))
12392 do_facet $SINGLEMDS sync
12393 # Make sure journal flushed.
12395 local blk1=$(do_facet $SINGLEMDS \
12396 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12397 grep Blockcount | awk '{print $4}')
12399 # Remove old files, some OI blocks will become idle.
12400 unlinkmany $myDIR/t- 10000
12401 # Create new files, idle OI blocks should be reused.
12402 createmany -o $myDIR/t- 2000
12403 do_facet $SINGLEMDS sync
12404 # Make sure journal flushed.
12406 local blk2=$(do_facet $SINGLEMDS \
12407 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12408 grep Blockcount | awk '{print $4}')
12410 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12412 run_test 228a "try to reuse idle OI blocks"
12415 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12416 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12417 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12418 skip "non-ldiskfs backend" && return
12420 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12421 local myDIR=$DIR/$tdir
12424 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12425 $LCTL set_param fail_loc=0x80001002
12426 createmany -o $myDIR/t- 10000
12427 $LCTL set_param fail_loc=0
12428 # The guard is current the largest FID holder
12430 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12432 local IDX=$(($SEQ % 64))
12434 do_facet $SINGLEMDS sync
12435 # Make sure journal flushed.
12437 local blk1=$(do_facet $SINGLEMDS \
12438 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12439 grep Blockcount | awk '{print $4}')
12441 # Remove old files, some OI blocks will become idle.
12442 unlinkmany $myDIR/t- 10000
12445 stop $SINGLEMDS || error "Fail to stop MDT."
12447 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12449 df $MOUNT || error "Fail to df."
12450 # Create new files, idle OI blocks should be reused.
12451 createmany -o $myDIR/t- 2000
12452 do_facet $SINGLEMDS sync
12453 # Make sure journal flushed.
12455 local blk2=$(do_facet $SINGLEMDS \
12456 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12457 grep Blockcount | awk '{print $4}')
12459 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12461 run_test 228b "idle OI blocks can be reused after MDT restart"
12465 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12466 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12467 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12468 skip "non-ldiskfs backend" && return
12470 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12471 local myDIR=$DIR/$tdir
12474 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12475 $LCTL set_param fail_loc=0x80001002
12476 # 20000 files can guarantee there are index nodes in the OI file
12477 createmany -o $myDIR/t- 20000
12478 $LCTL set_param fail_loc=0
12479 # The guard is current the largest FID holder
12481 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12483 local IDX=$(($SEQ % 64))
12485 do_facet $SINGLEMDS sync
12486 # Make sure journal flushed.
12488 local blk1=$(do_facet $SINGLEMDS \
12489 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12490 grep Blockcount | awk '{print $4}')
12492 # Remove old files, some OI blocks will become idle.
12493 unlinkmany $myDIR/t- 20000
12495 # The OI file should become empty now
12497 # Create new files, idle OI blocks should be reused.
12498 createmany -o $myDIR/t- 2000
12499 do_facet $SINGLEMDS sync
12500 # Make sure journal flushed.
12502 local blk2=$(do_facet $SINGLEMDS \
12503 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12504 grep Blockcount | awk '{print $4}')
12506 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12508 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12510 test_229() { # LU-2482, LU-3448
12511 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12512 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
12514 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12515 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12519 # Create a file with a released layout and stripe count 2.
12520 $MULTIOP $DIR/$tfile H2c ||
12521 error "failed to create file with released layout"
12523 $GETSTRIPE -v $DIR/$tfile
12525 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12526 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12528 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12529 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12530 stat $DIR/$tfile || error "failed to stat released file"
12532 chown $RUNAS_ID $DIR/$tfile ||
12533 error "chown $RUNAS_ID $DIR/$tfile failed"
12535 chgrp $RUNAS_ID $DIR/$tfile ||
12536 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12538 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12539 rm $DIR/$tfile || error "failed to remove released file"
12541 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12545 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12548 test_mkdir $DIR/$tdir
12549 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12550 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12551 [ $mdt_idx -ne 0 ] &&
12552 error "create local directory on wrong MDT $mdt_idx"
12554 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12555 error "create remote directory failed"
12556 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12557 [ $mdt_idx -ne $MDTIDX ] &&
12558 error "create remote directory on wrong MDT $mdt_idx"
12560 createmany -o $DIR/$tdir/test_230/t- 10 ||
12561 error "create files on remote directory failed"
12562 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12563 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12564 rm -r $DIR/$tdir || error "unlink remote directory failed"
12566 run_test 230a "Create remote directory and files under the remote directory"
12569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12570 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12577 local migrate_dir=$DIR/$tdir/migrate_dir
12578 local other_dir=$DIR/$tdir/other_dir
12580 test_mkdir $DIR/$tdir
12581 test_mkdir -i0 -c1 $migrate_dir
12582 test_mkdir -i0 -c1 $other_dir
12583 for ((i=0; i<10; i++)); do
12584 mkdir -p $migrate_dir/dir_${i}
12585 createmany -o $migrate_dir/dir_${i}/f 10 ||
12586 error "create files under remote dir failed $i"
12589 cp /etc/passwd $migrate_dir/$tfile
12590 cp /etc/passwd $other_dir/$tfile
12591 chattr +SAD $migrate_dir
12592 chattr +SAD $migrate_dir/$tfile
12594 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12595 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12596 local old_dir_mode=$(stat -c%f $migrate_dir)
12597 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12599 mkdir -p $migrate_dir/dir_default_stripe2
12600 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12601 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12603 mkdir -p $other_dir
12604 ln $migrate_dir/$tfile $other_dir/luna
12605 ln $migrate_dir/$tfile $migrate_dir/sofia
12606 ln $other_dir/$tfile $migrate_dir/david
12607 ln -s $migrate_dir/$tfile $other_dir/zachary
12608 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12609 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12611 $LFS migrate -m $MDTIDX $migrate_dir ||
12612 error "fails on migrating remote dir to MDT1"
12614 echo "migratate to MDT1, then checking.."
12615 for ((i = 0; i < 10; i++)); do
12616 for file in $(find $migrate_dir/dir_${i}); do
12617 mdt_index=$($LFS getstripe -M $file)
12618 [ $mdt_index == $MDTIDX ] ||
12619 error "$file is not on MDT${MDTIDX}"
12623 # the multiple link file should still in MDT0
12624 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12625 [ $mdt_index == 0 ] ||
12626 error "$file is not on MDT${MDTIDX}"
12628 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12629 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12630 error " expect $old_dir_flag get $new_dir_flag"
12632 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12633 [ "$old_file_flag" = "$new_file_flag" ] ||
12634 error " expect $old_file_flag get $new_file_flag"
12636 local new_dir_mode=$(stat -c%f $migrate_dir)
12637 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12638 error "expect mode $old_dir_mode get $new_dir_mode"
12640 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12641 [ "$old_file_mode" = "$new_file_mode" ] ||
12642 error "expect mode $old_file_mode get $new_file_mode"
12644 diff /etc/passwd $migrate_dir/$tfile ||
12645 error "$tfile different after migration"
12647 diff /etc/passwd $other_dir/luna ||
12648 error "luna different after migration"
12650 diff /etc/passwd $migrate_dir/sofia ||
12651 error "sofia different after migration"
12653 diff /etc/passwd $migrate_dir/david ||
12654 error "david different after migration"
12656 diff /etc/passwd $other_dir/zachary ||
12657 error "zachary different after migration"
12659 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12660 error "${tfile}_ln different after migration"
12662 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12663 error "${tfile}_ln_other different after migration"
12665 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12666 [ $stripe_count = 2 ] ||
12667 error "dir strpe_count $d != 2 after migration."
12669 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12670 [ $stripe_count = 2 ] ||
12671 error "file strpe_count $d != 2 after migration."
12673 #migrate back to MDT0
12676 $LFS migrate -m $MDTIDX $migrate_dir ||
12677 error "fails on migrating remote dir to MDT0"
12679 echo "migrate back to MDT0, checking.."
12680 for file in $(find $migrate_dir); do
12681 mdt_index=$($LFS getstripe -M $file)
12682 [ $mdt_index == $MDTIDX ] ||
12683 error "$file is not on MDT${MDTIDX}"
12686 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12687 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12688 error " expect $old_dir_flag get $new_dir_flag"
12690 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12691 [ "$old_file_flag" = "$new_file_flag" ] ||
12692 error " expect $old_file_flag get $new_file_flag"
12694 local new_dir_mode=$(stat -c%f $migrate_dir)
12695 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12696 error "expect mode $old_dir_mode get $new_dir_mode"
12698 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12699 [ "$old_file_mode" = "$new_file_mode" ] ||
12700 error "expect mode $old_file_mode get $new_file_mode"
12702 diff /etc/passwd ${migrate_dir}/$tfile ||
12703 error "$tfile different after migration"
12705 diff /etc/passwd ${other_dir}/luna ||
12706 error "luna different after migration"
12708 diff /etc/passwd ${migrate_dir}/sofia ||
12709 error "sofia different after migration"
12711 diff /etc/passwd ${other_dir}/zachary ||
12712 error "zachary different after migration"
12714 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12715 error "${tfile}_ln different after migration"
12717 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12718 error "${tfile}_ln_other different after migration"
12720 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12721 [ $stripe_count = 2 ] ||
12722 error "dir strpe_count $d != 2 after migration."
12724 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12725 [ $stripe_count = 2 ] ||
12726 error "file strpe_count $d != 2 after migration."
12728 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12730 run_test 230b "migrate directory"
12733 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12735 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12739 local migrate_dir=$DIR/$tdir/migrate_dir
12741 #If migrating directory fails in the middle, all entries of
12742 #the directory is still accessiable.
12743 test_mkdir $DIR/$tdir
12744 test_mkdir -i0 -c1 $migrate_dir
12746 createmany -o $migrate_dir/f 10 ||
12747 error "create files under ${migrate_dir} failed"
12749 #failed after migrating 5 entries
12750 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12751 do_facet mds1 lctl set_param fail_loc=0x20001801
12752 do_facet mds1 lctl set_param fail_val=5
12753 local t=$(ls $migrate_dir | wc -l)
12754 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
12755 error "migrate should fail after 5 entries"
12757 mkdir $migrate_dir/dir &&
12758 error "mkdir succeeds under migrating directory"
12759 touch $migrate_dir/file &&
12760 error "touch file succeeds under migrating directory"
12762 local u=$(ls $migrate_dir | wc -l)
12763 [ "$u" == "$t" ] || error "$u != $t during migration"
12765 for file in $(find $migrate_dir); do
12766 stat $file || error "stat $file failed"
12769 do_facet mds1 lctl set_param fail_loc=0
12770 do_facet mds1 lctl set_param fail_val=0
12772 $LFS migrate -m $MDTIDX $migrate_dir ||
12773 error "migrate open files should failed with open files"
12775 echo "Finish migration, then checking.."
12776 for file in $(find $migrate_dir); do
12777 mdt_index=$($LFS getstripe -M $file)
12778 [ $mdt_index == $MDTIDX ] ||
12779 error "$file is not on MDT${MDTIDX}"
12782 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12784 run_test 230c "check directory accessiblity if migration is failed"
12787 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12788 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12791 local migrate_dir=$DIR/$tdir/migrate_dir
12795 test_mkdir $DIR/$tdir
12796 test_mkdir -i0 -c1 $migrate_dir
12798 for ((i=0; i<100; i++)); do
12799 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12800 createmany -o $migrate_dir/dir_${i}/f 100 ||
12801 error "create files under remote dir failed $i"
12804 $LFS migrate -m $MDTIDX $migrate_dir ||
12805 error "migrate remote dir error"
12807 echo "Finish migration, then checking.."
12808 for file in $(find $migrate_dir); do
12809 mdt_index=$($LFS getstripe -M $file)
12810 [ $mdt_index == $MDTIDX ] ||
12811 error "$file is not on MDT${MDTIDX}"
12814 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12816 run_test 230d "check migrate big directory"
12820 # For simplicity this test assumes that max_pages_per_rpc
12821 # is the same across all OSCs
12822 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12823 local bulk_size=$((max_pages * 4096))
12825 mkdir -p $DIR/$tdir
12827 # clear the OSC stats
12828 $LCTL set_param osc.*.stats=0 &>/dev/null
12830 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12831 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12832 oflag=direct &>/dev/null || error "dd failed"
12834 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12835 if [ x$nrpcs != "x1" ]; then
12836 error "found $nrpc ost_write RPCs, not 1 as expected"
12839 # Drop the OSC cache, otherwise we will read from it
12840 cancel_lru_locks osc
12842 # clear the OSC stats
12843 $LCTL set_param osc.*.stats=0 &>/dev/null
12845 # Client reads $bulk_size.
12846 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12847 iflag=direct &>/dev/null || error "dd failed"
12849 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12850 if [ x$nrpcs != "x1" ]; then
12851 error "found $nrpc ost_read RPCs, not 1 as expected"
12854 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12857 mkdir -p $DIR/$tdir
12859 for i in {0..1023}; do
12860 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12861 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12862 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12866 run_test 231b "must not assert on fully utilized OST request buffer"
12869 mkdir -p $DIR/$tdir
12870 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12871 $LCTL set_param fail_loc=0x31c
12873 # ignore dd failure
12874 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12876 $LCTL set_param fail_loc=0
12877 umount_client $MOUNT || error "umount failed"
12878 mount_client $MOUNT || error "mount failed"
12880 run_test 232 "failed lock should not block umount"
12883 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12884 { skip "Need MDS version at least 2.3.64"; return; }
12886 local fid=$($LFS path2fid $MOUNT)
12887 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12888 error "cannot access $MOUNT using its FID '$fid'"
12890 run_test 233a "checking that OBF of the FS root succeeds"
12893 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12894 { skip "Need MDS version at least 2.5.90"; return; }
12896 local fid=$($LFS path2fid $MOUNT/.lustre)
12897 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12898 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12900 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12901 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12902 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12904 run_test 233b "checking that OBF of the FS .lustre succeeds"
12907 local p="$TMP/sanityN-$TESTNAME.parameters"
12908 save_lustre_params client "llite.*.xattr_cache" > $p
12909 lctl set_param llite.*.xattr_cache 1 ||
12910 { skip "xattr cache is not supported"; return 0; }
12912 mkdir -p $DIR/$tdir || error "mkdir failed"
12913 touch $DIR/$tdir/$tfile || error "touch failed"
12914 # OBD_FAIL_LLITE_XATTR_ENOMEM
12915 $LCTL set_param fail_loc=0x1405
12916 # output of the form: attr 2 4 44 3 fc13 x86_64
12917 V=($(IFS=".-" rpm -q attr))
12918 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
12919 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
12920 # attr pre-2.4.44-7 had a bug with rc
12921 # LU-3703 - SLES 11 and FC13 clients have older attr
12922 getfattr -n user.attr $DIR/$tdir/$tfile &&
12923 error "getfattr should have failed with ENOMEM"
12925 skip "LU-3703: attr version $(getfattr --version) too old"
12927 $LCTL set_param fail_loc=0x0
12930 restore_lustre_params < $p
12933 run_test 234 "xattr cache should not crash on ENOMEM"
12936 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12937 skip "Need MDS version at least 2.4.52" && return
12938 flock_deadlock $DIR/$tfile
12943 124) error "process hangs on a deadlock"
12945 *) error "error executing flock_deadlock $DIR/$tfile"
12949 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12953 check_swap_layouts_support && return 0
12954 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12956 local ref1=/etc/passwd
12957 local ref2=/etc/group
12958 local file1=$DIR/$tdir/f1
12959 local file2=$DIR/$tdir/f2
12961 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12962 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12963 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12964 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12965 local fd=$(free_fd)
12966 local cmd="exec $fd<>$file2"
12969 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12970 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12973 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12978 run_test 236 "Layout swap on open unlinked file"
12980 # test to verify file handle related system calls
12981 # (name_to_handle_at/open_by_handle_at)
12982 # The new system calls are supported in glibc >= 2.14.
12985 echo "Test file_handle syscalls" > $DIR/$tfile ||
12986 error "write failed"
12987 check_fhandle_syscalls $DIR/$tfile ||
12988 error "check_fhandle_syscalls failed"
12990 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12992 # LU-4659 linkea consistency
12994 local server_version=$(lustre_version_code $SINGLEMDS)
12996 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12997 [[ $server_version -gt $(version_code 2.5.1) &&
12998 $server_version -lt $(version_code 2.5.50) ]] ||
12999 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
13002 ln $DIR/$tfile $DIR/$tfile.lnk
13003 touch $DIR/$tfile.new
13004 mv $DIR/$tfile.new $DIR/$tfile
13005 local fid1=$($LFS path2fid $DIR/$tfile)
13006 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
13007 local path1=$($LFS fid2path $FSNAME "$fid1")
13008 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
13009 local path2=$($LFS fid2path $FSNAME "$fid2")
13010 [ $tfile.lnk == $path2 ] ||
13011 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
13014 run_test 238 "Verify linkea consistency"
13017 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
13018 skip "Need MDS version at least 2.5.60" && return
13019 local list=$(comma_list $(mdts_nodes))
13021 mkdir -p $DIR/$tdir
13022 createmany -o $DIR/$tdir/f- 5000
13023 unlinkmany $DIR/$tdir/f- 5000
13024 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
13025 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
13026 osc.*MDT*.sync_in_flight" | calc_sum)
13027 [ "$changes" -eq 0 ] || error "$changes not synced"
13029 run_test 239 "osp_sync test"
13032 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13034 mkdir -p $DIR/$tdir
13036 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
13037 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
13038 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
13039 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
13041 umount_client $MOUNT || error "umount failed"
13042 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
13043 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
13044 mount_client $MOUNT || error "failed to mount client"
13046 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
13047 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
13049 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
13052 for LOOP in $(seq $1); do
13053 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
13054 cancel_lru_locks osc
13059 for LOOP in $(seq $1); do
13060 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
13061 iflag=direct 2>/dev/null
13066 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13068 cancel_lru_locks osc
13069 test_241_bio 1000 &
13074 run_test 241 "bio vs dio"
13077 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
13079 test_241_dio 1000 &
13084 run_test 241b "dio vs dio"
13087 mkdir -p $DIR/$tdir
13088 touch $DIR/$tdir/$tfile
13090 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
13091 do_facet mds1 lctl set_param fail_loc=0x105
13092 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
13094 do_facet mds1 lctl set_param fail_loc=0
13095 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
13097 run_test 242 "mdt_readpage failure should not cause directory unreadable"
13101 test_mkdir -p $DIR/$tdir
13102 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
13104 run_test 243 "various group lock tests"
13108 test_mkdir -p $DIR/$tdir
13109 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
13110 sendfile_grouplock $DIR/$tdir/$tfile || \
13111 error "sendfile+grouplock failed"
13114 run_test 244 "sendfile with group lock tests"
13117 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
13118 && skip "no 16TB file size limit on ZFS" && return
13120 $SETSTRIPE -c 1 $DIR/$tfile
13121 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
13122 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
13123 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
13124 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
13125 conv=notrunc,fsync && error "append succeeded"
13128 run_test 250 "Write above 16T limit"
13131 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
13133 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
13134 #Skip once - writing the first stripe will succeed
13135 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13136 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
13137 error "short write happened"
13139 $LCTL set_param fail_loc=0xa0001407 fail_val=1
13140 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
13141 error "short read happened"
13145 run_test 251 "Handling short read and write correctly"
13155 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
13156 "$(facet_fstype mds1)" != "ldiskfs" ]; then
13157 skip "can only run lr_reader on ldiskfs target"
13161 # check lr_reader on OST0000
13163 dev=$(facet_device $tgt)
13164 out=$(do_facet $tgt $LR_READER $dev)
13165 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13167 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
13168 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
13169 error "Invalid uuid returned by $LR_READER on target $tgt"
13170 echo -e "uuid returned by $LR_READER is '$uuid'\n"
13172 # check lr_reader -c on MDT0000
13174 dev=$(facet_device $tgt)
13175 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
13176 echo "$LR_READER does not support additional options"
13179 out=$(do_facet $tgt $LR_READER -c $dev)
13180 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13182 num=$(echo "$out" | grep -c "mdtlov")
13183 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
13184 error "Invalid number of mdtlov clients returned by $LR_READER"
13185 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
13187 # check lr_reader -cr on MDT0000
13188 out=$(do_facet $tgt $LR_READER -cr $dev)
13189 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
13191 echo "$out" | grep -q "^reply_data:$" ||
13192 error "$LR_READER should have returned 'reply_data' section"
13193 num=$(echo "$out" | grep -c "client_generation")
13194 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
13196 run_test 252 "check lr_reader tool"
13199 cleanup_test_300() {
13203 test_striped_dir() {
13208 mkdir -p $DIR/$tdir
13210 SAVE_UMASK=$(umask)
13211 trap cleanup_test_300 RETURN EXIT
13213 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
13214 $DIR/$tdir/striped_dir ||
13215 error "set striped dir error"
13217 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
13218 [ "$mode" = "755" ] || error "expect 755 got $mode"
13220 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
13221 error "getdirstripe failed"
13222 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
13223 if [ "$stripe_count" != "2" ]; then
13224 error "stripe_count is $stripe_count, expect 2"
13227 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
13228 if [ "$stripe_index" != "$mdt_index" ]; then
13229 error "stripe_index is $stripe_index, expect $mdt_index"
13232 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13233 error "nlink error after create striped dir"
13235 mkdir $DIR/$tdir/striped_dir/a
13236 mkdir $DIR/$tdir/striped_dir/b
13238 stat $DIR/$tdir/striped_dir/a ||
13239 error "create dir under striped dir failed"
13240 stat $DIR/$tdir/striped_dir/b ||
13241 error "create dir under striped dir failed"
13243 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
13244 error "nlink error after mkdir"
13246 rmdir $DIR/$tdir/striped_dir/a
13247 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
13248 error "nlink error after rmdir"
13250 rmdir $DIR/$tdir/striped_dir/b
13251 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
13252 error "nlink error after rmdir"
13254 chattr +i $DIR/$tdir/striped_dir
13255 createmany -o $DIR/$tdir/striped_dir/f 10 &&
13256 error "immutable flags not working under striped dir!"
13257 chattr -i $DIR/$tdir/striped_dir
13259 rmdir $DIR/$tdir/striped_dir ||
13260 error "rmdir striped dir error"
13268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13269 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13271 test_striped_dir 0 || error "failed on striped dir on MDT0"
13272 test_striped_dir 1 || error "failed on striped dir on MDT0"
13274 run_test 300a "basic striped dir sanity test"
13277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13278 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13284 test_mkdir $DIR/$tdir || error "mkdir fail"
13285 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13286 error "set striped dir error"
13287 for ((i=0; i<10; i++)); do
13288 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
13290 touch $DIR/$tdir/striped_dir/file_$i ||
13291 error "touch error $i"
13292 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13293 [ $mtime1 -eq $mtime2 ] &&
13294 error "mtime not change after create"
13296 rm -f $DIR/$tdir/striped_dir/file_$i ||
13297 error "unlink error $i"
13298 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13299 [ $mtime2 -eq $mtime3 ] &&
13300 error "mtime did not change after unlink"
13304 run_test 300b "check ctime/mtime for striped dir"
13307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13308 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13311 mkdir -p $DIR/$tdir
13312 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13313 error "set striped dir error"
13315 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13316 error "chown striped dir failed"
13318 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13319 error "create 5k files failed"
13321 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13323 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13327 run_test 300c "chown && check ls under striped directory"
13330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13331 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13335 mkdir -p $DIR/$tdir
13336 $SETSTRIPE -c 2 $DIR/$tdir
13338 #local striped directory
13339 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13340 error "set striped dir error"
13341 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13342 error "create 10 files failed"
13344 #remote striped directory
13345 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13346 error "set striped dir error"
13347 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13348 error "create 10 files failed"
13350 for file in $(find $DIR/$tdir); do
13351 stripe_count=$($GETSTRIPE -c $file)
13352 [ $stripe_count -eq 2 ] ||
13353 error "wrong stripe $stripe_count for $file"
13358 run_test 300d "check default stripe under striped directory"
13361 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13362 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13366 mkdir -p $DIR/$tdir
13368 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13369 error "set striped dir error"
13371 touch $DIR/$tdir/striped_dir/a
13372 touch $DIR/$tdir/striped_dir/b
13373 touch $DIR/$tdir/striped_dir/c
13375 mkdir $DIR/$tdir/striped_dir/dir_a
13376 mkdir $DIR/$tdir/striped_dir/dir_b
13377 mkdir $DIR/$tdir/striped_dir/dir_c
13379 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13380 error "set striped dir under striped dir error"
13382 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13383 error "set striped dir under striped dir error"
13385 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13386 error "set striped dir under striped dir error"
13388 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
13389 error "rename dir under striped dir fails"
13391 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
13392 error "rename dir under different stripes fails"
13394 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13395 error "rename file under striped dir should succeed"
13397 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
13398 error "rename dir under striped dir should succeed"
13402 run_test 300e "check rename under striped directory"
13405 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13406 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13411 mkdir -p $DIR/$tdir
13413 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13414 error "set striped dir error"
13416 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13417 error "set striped dir error"
13419 touch $DIR/$tdir/striped_dir/a
13420 mkdir $DIR/$tdir/striped_dir/dir_a
13421 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13422 error "create striped dir under striped dir fails"
13424 touch $DIR/$tdir/striped_dir1/b
13425 mkdir $DIR/$tdir/striped_dir1/dir_b
13426 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13427 error "create striped dir under striped dir fails"
13429 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
13430 error "rename dir under different striped dir should fail"
13432 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
13433 error "rename striped dir under diff striped dir should fail"
13435 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13436 error "rename file under diff striped dirs fails"
13440 run_test 300f "check rename cross striped directory"
13442 test_300_check_default_striped_dir()
13445 local default_count=$2
13446 local default_index=$3
13449 local dir_stripe_index
13452 echo "checking $dirname $default_count $default_index"
13453 $LFS setdirstripe -D -c $default_count -i $default_index \
13454 -t all_char $DIR/$tdir/$dirname ||
13455 error "set default stripe on striped dir error"
13456 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13457 [ $stripe_count -eq $default_count ] ||
13458 error "expect $default_count get $stripe_count for $dirname"
13460 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13461 [ $stripe_index -eq $default_index ] ||
13462 error "expect $default_index get $stripe_index for $dirname"
13464 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13465 error "create dirs failed"
13467 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13468 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13469 for dir in $(find $DIR/$tdir/$dirname/*); do
13470 stripe_count=$($LFS getdirstripe -c $dir)
13471 [ $stripe_count -eq $default_count ] ||
13472 error "stripe count $default_count != $stripe_count for $dir"
13474 stripe_index=$($LFS getdirstripe -i $dir)
13475 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13476 error "$stripe_index != $default_index for $dir"
13478 #check default stripe
13479 stripe_count=$($LFS getdirstripe -D -c $dir)
13480 [ $stripe_count -eq $default_count ] ||
13481 error "default count $default_count != $stripe_count for $dir"
13483 stripe_index=$($LFS getdirstripe -D -i $dir)
13484 [ $stripe_index -eq $default_index ] ||
13485 error "default index $default_index != $stripe_index for $dir"
13487 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13491 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13497 mkdir $DIR/$tdir/normal_dir
13499 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13500 test_300_check_default_striped_dir normal_dir 1 0
13501 test_300_check_default_striped_dir normal_dir 2 1
13502 test_300_check_default_striped_dir normal_dir 2 -1
13504 #delete default stripe information
13505 echo "delete default stripeEA"
13506 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13507 error "set default stripe on striped dir error"
13509 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13510 for dir in $(find $DIR/$tdir/normal_dir/*); do
13511 stripe_count=$($LFS getdirstripe -c $dir)
13512 [ $stripe_count -eq 0 ] ||
13513 error "expect 1 get $stripe_count for $dir"
13514 stripe_index=$($LFS getdirstripe -i $dir)
13515 [ $stripe_index -eq 0 ] ||
13516 error "expect 0 get $stripe_index for $dir"
13519 run_test 300g "check default striped directory for normal directory"
13522 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13527 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13528 $DIR/$tdir/striped_dir ||
13529 error "set striped dir error"
13531 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13532 test_300_check_default_striped_dir striped_dir 1 0
13533 test_300_check_default_striped_dir striped_dir 2 1
13534 test_300_check_default_striped_dir striped_dir 2 -1
13536 #delete default stripe information
13537 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13538 error "set default stripe on striped dir error"
13540 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13541 for dir in $(find $DIR/$tdir/striped_dir/*); do
13542 stripe_count=$($LFS getdirstripe -c $dir)
13543 [ $stripe_count -eq 0 ] ||
13544 error "expect 1 get $stripe_count for $dir"
13547 run_test 300h "check default striped directory for striped directory"
13550 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13551 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13557 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13558 error "set striped dir error"
13560 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13561 error "create files under striped dir failed"
13563 # unfortunately, we need to umount to clear dir layout cache for now
13564 # once we fully implement dir layout, we can drop this
13565 umount_client $MOUNT || error "umount failed"
13566 mount_client $MOUNT || error "mount failed"
13568 #set the stripe to be unknown hash type
13569 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13570 $LCTL set_param fail_loc=0x1901
13571 for ((i = 0; i < 10; i++)); do
13572 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13573 error "stat f-$i failed"
13574 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13577 touch $DIR/$tdir/striped_dir/f0 &&
13578 error "create under striped dir with unknown hash should fail"
13580 $LCTL set_param fail_loc=0
13582 umount_client $MOUNT || error "umount failed"
13583 mount_client $MOUNT || error "mount failed"
13587 run_test 300i "client handle unknown hash type striped directory"
13590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13591 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13592 skip "Need MDS version at least 2.7.55" && return
13593 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13599 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
13600 $LCTL set_param fail_loc=0x1702
13601 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13602 error "set striped dir error"
13604 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13605 error "create files under striped dir failed"
13607 $LCTL set_param fail_loc=0
13609 rm -rf $DIR/$tdir || error "unlink striped dir fails"
13613 run_test 300j "test large update record"
13616 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13617 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
13618 skip "Need MDS version at least 2.7.55" && return
13619 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13625 #define OBD_FAIL_LARGE_STRIPE 0x1703
13626 $LCTL set_param fail_loc=0x1703
13627 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
13628 error "set striped dir error"
13629 $LCTL set_param fail_loc=0
13631 $LFS getdirstripe $DIR/$tdir/striped_dir ||
13632 error "getstripeddir fails"
13633 rm -rf $DIR/$tdir/striped_dir ||
13634 error "unlink striped dir fails"
13638 run_test 300k "test large striped directory"
13641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13642 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13645 test_mkdir -p $DIR/$tdir/striped_dir
13646 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
13647 error "chown $RUNAS_ID failed"
13648 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
13649 error "set default striped dir failed"
13651 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
13652 $LCTL set_param fail_loc=0x80000158
13653 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
13655 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
13656 [ $stripe_index -eq 1 ] ||
13657 error "expect 1 get $stripe_index for $dir"
13659 run_test 300l "non-root user to create dir under striped dir with stale layout"
13661 prepare_remote_file() {
13662 mkdir $DIR/$tdir/src_dir ||
13663 error "create remote source failed"
13665 cp /etc/hosts $DIR/$tdir/src_dir/a || error
13666 touch $DIR/$tdir/src_dir/a
13668 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
13669 error "create remote target dir failed"
13671 touch $DIR/$tdir/tgt_dir/b
13673 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
13674 error "rename dir cross MDT failed!"
13676 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
13677 error "src_child still exists after rename"
13679 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
13680 error "missing file(a) after rename"
13682 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
13683 error "diff after rename"
13687 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
13688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13689 local remote_file=$DIR/$tdir/tgt_dir/b
13691 mkdir -p $DIR/$tdir
13693 prepare_remote_file || error "prepare remote file failed"
13696 $OPENUNLINK $remote_file $remote_file || error
13697 $CHECKSTAT -a $remote_file || error
13699 run_test 310a "open unlink remote file"
13702 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
13703 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13704 local remote_file=$DIR/$tdir/tgt_dir/b
13706 mkdir -p $DIR/$tdir
13708 prepare_remote_file || error "prepare remote file failed"
13710 ln $remote_file $DIR/$tfile || error "link failed for remote file"
13711 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
13712 $CHECKSTAT -t file $remote_file || error "check file failed"
13714 run_test 310b "unlink remote file with multiple links while open"
13717 [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
13718 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13719 local remote_file=$DIR/$tdir/tgt_dir/b
13721 mkdir -p $DIR/$tdir
13723 prepare_remote_file || error "prepare remote file failed"
13725 ln $remote_file $DIR/$tfile || error "link failed for remote file"
13726 multiop_bg_pause $remote_file O_uc ||
13727 error "mulitop failed for remote file"
13729 $MULTIOP $DIR/$tfile Ouc
13730 kill -USR1 $MULTIPID
13733 run_test 310c "open-unlink remote file with multiple links"
13735 test_400a() { # LU-1606, was conf-sanity test_74
13736 local extra_flags=''
13737 local out=$TMP/$tfile
13738 local prefix=/usr/include/lustre
13741 if ! which $CC > /dev/null 2>&1; then
13742 skip_env "$CC is not installed"
13746 if ! [[ -d $prefix ]]; then
13747 # Assume we're running in tree and fixup the include path.
13748 extra_flags+=" -I$LUSTRE/../libcfs/include"
13749 extra_flags+=" -I$LUSTRE/include"
13750 extra_flags+=" -L$LUSTRE/utils"
13753 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
13754 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
13755 error "client api broken"
13758 run_test 400a "Lustre client api program can compile and link"
13760 test_400b() { # LU-1606, LU-5011
13762 local out=$TMP/$tfile
13763 local prefix=/usr/include/lustre
13765 # We use a hard coded prefix so that this test will not fail
13766 # when run in tree. There are headers in lustre/include/lustre/
13767 # that are not packaged (like lustre_idl.h) and have more
13768 # complicated include dependencies (like config.h and lnet/types.h).
13769 # Since this test about correct packaging we just skip them when
13770 # they don't exist (see below) rather than try to fixup cppflags.
13772 if ! which $CC > /dev/null 2>&1; then
13773 skip_env "$CC is not installed"
13777 for header in $prefix/*.h; do
13778 if ! [[ -f "$header" ]]; then
13782 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13783 continue # liblustreapi.h is deprecated.
13786 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13787 error "cannot compile '$header'"
13790 run_test 400b "packaged headers can be compiled"
13793 # tests that do cleanup/setup should be run at the end
13797 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13799 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13800 $LCTL set_param fail_loc=0x903
13802 cancel_lru_locks MGC
13804 FAIL_ON_ERROR=true cleanup
13805 FAIL_ON_ERROR=true setup
13807 run_test 900 "umount should not race with any mgc requeue thread"
13810 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13811 check_and_cleanup_lustre
13812 if [ "$I_MOUNTED" != "yes" ]; then
13813 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true