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: LU-9693 LU-6493 LU-9693 LU-11058
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c 77k"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054 ..
16 ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT"
18 # Check Grants after these tests
19 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
21 SRCDIR=$(cd $(dirname $0); echo $PWD)
22 export PATH=$PATH:/sbin
28 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
29 CREATETEST=${CREATETEST:-createtest}
31 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
33 OPENFILE=${OPENFILE:-openfile}
34 OPENUNLINK=${OPENUNLINK:-openunlink}
35 export MULTIOP=${MULTIOP:-multiop}
36 READS=${READS:-"reads"}
37 MUNLINK=${MUNLINK:-munlink}
38 SOCKETSERVER=${SOCKETSERVER:-socketserver}
39 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
40 MEMHOG=${MEMHOG:-memhog}
41 DIRECTIO=${DIRECTIO:-directio}
42 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
57 . $LUSTRE/tests/test-framework.sh
59 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
62 if [[ $MDSCOUNT -gt 1 ]]; then
63 # bug number: LU-11161
64 ALWAYS_EXCEPT+=" 160g"
68 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
70 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
71 # bug number for skipped test: LU-1957
72 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
74 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
77 # Get the SLES distro version
79 # Returns a version string that should only be used in comparing
80 # strings returned by version_code()
83 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
85 # All SuSE Linux versions have one decimal. version_code expects two
86 local sles_version=$version.0
87 version_code $sles_version
90 # Check if we are running on Ubuntu or SLES so we can make decisions on
92 if [ -r /etc/SuSE-release ]; then
93 sles_version=$(sles_version_code)
94 [ $sles_version -lt $(version_code 11.4.0) ] &&
95 # bug number for skipped test: LU-4341
96 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
97 [ $sles_version -lt $(version_code 12.0.0) ] &&
98 # bug number for skipped test: LU-3703
99 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
100 elif [ -r /etc/os-release ]; then
101 if grep -qi ubuntu /etc/os-release; then
102 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
103 -e 's/^VERSION=//p' \
107 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
108 # bug number for skipped test:
109 # LU-10334 LU-10335 LU-10335 LU-10335
110 ALWAYS_EXCEPT+=" 103a 130a 130b 130c"
111 # LU-10335 LU-10335 LU-10365 LU-10366
112 ALWAYS_EXCEPT+=" 130d 130e 400a 410"
121 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
122 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
131 check_swap_layouts_support()
133 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
134 skip "Does not support layout lock."
137 check_and_setup_lustre
141 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
143 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
144 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
145 rm -rf $DIR/[Rdfs][0-9]*
147 # $RUNAS_ID may get set incorrectly somewhere else
148 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
150 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
154 if [ "${ONLY}" = "MOUNT" ] ; then
155 echo "Lustre is up, please go on"
159 echo "preparing for tests involving mounts"
160 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
162 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
163 echo # add a newline after mke2fs.
167 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
168 lctl set_param debug=-1 2> /dev/null || true
171 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
173 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
175 run_test 0a "touch; rm ====================="
178 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
179 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
181 run_test 0b "chmod 0755 $DIR ============================="
184 $LCTL get_param mdc.*.import | grep "state: FULL" ||
185 error "import not FULL"
186 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
189 run_test 0c "check import proc"
191 test_0d() { # LU-3397
192 [ $(lustre_version_code mgs) -lt $(version_code 2.10.57) ] &&
193 skip "proc exports not supported before 2.10.57"
195 local mgs_exp="mgs.MGS.exports"
196 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
198 local exp_client_version
201 local temp_imp=$DIR/$tfile.import
202 local temp_exp=$DIR/$tfile.export
204 # save mgc import file to $temp_imp
205 $LCTL get_param mgc.*.import | tee $temp_imp
206 # Check if client uuid is found in MGS export
207 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
208 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
212 # save mgs export file to $temp_exp
213 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
215 # Compare the value of field "connect_flags"
216 imp_val=$(grep "connect_flags" $temp_imp)
217 exp_val=$(grep "connect_flags" $temp_exp)
218 [ "$exp_val" == "$imp_val" ] ||
219 error "export flags '$exp_val' != import flags '$imp_val'"
221 # Compare the value of client version
222 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
223 exp_val=$(version_code $exp_client_version)
224 imp_val=$(lustre_version_code client)
225 [ "$exp_val" == "$imp_val" ] ||
226 error "export client version '$exp_val' != '$imp_val'"
228 run_test 0d "check export proc ============================="
231 test_mkdir $DIR/$tdir
232 test_mkdir $DIR/$tdir/d2
233 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
234 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
237 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
239 run_test 1 "mkdir; remkdir; rmdir"
242 test_mkdir $DIR/$tdir
243 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
244 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
246 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
248 run_test 2 "mkdir; touch; rmdir; check file"
251 test_mkdir $DIR/$tdir
252 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
253 touch $DIR/$tdir/$tfile
254 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
256 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
258 run_test 3 "mkdir; touch; rmdir; check dir"
260 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
262 test_mkdir -i 1 $DIR/$tdir
264 touch $DIR/$tdir/$tfile ||
265 error "Create file under remote directory failed"
268 error "Expect error removing in-use dir $DIR/$tdir"
270 test -d $DIR/$tdir || error "Remote directory disappeared"
272 rm -rf $DIR/$tdir || error "remove remote dir error"
274 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
277 test_mkdir $DIR/$tdir
278 test_mkdir $DIR/$tdir/d2
279 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
280 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
281 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
283 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
286 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
287 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
288 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
289 error "$tfile does not have perm 0666 or UID $UID"
290 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
291 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
292 error "$tfile should be 0666 and owned by UID $UID"
294 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
297 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
300 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
301 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
302 error "$tfile should be owned by UID $RUNAS_ID"
303 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
304 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
305 error "$tfile should be owned by UID $RUNAS_ID"
307 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
310 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
313 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
314 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
315 error "$tfile should be owned by GID $UID"
316 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
317 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
318 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
320 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
323 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
325 test_mkdir $DIR/$tdir
326 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
327 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
328 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
329 test_mkdir $DIR/$tdir/d/subdir
330 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
331 error "$tdir/d/subdir should be GID $RUNAS_GID"
332 if [[ $MDSCOUNT -gt 1 ]]; then
333 # check remote dir sgid inherite
334 $LFS mkdir -i 0 $DIR/$tdir.local ||
335 error "mkdir $tdir.local failed"
336 chmod g+s $DIR/$tdir.local ||
337 error "chmod $tdir.local failed"
338 chgrp $RUNAS_GID $DIR/$tdir.local ||
339 error "chgrp $tdir.local failed"
340 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
341 error "mkdir $tdir.remote failed"
342 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
343 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
344 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
345 error "$tdir.remote should be mode 02755"
348 run_test 6g "verify new dir in sgid dir inherits group"
350 test_6h() { # bug 7331
351 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
353 touch $DIR/$tfile || error "touch failed"
354 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
355 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
356 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
357 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
358 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
360 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
363 test_mkdir $DIR/$tdir
364 $MCREATE $DIR/$tdir/$tfile
365 chmod 0666 $DIR/$tdir/$tfile
366 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
367 error "$tdir/$tfile should be mode 0666"
369 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
372 if [ ! -d $DIR/$tdir ]; then
373 test_mkdir $DIR/$tdir
375 $MCREATE $DIR/$tdir/$tfile
376 echo -n foo > $DIR/$tdir/$tfile
377 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
378 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
380 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
383 test_mkdir $DIR/$tdir
384 touch $DIR/$tdir/$tfile
385 chmod 0666 $DIR/$tdir/$tfile
386 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
387 error "$tfile mode not 0666"
389 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
392 test_mkdir $DIR/$tdir
393 test_mkdir $DIR/$tdir/d2
394 test_mkdir $DIR/$tdir/d2/d3
395 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
397 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
400 test_mkdir $DIR/$tdir
401 test_mkdir $DIR/$tdir/d2
402 touch $DIR/$tdir/d2/$tfile
403 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
404 error "$tdir/d2/$tfile not a file"
406 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
409 test_mkdir $DIR/$tdir
410 test_mkdir $DIR/$tdir/d2
411 chmod 0666 $DIR/$tdir/d2
412 chmod 0705 $DIR/$tdir/d2
413 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
414 error "$tdir/d2 mode not 0705"
416 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
419 test_mkdir $DIR/$tdir
420 touch $DIR/$tdir/$tfile
421 chmod 0666 $DIR/$tdir/$tfile
422 chmod 0654 $DIR/$tdir/$tfile
423 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
424 error "$tdir/d2 mode not 0654"
426 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
429 test_mkdir $DIR/$tdir
430 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
432 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
433 error "$tdir/$tfile size not 0 after truncate"
435 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
438 test_mkdir $DIR/$tdir
439 touch $DIR/$tdir/$tfile
441 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
443 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
446 test_mkdir $DIR/$tdir
447 touch $DIR/$tdir/$tfile
448 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
449 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
450 error "$tdir/${tfile_2} not a file after rename"
451 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
453 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
456 test_mkdir $DIR/$tdir
457 touch $DIR/$tdir/$tfile
458 rm -rf $DIR/$tdir/$tfile
459 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
461 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
464 test_mkdir $DIR/$tdir
465 touch $DIR/$tdir/$tfile
466 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
468 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
469 error "$tdir/l-exist not a symlink"
470 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
471 error "$tdir/l-exist not referencing a file"
472 rm -f $DIR/$tdir/l-exist
473 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
475 run_test 17a "symlinks: create, remove (real)"
478 test_mkdir $DIR/$tdir
479 ln -s no-such-file $DIR/$tdir/l-dangle
481 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
482 error "$tdir/l-dangle not referencing no-such-file"
483 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
484 error "$tdir/l-dangle not referencing non-existent file"
485 rm -f $DIR/$tdir/l-dangle
486 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
488 run_test 17b "symlinks: create, remove (dangling)"
490 test_17c() { # bug 3440 - don't save failed open RPC for replay
491 test_mkdir $DIR/$tdir
492 ln -s foo $DIR/$tdir/$tfile
493 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
495 run_test 17c "symlinks: open dangling (should return error)"
498 test_mkdir $DIR/$tdir
499 ln -s foo $DIR/$tdir/$tfile
500 touch $DIR/$tdir/$tfile || error "creating to new symlink"
502 run_test 17d "symlinks: create dangling"
505 test_mkdir $DIR/$tdir
506 local foo=$DIR/$tdir/$tfile
507 ln -s $foo $foo || error "create symlink failed"
508 ls -l $foo || error "ls -l failed"
509 ls $foo && error "ls not failed" || true
511 run_test 17e "symlinks: create recursive symlink (should return error)"
514 test_mkdir $DIR/$tdir
515 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
516 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
517 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
518 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
519 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
520 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
523 run_test 17f "symlinks: long and very long symlink name"
525 # str_repeat(S, N) generate a string that is string S repeated N times
530 while [ $((n -= 1)) -ge 0 ]; do
536 # Long symlinks and LU-2241
538 test_mkdir $DIR/$tdir
539 local TESTS="59 60 61 4094 4095"
541 # Fix for inode size boundary in 2.1.4
542 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
545 # Patch not applied to 2.2 or 2.3 branches
546 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
547 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
550 # skip long symlink name for rhel6.5.
551 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
552 grep -q '6.5' /etc/redhat-release &>/dev/null &&
553 TESTS="59 60 61 4062 4063"
556 local SYMNAME=$(str_repeat 'x' $i)
557 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
558 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
561 run_test 17g "symlinks: really long symlink name and inode boundaries"
563 test_17h() { #bug 17378
564 [ $PARALLEL == "yes" ] && skip "skip parallel run"
565 remote_mds_nodsh && skip "remote MDS with nodsh"
569 test_mkdir $DIR/$tdir
570 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
571 $LFS setstripe -c -1 $DIR/$tdir
572 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
573 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
574 touch $DIR/$tdir/$tfile || true
576 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
578 test_17i() { #bug 20018
579 [ $PARALLEL == "yes" ] && skip "skip parallel run"
580 remote_mds_nodsh && skip "remote MDS with nodsh"
582 local foo=$DIR/$tdir/$tfile
585 test_mkdir -c1 $DIR/$tdir
586 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
587 ln -s $foo $foo || error "create symlink failed"
588 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
589 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
590 ls -l $foo && error "error not detected"
593 run_test 17i "don't panic on short symlink (should return error)"
595 test_17k() { #bug 22301
596 [ $PARALLEL == "yes" ] && skip "skip parallel run"
597 [[ -z "$(which rsync 2>/dev/null)" ]] &&
598 skip "no rsync command"
599 rsync --help | grep -q xattr ||
600 skip_env "$(rsync --version | head -n1) does not support xattrs"
601 test_mkdir $DIR/$tdir
602 test_mkdir $DIR/$tdir.new
603 touch $DIR/$tdir/$tfile
604 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
605 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
606 error "rsync failed with xattrs enabled"
608 run_test 17k "symlinks: rsync with xattrs enabled"
610 test_17l() { # LU-279
611 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
612 skip "no getfattr command"
614 test_mkdir $DIR/$tdir
615 touch $DIR/$tdir/$tfile
616 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
617 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
618 # -h to not follow symlinks. -m '' to list all the xattrs.
619 # grep to remove first line: '# file: $path'.
620 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
622 lgetxattr_size_check $path $xattr ||
623 error "lgetxattr_size_check $path $xattr failed"
627 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
632 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
633 skip_env "ldiskfs only test"
634 remote_mds_nodsh && skip "remote MDS with nodsh"
635 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
636 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
637 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
639 local short_sym="0123456789"
640 local wdir=$DIR/$tdir
645 # create a long symlink file
646 for ((i = 0; i < 4; ++i)); do
647 long_sym=${long_sym}${long_sym}
650 echo "create 512 short and long symlink files under $wdir"
651 for ((i = 0; i < 256; ++i)); do
652 ln -sf ${long_sym}"a5a5" $wdir/long-$i
653 ln -sf ${short_sym}"a5a5" $wdir/short-$i
659 wait_delete_completed
661 echo "recreate the 512 symlink files with a shorter string"
662 for ((i = 0; i < 512; ++i)); do
663 # rewrite the symlink file with a shorter string
664 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
665 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
668 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
669 local devname=$(mdsdevname $mds_index)
671 echo "stop and checking mds${mds_index}:"
672 # e2fsck should not return error
674 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
677 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
678 error "start mds${mds_index} failed"
679 df $MOUNT > /dev/null 2>&1
681 error "e2fsck detected error for short/long symlink: rc=$rc"
684 run_test 17m "run e2fsck against MDT which contains short/long symlink"
686 check_fs_consistency_17n() {
690 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
691 # so it only check MDT1/MDT2 instead of all of MDTs.
692 for mdt_index in 1 2; do
693 local devname=$(mdsdevname $mdt_index)
694 # e2fsck should not return error
696 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
699 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
700 error "mount mds$mdt_index failed"
701 df $MOUNT > /dev/null 2>&1
707 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
708 [ $PARALLEL == "yes" ] && skip "skip parallel run"
709 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
710 skip_env "ldiskfs only test"
711 remote_mds_nodsh && skip "remote MDS with nodsh"
712 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
713 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
714 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
718 test_mkdir $DIR/$tdir
719 for ((i=0; i<10; i++)); do
720 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
721 error "create remote dir error $i"
722 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
723 error "create files under remote dir failed $i"
726 check_fs_consistency_17n ||
727 error "e2fsck report error after create files under remote dir"
729 for ((i = 0; i < 10; i++)); do
730 rm -rf $DIR/$tdir/remote_dir_${i} ||
731 error "destroy remote dir error $i"
734 check_fs_consistency_17n ||
735 error "e2fsck report error after unlink files under remote dir"
737 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
738 skip "lustre < 2.4.50 does not support migrate mv"
740 for ((i = 0; i < 10; i++)); do
741 mkdir -p $DIR/$tdir/remote_dir_${i}
742 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
743 error "create files under remote dir failed $i"
744 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
745 error "migrate remote dir error $i"
747 check_fs_consistency_17n || error "e2fsck report error after migration"
749 for ((i = 0; i < 10; i++)); do
750 rm -rf $DIR/$tdir/remote_dir_${i} ||
751 error "destroy remote dir error $i"
754 check_fs_consistency_17n || error "e2fsck report error after unlink"
756 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
759 remote_mds_nodsh && skip "remote MDS with nodsh"
760 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
761 skip "Need MDS version at least 2.3.64"
763 local wdir=$DIR/${tdir}o
769 mdt_index=$($LFS getstripe -m $wdir/$tfile)
770 mdt_index=$((mdt_index + 1))
773 #fail mds will wait the failover finish then set
774 #following fail_loc to avoid interfer the recovery process.
777 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
778 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
779 ls -l $wdir/$tfile && rc=1
780 do_facet mds${mdt_index} lctl set_param fail_loc=0
781 [[ $rc -eq 0 ]] || error "stat file should fail"
783 run_test 17o "stat file with incompat LMA feature"
786 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
787 ls $DIR || error "Failed to ls $DIR: $?"
789 run_test 18 "touch .../f ; ls ... =============================="
795 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
797 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
800 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
802 run_test 19b "ls -l .../f19 (should return error) =============="
805 [ $RUNAS_ID -eq $UID ] &&
806 skip_env "RUNAS_ID = UID = $UID -- skipping"
808 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
810 run_test 19c "$RUNAS touch .../f19 (should return error) =="
813 cat $DIR/f19 && error || true
815 run_test 19d "cat .../f19 (should return error) =============="
824 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
826 run_test 20 "touch .../f ; ls -l ..."
829 test_mkdir $DIR/$tdir
830 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
831 ln -s dangle $DIR/$tdir/link
832 echo foo >> $DIR/$tdir/link
833 cat $DIR/$tdir/dangle
834 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
835 $CHECKSTAT -f -t file $DIR/$tdir/link ||
836 error "$tdir/link not linked to a file"
838 run_test 21 "write to dangling link"
841 local wdir=$DIR/$tdir
843 chown $RUNAS_ID:$RUNAS_GID $wdir
844 (cd $wdir || error "cd $wdir failed";
845 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
847 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
848 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
849 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
850 error "checkstat -u failed"
852 run_test 22 "unpack tar archive as non-root user"
856 test_mkdir $DIR/$tdir
857 local file=$DIR/$tdir/$tfile
859 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
860 openfile -f O_CREAT:O_EXCL $file &&
861 error "$file recreate succeeded" || true
863 run_test 23a "O_CREAT|O_EXCL in subdir"
865 test_23b() { # bug 18988
866 test_mkdir $DIR/$tdir
867 local file=$DIR/$tdir/$tfile
870 echo foo > $file || error "write filed"
871 echo bar >> $file || error "append filed"
872 $CHECKSTAT -s 8 $file || error "wrong size"
875 run_test 23b "O_APPEND check"
877 # LU-9409, size with O_APPEND and tiny writes
879 local file=$DIR/$tfile
882 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
883 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
887 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
888 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
890 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
893 #racing tiny & normal writes
894 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
895 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
897 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
900 #racing tiny & normal writes 2, ugly numbers
901 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
902 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
904 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
907 run_test 23c "O_APPEND size checks for tiny writes"
909 # LU-11069 file offset is correct after appending writes
911 local file=$DIR/$tfile
914 echo CentaurHauls > $file
915 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
916 if ((offset != 26)); then
917 error "wrong offset, expected 26, got '$offset'"
920 run_test 23d "file offset is correct after appending writes"
924 echo '-- same directory rename'
925 test_mkdir $DIR/$tdir
926 touch $DIR/$tdir/$tfile.1
927 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
928 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
930 run_test 24a "rename file to non-existent target"
933 test_mkdir $DIR/$tdir
934 touch $DIR/$tdir/$tfile.{1,2}
935 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
936 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
937 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
939 run_test 24b "rename file to existing target"
942 test_mkdir $DIR/$tdir
943 test_mkdir $DIR/$tdir/d$testnum.1
944 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
945 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
946 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
948 run_test 24c "rename directory to non-existent target"
951 test_mkdir -c1 $DIR/$tdir
952 test_mkdir -c1 $DIR/$tdir/d$testnum.1
953 test_mkdir -c1 $DIR/$tdir/d$testnum.2
954 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
955 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
956 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
958 run_test 24d "rename directory to existing target"
961 echo '-- cross directory renames --'
965 mv $DIR/R5a/f $DIR/R5b/g
966 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
967 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
969 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
974 touch $DIR/R6a/f $DIR/R6b/g
975 mv $DIR/R6a/f $DIR/R6b/g
976 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
977 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
979 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
984 test_mkdir $DIR/R7a/d
985 mv $DIR/R7a/d $DIR/R7b/e
986 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
987 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
989 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
992 test_mkdir -c1 $DIR/R8a
993 test_mkdir -c1 $DIR/R8b
994 test_mkdir -c1 $DIR/R8a/d
995 test_mkdir -c1 $DIR/R8b/e
996 mrename $DIR/R8a/d $DIR/R8b/e
997 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
998 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1000 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1003 echo "-- rename error cases"
1005 test_mkdir $DIR/R9/a
1007 mrename $DIR/R9/f $DIR/R9/a
1008 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1009 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1010 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1012 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1016 mrename $DIR/R10/f $DIR/R10/g
1017 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1018 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1019 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1021 run_test 24j "source does not exist ============================"
1024 test_mkdir $DIR/R11a
1025 test_mkdir $DIR/R11a/d
1027 mv $DIR/R11a/f $DIR/R11a/d
1028 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1029 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1031 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1033 # bug 2429 - rename foo foo foo creates invalid file
1036 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1038 run_test 24l "Renaming a file to itself ========================"
1042 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1043 # on ext3 this does not remove either the source or target files
1044 # though the "expected" operation would be to remove the source
1045 $CHECKSTAT -t file ${f} || error "${f} missing"
1046 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1048 run_test 24m "Renaming a file to a hard link to itself ========="
1052 # this stats the old file after it was renamed, so it should fail
1054 $CHECKSTAT ${f} || error "${f} missing"
1056 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1057 $CHECKSTAT -a ${f} || error "${f} exists"
1059 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1062 test_mkdir $DIR/$tdir
1063 rename_many -s random -v -n 10 $DIR/$tdir
1065 run_test 24o "rename of files during htree split"
1068 test_mkdir $DIR/R12a
1069 test_mkdir $DIR/R12b
1070 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1071 mrename $DIR/R12a $DIR/R12b
1072 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1073 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1074 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1075 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1077 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1079 cleanup_multiop_pause() {
1081 kill -USR1 $MULTIPID
1085 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1087 test_mkdir $DIR/R13a
1088 test_mkdir $DIR/R13b
1089 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1090 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1093 trap cleanup_multiop_pause EXIT
1094 mrename $DIR/R13a $DIR/R13b
1095 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1096 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1097 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1098 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1099 cleanup_multiop_pause
1100 wait $MULTIPID || error "multiop close failed"
1102 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1104 test_24r() { #bug 3789
1105 test_mkdir $DIR/R14a
1106 test_mkdir $DIR/R14a/b
1107 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1108 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1109 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1111 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1114 test_mkdir $DIR/R15a
1115 test_mkdir $DIR/R15a/b
1116 test_mkdir $DIR/R15a/b/c
1117 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1118 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1119 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1121 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1123 test_mkdir $DIR/R16a
1124 test_mkdir $DIR/R16a/b
1125 test_mkdir $DIR/R16a/b/c
1126 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1127 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1128 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1130 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1132 test_24u() { # bug12192
1133 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1134 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1136 run_test 24u "create stripe file"
1140 size=$(getconf PAGE_SIZE 2>/dev/null)
1141 echo -n ${size:-4096}
1144 simple_cleanup_common() {
1147 [ -z "$DIR" -o -z "$tdir" ] && return 0
1149 local start=$SECONDS
1152 wait_delete_completed
1153 echo "cleanup time $((SECONDS - start))"
1157 max_pages_per_rpc() {
1158 local mdtname="$(printf "MDT%04x" ${1:-0})"
1159 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1163 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1165 local nrfiles=${COUNT:-100000}
1166 local fname="$DIR/$tdir/$tfile"
1168 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1169 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1171 test_mkdir "$(dirname $fname)"
1172 # assume MDT0000 has the fewest inodes
1173 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1174 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1175 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1177 trap simple_cleanup_common EXIT
1179 createmany -m "$fname" $nrfiles
1181 cancel_lru_locks mdc
1182 lctl set_param mdc.*.stats clear
1184 # was previously test_24D: LU-6101
1185 # readdir() returns correct number of entries after cursor reload
1186 local num_ls=$(ls $DIR/$tdir | wc -l)
1187 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1188 local num_all=$(ls -a $DIR/$tdir | wc -l)
1189 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1190 $num_all -ne $((nrfiles + 2)) ]; then
1191 error "Expected $nrfiles files, got $num_ls " \
1192 "($num_uniq unique $num_all .&..)"
1194 # LU-5 large readdir
1195 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1196 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1197 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1198 # take into account of overhead in lu_dirpage header and end mark in
1199 # each page, plus one in rpc_num calculation.
1200 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1201 local page_entries=$((($(page_size) - 24) / dirent_size))
1202 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1203 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1204 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1205 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1206 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1207 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1208 error "large readdir doesn't take effect: " \
1209 "$mds_readpage should be about $rpc_max"
1211 simple_cleanup_common
1213 run_test 24v "list large directory (test hash collision, b=17560)"
1215 test_24w() { # bug21506
1217 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1218 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1219 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1220 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1221 [[ "$SZ1" -eq "$SZ2" ]] ||
1222 error "Error reading at the end of the file $tfile"
1224 run_test 24w "Reading a file larger than 4Gb"
1227 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1228 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1229 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1230 skip "Need MDS version at least 2.7.56"
1233 local remote_dir=$DIR/$tdir/remote_dir
1235 test_mkdir $DIR/$tdir
1236 $LFS mkdir -i $MDTIDX $remote_dir ||
1237 error "create remote directory failed"
1239 test_mkdir $DIR/$tdir/src_dir
1240 touch $DIR/$tdir/src_file
1241 test_mkdir $remote_dir/tgt_dir
1242 touch $remote_dir/tgt_file
1244 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1245 error "rename dir cross MDT failed!"
1247 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1248 error "rename file cross MDT failed!"
1250 touch $DIR/$tdir/ln_file
1251 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1252 error "ln file cross MDT failed"
1254 rm -rf $DIR/$tdir || error "Can not delete directories"
1256 run_test 24x "cross MDT rename/link"
1259 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1260 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1262 local remote_dir=$DIR/$tdir/remote_dir
1265 test_mkdir $DIR/$tdir
1266 $LFS mkdir -i $mdtidx $remote_dir ||
1267 error "create remote directory failed"
1269 test_mkdir $remote_dir/src_dir
1270 touch $remote_dir/src_file
1271 test_mkdir $remote_dir/tgt_dir
1272 touch $remote_dir/tgt_file
1274 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1275 error "rename subdir in the same remote dir failed!"
1277 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1278 error "rename files in the same remote dir failed!"
1280 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1281 error "link files in the same remote dir failed!"
1283 rm -rf $DIR/$tdir || error "Can not delete directories"
1285 run_test 24y "rename/link on the same dir should succeed"
1287 test_24A() { # LU-3182
1291 test_mkdir $DIR/$tdir
1292 trap simple_cleanup_common EXIT
1293 createmany -m $DIR/$tdir/$tfile $NFILES
1294 local t=$(ls $DIR/$tdir | wc -l)
1295 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1296 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1297 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1298 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1301 simple_cleanup_common || error "Can not delete directories"
1303 run_test 24A "readdir() returns correct number of entries."
1305 test_24B() { # LU-4805
1306 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1310 test_mkdir $DIR/$tdir
1311 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1312 error "create striped dir failed"
1314 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1315 [ $count -eq 2 ] || error "Expected 2, got $count"
1317 touch $DIR/$tdir/striped_dir/a
1319 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1320 [ $count -eq 3 ] || error "Expected 3, got $count"
1322 touch $DIR/$tdir/striped_dir/.f
1324 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1325 [ $count -eq 4 ] || error "Expected 4, got $count"
1327 rm -rf $DIR/$tdir || error "Can not delete directories"
1329 run_test 24B "readdir for striped dir return correct number of entries"
1332 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1338 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1339 error "create striped dir failed"
1341 cd $DIR/$tdir/d0/striped_dir
1343 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1344 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1345 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1347 [ "$d0_ino" = "$parent_ino" ] ||
1348 error ".. wrong, expect $d0_ino, get $parent_ino"
1350 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1351 error "mv striped dir failed"
1353 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1355 [ "$d1_ino" = "$parent_ino" ] ||
1356 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1358 run_test 24C "check .. in striped dir"
1361 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1362 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1365 mkdir $DIR/$tdir/src_dir
1366 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1367 error "create remote source failed"
1369 touch $DIR/$tdir/src_dir/src_child/a
1371 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1372 error "create remote target dir failed"
1374 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1375 error "create remote target child failed"
1377 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1378 error "rename dir cross MDT failed!"
1382 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1383 error "src_child still exists after rename"
1385 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1386 error "missing file(a) after rename"
1388 rm -rf $DIR/$tdir || error "Can not delete directories"
1390 run_test 24E "cross MDT rename/link"
1393 echo '== symlink sanity ============================================='
1397 touch $DIR/s25/foo ||
1398 error "File creation in symlinked directory failed"
1400 run_test 25a "create file in symlinked directory ==============="
1403 [ ! -d $DIR/d25 ] && test_25a
1404 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1406 run_test 25b "lookup file in symlinked directory ==============="
1410 test_mkdir $DIR/d26/d26-2
1411 ln -s d26/d26-2 $DIR/s26
1412 touch $DIR/s26/foo || error "File creation failed"
1414 run_test 26a "multiple component symlink ======================="
1417 test_mkdir -p $DIR/$tdir/d26-2
1418 ln -s $tdir/d26-2/foo $DIR/s26-2
1419 touch $DIR/s26-2 || error "File creation failed"
1421 run_test 26b "multiple component symlink at end of lookup ======"
1424 test_mkdir $DIR/d26.2
1425 touch $DIR/d26.2/foo
1426 ln -s d26.2 $DIR/s26.2-1
1427 ln -s s26.2-1 $DIR/s26.2-2
1428 ln -s s26.2-2 $DIR/s26.2-3
1429 chmod 0666 $DIR/s26.2-3/foo
1431 run_test 26c "chain of symlinks"
1433 # recursive symlinks (bug 439)
1435 ln -s d26-3/foo $DIR/d26-3
1437 run_test 26d "create multiple component recursive symlink"
1440 [ ! -h $DIR/d26-3 ] && test_26d
1443 run_test 26e "unlink multiple component recursive symlink"
1445 # recursive symlinks (bug 7022)
1447 test_mkdir $DIR/$tdir
1448 test_mkdir $DIR/$tdir/$tfile
1449 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1450 test_mkdir -p lndir/bar1
1451 test_mkdir $DIR/$tdir/$tfile/$tfile
1452 cd $tfile || error "cd $tfile failed"
1453 ln -s .. dotdot || error "ln dotdot failed"
1454 ln -s dotdot/lndir lndir || error "ln lndir failed"
1455 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1456 output=`ls $tfile/$tfile/lndir/bar1`
1457 [ "$output" = bar1 ] && error "unexpected output"
1458 rm -r $tfile || error "rm $tfile failed"
1459 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1461 run_test 26f "rm -r of a directory which has recursive symlink"
1464 test_mkdir $DIR/$tdir
1465 $LFS getstripe $DIR/$tdir
1466 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1467 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1468 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1470 run_test 27a "one stripe file"
1473 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1475 test_mkdir $DIR/$tdir
1476 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1477 $LFS getstripe -c $DIR/$tdir/$tfile
1478 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1479 error "two-stripe file doesn't have two stripes"
1481 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1483 run_test 27b "create and write to two stripe file"
1486 test_mkdir $DIR/$tdir
1487 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1488 error "setstripe failed"
1489 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1490 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1492 run_test 27d "create file with default settings"
1495 # LU-5839 adds check for existed layout before setting it
1496 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1497 skip "Need MDS version at least 2.7.56"
1499 test_mkdir $DIR/$tdir
1500 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1501 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1502 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1504 run_test 27e "setstripe existing file (should return error)"
1507 test_mkdir $DIR/$tdir
1508 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1509 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1510 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1511 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1512 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1513 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1515 run_test 27f "setstripe with bad stripe size (should return error)"
1518 test_mkdir $DIR/$tdir
1519 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1520 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1521 error "$DIR/$tdir/$tfile has object"
1523 run_test 27g "$LFS getstripe with no objects"
1526 test_mkdir $DIR/$tdir
1527 touch $DIR/$tdir/$tfile || error "touch failed"
1528 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1529 error "missing objects"
1531 run_test 27i "$LFS getstripe with some objects"
1534 test_mkdir $DIR/$tdir
1535 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1536 error "setstripe failed" || true
1538 run_test 27j "setstripe with bad stripe offset (should return error)"
1540 test_27k() { # bug 2844
1541 test_mkdir $DIR/$tdir
1542 local file=$DIR/$tdir/$tfile
1543 local ll_max_blksize=$((4 * 1024 * 1024))
1544 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1545 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1546 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1547 dd if=/dev/zero of=$file bs=4k count=1
1548 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1549 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1551 run_test 27k "limit i_blksize for broken user apps"
1554 mcreate $DIR/$tfile || error "creating file"
1555 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1556 error "setstripe should have failed" || true
1558 run_test 27l "check setstripe permissions (should return error)"
1561 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1563 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1565 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1566 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1568 trap simple_cleanup_common EXIT
1569 test_mkdir $DIR/$tdir
1570 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1571 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1572 error "dd should fill OST0"
1574 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1576 [ $i -gt 256 ] && break
1579 touch $DIR/$tdir/$tfile.$i
1580 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1581 awk '{print $1}'| grep -w "0") ] &&
1582 error "OST0 was full but new created file still use it"
1584 touch $DIR/$tdir/$tfile.$i
1585 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1586 awk '{print $1}'| grep -w "0") ] &&
1587 error "OST0 was full but new created file still use it"
1588 simple_cleanup_common
1590 run_test 27m "create file while OST0 was full"
1593 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1594 awk '{ print $1 * 2; exit; }')
1598 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1599 # if the OST isn't full anymore.
1601 local OSTIDX=${1:-""}
1603 local list=$(comma_list $(osts_nodes))
1604 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1606 do_nodes $list lctl set_param fail_loc=0
1607 sync # initiate all OST_DESTROYs from MDS to OST
1611 exhaust_precreations() {
1614 local FAILIDX=${3:-$OSTIDX}
1615 local ofacet=ost$((OSTIDX + 1))
1617 test_mkdir -p -c1 $DIR/$tdir
1618 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1619 local mfacet=mds$((mdtidx + 1))
1620 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1622 local OST=$(ostname_from_index $OSTIDX)
1625 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1626 local last_id=$(do_facet $mfacet lctl get_param -n \
1627 osc.$mdtosc_proc1.prealloc_last_id)
1628 local next_id=$(do_facet $mfacet lctl get_param -n \
1629 osc.$mdtosc_proc1.prealloc_next_id)
1631 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1632 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1634 test_mkdir -p $DIR/$tdir/${OST}
1635 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1636 #define OBD_FAIL_OST_ENOSPC 0x215
1637 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1638 echo "Creating to objid $last_id on ost $OST..."
1639 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1640 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1641 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1645 exhaust_all_precreations() {
1647 for (( i=0; i < OSTCOUNT; i++ )) ; do
1648 exhaust_precreations $i $1 -1
1653 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1654 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1655 remote_mds_nodsh && skip "remote MDS with nodsh"
1656 remote_ost_nodsh && skip "remote OST with nodsh"
1659 rm -f $DIR/$tdir/$tfile
1660 exhaust_precreations 0 0x80000215
1661 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1662 touch $DIR/$tdir/$tfile || error "touch failed"
1663 $LFS getstripe $DIR/$tdir/$tfile
1666 run_test 27n "create file with some full OSTs"
1669 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1670 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1671 remote_mds_nodsh && skip "remote MDS with nodsh"
1672 remote_ost_nodsh && skip "remote OST with nodsh"
1675 rm -f $DIR/$tdir/$tfile
1676 exhaust_all_precreations 0x215
1678 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1683 run_test 27o "create file with all full OSTs (should error)"
1686 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1687 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1688 remote_mds_nodsh && skip "remote MDS with nodsh"
1689 remote_ost_nodsh && skip "remote OST with nodsh"
1692 rm -f $DIR/$tdir/$tfile
1693 test_mkdir $DIR/$tdir
1695 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1696 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1697 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1699 exhaust_precreations 0 0x80000215
1700 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1701 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1702 $LFS getstripe $DIR/$tdir/$tfile
1706 run_test 27p "append to a truncated file with some full OSTs"
1709 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1710 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1711 remote_mds_nodsh && skip "remote MDS with nodsh"
1712 remote_ost_nodsh && skip "remote OST with nodsh"
1715 rm -f $DIR/$tdir/$tfile
1717 test_mkdir $DIR/$tdir
1718 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1719 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1720 error "truncate $DIR/$tdir/$tfile failed"
1721 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1723 exhaust_all_precreations 0x215
1725 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1726 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1730 run_test 27q "append to truncated file with all OSTs full (should error)"
1733 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1735 remote_mds_nodsh && skip "remote MDS with nodsh"
1736 remote_ost_nodsh && skip "remote OST with nodsh"
1739 rm -f $DIR/$tdir/$tfile
1740 exhaust_precreations 0 0x80000215
1742 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1746 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1748 test_27s() { # bug 10725
1749 test_mkdir $DIR/$tdir
1750 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1751 local stripe_count=0
1752 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1753 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1754 error "stripe width >= 2^32 succeeded" || true
1757 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1759 test_27t() { # bug 10864
1764 $WLFS getstripe $tfile
1767 run_test 27t "check that utils parse path correctly"
1769 test_27u() { # bug 4900
1770 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1771 remote_mds_nodsh && skip "remote MDS with nodsh"
1774 local list=$(comma_list $(mdts_nodes))
1776 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1777 do_nodes $list $LCTL set_param fail_loc=0x139
1778 test_mkdir -p $DIR/$tdir
1779 trap simple_cleanup_common EXIT
1780 createmany -o $DIR/$tdir/t- 1000
1781 do_nodes $list $LCTL set_param fail_loc=0
1783 TLOG=$TMP/$tfile.getstripe
1784 $LFS getstripe $DIR/$tdir > $TLOG
1785 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1786 unlinkmany $DIR/$tdir/t- 1000
1788 [[ $OBJS -gt 0 ]] &&
1789 error "$OBJS objects created on OST-0. See $TLOG" ||
1792 run_test 27u "skip object creation on OSC w/o objects"
1794 test_27v() { # bug 4900
1795 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1796 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1797 remote_mds_nodsh && skip "remote MDS with nodsh"
1798 remote_ost_nodsh && skip "remote OST with nodsh"
1800 exhaust_all_precreations 0x215
1803 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1805 touch $DIR/$tdir/$tfile
1806 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1808 for (( i=1; i < OSTCOUNT; i++ )); do
1809 do_facet ost$i lctl set_param fail_loc=0x705
1811 local START=`date +%s`
1812 createmany -o $DIR/$tdir/$tfile 32
1814 local FINISH=`date +%s`
1815 local TIMEOUT=`lctl get_param -n timeout`
1816 local PROCESS=$((FINISH - START))
1817 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1818 error "$FINISH - $START >= $TIMEOUT / 2"
1819 sleep $((TIMEOUT / 2 - PROCESS))
1822 run_test 27v "skip object creation on slow OST"
1824 test_27w() { # bug 10997
1825 test_mkdir $DIR/$tdir
1826 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1827 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1828 error "stripe size $size != 65536" || true
1829 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1830 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1832 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1835 [[ $OSTCOUNT -lt 2 ]] &&
1836 skip_env "skipping multiple stripe count/offset test"
1838 test_mkdir $DIR/$tdir
1839 for i in $(seq 1 $OSTCOUNT); do
1841 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1842 error "setstripe -c $i -i $offset failed"
1843 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1844 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1845 [ $count -ne $i ] && error "stripe count $count != $i" || true
1846 [ $index -ne $offset ] &&
1847 error "stripe offset $index != $offset" || true
1850 run_test 27wa "check $LFS setstripe -c -i options"
1853 remote_ost_nodsh && skip "remote OST with nodsh"
1854 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1855 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1857 OFFSET=$(($OSTCOUNT - 1))
1859 local OST=$(ostname_from_index $OSTIDX)
1861 test_mkdir $DIR/$tdir
1862 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1863 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1865 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1866 for i in $(seq 0 $OFFSET); do
1867 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1868 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1869 error "OST0 was degraded but new created file still use it"
1871 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1873 run_test 27x "create files while OST0 is degraded"
1876 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1877 remote_mds_nodsh && skip "remote MDS with nodsh"
1878 remote_ost_nodsh && skip "remote OST with nodsh"
1879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1881 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1882 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1883 osc.$mdtosc.prealloc_last_id)
1884 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1885 osc.$mdtosc.prealloc_next_id)
1886 local fcount=$((last_id - next_id))
1887 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1888 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1890 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1891 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1892 local OST_DEACTIVE_IDX=-1
1897 for OSC in $MDS_OSCS; do
1898 OST=$(osc_to_ost $OSC)
1899 OSTIDX=$(index_from_ostuuid $OST)
1900 if [ $OST_DEACTIVE_IDX == -1 ]; then
1901 OST_DEACTIVE_IDX=$OSTIDX
1903 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1904 echo $OSC "is Deactivated:"
1905 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1909 OSTIDX=$(index_from_ostuuid $OST)
1910 test_mkdir $DIR/$tdir
1911 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1913 for OSC in $MDS_OSCS; do
1914 OST=$(osc_to_ost $OSC)
1915 OSTIDX=$(index_from_ostuuid $OST)
1916 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1917 echo $OST "is degraded:"
1918 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1919 obdfilter.$OST.degraded=1
1924 createmany -o $DIR/$tdir/$tfile $fcount
1926 for OSC in $MDS_OSCS; do
1927 OST=$(osc_to_ost $OSC)
1928 OSTIDX=$(index_from_ostuuid $OST)
1929 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1930 echo $OST "is recovered from degraded:"
1931 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1932 obdfilter.$OST.degraded=0
1934 do_facet $SINGLEMDS lctl --device %$OSC activate
1938 # all osp devices get activated, hence -1 stripe count restored
1939 local stripe_count=0
1941 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1942 # devices get activated.
1944 $LFS setstripe -c -1 $DIR/$tfile
1945 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1947 [ $stripe_count -ne $OSTCOUNT ] &&
1948 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1951 run_test 27y "create files while OST0 is degraded and the rest inactive"
1957 lmm_count=$($GETSTRIPE -c $1)
1958 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1959 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1961 local old_ifs="$IFS"
1963 fid=($($LFS path2fid $1))
1966 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1967 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1969 # compare lmm_seq and lu_fid->f_seq
1970 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1971 # compare lmm_object_id and lu_fid->oid
1972 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1974 # check the trusted.fid attribute of the OST objects of the file
1975 local have_obdidx=false
1977 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1978 # skip lines up to and including "obdidx"
1979 [ -z "$obdidx" ] && break
1980 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1981 $have_obdidx || continue
1983 local ost=$((obdidx + 1))
1984 local dev=$(ostdevname $ost)
1987 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1989 seq=$(echo $seq | sed -e "s/^0x//g")
1990 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1991 oid_hex=$(echo $oid)
1993 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1995 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1999 # Don't unmount/remount the OSTs if we don't need to do that.
2000 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2001 # update too, until that use mount/ll_decode_filter_fid/mount.
2002 # Re-enable when debugfs will understand new filter_fid.
2004 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2005 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2006 $dev 2>/dev/null" | grep "parent=")
2008 if [ -z "$ff" ]; then
2010 mount_fstype ost$ost
2011 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2012 $(facet_mntpt ost$ost)/$obj_file)
2013 unmount_fstype ost$ost
2014 start ost$ost $dev $OST_MOUNT_OPTS
2018 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2020 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2022 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2023 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2025 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2026 # stripe_size=1048576 component_id=1 component_start=0 \
2027 # component_end=33554432
2028 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2029 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2030 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2032 if grep -q 'stripe=' <<<$ff; then
2033 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2035 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2036 # into f_ver in this case. See comment on ff_parent.
2037 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2040 # compare lmm_seq and filter_fid->ff_parent.f_seq
2041 [ $ff_pseq = $lmm_seq ] ||
2042 error "FF parent SEQ $ff_pseq != $lmm_seq"
2043 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2044 [ $ff_poid = $lmm_oid ] ||
2045 error "FF parent OID $ff_poid != $lmm_oid"
2046 (($ff_pstripe == $stripe_nr)) ||
2047 error "FF stripe $ff_pstripe != $stripe_nr"
2049 stripe_nr=$((stripe_nr + 1))
2050 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2052 if grep -q 'stripe_count=' <<<$ff; then
2053 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2054 -e 's/ .*//' <<<$ff)
2055 [ $lmm_count = $ff_scnt ] ||
2056 error "FF stripe count $lmm_count != $ff_scnt"
2062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2063 remote_ost_nodsh && skip "remote OST with nodsh"
2065 test_mkdir $DIR/$tdir
2066 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2067 { error "setstripe -c -1 failed"; return 1; }
2068 # We need to send a write to every object to get parent FID info set.
2069 # This _should_ also work for setattr, but does not currently.
2070 # touch $DIR/$tdir/$tfile-1 ||
2071 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2072 { error "dd $tfile-1 failed"; return 2; }
2073 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2074 { error "setstripe -c -1 failed"; return 3; }
2075 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2076 { error "dd $tfile-2 failed"; return 4; }
2078 # make sure write RPCs have been sent to OSTs
2081 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2082 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2084 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2086 test_27A() { # b=19102
2087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2089 save_layout_restore_at_exit $MOUNT
2090 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2091 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2092 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2093 local default_size=$($GETSTRIPE -S $MOUNT)
2094 local default_offset=$($GETSTRIPE -i $MOUNT)
2095 local dsize=$(do_facet $SINGLEMDS \
2096 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2097 [ $default_size -eq $dsize ] ||
2098 error "stripe size $default_size != $dsize"
2099 [ $default_offset -eq -1 ] ||
2100 error "stripe offset $default_offset != -1"
2102 run_test 27A "check filesystem-wide default LOV EA values"
2104 test_27B() { # LU-2523
2105 test_mkdir $DIR/$tdir
2106 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2108 # open f1 with O_LOV_DELAY_CREATE
2110 # call setstripe ioctl on open file descriptor for f1
2112 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2116 # open f1 with O_LOV_DELAY_CREATE
2118 # call setstripe ioctl on open file descriptor for f1
2120 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2122 # Allow multiop to fail in imitation of NFS's busted semantics.
2125 run_test 27B "call setstripe on open unlinked file/rename victim"
2127 test_27C() { #LU-2871
2128 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2136 test_mkdir $DIR/$tdir
2138 for i in $(seq 0 $((OSTCOUNT - 1))); do
2139 # set stripe across all OSTs starting from OST$i
2140 $SETSTRIPE -i $i -c -1 $tfile$i
2141 # get striping information
2142 ost_idx=($($GETSTRIPE $tfile$i |
2143 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2147 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2148 error "${#ost_idx[@]} != $OSTCOUNT"
2150 for index in $(seq 0 $((OSTCOUNT - 1))); do
2152 for j in $(echo ${ost_idx[@]}); do
2153 if [ $index -eq $j ]; then
2159 error "Can not find $index in ${ost_idx[@]}"
2163 run_test 27C "check full striping across all OSTs"
2166 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2167 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2168 remote_mds_nodsh && skip "remote MDS with nodsh"
2170 local POOL=${POOL:-testpool}
2172 local last_ost=$(($OSTCOUNT - 1))
2174 local ost_list=$(seq $first_ost $ost_step $last_ost)
2175 local ost_range="$first_ost $last_ost $ost_step"
2177 if ! combined_mgs_mds ; then
2181 test_mkdir $DIR/$tdir
2182 pool_add $POOL || error "pool_add failed"
2183 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2186 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2188 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2189 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2190 skip27D+=" -s 30,31"
2191 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2192 error "llapi_layout_test failed"
2194 destroy_test_pools || error "destroy test pools failed"
2196 if ! combined_mgs_mds ; then
2200 run_test 27D "validate llapi_layout API"
2202 # Verify that default_easize is increased from its initial value after
2203 # accessing a widely striped file.
2205 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2206 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2207 skip "client does not have LU-3338 fix"
2209 # 72 bytes is the minimum space required to store striping
2210 # information for a file striped across one OST:
2211 # (sizeof(struct lov_user_md_v3) +
2212 # sizeof(struct lov_user_ost_data_v1))
2214 $LCTL set_param -n llite.*.default_easize $min_easize ||
2215 error "lctl set_param failed"
2216 local easize=$($LCTL get_param -n llite.*.default_easize)
2218 [ $easize -eq $min_easize ] ||
2219 error "failed to set default_easize"
2221 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2222 error "setstripe failed"
2226 easize=$($LCTL get_param -n llite.*.default_easize)
2228 [ $easize -gt $min_easize ] ||
2229 error "default_easize not updated"
2231 run_test 27E "check that default extended attribute size properly increases"
2233 test_27F() { # LU-5346/LU-7975
2234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2235 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2236 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2237 skip "Need MDS version at least 2.8.51"
2238 remote_ost_nodsh && skip "remote OST with nodsh"
2240 test_mkdir $DIR/$tdir
2242 $SETSTRIPE -c 2 $DIR/$tdir
2244 # stop all OSTs to reproduce situation for LU-7975 ticket
2245 for num in $(seq $OSTCOUNT); do
2249 # open/create f0 with O_LOV_DELAY_CREATE
2250 # truncate f0 to a non-0 size
2252 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2254 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2255 # open/write it again to force delayed layout creation
2256 cat /etc/hosts > $DIR/$tdir/f0 &
2260 for num in $(seq $OSTCOUNT); do
2261 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2262 error "ost$num failed to start"
2265 wait $catpid || error "cat failed"
2267 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2268 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2271 run_test 27F "Client resend delayed layout creation with non-zero size"
2273 test_27G() { #LU-10629
2274 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2275 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2276 local POOL=${POOL:-testpool}
2277 local ostrange="0 0 1"
2279 test_mkdir $DIR/$tdir
2280 pool_add $POOL || error "pool_add failed"
2281 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2282 $LFS setstripe -p $POOL $DIR/$tdir
2284 local pool=$($LFS getstripe -p $DIR/$tdir)
2286 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2288 $LFS setstripe -d $DIR/$tdir
2290 pool=$($LFS getstripe -p $DIR/$tdir)
2294 [ -z "$pool" ] || error "'$pool' is not empty"
2296 run_test 27G "Clear OST pool from stripe"
2298 # createtest also checks that device nodes are created and
2299 # then visible correctly (#2091)
2300 test_28() { # bug 2091
2302 $CREATETEST $DIR/d28/ct || error "createtest failed"
2304 run_test 28 "create/mknod/mkdir with bad file types ============"
2307 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2309 sync; sleep 1; sync # flush out any dirty pages from previous tests
2316 declare -i LOCKCOUNTORIG=0
2317 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2318 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2320 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2322 declare -i LOCKUNUSEDCOUNTORIG=0
2323 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2324 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2331 declare -i LOCKCOUNTCURRENT=0
2332 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2333 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2336 declare -i LOCKUNUSEDCOUNTCURRENT=0
2337 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2338 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2341 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2342 $LCTL set_param -n ldlm.dump_namespaces ""
2343 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2344 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2345 log "dumped log to $TMP/test_29.dk (bug 5793)"
2348 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2349 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2350 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2351 log "dumped log to $TMP/test_29.dk (bug 5793)"
2355 run_test 29 "IT_GETATTR regression ============================"
2357 test_30a() { # was test_30
2358 cp $(which ls) $DIR || cp /bin/ls $DIR
2359 $DIR/ls / || error "Can't execute binary from lustre"
2362 run_test 30a "execute binary from Lustre (execve) =============="
2365 cp `which ls` $DIR || cp /bin/ls $DIR
2367 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2370 run_test 30b "execute binary from Lustre as non-root ==========="
2372 test_30c() { # b=22376
2373 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2375 cp `which ls` $DIR || cp /bin/ls $DIR
2377 cancel_lru_locks mdc
2378 cancel_lru_locks osc
2379 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2382 run_test 30c "execute binary from Lustre without read perms ===="
2385 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2386 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2388 run_test 31a "open-unlink file =================================="
2391 touch $DIR/f31 || error "touch $DIR/f31 failed"
2392 ln $DIR/f31 $DIR/f31b || error "ln failed"
2393 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2394 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2396 run_test 31b "unlink file with multiple links while open ======="
2399 touch $DIR/f31 || error "touch $DIR/f31 failed"
2400 ln $DIR/f31 $DIR/f31c || error "ln failed"
2401 multiop_bg_pause $DIR/f31 O_uc ||
2402 error "multiop_bg_pause for $DIR/f31 failed"
2404 $MULTIOP $DIR/f31c Ouc
2405 kill -USR1 $MULTIPID
2408 run_test 31c "open-unlink file with multiple links ============="
2411 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2412 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2414 run_test 31d "remove of open directory ========================="
2416 test_31e() { # bug 2904
2417 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2419 run_test 31e "remove of open non-empty directory ==============="
2421 test_31f() { # bug 4554
2422 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2425 test_mkdir $DIR/d31f
2426 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2427 cp /etc/hosts $DIR/d31f
2429 $GETSTRIPE $DIR/d31f/hosts
2430 multiop_bg_pause $DIR/d31f D_c || return 1
2433 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2434 test_mkdir $DIR/d31f
2435 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2436 cp /etc/hosts $DIR/d31f
2438 $GETSTRIPE $DIR/d31f/hosts
2439 multiop_bg_pause $DIR/d31f D_c || return 1
2442 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2443 wait $MULTIPID || error "first opendir $MULTIPID failed"
2447 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2448 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2451 run_test 31f "remove of open directory with open-unlink file ==="
2454 echo "-- cross directory link --"
2455 test_mkdir -c1 $DIR/${tdir}ga
2456 test_mkdir -c1 $DIR/${tdir}gb
2457 touch $DIR/${tdir}ga/f
2458 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2459 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2460 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2461 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2462 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2464 run_test 31g "cross directory link==============="
2467 echo "-- cross directory link --"
2468 test_mkdir -c1 $DIR/${tdir}
2469 test_mkdir -c1 $DIR/${tdir}/dir
2470 touch $DIR/${tdir}/f
2471 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2472 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2473 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2474 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2475 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2477 run_test 31h "cross directory link under child==============="
2480 echo "-- cross directory link --"
2481 test_mkdir -c1 $DIR/$tdir
2482 test_mkdir -c1 $DIR/$tdir/dir
2483 touch $DIR/$tdir/dir/f
2484 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2485 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2486 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2487 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2488 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2490 run_test 31i "cross directory link under parent==============="
2493 test_mkdir -c1 -p $DIR/$tdir
2494 test_mkdir -c1 -p $DIR/$tdir/dir1
2495 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2496 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2497 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2498 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2501 run_test 31j "link for directory==============="
2504 test_mkdir -c1 -p $DIR/$tdir
2506 touch $DIR/$tdir/exist
2507 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2508 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2509 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2510 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2511 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2512 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2513 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2516 run_test 31k "link to file: the same, non-existing, dir==============="
2522 touch $DIR/d31m2/exist
2523 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2524 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2525 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2526 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2527 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2528 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2531 run_test 31m "link to file: the same, non-existing, dir==============="
2534 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2535 nlink=$(stat --format=%h $DIR/$tfile)
2536 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2538 local cmd="exec $fd<$DIR/$tfile"
2541 trap "eval $cmd" EXIT
2542 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2543 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2544 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2545 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2546 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2549 run_test 31n "check link count of unlinked file"
2552 local TEMPNAME=$(mktemp $1_XXXXXX)
2553 mlink $TEMPNAME $1 2> /dev/null &&
2554 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2558 test_31o() { # LU-2901
2559 test_mkdir $DIR/$tdir
2560 for LOOP in $(seq 100); do
2561 rm -f $DIR/$tdir/$tfile*
2562 for THREAD in $(seq 8); do
2563 link_one $DIR/$tdir/$tfile.$LOOP &
2566 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2567 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2568 error "$LINKS duplicate links to $tfile.$LOOP" &&
2572 run_test 31o "duplicate hard links with same filename"
2575 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2577 test_mkdir $DIR/$tdir
2578 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2579 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2581 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2582 error "open unlink test1 failed"
2583 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2584 error "open unlink test2 failed"
2586 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2587 error "test1 still exists"
2588 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2589 error "test2 still exists"
2591 run_test 31p "remove of open striped directory"
2593 cleanup_test32_mount() {
2596 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2597 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2598 losetup -d $loopdev || true
2604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2606 echo "== more mountpoints and symlinks ================="
2607 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2608 trap cleanup_test32_mount EXIT
2609 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2610 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2611 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2612 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2613 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2614 cleanup_test32_mount
2616 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2619 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2621 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2622 trap cleanup_test32_mount EXIT
2623 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2624 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2625 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2626 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2627 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2628 cleanup_test32_mount
2630 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2635 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2636 trap cleanup_test32_mount EXIT
2637 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2638 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2639 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2640 test_mkdir -p $DIR/$tdir/d2/test_dir
2641 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2642 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2643 cleanup_test32_mount
2645 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2648 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2650 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2651 trap cleanup_test32_mount EXIT
2652 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2653 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2654 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2655 test_mkdir -p $DIR/$tdir/d2/test_dir
2656 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2657 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2658 cleanup_test32_mount
2660 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2664 test_mkdir -p $DIR/$tdir/tmp
2665 local tmp_dir=$DIR/$tdir/tmp
2666 ln -s $DIR/$tdir $tmp_dir/symlink11
2667 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2668 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2669 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2671 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2675 test_mkdir -p $DIR/$tdir/tmp
2676 local tmp_dir=$DIR/$tdir/tmp
2677 ln -s $DIR/$tdir $tmp_dir/symlink11
2678 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2679 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2680 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2682 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2685 local tmp_dir=$DIR/$tdir/tmp
2686 test_mkdir -p $tmp_dir
2687 test_mkdir $DIR/${tdir}2
2688 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2689 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2690 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2691 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2692 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2693 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2695 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2698 rm -fr $DIR/$tdir $DIR/${tdir}2
2699 tmp_dir=$DIR/$tdir/tmp
2700 test_mkdir -p $tmp_dir
2701 test_mkdir $DIR/${tdir}2
2702 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2703 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2704 ls $tmp_dir/symlink12 || error "listing symlink12"
2705 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2707 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2710 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2712 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2713 trap cleanup_test32_mount EXIT
2714 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2715 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2716 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2717 touch $DIR/$tdir/test_file
2718 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2719 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2720 cleanup_test32_mount
2722 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2727 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2728 trap cleanup_test32_mount EXIT
2729 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2730 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2731 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2732 touch $DIR/$tdir/test_file
2733 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2734 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2735 cleanup_test32_mount
2737 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2740 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2743 trap cleanup_test32_mount EXIT
2744 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2745 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2746 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2747 test_mkdir -p $DIR/$tdir/d2
2748 touch $DIR/$tdir/d2/test_file || error "touch failed"
2749 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2750 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
2751 cleanup_test32_mount
2753 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2756 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2759 trap cleanup_test32_mount EXIT
2760 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2761 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2762 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2763 test_mkdir -p $DIR/$tdir/d2
2764 touch $DIR/$tdir/d2/test_file || error "touch failed"
2765 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2766 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
2767 cleanup_test32_mount
2769 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2773 test_mkdir -p $DIR/d32m/tmp
2774 TMP_DIR=$DIR/d32m/tmp
2775 ln -s $DIR $TMP_DIR/symlink11
2776 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2777 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
2778 error "symlink11 not a link"
2779 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
2780 error "symlink01 not a link"
2782 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2786 test_mkdir -p $DIR/d32n/tmp
2787 TMP_DIR=$DIR/d32n/tmp
2788 ln -s $DIR $TMP_DIR/symlink11
2789 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2790 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
2791 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
2793 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2797 test_mkdir -p $DIR/d32o/tmp
2798 TMP_DIR=$DIR/d32o/tmp
2799 ln -s $DIR/$tfile $TMP_DIR/symlink12
2800 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2801 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
2802 error "symlink12 not a link"
2803 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
2804 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
2805 error "$DIR/d32o/tmp/symlink12 not file type"
2806 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
2807 error "$DIR/d32o/symlink02 not file type"
2809 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2819 test_mkdir -p $DIR/d32p/tmp
2821 TMP_DIR=$DIR/d32p/tmp
2823 ln -s $DIR/$tfile $TMP_DIR/symlink12
2825 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2827 cat $DIR/d32p/tmp/symlink12 ||
2828 error "Can't open $DIR/d32p/tmp/symlink12"
2830 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
2833 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2836 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2838 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2839 trap cleanup_test32_mount EXIT
2840 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2841 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2842 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2843 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2844 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2845 cleanup_test32_mount
2847 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2850 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2852 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2853 trap cleanup_test32_mount EXIT
2854 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2855 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2856 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2857 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2858 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2859 cleanup_test32_mount
2861 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2866 chmod 444 $DIR/$tfile
2867 chown $RUNAS_ID $DIR/$tfile
2869 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2872 run_test 33aa "write file with mode 444 (should return error)"
2876 test_mkdir $DIR/$tdir
2877 chown $RUNAS_ID $DIR/$tdir
2878 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2879 error "$RUNAS create $tdir/$tfile failed"
2880 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2881 error "open RDWR" || true
2883 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2887 test_mkdir $DIR/$tdir
2888 chown $RUNAS_ID $DIR/$tdir
2889 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2891 run_test 33b "test open file with malformed flags (No panic)"
2894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2895 remote_ost_nodsh && skip "remote OST with nodsh"
2904 test_mkdir $DIR/$tdir
2905 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2908 for ostnum in $(seq $OSTCOUNT); do
2909 # test-framework's OST numbering is one-based, while Lustre's
2911 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2912 # Parsing llobdstat's output sucks; we could grep the /proc
2913 # path, but that's likely to not be as portable as using the
2914 # llobdstat utility. So we parse lctl output instead.
2915 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2916 obdfilter/$ostname/stats |
2917 awk '/^write_bytes/ {print $7}' )
2918 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2919 if (( ${write_bytes:-0} > 0 ))
2926 $all_zeros || return 0
2929 echo foo > $DIR/$tdir/bar
2933 # Total up write_bytes after writing. We'd better find non-zeros.
2934 for ostnum in $(seq $OSTCOUNT); do
2935 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2936 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2937 obdfilter/$ostname/stats |
2938 awk '/^write_bytes/ {print $7}' )
2939 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2940 if (( ${write_bytes:-0} > 0 ))
2949 for ostnum in $(seq $OSTCOUNT); do
2950 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2951 echo "Check that write_bytes is present in obdfilter/*/stats:"
2952 do_facet ost$ostnum lctl get_param -n \
2953 obdfilter/$ostname/stats
2955 error "OST not keeping write_bytes stats (b22312)"
2958 run_test 33c "test llobdstat and write_bytes"
2961 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
2962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2965 local remote_dir=$DIR/$tdir/remote_dir
2967 test_mkdir $DIR/$tdir
2968 $LFS mkdir -i $MDTIDX $remote_dir ||
2969 error "create remote directory failed"
2971 touch $remote_dir/$tfile
2972 chmod 444 $remote_dir/$tfile
2973 chown $RUNAS_ID $remote_dir/$tfile
2975 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2977 chown $RUNAS_ID $remote_dir
2978 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2979 error "create" || true
2980 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2981 error "open RDWR" || true
2982 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
2984 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2987 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2991 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2992 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2993 mkdir $DIR/$tdir/local_dir
2995 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2996 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2997 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2999 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3000 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3002 rmdir $DIR/$tdir/* || error "rmdir failed"
3005 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3006 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3007 mkdir $DIR/$tdir/local_dir
3009 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3010 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3011 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3013 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3014 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3016 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3019 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3020 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3021 mkdir $DIR/$tdir/local_dir
3023 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3024 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3025 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3027 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3028 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3030 run_test 33e "mkdir and striped directory should have same mode"
3034 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3038 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3039 remote_mds_nodsh && skip "remote MDS with nodsh"
3042 chmod go+rwx $DIR/$tdir
3043 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3044 trap cleanup_33f EXIT
3046 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3047 error "cannot create striped directory"
3049 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3050 error "cannot create files in striped directory"
3052 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3053 error "cannot remove files in striped directory"
3055 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3056 error "cannot remove striped directory"
3060 run_test 33f "nonroot user can create, access, and remove a striped directory"
3063 mkdir -p $DIR/$tdir/dir2
3065 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3067 [[ $err =~ "exists" ]] || error "Not exists error"
3069 run_test 33g "nonroot user create already existing root created file"
3071 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3074 $MCREATE $DIR/f34 || error "mcreate failed"
3075 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3076 error "getstripe failed"
3077 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3078 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3079 error "getstripe failed"
3080 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3081 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3083 run_test 34a "truncate file that has not been opened ==========="
3086 [ ! -f $DIR/f34 ] && test_34a
3087 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3088 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3089 $OPENFILE -f O_RDONLY $DIR/f34
3090 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3091 error "getstripe failed"
3092 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3093 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3095 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3098 [ ! -f $DIR/f34 ] && test_34a
3099 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3100 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3101 $OPENFILE -f O_RDWR $DIR/f34
3102 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3103 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3104 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3106 run_test 34c "O_RDWR opening file-with-size works =============="
3109 [ ! -f $DIR/f34 ] && test_34a
3110 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3112 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3113 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3116 run_test 34d "write to sparse file ============================="
3120 $MCREATE $DIR/f34e || error "mcreate failed"
3121 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3122 $CHECKSTAT -s 1000 $DIR/f34e ||
3123 error "Size of $DIR/f34e not equal to 1000 bytes"
3124 $OPENFILE -f O_RDWR $DIR/f34e
3125 $CHECKSTAT -s 1000 $DIR/f34e ||
3126 error "Size of $DIR/f34e not equal to 1000 bytes"
3128 run_test 34e "create objects, some with size and some without =="
3130 test_34f() { # bug 6242, 6243
3131 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3135 $MCREATE $DIR/f34f || error "mcreate failed"
3136 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3137 dd if=$DIR/f34f of=$TMP/f34f
3138 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3139 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3140 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3141 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3142 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3144 run_test 34f "read from a file with no objects until EOF ======="
3147 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3149 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3151 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3152 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3153 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3154 cancel_lru_locks osc
3155 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3156 error "wrong size after lock cancel"
3158 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3159 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3160 error "expanding truncate failed"
3161 cancel_lru_locks osc
3162 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3163 error "wrong expanded size after lock cancel"
3165 run_test 34g "truncate long file ==============================="
3168 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3173 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3174 sync # Flush the cache so that multiop below does not block on cache
3175 # flush when getting the group lock
3176 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3179 # Since just timed wait is not good enough, let's do a sync write
3180 # that way we are sure enough time for a roundtrip + processing
3181 # passed + 2 seconds of extra margin.
3182 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
3186 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3187 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3191 local nsz=`stat -c %s $DIR/$tfile`
3192 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3194 run_test 34h "ftruncate file under grouplock should not block"
3197 cp /bin/sh $DIR/f35a
3199 chown $RUNAS_ID $DIR/f35a
3200 $RUNAS $DIR/f35a && error || true
3203 run_test 35a "exec file with mode 444 (should return and not leak)"
3207 utime $DIR/f36 || error "utime failed for MDS"
3209 run_test 36a "MDS utime check (mknod, utime)"
3213 utime $DIR/f36 || error "utime failed for OST"
3215 run_test 36b "OST utime check (open, utime)"
3220 chown $RUNAS_ID $DIR/d36
3221 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3223 run_test 36c "non-root MDS utime check (mknod, utime)"
3226 [ ! -d $DIR/d36 ] && test_36c
3227 echo "" > $DIR/d36/f36
3228 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3230 run_test 36d "non-root OST utime check (open, utime)"
3233 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3235 test_mkdir $DIR/$tdir
3236 touch $DIR/$tdir/$tfile
3237 $RUNAS utime $DIR/$tdir/$tfile &&
3238 error "utime worked, expected failure" || true
3240 run_test 36e "utime on non-owned file (should return error)"
3244 local LANG_SAVE=$LANG
3245 local LC_LANG_SAVE=$LC_LANG
3246 export LANG=C LC_LANG=C # for date language
3248 DATESTR="Dec 20 2000"
3249 test_mkdir $DIR/$tdir
3250 lctl set_param fail_loc=$fl
3252 cp /etc/hosts $DIR/$tdir/$tfile
3253 sync & # write RPC generated with "current" inode timestamp, but delayed
3255 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3256 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3257 cancel_lru_locks osc
3258 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3260 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3261 echo "BEFORE: $LS_BEFORE" && \
3262 echo "AFTER : $LS_AFTER" && \
3263 echo "WANT : $DATESTR" && \
3264 error "$DIR/$tdir/$tfile timestamps changed" || true
3266 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3270 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3272 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3273 subr_36fh "0x80000214"
3275 run_test 36f "utime on file racing with OST BRW write =========="
3278 remote_ost_nodsh && skip "remote OST with nodsh"
3279 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3285 test_mkdir $DIR/$tdir
3286 fmd_max_age=$(do_facet ost1 \
3287 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3290 fmd_before=$(do_facet ost1 \
3291 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3292 touch $DIR/$tdir/$tfile
3293 sleep $((fmd_max_age + 12))
3294 fmd_after=$(do_facet ost1 \
3295 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3297 echo "fmd_before: $fmd_before"
3298 echo "fmd_after: $fmd_after"
3299 [[ $fmd_after -gt $fmd_before ]] &&
3300 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3301 error "fmd didn't expire after ping" || true
3303 run_test 36g "filter mod data cache expiry ====================="
3306 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3308 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3309 subr_36fh "0x80000227"
3311 run_test 36h "utime on file racing with OST BRW write =========="
3314 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3316 test_mkdir $DIR/$tdir
3317 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3319 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3320 local new_mtime=$((mtime + 200))
3322 #change Modify time of striped dir
3323 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3324 error "change mtime failed"
3326 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3328 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3330 run_test 36i "change mtime on striped directory"
3332 # test_37 - duplicate with tests 32q 32r
3335 local file=$DIR/$tfile
3337 openfile -f O_DIRECTORY $file
3340 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3341 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3343 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3345 test_39a() { # was test_39
3347 touch $DIR/${tfile}2
3348 # ls -l $DIR/$tfile $DIR/${tfile}2
3349 # ls -lu $DIR/$tfile $DIR/${tfile}2
3350 # ls -lc $DIR/$tfile $DIR/${tfile}2
3352 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3353 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3355 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3357 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3359 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3360 error "O_TRUNC didn't change timestamps"
3363 run_test 39a "mtime changed on create"
3366 test_mkdir -c1 $DIR/$tdir
3367 cp -p /etc/passwd $DIR/$tdir/fopen
3368 cp -p /etc/passwd $DIR/$tdir/flink
3369 cp -p /etc/passwd $DIR/$tdir/funlink
3370 cp -p /etc/passwd $DIR/$tdir/frename
3371 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3374 echo "aaaaaa" >> $DIR/$tdir/fopen
3375 echo "aaaaaa" >> $DIR/$tdir/flink
3376 echo "aaaaaa" >> $DIR/$tdir/funlink
3377 echo "aaaaaa" >> $DIR/$tdir/frename
3379 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3380 local link_new=`stat -c %Y $DIR/$tdir/flink`
3381 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3382 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3384 cat $DIR/$tdir/fopen > /dev/null
3385 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3386 rm -f $DIR/$tdir/funlink2
3387 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3389 for (( i=0; i < 2; i++ )) ; do
3390 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3391 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3392 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3393 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3395 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3396 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3397 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3398 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3400 cancel_lru_locks osc
3401 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3404 run_test 39b "mtime change on open, link, unlink, rename ======"
3406 # this should be set to past
3407 TEST_39_MTIME=`date -d "1 year ago" +%s`
3413 local mtime0=`stat -c %Y $DIR1/$tfile`
3415 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3416 local mtime1=`stat -c %Y $DIR1/$tfile`
3417 [ "$mtime1" = $TEST_39_MTIME ] || \
3418 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3421 echo hello >> $DIR1/$tfile
3423 local mtime2=`stat -c %Y $DIR1/$tfile`
3424 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3425 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3427 mv $DIR1/$tfile $DIR1/$tfile-1
3429 for (( i=0; i < 2; i++ )) ; do
3430 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3431 [ "$mtime2" = "$mtime3" ] || \
3432 error "mtime ($mtime2) changed (to $mtime3) on rename"
3434 cancel_lru_locks osc
3435 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3438 run_test 39c "mtime change on rename ==========================="
3442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3445 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3447 for (( i=0; i < 2; i++ )) ; do
3448 local mtime=`stat -c %Y $DIR1/$tfile`
3449 [ $mtime = $TEST_39_MTIME ] || \
3450 error "mtime($mtime) is not set to $TEST_39_MTIME"
3452 cancel_lru_locks osc
3453 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3456 run_test 39d "create, utime, stat =============================="
3460 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3463 local mtime1=`stat -c %Y $DIR1/$tfile`
3465 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3467 for (( i=0; i < 2; i++ )) ; do
3468 local mtime2=`stat -c %Y $DIR1/$tfile`
3469 [ $mtime2 = $TEST_39_MTIME ] || \
3470 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3472 cancel_lru_locks osc
3473 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3476 run_test 39e "create, stat, utime, stat ========================"
3480 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3483 mtime1=`stat -c %Y $DIR1/$tfile`
3486 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3488 for (( i=0; i < 2; i++ )) ; do
3489 local mtime2=`stat -c %Y $DIR1/$tfile`
3490 [ $mtime2 = $TEST_39_MTIME ] || \
3491 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3493 cancel_lru_locks osc
3494 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3497 run_test 39f "create, stat, sleep, utime, stat ================="
3501 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3503 echo hello >> $DIR1/$tfile
3504 local mtime1=`stat -c %Y $DIR1/$tfile`
3507 chmod o+r $DIR1/$tfile
3509 for (( i=0; i < 2; i++ )) ; do
3510 local mtime2=`stat -c %Y $DIR1/$tfile`
3511 [ "$mtime1" = "$mtime2" ] || \
3512 error "lost mtime: $mtime2, should be $mtime1"
3514 cancel_lru_locks osc
3515 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3518 run_test 39g "write, chmod, stat ==============================="
3522 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3528 echo hello >> $DIR1/$tfile
3529 local mtime1=`stat -c %Y $DIR1/$tfile`
3531 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3533 if [ "$d1" != "$d2" ]; then
3534 echo "write and touch not within one second"
3536 for (( i=0; i < 2; i++ )) ; do
3537 local mtime2=`stat -c %Y $DIR1/$tfile`
3538 [ "$mtime2" = $TEST_39_MTIME ] || \
3539 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3541 cancel_lru_locks osc
3542 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3546 run_test 39h "write, utime within one second, stat ============="
3549 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3554 echo hello >> $DIR1/$tfile
3555 local mtime1=`stat -c %Y $DIR1/$tfile`
3557 mv $DIR1/$tfile $DIR1/$tfile-1
3559 for (( i=0; i < 2; i++ )) ; do
3560 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3562 [ "$mtime1" = "$mtime2" ] || \
3563 error "lost mtime: $mtime2, should be $mtime1"
3565 cancel_lru_locks osc
3566 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3569 run_test 39i "write, rename, stat =============================="
3572 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3574 start_full_debug_logging
3578 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3579 lctl set_param fail_loc=0x80000412
3580 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3581 error "multiop failed"
3583 local mtime1=`stat -c %Y $DIR1/$tfile`
3585 mv $DIR1/$tfile $DIR1/$tfile-1
3587 kill -USR1 $multipid
3588 wait $multipid || error "multiop close failed"
3590 for (( i=0; i < 2; i++ )) ; do
3591 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3592 [ "$mtime1" = "$mtime2" ] ||
3593 error "mtime is lost on close: $mtime2, " \
3596 cancel_lru_locks osc
3597 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3599 lctl set_param fail_loc=0
3600 stop_full_debug_logging
3602 run_test 39j "write, rename, close, stat ======================="
3605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3610 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3612 local mtime1=`stat -c %Y $DIR1/$tfile`
3614 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3616 kill -USR1 $multipid
3617 wait $multipid || error "multiop close failed"
3619 for (( i=0; i < 2; i++ )) ; do
3620 local mtime2=`stat -c %Y $DIR1/$tfile`
3622 [ "$mtime2" = $TEST_39_MTIME ] || \
3623 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3625 cancel_lru_locks osc
3626 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3629 run_test 39k "write, utime, close, stat ========================"
3631 # this should be set to future
3632 TEST_39_ATIME=`date -d "1 year" +%s`
3635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3636 remote_mds_nodsh && skip "remote MDS with nodsh"
3638 local atime_diff=$(do_facet $SINGLEMDS \
3639 lctl get_param -n mdd.*MDT0000*.atime_diff)
3643 # test setting directory atime to future
3644 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3645 local atime=$(stat -c %X $DIR/$tdir)
3646 [ "$atime" = $TEST_39_ATIME ] ||
3647 error "atime is not set to future: $atime, $TEST_39_ATIME"
3649 # test setting directory atime from future to now
3650 local now=$(date +%s)
3651 touch -a -d @$now $DIR/$tdir
3653 atime=$(stat -c %X $DIR/$tdir)
3654 [ "$atime" -eq "$now" ] ||
3655 error "atime is not updated from future: $atime, $now"
3657 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3660 # test setting directory atime when now > dir atime + atime_diff
3661 local d1=$(date +%s)
3663 local d2=$(date +%s)
3664 cancel_lru_locks mdc
3665 atime=$(stat -c %X $DIR/$tdir)
3666 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3667 error "atime is not updated : $atime, should be $d2"
3669 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3672 # test not setting directory atime when now < dir atime + atime_diff
3674 cancel_lru_locks mdc
3675 atime=$(stat -c %X $DIR/$tdir)
3676 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3677 error "atime is updated to $atime, should remain $d1<atime<$d2"
3679 do_facet $SINGLEMDS \
3680 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3682 run_test 39l "directory atime update ==========================="
3685 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3689 local far_past_mtime=$(date -d "May 29 1953" +%s)
3690 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3692 touch -m -d @$far_past_mtime $DIR1/$tfile
3693 touch -a -d @$far_past_atime $DIR1/$tfile
3695 for (( i=0; i < 2; i++ )) ; do
3696 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3697 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3698 error "atime or mtime set incorrectly"
3700 cancel_lru_locks osc
3701 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3704 run_test 39m "test atime and mtime before 1970"
3706 test_39n() { # LU-3832
3707 remote_mds_nodsh && skip "remote MDS with nodsh"
3709 local atime_diff=$(do_facet $SINGLEMDS \
3710 lctl get_param -n mdd.*MDT0000*.atime_diff)
3715 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3718 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3719 atime0=$(stat -c %X $DIR/$tfile)
3722 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3723 atime1=$(stat -c %X $DIR/$tfile)
3726 cancel_lru_locks mdc
3727 cancel_lru_locks osc
3728 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3729 atime2=$(stat -c %X $DIR/$tfile)
3731 do_facet $SINGLEMDS \
3732 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3734 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3735 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3737 run_test 39n "check that O_NOATIME is honored"
3740 TESTDIR=$DIR/$tdir/$tfile
3741 [ -e $TESTDIR ] && rm -rf $TESTDIR
3748 links2=$(stat -c %h .)
3749 [ $(($links1 + 2)) != $links2 ] &&
3750 error "wrong links count $(($links1 + 2)) != $links2"
3752 links3=$(stat -c %h .)
3753 [ $(($links1 + 1)) != $links3 ] &&
3754 error "wrong links count $links1 != $links3"
3757 run_test 39o "directory cached attributes updated after create"
3760 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3763 TESTDIR=$DIR/$tdir/$tdir
3764 [ -e $TESTDIR ] && rm -rf $TESTDIR
3765 test_mkdir -p $TESTDIR
3769 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3770 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3772 links2=$(stat -c %h .)
3773 [ $(($links1 + 2)) != $links2 ] &&
3774 error "wrong links count $(($links1 + 2)) != $links2"
3776 links3=$(stat -c %h .)
3777 [ $(($links1 + 1)) != $links3 ] &&
3778 error "wrong links count $links1 != $links3"
3781 run_test 39p "remote directory cached attributes updated after create ========"
3784 test_39q() { # LU-8041
3785 local testdir=$DIR/$tdir
3787 multiop_bg_pause $testdir D_c || error "multiop failed"
3789 cancel_lru_locks mdc
3790 kill -USR1 $multipid
3791 local atime=$(stat -c %X $testdir)
3792 [ "$atime" -ne 0 ] || error "atime is zero"
3794 run_test 39q "close won't zero out atime"
3797 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3798 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3799 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3800 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3801 error "$tfile is not 4096 bytes in size"
3803 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3807 small_write $DIR/f41 18
3809 run_test 41 "test small file write + fstat ====================="
3811 count_ost_writes() {
3812 lctl get_param -n ${OSC}.*.stats |
3813 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3814 END { printf("%0.0f", writes) }'
3821 BG_DIRTY_RATIO_SAVE=10
3822 MAX_BG_DIRTY_RATIO=25
3826 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3827 # dirty_ratio, dirty_background_ratio
3828 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3829 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3830 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3831 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3833 # if file not here, we are a 2.4 kernel
3834 kill -CONT `pidof kupdated`
3839 # setup the trap first, so someone cannot exit the test at the
3840 # exact wrong time and mess up a machine
3841 trap start_writeback EXIT
3842 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3843 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3844 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3845 sysctl -w vm.dirty_writeback_centisecs=0
3846 sysctl -w vm.dirty_writeback_centisecs=0
3847 # save and increase /proc/sys/vm/dirty_ratio
3848 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3849 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3850 # save and increase /proc/sys/vm/dirty_background_ratio
3851 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3852 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3854 # if file not here, we are a 2.4 kernel
3855 kill -STOP `pidof kupdated`
3859 # ensure that all stripes have some grant before we test client-side cache
3861 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3862 dd if=/dev/zero of=$i bs=4k count=1
3867 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3868 # file truncation, and file removal.
3870 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3873 cancel_lru_locks $OSC
3875 sync; sleep 1; sync # just to be safe
3876 BEFOREWRITES=`count_ost_writes`
3877 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3878 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3879 AFTERWRITES=`count_ost_writes`
3880 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3881 error "$BEFOREWRITES < $AFTERWRITES"
3884 run_test 42a "ensure that we don't flush on close"
3887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3890 cancel_lru_locks $OSC
3893 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3894 BEFOREWRITES=$(count_ost_writes)
3895 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3896 AFTERWRITES=$(count_ost_writes)
3897 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3898 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3900 BEFOREWRITES=$(count_ost_writes)
3901 sync || error "sync: $?"
3902 AFTERWRITES=$(count_ost_writes)
3903 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3904 error "$BEFOREWRITES < $AFTERWRITES on sync"
3906 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3910 run_test 42b "test destroy of file with cached dirty data ======"
3912 # if these tests just want to test the effect of truncation,
3913 # they have to be very careful. consider:
3914 # - the first open gets a {0,EOF}PR lock
3915 # - the first write conflicts and gets a {0, count-1}PW
3916 # - the rest of the writes are under {count,EOF}PW
3917 # - the open for truncate tries to match a {0,EOF}PR
3918 # for the filesize and cancels the PWs.
3919 # any number of fixes (don't get {0,EOF} on open, match
3920 # composite locks, do smarter file size management) fix
3921 # this, but for now we want these tests to verify that
3922 # the cancellation with truncate intent works, so we
3923 # start the file with a full-file pw lock to match against
3924 # until the truncate.
3929 cancel_lru_locks $OSC
3931 # prime the file with 0,EOF PW to match
3935 # now the real test..
3936 dd if=/dev/zero of=$file bs=1024 count=100
3937 BEFOREWRITES=`count_ost_writes`
3938 $TRUNCATE $file $offset
3939 cancel_lru_locks $OSC
3940 AFTERWRITES=`count_ost_writes`
3945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3948 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
3949 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3952 run_test 42c "test partial truncate of file with cached dirty data"
3955 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3958 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
3959 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3962 run_test 42d "test complete truncate of file with cached dirty data"
3964 test_42e() { # bug22074
3965 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3967 local TDIR=$DIR/${tdir}e
3968 local pagesz=$(page_size)
3969 local pages=16 # hardcoded 16 pages, don't change it.
3970 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3971 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3975 test_mkdir $DIR/${tdir}e
3976 $SETSTRIPE -c 1 $TDIR
3977 createmany -o $TDIR/f $files
3979 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3981 # we assume that with $OSTCOUNT files, at least one of them will
3982 # be allocated on OST0.
3983 warmup_files=$((OSTCOUNT * max_dirty_mb))
3984 createmany -o $TDIR/w $warmup_files
3986 # write a large amount of data into one file and sync, to get good
3987 # avail_grant number from OST.
3988 for ((i=0; i<$warmup_files; i++)); do
3989 idx=$($GETSTRIPE -i $TDIR/w$i)
3990 [ $idx -ne 0 ] && continue
3991 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3994 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3996 $LCTL get_param $proc_osc0/cur_dirty_bytes
3997 $LCTL get_param $proc_osc0/cur_grant_bytes
3999 # create as much dirty pages as we can while not to trigger the actual
4000 # RPCs directly. but depends on the env, VFS may trigger flush during this
4001 # period, hopefully we are good.
4002 for ((i=0; i<$warmup_files; i++)); do
4003 idx=$($GETSTRIPE -i $TDIR/w$i)
4004 [ $idx -ne 0 ] && continue
4005 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4007 $LCTL get_param $proc_osc0/cur_dirty_bytes
4008 $LCTL get_param $proc_osc0/cur_grant_bytes
4010 # perform the real test
4011 $LCTL set_param $proc_osc0/rpc_stats 0
4012 for ((;i<$files; i++)); do
4013 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
4014 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
4017 $LCTL get_param $proc_osc0/rpc_stats
4020 local have_ppr=false
4021 $LCTL get_param $proc_osc0/rpc_stats |
4022 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4023 # skip lines until we are at the RPC histogram data
4024 [ "$PPR" == "pages" ] && have_ppr=true && continue
4025 $have_ppr || continue
4027 # we only want the percent stat for < 16 pages
4028 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4030 percent=$((percent + WPCT))
4031 if [[ $percent -gt 15 ]]; then
4032 error "less than 16-pages write RPCs" \
4039 run_test 42e "verify sub-RPC writes are not done synchronously"
4041 test_43A() { # was test_43
4042 test_mkdir $DIR/$tdir
4043 cp -p /bin/ls $DIR/$tdir/$tfile
4044 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4046 # give multiop a chance to open
4049 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4052 run_test 43A "execution of file opened for write should return -ETXTBSY"
4055 test_mkdir $DIR/$tdir
4056 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
4057 cp -p multiop $DIR/$tdir/multiop
4058 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
4059 error "multiop open $TMP/$tfile.junk failed"
4060 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
4062 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
4063 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
4064 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
4066 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4069 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4071 test_mkdir $DIR/$tdir
4072 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
4073 cp -p multiop $DIR/$tdir/multiop
4074 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
4075 error "multiop open $TMP/$tfile.junk failed"
4076 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
4078 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
4079 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
4080 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
4082 run_test 43b "truncate of file being executed should return -ETXTBSY"
4085 local testdir="$DIR/$tdir"
4088 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4089 ( cd $testdir && md5sum -c )
4091 run_test 43c "md5sum of copy into lustre"
4093 test_44A() { # was test_44
4094 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4096 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4097 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4099 run_test 44A "zero length read from a sparse stripe"
4102 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4104 [ -z "$nstripe" ] && skip "can't get stripe info"
4105 [[ $nstripe -gt $OSTCOUNT ]] &&
4106 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4108 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4110 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4111 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4115 OFFSETS="0 $((stride/2)) $((stride-1))"
4116 for offset in $OFFSETS; do
4117 for i in $(seq 0 $((nstripe-1))); do
4118 local GLOBALOFFSETS=""
4120 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4121 local myfn=$DIR/d44a-$size
4122 echo "--------writing $myfn at $size"
4123 ll_sparseness_write $myfn $size ||
4124 error "ll_sparseness_write"
4125 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4126 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4127 error "ll_sparseness_verify $GLOBALOFFSETS"
4129 for j in $(seq 0 $((nstripe-1))); do
4131 size=$((((j + $nstripe )*$stride + $offset)))
4132 ll_sparseness_write $myfn $size ||
4133 error "ll_sparseness_write"
4134 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4136 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4137 error "ll_sparseness_verify $GLOBALOFFSETS"
4142 run_test 44a "test sparse pwrite ==============================="
4146 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4152 before=`dirty_osc_total`
4153 echo executing "\"$*\""
4155 after=`dirty_osc_total`
4156 echo before $before, after $after
4159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4162 # Obtain grants from OST if it supports it
4163 echo blah > ${f}_grant
4166 do_dirty_record "echo blah > $f"
4167 [[ $before -eq $after ]] && error "write wasn't cached"
4168 do_dirty_record "> $f"
4169 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4170 do_dirty_record "echo blah > $f"
4171 [[ $before -eq $after ]] && error "write wasn't cached"
4172 do_dirty_record "sync"
4173 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4174 do_dirty_record "echo blah > $f"
4175 [[ $before -eq $after ]] && error "write wasn't cached"
4176 do_dirty_record "cancel_lru_locks osc"
4177 [[ $before -gt $after ]] ||
4178 error "lock cancellation didn't lower dirty count"
4181 run_test 45 "osc io page accounting ============================"
4183 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4184 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4185 # objects offset and an assert hit when an rpc was built with 1023's mapped
4186 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4193 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4195 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
4196 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
4200 run_test 46 "dirtying a previously written page ================"
4202 # test_47 is removed "Device nodes check" is moved to test_28
4204 test_48a() { # bug 2399
4205 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
4206 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
4207 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4209 test_mkdir $DIR/$tdir
4211 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4212 test_mkdir $DIR/$tdir
4213 touch foo || error "'touch foo' failed after recreating cwd"
4215 touch .foo || error "'touch .foo' failed after recreating cwd"
4217 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4218 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4219 cd . || error "'cd .' failed after recreating cwd"
4220 mkdir . && error "'mkdir .' worked after recreating cwd"
4221 rmdir . && error "'rmdir .' worked after recreating cwd"
4222 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4223 cd .. || error "'cd ..' failed after recreating cwd"
4225 run_test 48a "Access renamed working dir (should return errors)="
4227 test_48b() { # bug 2399
4229 test_mkdir $DIR/$tdir
4231 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4232 touch foo && error "'touch foo' worked after removing cwd"
4233 mkdir foo && error "'mkdir foo' worked after removing cwd"
4234 touch .foo && error "'touch .foo' worked after removing cwd"
4235 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4236 ls . > /dev/null && error "'ls .' worked after removing cwd"
4237 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4238 mkdir . && error "'mkdir .' worked after removing cwd"
4239 rmdir . && error "'rmdir .' worked after removing cwd"
4240 ln -s . foo && error "'ln -s .' worked after removing cwd"
4241 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4243 run_test 48b "Access removed working dir (should return errors)="
4245 test_48c() { # bug 2350
4246 #lctl set_param debug=-1
4249 test_mkdir -p $DIR/$tdir/dir
4251 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4252 $TRACE touch foo && error "touch foo worked after removing cwd"
4253 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4254 touch .foo && error "touch .foo worked after removing cwd"
4255 mkdir .foo && error "mkdir .foo worked after removing cwd"
4256 $TRACE ls . && error "'ls .' worked after removing cwd"
4257 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4258 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4259 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4260 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4261 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4263 run_test 48c "Access removed working subdir (should return errors)"
4265 test_48d() { # bug 2350
4266 #lctl set_param debug=-1
4269 test_mkdir -p $DIR/$tdir/dir
4271 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4272 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4273 $TRACE touch foo && error "'touch foo' worked after removing parent"
4274 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4275 touch .foo && error "'touch .foo' worked after removing parent"
4276 mkdir .foo && error "mkdir .foo worked after removing parent"
4277 $TRACE ls . && error "'ls .' worked after removing parent"
4278 $TRACE ls .. && error "'ls ..' worked after removing parent"
4279 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4280 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4281 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4284 run_test 48d "Access removed parent subdir (should return errors)"
4286 test_48e() { # bug 4134
4287 #lctl set_param debug=-1
4290 test_mkdir -p $DIR/$tdir/dir
4292 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4293 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4294 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4295 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4296 # On a buggy kernel addition of "touch foo" after cd .. will
4297 # produce kernel oops in lookup_hash_it
4298 touch ../foo && error "'cd ..' worked after recreate parent"
4300 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4302 run_test 48e "Access to recreated parent subdir (should return errors)"
4304 test_49() { # LU-1030
4305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4306 remote_ost_nodsh && skip "remote OST with nodsh"
4308 # get ost1 size - lustre-OST0000
4309 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4311 # write 800M at maximum
4312 [[ $ost1_size -lt 2 ]] && ost1_size=2
4313 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4315 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4316 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4319 # change max_pages_per_rpc while writing the file
4320 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4321 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4322 # loop until dd process exits
4323 while ps ax -opid | grep -wq $dd_pid; do
4324 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4325 sleep $((RANDOM % 5 + 1))
4327 # restore original max_pages_per_rpc
4328 $LCTL set_param $osc1_mppc=$orig_mppc
4329 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4331 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4335 test_mkdir $DIR/$tdir
4337 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4339 run_test 50 "special situations: /proc symlinks ==============="
4341 test_51a() { # was test_51
4342 # bug 1516 - create an empty entry right after ".." then split dir
4343 test_mkdir -c1 $DIR/$tdir
4344 touch $DIR/$tdir/foo
4345 $MCREATE $DIR/$tdir/bar
4347 createmany -m $DIR/$tdir/longfile 201
4349 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4350 $MCREATE $DIR/$tdir/longfile$FNUM
4355 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4357 run_test 51a "special situations: split htree with empty entry =="
4359 cleanup_print_lfs_df () {
4366 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4368 local dir=$DIR/$tdir
4369 local nrdirs=$((65536 + 100))
4371 # cleanup the directory
4378 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
4379 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4380 [[ $numfree -lt $nrdirs ]] &&
4381 skip "not enough free inodes ($numfree) on MDT$mdtidx"
4383 # need to check free space for the directories as well
4384 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4385 numfree=$(( blkfree / $(fs_inode_ksize) ))
4386 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
4388 trap cleanup_print_lfs_df EXIT
4391 createmany -d $dir/d $nrdirs || {
4392 unlinkmany $dir/d $nrdirs
4393 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4397 nrdirs=$(ls -U $dir | wc -l)
4399 # unlink all but 100 subdirectories, then check it still works
4401 local delete=$((nrdirs - left))
4406 # for ldiskfs the nlink count should be 1, but this is OSD specific
4407 # and so this is listed for informational purposes only
4408 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4409 unlinkmany -d $dir/d $delete ||
4410 error "unlink of first $delete subdirs failed"
4412 echo "nlink between: $(stat -c %h $dir)"
4413 local found=$(ls -U $dir | wc -l)
4414 [ $found -ne $left ] &&
4415 error "can't find subdirs: found only $found, expected $left"
4417 unlinkmany -d $dir/d $delete $left ||
4418 error "unlink of second $left subdirs failed"
4419 # regardless of whether the backing filesystem tracks nlink accurately
4420 # or not, the nlink count shouldn't be more than "." and ".." here
4421 local after=$(stat -c %h $dir)
4422 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4423 echo "nlink after: $after"
4425 cleanup_print_lfs_df
4427 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4430 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4431 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
4433 test_mkdir $DIR/$tdir
4434 createmany -o $DIR/$tdir/t- 1000
4435 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4436 for N in $(seq 0 $((OSTCOUNT - 1))); do
4437 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4438 END { printf("%0.0f", objs) }' $TMP/$tfile)
4439 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4440 '($1 == '$N') { objs += 1 } \
4441 END { printf("%0.0f", objs) }')
4442 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4444 unlinkmany $DIR/$tdir/t- 1000
4447 for N in $(seq 1 $((OSTCOUNT - 1))); do
4448 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4449 error "OST $N has less objects vs OST $NLAST" \
4450 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4451 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4452 error "OST $N has less objects vs OST $NLAST" \
4453 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4455 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4456 error "OST $N has less #0 objects vs OST $NLAST" \
4457 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4458 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4459 error "OST $N has less #0 objects vs OST $NLAST" \
4460 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4465 run_test 51d "check object distribution"
4468 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4469 skip_env "ldiskfs only test"
4472 test_mkdir -c1 $DIR/$tdir
4473 test_mkdir -c1 $DIR/$tdir/d0
4475 touch $DIR/$tdir/d0/foo
4476 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4477 error "file exceed 65000 nlink limit!"
4478 unlinkmany $DIR/$tdir/d0/f- 65001
4481 run_test 51e "check file nlink limit"
4484 test_mkdir $DIR/$tdir
4487 local ulimit_old=$(ulimit -n)
4488 local spare=20 # number of spare fd's for scripts/libraries, etc.
4489 local mdt=$($LFS getstripe -m $DIR/$tdir)
4490 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4492 echo "MDT$mdt numfree=$numfree, max=$max"
4493 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4494 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4495 while ! ulimit -n $((numfree + spare)); do
4496 numfree=$((numfree * 3 / 4))
4498 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4500 echo "left ulimit at $ulimit_old"
4503 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4504 unlinkmany $DIR/$tdir/f $numfree
4505 error "create+open $numfree files in $DIR/$tdir failed"
4507 ulimit -n $ulimit_old
4509 # if createmany exits at 120s there will be fewer than $numfree files
4510 unlinkmany $DIR/$tdir/f $numfree || true
4512 run_test 51f "check many open files limit"
4515 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4516 test_mkdir $DIR/$tdir
4517 touch $DIR/$tdir/foo
4518 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4519 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4520 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4521 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4522 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4524 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4525 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4526 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4528 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4529 cp -r $DIR/$tdir $TMP/
4530 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4532 run_test 52a "append-only flag test (should return errors)"
4535 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4536 test_mkdir $DIR/$tdir
4537 touch $DIR/$tdir/foo
4538 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4539 cat test > $DIR/$tdir/foo && error "cat test worked"
4540 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4541 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4542 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4544 echo foo >> $DIR/$tdir/foo && error "echo worked"
4545 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4546 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4547 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4548 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4550 chattr -i $DIR/$tdir/foo || error "chattr failed"
4552 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4554 run_test 52b "immutable flag test (should return errors) ======="
4557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4558 remote_mds_nodsh && skip "remote MDS with nodsh"
4559 remote_ost_nodsh && skip "remote OST with nodsh"
4572 local support_last_seq=true
4574 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4575 support_last_seq=false
4578 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4580 for value in $(do_facet $SINGLEMDS \
4581 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4582 param=$(echo ${value[0]} | cut -d "=" -f1)
4583 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4585 if $support_last_seq; then
4586 param_seq=$(echo $param |
4587 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4588 mds_last_seq=$(do_facet $SINGLEMDS \
4589 $LCTL get_param -n $param_seq)
4591 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4593 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4594 node=$(facet_active_host ost$((ostnum+1)))
4595 param="obdfilter.$ostname.last_id"
4596 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4597 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4598 ost_last_id=$ost_last
4600 if $support_last_seq; then
4601 ost_last_id=$(echo $ost_last |
4602 awk -F':' '{print $2}' |
4604 ost_last_seq=$(echo $ost_last |
4605 awk -F':' '{print $1}')
4606 [[ $ost_last_seq = $mds_last_seq ]] || continue
4609 if [[ $ost_last_id != $mds_last ]]; then
4610 error "$ost_last_id != $mds_last"
4617 $found || error "can not match last_seq/last_id for $mdtosc"
4620 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4623 perl -MSocket -e ';' || skip "no Socket perl module installed"
4625 $SOCKETSERVER $DIR/socket ||
4626 error "$SOCKETSERVER $DIR/socket failed: $?"
4627 $SOCKETCLIENT $DIR/socket ||
4628 error "$SOCKETCLIENT $DIR/socket failed: $?"
4629 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4631 run_test 54a "unix domain socket test =========================="
4637 dd if=/dev/zero of=$f bs=$(page_size) count=1
4639 run_test 54b "char device works in lustre ======================"
4642 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4643 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4644 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4646 for i in $(seq 3 7); do
4647 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4656 loopdev="$DIR/loop54c"
4659 $UMOUNT $DIR/$tdir || rc=$?
4660 losetup -d $loopdev || true
4661 losetup -d $LOOPDEV || true
4662 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4667 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4669 loopdev="$DIR/loop54c"
4672 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
4673 trap cleanup_54c EXIT
4674 mknod $loopdev b 7 $LOOPNUM
4675 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4676 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4677 losetup $loopdev $DIR/$tfile ||
4678 error "can't set up $loopdev for $DIR/$tfile"
4679 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4680 test_mkdir $DIR/$tdir
4681 mount -t ext2 $loopdev $DIR/$tdir ||
4682 error "error mounting $loopdev on $DIR/$tdir"
4683 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4686 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4690 run_test 54c "block device works in lustre ====================="
4696 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4698 run_test 54d "fifo device works in lustre ======================"
4703 cp -aL /dev/console $f
4704 echo $string > $f || error "echo $string to $f failed"
4706 run_test 54e "console/tty device works in lustre ======================"
4710 local dir=$DIR/$tdir
4713 test_mkdir -p $dir/dir
4714 for i in $(seq $numfiles); do
4716 touch $dir/dir/file$i
4719 local numcomp=$($LFS getstripe --component-count $dir)
4721 [[ $numcomp == 0 ]] && numcomp=1
4723 # test lfs getstripe with --recursive
4724 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
4726 [[ $filenum -eq $((numfiles * 2)) ]] ||
4727 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
4728 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
4729 [[ $filenum -eq $numfiles ]] ||
4730 error "$LFS getstripe $dir: found $filenum, not $numfiles"
4731 echo "$LFS getstripe showed obdidx or l_ost_idx"
4733 # test lfs getstripe with file instead of dir
4734 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
4735 [[ $filenum -eq 1 ]] ||
4736 error "$LFS getstripe $dir/file1: found $filenum, not 1"
4737 echo "$LFS getstripe file1 passed"
4739 #test lfs getstripe with --verbose
4740 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
4741 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4742 error "$LFS getstripe --verbose $dir: "\
4743 "got $filenum want $((numfiles * numcomp)) lmm_magic"
4744 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
4745 error "$LFS getstripe $dir: showed lmm_magic"
4747 #test lfs getstripe with -v prints lmm_fid
4748 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
4749 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4750 error "$LFS getstripe -v $dir: "\
4751 "got $filenum want $((numfiles * numcomp)) lmm_fid"
4752 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
4753 error "$LFS getstripe $dir: showed lmm_fid by default"
4754 echo "$LFS getstripe --verbose passed"
4756 #check for FID information
4757 local fid1=$($LFS getstripe --fid $dir/file1)
4758 local fid2=$($LFS getstripe --verbose $dir/file1 |
4759 awk '/lmm_fid: / { print $2; exit; }')
4760 local fid3=$($LFS path2fid $dir/file1)
4762 [ "$fid1" != "$fid2" ] &&
4763 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
4764 [ "$fid1" != "$fid3" ] &&
4765 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
4766 echo "$LFS getstripe --fid passed"
4768 #test lfs getstripe with --obd
4769 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
4770 error "$LFS getstripe --obd wrong_uuid: should return error"
4772 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4775 local obduuid=$(ostuuid_from_index $ostidx)
4776 local found=$($LFS getstripe -r --obd $obduuid $dir |
4777 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
4779 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
4780 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
4782 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
4785 [[ $found -eq $filenum ]] ||
4786 error "$LFS getstripe --obd: found $found expect $filenum"
4787 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
4788 sed '/^[ ]*'${ostidx}'[ ]/d' |
4789 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4790 error "$LFS getstripe --obd: should not show file on other obd"
4791 echo "$LFS getstripe --obd passed"
4793 run_test 56a "check $LFS getstripe"
4796 local dir=$DIR/$tdir
4800 for i in $(seq $numdirs); do
4801 test_mkdir $dir/dir$i
4804 # test lfs getdirstripe default mode is non-recursion, which is
4805 # different from lfs getstripe
4806 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
4808 [[ $dircnt -eq 1 ]] ||
4809 error "$LFS getdirstripe: found $dircnt, not 1"
4810 dircnt=$($LFS getdirstripe --recursive $dir |
4811 grep -c lmv_stripe_count)
4812 [[ $dircnt -eq $((numdirs + 1)) ]] ||
4813 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
4815 run_test 56b "check $LFS getdirstripe"
4818 remote_ost_nodsh && skip "remote OST with nodsh"
4821 local ost_name=$(ostname_from_index $ost_idx)
4822 local old_status=$(ost_dev_status $ost_idx)
4824 [[ -z "$old_status" ]] ||
4825 skip_env "OST $ost_name is in $old_status status"
4827 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4830 local new_status=$(ost_dev_status $ost_idx)
4832 [[ "$new_status" = "D" ]] ||
4833 error "OST $ost_name is in status of '$new_status', not 'D'"
4835 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4838 new_status=$(ost_dev_status $ost_idx)
4839 [[ -z "$new_status" ]] ||
4840 error "OST $ost_name is in status of '$new_status', not ''"
4842 run_test 56c "check 'lfs df' showing device status"
4847 local local_tdir="$1"
4848 local local_numfiles="$2"
4849 local local_numdirs="$3"
4850 local dir_params="$4"
4851 local dir_stripe_params="$5"
4853 if [ ! -d "$local_tdir" ] ; then
4854 test_mkdir -p $dir_stripe_params $local_tdir
4855 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
4856 for i in $(seq $local_numfiles) ; do
4857 touch $local_tdir/file$i
4859 for i in $(seq $local_numdirs) ; do
4860 test_mkdir $dir_stripe_params $local_tdir/dir$i
4861 for j in $(seq $local_numfiles) ; do
4862 touch $local_tdir/dir$i/file$j
4868 setup_56_special() {
4870 local local_numfiles=$2
4871 local local_numdirs=$3
4873 setup_56 $local_tdir $local_numfiles $local_numdirs
4875 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
4876 for i in $(seq $local_numfiles) ; do
4877 mknod $local_tdir/loop${i}b b 7 $i
4878 mknod $local_tdir/null${i}c c 1 3
4879 ln -s $local_tdir/file1 $local_tdir/link${i}
4881 for i in $(seq $local_numdirs) ; do
4882 mknod $local_tdir/dir$i/loop${i}b b 7 $i
4883 mknod $local_tdir/dir$i/null${i}c c 1 3
4884 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
4890 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4891 local expected=$(($NUMDIRS + 2))
4893 setup_56 $dir $NUMFILES $NUMDIRS
4895 # test lfs find with -name
4896 for i in $(seq $NUMFILES) ; do
4897 local nums=$($LFS find -name "*$i" $dir | wc -l)
4899 [ $nums -eq $expected ] ||
4900 error "lfs find -name '*$i' $dir wrong: "\
4901 "found $nums, expected $expected"
4904 run_test 56g "check lfs find -name"
4907 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4908 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4910 setup_56 $dir $NUMFILES $NUMDIRS
4912 # test lfs find with ! -name
4913 for i in $(seq $NUMFILES) ; do
4914 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
4916 [ $nums -eq $expected ] ||
4917 error "lfs find ! -name '*$i' $dir wrong: "\
4918 "found $nums, expected $expected"
4921 run_test 56h "check lfs find ! -name"
4924 local dir=$DIR/$tdir
4928 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
4931 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
4933 run_test 56i "check 'lfs find -ost UUID' skips directories"
4936 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4938 setup_56_special $dir $NUMFILES $NUMDIRS
4940 local expected=$((NUMDIRS + 1))
4941 local cmd="$LFS find -type d $dir"
4942 local nums=$($cmd | wc -l)
4944 [ $nums -eq $expected ] ||
4945 error "'$cmd' wrong: found $nums, expected $expected"
4947 run_test 56j "check lfs find -type d"
4950 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4952 setup_56_special $dir $NUMFILES $NUMDIRS
4954 local expected=$(((NUMDIRS + 1) * NUMFILES))
4955 local cmd="$LFS find -type f $dir"
4956 local nums=$($cmd | wc -l)
4958 [ $nums -eq $expected ] ||
4959 error "'$cmd' wrong: found $nums, expected $expected"
4961 run_test 56k "check lfs find -type f"
4964 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4966 setup_56_special $dir $NUMFILES $NUMDIRS
4968 local expected=$((NUMDIRS + NUMFILES))
4969 local cmd="$LFS find -type b $dir"
4970 local nums=$($cmd | wc -l)
4972 [ $nums -eq $expected ] ||
4973 error "'$cmd' wrong: found $nums, expected $expected"
4975 run_test 56l "check lfs find -type b"
4978 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4980 setup_56_special $dir $NUMFILES $NUMDIRS
4982 local expected=$((NUMDIRS + NUMFILES))
4983 local cmd="$LFS find -type c $dir"
4984 local nums=$($cmd | wc -l)
4985 [ $nums -eq $expected ] ||
4986 error "'$cmd' wrong: found $nums, expected $expected"
4988 run_test 56m "check lfs find -type c"
4991 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4992 setup_56_special $dir $NUMFILES $NUMDIRS
4994 local expected=$((NUMDIRS + NUMFILES))
4995 local cmd="$LFS find -type l $dir"
4996 local nums=$($cmd | wc -l)
4998 [ $nums -eq $expected ] ||
4999 error "'$cmd' wrong: found $nums, expected $expected"
5001 run_test 56n "check lfs find -type l"
5004 local dir=$DIR/$tdir
5006 setup_56 $dir $NUMFILES $NUMDIRS
5007 utime $dir/file1 > /dev/null || error "utime (1)"
5008 utime $dir/file2 > /dev/null || error "utime (2)"
5009 utime $dir/dir1 > /dev/null || error "utime (3)"
5010 utime $dir/dir2 > /dev/null || error "utime (4)"
5011 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5012 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5015 local nums=$($LFS find -mtime +0 $dir | wc -l)
5017 [ $nums -eq $expected ] ||
5018 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5021 cmd="$LFS find -mtime 0 $dir"
5022 nums=$($cmd | wc -l)
5023 [ $nums -eq $expected ] ||
5024 error "'$cmd' wrong: found $nums, expected $expected"
5026 run_test 56o "check lfs find -mtime for old files"
5029 [ $RUNAS_ID -eq $UID ] &&
5030 skip_env "RUNAS_ID = UID = $UID -- skipping"
5032 local dir=$DIR/$tdir
5034 setup_56 $dir $NUMFILES $NUMDIRS
5035 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5037 local expected=$NUMFILES
5038 local cmd="$LFS find -uid $RUNAS_ID $dir"
5039 local nums=$($cmd | wc -l)
5041 [ $nums -eq $expected ] ||
5042 error "'$cmd' wrong: found $nums, expected $expected"
5044 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5045 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5046 nums=$($cmd | wc -l)
5047 [ $nums -eq $expected ] ||
5048 error "'$cmd' wrong: found $nums, expected $expected"
5050 run_test 56p "check lfs find -uid and ! -uid"
5053 [ $RUNAS_ID -eq $UID ] &&
5054 skip_env "RUNAS_ID = UID = $UID -- skipping"
5056 local dir=$DIR/$tdir
5058 setup_56 $dir $NUMFILES $NUMDIRS
5059 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5061 local expected=$NUMFILES
5062 local cmd="$LFS find -gid $RUNAS_GID $dir"
5063 local nums=$($cmd | wc -l)
5065 [ $nums -eq $expected ] ||
5066 error "'$cmd' wrong: found $nums, expected $expected"
5068 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5069 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5070 nums=$($cmd | wc -l)
5071 [ $nums -eq $expected ] ||
5072 error "'$cmd' wrong: found $nums, expected $expected"
5074 run_test 56q "check lfs find -gid and ! -gid"
5077 local dir=$DIR/$tdir
5079 setup_56 $dir $NUMFILES $NUMDIRS
5082 local cmd="$LFS find -size 0 -type f $dir"
5083 local nums=$($cmd | wc -l)
5085 [ $nums -eq $expected ] ||
5086 error "'$cmd' wrong: found $nums, expected $expected"
5088 cmd="$LFS find ! -size 0 -type f $dir"
5089 nums=$($cmd | wc -l)
5090 [ $nums -eq $expected ] ||
5091 error "'$cmd' wrong: found $nums, expected $expected"
5092 echo "test" > $dir/$tfile
5093 echo "test2" > $dir/$tfile.2 && sync
5095 cmd="$LFS find -size 5 -type f $dir"
5096 nums=$($cmd | wc -l)
5097 [ $nums -eq $expected ] ||
5098 error "'$cmd' wrong: found $nums, expected $expected"
5100 cmd="$LFS find -size +5 -type f $dir"
5101 nums=$($cmd | wc -l)
5102 [ $nums -eq $expected ] ||
5103 error "'$cmd' wrong: found $nums, expected $expected"
5105 cmd="$LFS find -size +0 -type f $dir"
5106 nums=$($cmd | wc -l)
5107 [ $nums -eq $expected ] ||
5108 error "'$cmd' wrong: found $nums, expected $expected"
5110 cmd="$LFS find ! -size -5 -type f $dir"
5111 nums=$($cmd | wc -l)
5112 [ $nums -eq $expected ] ||
5113 error "'$cmd' wrong: found $nums, expected $expected"
5115 cmd="$LFS find -size -5 -type f $dir"
5116 nums=$($cmd | wc -l)
5117 [ $nums -eq $expected ] ||
5118 error "'$cmd' wrong: found $nums, expected $expected"
5120 run_test 56r "check lfs find -size works"
5122 test_56s() { # LU-611 #LU-9369
5123 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
5125 local dir=$DIR/$tdir
5126 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5128 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5129 for i in $(seq $NUMDIRS); do
5130 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5133 local expected=$NUMDIRS
5134 local cmd="$LFS find -c $OSTCOUNT $dir"
5135 local nums=$($cmd | wc -l)
5137 [ $nums -eq $expected ] || {
5138 $LFS getstripe -R $dir
5139 error "'$cmd' wrong: found $nums, expected $expected"
5142 expected=$((NUMDIRS + onestripe))
5143 cmd="$LFS find -stripe-count +0 -type f $dir"
5144 nums=$($cmd | wc -l)
5145 [ $nums -eq $expected ] || {
5146 $LFS getstripe -R $dir
5147 error "'$cmd' wrong: found $nums, expected $expected"
5151 cmd="$LFS find -stripe-count 1 -type f $dir"
5152 nums=$($cmd | wc -l)
5153 [ $nums -eq $expected ] || {
5154 $LFS getstripe -R $dir
5155 error "'$cmd' wrong: found $nums, expected $expected"
5158 cmd="$LFS find -stripe-count -2 -type f $dir"
5159 nums=$($cmd | wc -l)
5160 [ $nums -eq $expected ] || {
5161 $LFS getstripe -R $dir
5162 error "'$cmd' wrong: found $nums, expected $expected"
5166 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5167 nums=$($cmd | wc -l)
5168 [ $nums -eq $expected ] || {
5169 $LFS getstripe -R $dir
5170 error "'$cmd' wrong: found $nums, expected $expected"
5173 run_test 56s "check lfs find -stripe-count works"
5175 test_56t() { # LU-611 #LU-9369
5176 local dir=$DIR/$tdir
5178 setup_56 $dir 0 $NUMDIRS
5179 for i in $(seq $NUMDIRS); do
5180 $LFS setstripe -S 8M $dir/dir$i/$tfile
5183 local expected=$NUMDIRS
5184 local cmd="$LFS find -S 8M $dir"
5185 local nums=$($cmd | wc -l)
5187 [ $nums -eq $expected ] || {
5188 $LFS getstripe -R $dir
5189 error "'$cmd' wrong: found $nums, expected $expected"
5193 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5195 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5197 expected=$(((NUMDIRS + 1) * NUMFILES))
5198 cmd="$LFS find -stripe-size 512k -type f $dir"
5199 nums=$($cmd | wc -l)
5200 [ $nums -eq $expected ] ||
5201 error "'$cmd' wrong: found $nums, expected $expected"
5203 cmd="$LFS find -stripe-size +320k -type f $dir"
5204 nums=$($cmd | wc -l)
5205 [ $nums -eq $expected ] ||
5206 error "'$cmd' wrong: found $nums, expected $expected"
5208 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5209 cmd="$LFS find -stripe-size +200k -type f $dir"
5210 nums=$($cmd | wc -l)
5211 [ $nums -eq $expected ] ||
5212 error "'$cmd' wrong: found $nums, expected $expected"
5214 cmd="$LFS find -stripe-size -640k -type f $dir"
5215 nums=$($cmd | wc -l)
5216 [ $nums -eq $expected ] ||
5217 error "'$cmd' wrong: found $nums, expected $expected"
5220 cmd="$LFS find -stripe-size 256k -type f $dir"
5221 nums=$($cmd | wc -l)
5222 [ $nums -eq $expected ] ||
5223 error "'$cmd' wrong: found $nums, expected $expected"
5225 cmd="$LFS find -stripe-size -320k -type f $dir"
5226 nums=$($cmd | wc -l)
5227 [ $nums -eq $expected ] ||
5228 error "'$cmd' wrong: found $nums, expected $expected"
5231 cmd="$LFS find -stripe-size 1024k -type f $dir"
5232 nums=$($cmd | wc -l)
5233 [ $nums -eq $expected ] ||
5234 error "'$cmd' wrong: found $nums, expected $expected"
5236 run_test 56t "check lfs find -stripe-size works"
5238 test_56u() { # LU-611
5239 local dir=$DIR/$tdir
5241 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5243 if [[ $OSTCOUNT -gt 1 ]]; then
5244 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5250 local expected=$(((NUMDIRS + 1) * NUMFILES))
5251 local cmd="$LFS find -stripe-index 0 -type f $dir"
5252 local nums=$($cmd | wc -l)
5254 [ $nums -eq $expected ] ||
5255 error "'$cmd' wrong: found $nums, expected $expected"
5258 cmd="$LFS find -stripe-index 1 -type f $dir"
5259 nums=$($cmd | wc -l)
5260 [ $nums -eq $expected ] ||
5261 error "'$cmd' wrong: found $nums, expected $expected"
5263 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5264 nums=$($cmd | wc -l)
5265 [ $nums -eq $expected ] ||
5266 error "'$cmd' wrong: found $nums, expected $expected"
5269 # This should produce an error and not return any files
5270 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5271 nums=$($cmd 2>/dev/null | wc -l)
5272 [ $nums -eq $expected ] ||
5273 error "'$cmd' wrong: found $nums, expected $expected"
5275 if [[ $OSTCOUNT -gt 1 ]]; then
5276 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5277 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5278 nums=$($cmd | wc -l)
5279 [ $nums -eq $expected ] ||
5280 error "'$cmd' wrong: found $nums, expected $expected"
5283 run_test 56u "check lfs find -stripe-index works"
5287 local dir=$DIR/$tdir
5289 setup_56 $dir $NUMFILES $NUMDIRS
5291 UUID=$(mdtuuid_from_index $mdt_idx $dir)
5292 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
5294 for file in $($LFS find -m $UUID $dir); do
5295 file_midx=$($LFS getstripe -m $file)
5296 [ $file_midx -eq $mdt_idx ] ||
5297 error "lfs find -m $UUID != getstripe -m $file_midx"
5300 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
5303 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5304 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5306 local dir=$DIR/$tdir
5308 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5310 local stripe_size=$($LFS getstripe -S -d $dir) ||
5311 error "$LFS getstripe -S -d $dir failed"
5312 stripe_size=${stripe_size%% *}
5314 local file_size=$((stripe_size * OSTCOUNT))
5315 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5316 local required_space=$((file_num * file_size))
5317 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5319 [[ $free_space -le $((required_space / 1024)) ]] &&
5320 skip_env "need $required_space, have $free_space kbytes"
5323 local dd_count=$((file_size / dd_bs))
5325 # write data into the files
5330 for i in $(seq $NUMFILES); do
5332 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5333 error "write data into $file failed"
5335 for i in $(seq $NUMDIRS); do
5336 for j in $(seq $NUMFILES); do
5337 file=$dir/dir$i/file$j
5338 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5339 error "write data into $file failed"
5343 # $LFS_MIGRATE will fail if hard link migration is unsupported
5344 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5345 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5346 error "creating links to $dir/dir1/file1 failed"
5351 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5354 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5357 eval $cmd || error "$cmd failed"
5359 check_stripe_count $dir/file1 $expected
5361 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
5363 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5364 # OST 1 if it is on OST 0. This file is small enough to
5365 # be on only one stripe.
5366 file=$dir/migr_1_ost
5367 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5368 error "write data into $file failed"
5369 local obdidx=$($LFS getstripe -i $file)
5370 local oldmd5=$(md5sum $file)
5373 [[ $obdidx -eq 0 ]] && newobdidx=1
5374 cmd="$LFS migrate -i $newobdidx $file"
5376 eval $cmd || error "$cmd failed"
5378 local realobdix=$($LFS getstripe -i $file)
5379 local newmd5=$(md5sum $file)
5381 [[ $newobdidx -ne $realobdix ]] &&
5382 error "new OST is different (was=$obdidx, "\
5383 "wanted=$newobdidx, got=$realobdix)"
5384 [[ "$oldmd5" != "$newmd5" ]] &&
5385 error "md5sum differ: $oldmd5, $newmd5"
5389 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5391 eval $cmd || error "$cmd failed"
5393 for j in $(seq $NUMFILES); do
5394 check_stripe_count $dir/dir1/file$j $expected
5397 # lfs_migrate works with lfs find
5398 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5399 $LFS_MIGRATE -y -c $expected"
5401 eval $cmd || error "$cmd failed"
5403 for i in $(seq 2 $NUMFILES); do
5404 check_stripe_count $dir/file$i $expected
5406 for i in $(seq 2 $NUMDIRS); do
5407 for j in $(seq $NUMFILES); do
5408 check_stripe_count $dir/dir$i/file$j $expected
5412 run_test 56w "check lfs_migrate -c stripe_count works"
5415 local file1=$DIR/$tdir/file1
5416 local create_pool=false
5417 local initial_pool=$($LFS getstripe -p $DIR)
5421 echo -n "Creating test dir..."
5422 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5425 echo -n "Creating test file..."
5426 touch $file1 || error "cannot create file"
5429 echo -n "Detecting existing pools..."
5430 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
5432 if [ ${#pool_list[@]} -gt 0 ]; then
5433 echo "${pool_list[@]}"
5434 for thispool in "${pool_list[@]}"; do
5435 if [[ -z "$initial_pool" ||
5436 "$initial_pool" != "$thispool" ]]; then
5438 echo "Using existing pool '$pool'"
5443 echo "none detected."
5445 if [ -z "$pool" ]; then
5446 pool=${POOL:-testpool}
5447 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5448 echo -n "Creating pool '$pool'..."
5450 pool_add $pool &> /dev/null ||
5451 error "pool_add failed"
5454 echo -n "Adding target to pool..."
5455 pool_add_targets $pool 0 0 1 &> /dev/null ||
5456 error "pool_add_targets failed"
5460 echo -n "Setting pool using -p option..."
5461 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5462 error "migrate failed rc = $?"
5465 echo -n "Verifying test file is in pool after migrating..."
5466 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5467 error "file was not migrated to pool $pool"
5470 echo -n "Removing test file from pool '$pool'..."
5471 $LFS migrate $file1 &> /dev/null ||
5472 error "cannot remove from pool"
5473 [ "$($LFS getstripe -p $file1)" ] &&
5474 error "pool still set"
5477 echo -n "Setting pool using --pool option..."
5478 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5479 error "migrate failed rc = $?"
5484 if $create_pool; then
5485 destroy_test_pools 2> /dev/null ||
5486 error "destroy test pools failed"
5489 run_test 56wb "check lfs_migrate pool support"
5492 local file1="$DIR/$tdir/file 1"
5494 echo -n "Creating test dir..."
5495 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5496 local def_stripe_size=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
5497 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5498 error "cannot set stripe"
5501 echo -n "Setting initial stripe for test file..."
5502 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5503 error "cannot set stripe"
5504 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5505 error "stripe size not set"
5508 # File currently set to -S 512K -c 1
5510 # Ensure -c and -S options are rejected when -R is set
5511 echo -n "Verifying incompatible options are detected..."
5512 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5513 error "incompatible -c and -R options not detected"
5514 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5515 error "incompatible -S and -R options not detected"
5518 # Ensure unrecognized options are passed through to 'lfs migrate'
5519 echo -n "Verifying -S option is passed through to lfs migrate..."
5520 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5521 error "migration failed"
5522 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5523 error "file was not restriped"
5526 # File currently set to -S 1M -c 1
5528 # Ensure long options are supported
5529 echo -n "Verifying long options supported..."
5530 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5531 error "long option without argument not supported"
5532 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5533 error "long option with argument not supported"
5534 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5535 error "file not restriped with --stripe-size option"
5538 # File currently set to -S 512K -c 1
5540 if [ "$OSTCOUNT" -gt 1 ]; then
5541 echo -n "Verifying explicit stripe count can be set..."
5542 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5543 error "migrate failed"
5544 [ $($LFS getstripe -c "$file1") -eq 2 ] ||
5545 error "file not restriped to explicit count"
5549 # File currently set to -S 512K -c 1 or -S 512K -c 2
5551 # Ensure parent striping is used if -R is set, and no stripe
5552 # count or size is specified
5553 echo -n "Setting stripe for parent directory..."
5554 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5555 error "cannot set stripe"
5558 echo -n "Verifying restripe option uses parent stripe settings..."
5559 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5560 error "migrate failed"
5561 [ $($LFS getstripe -S "$file1") -eq $def_stripe_size ] ||
5562 error "file not restriped to parent settings"
5563 [ $($LFS getstripe -c "$file1") -eq 1 ] ||
5564 error "file not restriped to parent settings"
5567 # File currently set to -S 1M -c 1
5569 # Ensure striping is preserved if -R is not set, and no stripe
5570 # count or size is specified
5571 echo -n "Verifying striping size preserved when not specified..."
5572 local orig_stripe_size=$($LFS getstripe -S "$file1" 2>/dev/null)
5573 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5574 error "cannot set stripe on parent directory"
5575 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5576 error "migrate failed"
5577 [ $($LFS getstripe -S "$file1") -eq $orig_stripe_size ] ||
5578 error "file was restriped"
5581 # Ensure file name properly detected when final option has no argument
5582 echo -n "Verifying file name properly detected..."
5583 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5584 error "file name interpreted as option argument"
5590 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5593 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5595 local file1=$DIR/$tdir/file1
5597 echo -n "Creating test dir..."
5598 test_mkdir $DIR/$tdir || error "cannot create dir"
5601 echo -n "Creating test file..."
5605 # Ensure 'lfs migrate' will fail by using a non-existent option,
5606 # and make sure rsync is not called to recover
5607 echo -n "Make sure --no-rsync option works..."
5608 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
5609 grep -q 'refusing to fall back to rsync' ||
5610 error "rsync was called with --no-rsync set"
5613 # Ensure rsync is called without trying 'lfs migrate' first
5614 echo -n "Make sure --rsync option works..."
5615 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
5616 grep -q 'falling back to rsync' &&
5617 error "lfs migrate was called with --rsync set"
5620 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
5621 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
5622 grep -q 'at the same time' ||
5623 error "--rsync and --no-rsync accepted concurrently"
5629 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
5632 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5633 check_swap_layouts_support
5635 local dir=$DIR/$tdir
5636 local ref1=/etc/passwd
5637 local file1=$dir/file1
5639 test_mkdir $dir || error "creating dir $dir"
5640 $LFS setstripe -c 2 $file1
5642 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5643 stripe=$($LFS getstripe -c $file1)
5644 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5645 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5650 run_test 56x "lfs migration support"
5653 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5654 check_swap_layouts_support
5656 local dir=$DIR/$tdir/$testnum
5660 local ref1=/etc/passwd
5661 local file1=$dir/file1
5663 $LFS setstripe -c 2 $file1
5665 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5667 local stripe=$($LFS getstripe -c $file1)
5669 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5670 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5675 run_test 56xa "lfs migration --block support"
5677 check_migrate_links() {
5679 local file1="$dir/file1"
5682 local total_count=$(($begin + $count - 1))
5683 local symlink_count=10
5686 if [ ! -f "$file1" ]; then
5687 echo -n "creating initial file..."
5688 $LFS setstripe -c 1 -S "512k" "$file1" ||
5689 error "cannot setstripe initial file"
5692 echo -n "creating symlinks..."
5693 for s in $(seq 1 $symlink_count); do
5694 ln -s "$file1" "$dir/slink$s" ||
5695 error "cannot create symlinks"
5699 echo -n "creating nonlinked files..."
5700 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5701 error "cannot create nonlinked files"
5706 if [ ! -f "$dir/file$total_count" ]; then
5707 echo -n "creating hard links $begin:$total_count..."
5708 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5709 /dev/null || error "cannot create hard links"
5713 echo -n "checking number of hard links listed in xattrs..."
5714 local fid=$($LFS getstripe -F "$file1")
5715 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5718 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5719 skip "hard link list has unexpected size, skipping test"
5721 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5722 error "link names should exceed xattrs size"
5725 echo -n "migrating files..."
5726 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5728 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5731 # make sure all links have been properly migrated
5732 echo -n "verifying files..."
5733 fid=$($LFS getstripe -F "$file1") ||
5734 error "cannot get fid for file $file1"
5735 for i in $(seq 2 $total_count); do
5736 local fid2=$($LFS getstripe -F $dir/file$i)
5738 [ "$fid2" == "$fid" ] ||
5739 error "migrated hard link has mismatched FID"
5742 # make sure hard links were properly detected, and migration was
5743 # performed only once for the entire link set; nonlinked files should
5745 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5746 local expected=$(($uniq_count + 1))
5748 [ "$actual" -eq "$expected" ] ||
5749 error "hard links individually migrated ($actual != $expected)"
5751 # make sure the correct number of hard links are present
5752 local hardlinks=$(stat -c '%h' "$file1")
5754 [ $hardlinks -eq $total_count ] ||
5755 error "num hard links $hardlinks != $total_count"
5762 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
5763 skip "Need MDS version at least 2.10.55"
5765 local dir="$DIR/$tdir"
5767 test_mkdir "$dir" || error "cannot create dir $dir"
5769 echo "testing lfs migrate mode when all links fit within xattrs"
5770 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 2 99
5772 echo "testing rsync mode when all links fit within xattrs"
5773 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 2 99
5775 echo "testing lfs migrate mode when all links do not fit within xattrs"
5776 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 101 100
5778 echo "testing rsync mode when all links do not fit within xattrs"
5779 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 101 100
5784 run_test 56xb "lfs migration hard link support"
5787 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
5788 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
5791 local dir=$DIR/$tdir
5795 test_mkdir -p $dir || error "creating dir $dir"
5796 touch $f1 || error "creating std file $f1"
5797 $MULTIOP $f2 H2c || error "creating released file $f2"
5799 # a directory can be raid0, so ask only for files
5800 res=$($LFS find $dir -L raid0 -type f | wc -l)
5801 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5803 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
5804 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5806 # only files can be released, so no need to force file search
5807 res=$($LFS find $dir -L released)
5808 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5810 res=$($LFS find $dir -type f \! -L released)
5811 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5813 run_test 56y "lfs find -L raid0|released"
5815 test_56z() { # LU-4824
5816 # This checks to make sure 'lfs find' continues after errors
5817 # There are two classes of errors that should be caught:
5818 # - If multiple paths are provided, all should be searched even if one
5820 # - If errors are encountered during the search, it should not terminate
5822 local dir=$DIR/$tdir
5826 for i in d{0..9}; do
5829 touch $dir/d{0..9}/$tfile
5830 $LFS find $DIR/non_existent_dir $dir &&
5831 error "$LFS find did not return an error"
5832 # Make a directory unsearchable. This should NOT be the last entry in
5833 # directory order. Arbitrarily pick the 6th entry
5834 chmod 700 $($LFS find $dir -type d | sed '6!d')
5836 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
5838 # The user should be able to see 10 directories and 9 files
5839 [ $count == 19 ] || error "$LFS find did not continue after error"
5841 run_test 56z "lfs find should continue after an error"
5843 test_56aa() { # LU-5937
5844 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
5846 local dir=$DIR/$tdir
5849 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
5851 createmany -o $dir/striped_dir/${tfile}- 1024
5852 local dirs=$($LFS find --size +8k $dir/)
5854 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5856 run_test 56aa "lfs find --size under striped dir"
5858 test_56ab() { # LU-10705
5859 test_mkdir $DIR/$tdir
5860 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
5861 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
5862 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
5863 # Flush writes to ensure valid blocks. Need to be more thorough for
5864 # ZFS, since blocks are not allocated/returned to client immediately.
5866 wait_zfs_commit ost1 2
5867 cancel_lru_locks osc
5870 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
5872 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
5874 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
5875 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
5877 rm -f $DIR/$tdir/$tfile.[123]
5879 run_test 56ab "lfs find --blocks"
5882 # Create composite files with one component
5883 local dir=$DIR/$tdir
5885 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
5886 # Create composite files with three components
5887 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
5888 # Create non-composite files
5889 createmany -o $dir/${tfile}- 10
5891 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
5893 [[ $nfiles == 10 ]] ||
5894 error "lfs find -E 1M found $nfiles != 10 files"
5896 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
5897 [[ $nfiles == 25 ]] ||
5898 error "lfs find ! -E 1M found $nfiles != 25 files"
5900 # All files have a component that starts at 0
5901 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
5902 [[ $nfiles == 35 ]] ||
5903 error "lfs find --component-start 0 - $nfiles != 35 files"
5905 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
5906 [[ $nfiles == 15 ]] ||
5907 error "lfs find --component-start 2M - $nfiles != 15 files"
5909 # All files created here have a componenet that does not starts at 2M
5910 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
5911 [[ $nfiles == 35 ]] ||
5912 error "lfs find ! --component-start 2M - $nfiles != 35 files"
5914 # Find files with a specified number of components
5915 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
5916 [[ $nfiles == 15 ]] ||
5917 error "lfs find --component-count 3 - $nfiles != 15 files"
5919 # Remember non-composite files have a component count of zero
5920 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
5921 [[ $nfiles == 10 ]] ||
5922 error "lfs find --component-count 0 - $nfiles != 10 files"
5924 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
5925 [[ $nfiles == 20 ]] ||
5926 error "lfs find ! --component-count 3 - $nfiles != 20 files"
5928 # All files have a flag called "init"
5929 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
5930 [[ $nfiles == 35 ]] ||
5931 error "lfs find --component-flags init - $nfiles != 35 files"
5933 # Multi-component files will have a component not initialized
5934 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
5935 [[ $nfiles == 15 ]] ||
5936 error "lfs find !--component-flags init - $nfiles != 15 files"
5941 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
5944 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
5945 skip "Need MDS version at least 2.10.57"
5955 # create mirrored directories and mirrored files
5956 mkdir $td || error "mkdir $td failed"
5957 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
5958 createmany -o $tf- 10 || error "create $tf- failed"
5960 for i in $(seq 2); do
5962 mkdir $dir || error "mkdir $dir failed"
5963 $LFS mirror create -N$((3 + i)) $dir ||
5964 error "create mirrored dir $dir failed"
5965 createmany -o $dir/$tfile- 10 ||
5966 error "create $dir/$tfile- failed"
5969 # change the states of some mirrored files
5971 for i in $(seq 2); do
5973 for j in $(seq 4 9); do
5974 echo foo > $dir/$tfile-$j
5978 # find mirrored files with specific mirror count
5979 cmd="$LFS find --mirror-count 3 --type f $td"
5980 nfiles=$($cmd | wc -l)
5981 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
5983 cmd="$LFS find ! --mirror-count 3 --type f $td"
5984 nfiles=$($cmd | wc -l)
5985 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
5987 cmd="$LFS find --mirror-count +2 --type f $td"
5988 nfiles=$($cmd | wc -l)
5989 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
5991 cmd="$LFS find --mirror-count -6 --type f $td"
5992 nfiles=$($cmd | wc -l)
5993 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
5995 # find mirrored files with specific file state
5996 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
5997 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
5999 cmd="$LFS find --mirror-state=ro --type f $td"
6000 nfiles=$($cmd | wc -l)
6001 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
6003 cmd="$LFS find ! --mirror-state=ro --type f $td"
6004 nfiles=$($cmd | wc -l)
6005 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6007 cmd="$LFS find --mirror-state=wp --type f $td"
6008 nfiles=$($cmd | wc -l)
6009 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6011 cmd="$LFS find ! --mirror-state=sp --type f $td"
6012 nfiles=$($cmd | wc -l)
6013 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6015 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6018 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6019 # note test will not do anything if MDS is not local
6020 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
6021 skip_env "ldiskfs only test"
6023 remote_mds_nodsh && skip "remote MDS with nodsh"
6025 local MNTDEV="osd*.*MDT*.mntdev"
6026 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6027 [ -z "$DEV" ] && error "can't access $MNTDEV"
6028 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
6029 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
6030 error "can't access $DEV"
6031 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
6032 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
6036 run_test 57a "verify MDS filesystem created with large inodes =="
6039 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6040 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
6041 skip_env "ldiskfs only test"
6043 remote_mds_nodsh && skip "remote MDS with nodsh"
6045 local dir=$DIR/$tdir
6048 local fileN=$dir/f$filecount
6050 rm -rf $dir || error "removing $dir"
6052 local mdtidx=$($LFS getstripe -m $dir)
6053 local mdtname=MDT$(printf %04x $mdtidx)
6054 local facet=mds$((mdtidx + 1))
6056 echo "mcreating $filecount files"
6057 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
6059 # verify that files do not have EAs yet
6060 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
6061 error "$file1 has an EA"
6062 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
6063 error "$fileN has an EA"
6067 df $dir #make sure we get new statfs data
6068 local mdsfree=$(do_facet $facet \
6069 lctl get_param -n osd*.*$mdtname.kbytesfree)
6070 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6073 echo "opening files to create objects/EAs"
6074 for file in $(seq -f $dir/f%g 1 $filecount); do
6075 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
6076 error "opening $file"
6079 # verify that files have EAs now
6080 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
6081 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
6083 sleep 1 #make sure we get new statfs data
6085 local mdsfree2=$(do_facet $facet \
6086 lctl get_param -n osd*.*$mdtname.kbytesfree)
6087 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6089 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
6090 if [ "$mdsfree" != "$mdsfree2" ]; then
6091 error "MDC before $mdcfree != after $mdcfree2"
6093 echo "MDC before $mdcfree != after $mdcfree2"
6094 echo "unable to confirm if MDS has large inodes"
6099 run_test 57b "default LOV EAs are stored inside large inodes ==="
6102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6103 [ -z "$(which wiretest 2>/dev/null)" ] &&
6104 skip_env "could not find wiretest"
6108 run_test 58 "verify cross-platform wire constants =============="
6111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6113 echo "touch 130 files"
6114 createmany -o $DIR/f59- 130
6116 unlinkmany $DIR/f59- 130
6118 # wait for commitment of removal
6119 wait_delete_completed
6121 run_test 59 "verify cancellation of llog records async ========="
6123 TEST60_HEAD="test_60 run $RANDOM"
6125 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6126 remote_mgs_nodsh && skip "remote MGS with nodsh"
6127 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6128 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6129 skip_env "missing subtest run-llog.sh"
6131 log "$TEST60_HEAD - from kernel mode"
6132 do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
6133 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
6134 do_facet mgs $LCTL dk > $TMP/$tfile
6136 # LU-6388: test llog_reader
6137 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6138 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6139 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6140 skip_env "missing llog_reader"
6141 local fstype=$(facet_fstype mgs)
6142 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6143 skip_env "Only for ldiskfs or zfs type mgs"
6145 local mntpt=$(facet_mntpt mgs)
6146 local mgsdev=$(mgsdevname 1)
6158 #get fid and record list
6159 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6161 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6163 #remount mgs as ldiskfs or zfs type
6164 stop mgs || error "stop mgs failed"
6165 mount_fstype mgs || error "remount mgs failed"
6166 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6169 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6170 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6175 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6177 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6179 echo "obj_file is $obj_file"
6180 do_facet mgs $llog_reader $obj_file
6182 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6183 awk '{ print $3 }' | sed -e "s/^type=//g")
6184 if [ $rec_type != $rec ]; then
6185 echo "FAILED test_60a wrong record type $rec_type," \
6191 #check obj path if record type is LLOG_LOGID_MAGIC
6192 if [ "$rec" == "1064553b" ]; then
6193 path=$(do_facet mgs $llog_reader $obj_file |
6194 grep "path=" | awk '{ print $NF }' |
6195 sed -e "s/^path=//g")
6196 if [ $obj_file != $mntpt/$path ]; then
6197 echo "FAILED test_60a wrong obj path" \
6198 "$montpt/$path, should be $obj_file"
6205 #restart mgs before "error", otherwise it will block the next test
6206 stop mgs || error "stop mgs failed"
6207 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6208 $pass || error "test failed, see FAILED test_60a messages for specifics"
6210 run_test 60a "llog_test run from kernel module and test llog_reader"
6213 remote_mgs_nodsh && skip "remote MGS with nodsh"
6215 # test old logid format
6216 if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
6217 do_facet mgs $LCTL dl | grep MGS
6218 do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
6219 error "old llog_print failed"
6222 # test new logid format
6223 if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
6224 do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
6225 error "new llog_print failed"
6228 run_test 60aa "llog_print works with FIDs and simple names"
6231 # test llog_print with params
6233 [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.11.51) ]] ||
6234 skip "Need server version greater than 2.11.51"
6239 orig_val=$(do_facet mgs $LCTL get_param jobid_name)
6240 do_facet mgs $LCTL set_param -P jobid_name="testname"
6242 yaml=$(do_facet mgs $LCTL --device MGS llog_print params |
6243 grep jobid_name | tail -n 1)
6245 local param=`awk '{ print $10 }' <<< "$yaml"`
6246 local val=`awk '{ print $12 }' <<< "$yaml"`
6247 #return to the default
6248 do_facet mgs $LCTL set_param -P jobid_name=$orig_val
6249 [ $val = "testname" ] || error "bad value: $val"
6250 [ $param = "jobid_name," ] || error "Bad param: $param"
6252 run_test 60ab "llog_print params output values from set_param -P"
6254 test_60b() { # bug 6411
6255 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6258 LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6270 [[ $LLOG_COUNT -gt 100 ]] &&
6271 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6273 run_test 60b "limit repeated messages from CERROR/CWARN ========"
6276 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6278 echo "create 5000 files"
6279 createmany -o $DIR/f60c- 5000
6280 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6281 lctl set_param fail_loc=0x80000137
6282 unlinkmany $DIR/f60c- 5000
6283 lctl set_param fail_loc=0
6285 run_test 60c "unlink file when mds full"
6288 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6290 SAVEPRINTK=$(lctl get_param -n printk)
6291 # verify "lctl mark" is even working"
6292 MESSAGE="test message ID $RANDOM $$"
6293 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6294 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6296 lctl set_param printk=0 || error "set lnet.printk failed"
6297 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6298 MESSAGE="new test message ID $RANDOM $$"
6299 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6300 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6301 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6303 lctl set_param -n printk="$SAVEPRINTK"
6305 run_test 60d "test printk console message masking"
6308 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6309 remote_mds_nodsh && skip "remote MDS with nodsh"
6312 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6313 do_facet mds1 lctl set_param fail_loc=0x15b
6316 run_test 60e "no space while new llog is being created"
6319 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6322 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
6323 cancel_lru_locks osc
6324 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6327 run_test 61 "mmap() writes don't make sync hang ================"
6329 # bug 2330 - insufficient obd_match error checking causes LBUG
6331 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6335 cancel_lru_locks osc
6336 lctl set_param fail_loc=0x405
6337 cat $f && error "cat succeeded, expect -EIO"
6338 lctl set_param fail_loc=0
6340 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6341 # match every page all of the time.
6342 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6344 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6345 # Though this test is irrelevant anymore, it helped to reveal some
6346 # other grant bugs (LU-4482), let's keep it.
6347 test_63a() { # was test_63
6348 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6350 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
6352 for i in `seq 10` ; do
6353 dd if=/dev/zero of=$DIR/f63 bs=8k &
6359 rm -f $DIR/f63 || true
6361 run_test 63a "Verify oig_wait interruption does not crash ======="
6363 # bug 2248 - async write errors didn't return to application on sync
6364 # bug 3677 - async write errors left page locked
6366 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6369 lctl set_param debug=-1
6371 # ensure we have a grant to do async writes
6372 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6375 sync # sync lest earlier test intercept the fail_loc
6377 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6378 lctl set_param fail_loc=0x80000406
6379 $MULTIOP $DIR/$tfile Owy && \
6380 error "sync didn't return ENOMEM"
6381 sync; sleep 2; sync # do a real sync this time to flush page
6382 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6383 error "locked page left in cache after async error" || true
6386 run_test 63b "async write errors should be returned to fsync ==="
6389 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6392 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6394 run_test 64a "verify filter grant calculations (in kernel) ====="
6397 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6399 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6401 run_test 64b "check out-of-space detection on client"
6404 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6406 run_test 64c "verify grant shrink"
6408 # this does exactly what osc_request.c:osc_announce_cached() does in
6409 # order to calculate max amount of grants to ask from server
6413 local page_size=$(get_page_size client)
6415 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
6416 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
6418 ((rpc_in_flight ++));
6419 nrpages=$((nrpages * rpc_in_flight))
6421 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
6423 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / page_size))
6425 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6426 local undirty=$((nrpages * page_size))
6428 local max_extent_pages
6429 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
6430 grep grant_max_extent_size | awk '{print $2}')
6431 max_extent_pages=$((max_extent_pages / page_size))
6432 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6433 local grant_extent_tax
6434 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6435 grep grant_extent_tax | awk '{print $2}')
6437 undirty=$((undirty + nrextents * grant_extent_tax))
6442 # this is size of unit for grant allocation. It should be equal to
6443 # what tgt_grant.c:tgt_grant_chunk() calculates
6447 local grant_extent_tax
6449 max_brw_size=$($LCTL get_param osc.${tgt}.import |
6450 grep max_brw_size | awk '{print $2}')
6452 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6453 grep grant_extent_tax | awk '{print $2}')
6455 echo $(((max_brw_size + grant_extent_tax) * 2))
6459 [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] &&
6460 skip "OST < 2.10.55 doesn't limit grants enough"
6462 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
6463 local file=$DIR/$tfile
6465 [[ $($LCTL get_param osc.${tgt}.import |
6466 grep "connect_flags:.*grant_param") ]] ||
6467 skip "no grant_param connect flag"
6469 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
6471 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
6473 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
6474 stack_trap "rm -f $file" EXIT
6476 $SETSTRIPE $file -i 0 -c 1
6477 dd if=/dev/zero of=$file bs=1M count=1000 &
6482 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
6483 if [[ $cur_grant -gt $max_cur_granted ]]
6486 error "cur_grant $cur_grant > $max_cur_granted"
6489 [[ $? -ne 0 ]] && break;
6494 wait_delete_completed
6495 $LCTL set_param debug="$olddebug" 2> /dev/null || true
6497 run_test 64d "check grant limit exceed"
6499 # bug 1414 - set/get directories' stripe info
6501 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6503 test_mkdir $DIR/$tdir
6505 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
6507 run_test 65a "directory with no stripe info"
6510 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6512 test_mkdir $DIR/$tdir
6513 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6515 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6518 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
6520 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
6523 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6524 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
6526 test_mkdir $DIR/$tdir
6527 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
6529 $LFS setstripe -S $((stripesize * 4)) -i 1 \
6530 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
6532 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
6534 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
6537 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6539 test_mkdir $DIR/$tdir
6540 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
6541 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6543 if [[ $STRIPECOUNT -le 0 ]]; then
6545 elif [[ $STRIPECOUNT -gt 2000 ]]; then
6546 #LOV_MAX_STRIPE_COUNT is 2000
6547 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
6549 sc=$(($STRIPECOUNT - 1))
6551 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
6552 touch $DIR/$tdir/f4 $DIR/$tdir/f5
6553 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
6554 error "lverify failed"
6556 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
6559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6561 test_mkdir $DIR/$tdir
6563 $SETSTRIPE $DIR/$tdir || error "setstripe"
6564 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
6565 error "no stripe info failed"
6567 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
6569 run_test 65e "directory setstripe defaults"
6572 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6574 test_mkdir $DIR/${tdir}f
6575 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
6577 run_test 65f "dir setstripe permission (should return error) ==="
6580 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6582 test_mkdir $DIR/$tdir
6583 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6585 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6586 error "setstripe -S failed"
6587 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
6588 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6589 error "delete default stripe failed"
6591 run_test 65g "directory setstripe -d"
6594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6596 test_mkdir $DIR/$tdir
6597 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6599 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6600 error "setstripe -S failed"
6601 test_mkdir $DIR/$tdir/dd1
6602 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
6603 error "stripe info inherit failed"
6605 run_test 65h "directory stripe info inherit ===================="
6608 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6610 save_layout_restore_at_exit $MOUNT
6612 # bug6367: set non-default striping on root directory
6613 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
6615 # bug12836: getstripe on -1 default directory striping
6616 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
6618 # bug12836: getstripe -v on -1 default directory striping
6619 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
6621 # bug12836: new find on -1 default directory striping
6622 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
6624 run_test 65i "various tests to set root directory striping"
6626 test_65j() { # bug6367
6627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6631 # if we aren't already remounting for each test, do so for this test
6632 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
6633 cleanup || error "failed to unmount"
6637 save_layout_restore_at_exit $MOUNT
6639 $SETSTRIPE -d $MOUNT || error "setstripe failed"
6641 run_test 65j "set default striping on root directory (bug 6367)="
6645 wait_delete_completed
6646 do_facet $SINGLEMDS "lctl set_param -n \
6647 osp.$ost*MDT0000.max_create_count=$max_count"
6648 do_facet $SINGLEMDS "lctl set_param -n \
6649 osp.$ost*MDT0000.create_count=$count"
6650 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6651 echo $INACTIVE_OSC "is Activate"
6653 wait_osc_import_state mds ost$ostnum FULL
6656 test_65k() { # bug11679
6657 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6658 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6659 remote_mds_nodsh && skip "remote MDS with nodsh"
6661 local disable_precreate=true
6662 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
6663 disable_precreate=false
6665 echo "Check OST status: "
6666 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
6667 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
6669 for OSC in $MDS_OSCS; do
6670 echo $OSC "is active"
6671 do_facet $SINGLEMDS lctl --device %$OSC activate
6674 for INACTIVE_OSC in $MDS_OSCS; do
6675 local ost=$(osc_to_ost $INACTIVE_OSC)
6676 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
6677 lov.*md*.target_obd |
6678 awk -F: /$ost/'{ print $1 }' | head -n 1)
6681 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
6682 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
6684 echo "Deactivate: " $INACTIVE_OSC
6685 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
6687 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
6688 osp.$ost*MDT0000.create_count")
6689 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
6690 osp.$ost*MDT0000.max_create_count")
6691 $disable_precreate &&
6692 do_facet $SINGLEMDS "lctl set_param -n \
6693 osp.$ost*MDT0000.max_create_count=0"
6695 for idx in $(seq 0 $((OSTCOUNT - 1))); do
6696 [ -f $DIR/$tdir/$idx ] && continue
6697 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
6698 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
6700 error "setstripe $idx should succeed"; }
6701 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
6703 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
6706 do_facet $SINGLEMDS "lctl set_param -n \
6707 osp.$ost*MDT0000.max_create_count=$max_count"
6708 do_facet $SINGLEMDS "lctl set_param -n \
6709 osp.$ost*MDT0000.create_count=$count"
6710 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6711 echo $INACTIVE_OSC "is Activate"
6713 wait_osc_import_state mds ost$ostnum FULL
6716 run_test 65k "validate manual striping works properly with deactivated OSCs"
6718 test_65l() { # bug 12836
6719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6721 test_mkdir -p $DIR/$tdir/test_dir
6722 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
6723 $LFS find -mtime -1 $DIR/$tdir >/dev/null
6725 run_test 65l "lfs find on -1 stripe dir ========================"
6728 local layout=$(save_layout $MOUNT)
6729 $RUNAS $SETSTRIPE -c 2 $MOUNT && {
6730 restore_layout $MOUNT $layout
6731 error "setstripe should fail by non-root users"
6735 run_test 65m "normal user can't set filesystem default stripe"
6737 # bug 2543 - update blocks count on client
6739 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6742 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6743 sync; sync_all_data; sync; sync_all_data
6744 cancel_lru_locks osc
6745 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6746 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6748 run_test 66 "update inode blocks count on client ==============="
6751 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6755 swapon -s | awk '($1 == "'$1'") { print $4 }'
6758 # bug5265, obdfilter oa2dentry return -ENOENT
6759 # #define OBD_FAIL_SRV_ENOENT 0x217
6761 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6762 remote_ost_nodsh && skip "remote OST with nodsh"
6765 $SETSTRIPE -c 1 -i 0 $f
6767 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6769 do_facet ost1 lctl set_param fail_loc=0x217
6770 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6771 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6773 do_facet ost1 lctl set_param fail_loc=0
6774 $DIRECTIO write $f 0 2 || error "write error"
6776 cancel_lru_locks osc
6777 $DIRECTIO read $f 0 1 || error "read error"
6779 do_facet ost1 lctl set_param fail_loc=0x217
6780 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6782 do_facet ost1 lctl set_param fail_loc=0
6785 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6788 test_mkdir $DIR/$tdir
6789 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6790 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6792 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6794 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6795 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6796 [ "$RUNAS_ID" = "$UID" ] &&
6797 skip_env "RUNAS_ID = UID = $UID -- skipping"
6798 # Check that testing environment is properly set up. Skip if not
6799 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
6800 skip_env "User $RUNAS_ID does not exist - skipping"
6803 chmod 777 $DIR/$tfile
6804 chmod ug+s $DIR/$tfile
6805 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6806 error "$RUNAS dd $DIR/$tfile failed"
6807 # See if we are still setuid/sgid
6808 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6809 error "S/gid is not dropped on write"
6810 # Now test that MDS is updated too
6811 cancel_lru_locks mdc
6812 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6813 error "S/gid is not dropped on MDS"
6816 run_test 72a "Test that remove suid works properly (bug5695) ===="
6818 test_72b() { # bug 24226 -- keep mode setting when size is not changing
6821 [ "$RUNAS_ID" = "$UID" ] &&
6822 skip_env "RUNAS_ID = UID = $UID -- skipping"
6823 [ "$RUNAS_ID" -eq 0 ] &&
6824 skip_env "RUNAS_ID = 0 -- skipping"
6825 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6826 # Check that testing environment is properly set up. Skip if not
6827 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
6828 skip_env "User $RUNAS_ID does not exist - skipping"
6830 touch $DIR/${tfile}-f{g,u}
6831 test_mkdir $DIR/${tfile}-dg
6832 test_mkdir $DIR/${tfile}-du
6833 chmod 770 $DIR/${tfile}-{f,d}{g,u}
6834 chmod g+s $DIR/${tfile}-{f,d}g
6835 chmod u+s $DIR/${tfile}-{f,d}u
6836 for perm in 777 2777 4777; do
6837 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
6838 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
6839 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
6840 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
6844 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
6846 # bug 3462 - multiple simultaneous MDC requests
6848 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6850 test_mkdir $DIR/d73-1
6851 test_mkdir $DIR/d73-2
6852 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
6855 lctl set_param fail_loc=0x80000129
6856 $MULTIOP $DIR/d73-1/f73-2 Oc &
6858 lctl set_param fail_loc=0
6860 $MULTIOP $DIR/d73-2/f73-3 Oc &
6864 wait $pid1 || return 1
6868 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
6869 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
6870 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
6874 run_test 73 "multiple MDC requests (should not deadlock)"
6876 test_74a() { # bug 6149, 6184
6877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6880 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6882 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6883 # will spin in a tight reconnection loop
6884 $LCTL set_param fail_loc=0x8000030e
6885 # get any lock that won't be difficult - lookup works.
6887 $LCTL set_param fail_loc=0
6891 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
6893 test_74b() { # bug 13310
6894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6896 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
6898 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
6899 # will spin in a tight reconnection loop
6900 $LCTL set_param fail_loc=0x8000030e
6901 # get a "difficult" lock
6903 $LCTL set_param fail_loc=0
6907 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
6910 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6912 #define OBD_FAIL_LDLM_NEW_LOCK
6913 $LCTL set_param fail_loc=0x319
6914 touch $DIR/$tfile && error "touch successful"
6915 $LCTL set_param fail_loc=0
6918 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
6921 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
6924 test_76() { # Now for bug 20433, added originally in bug 1443
6925 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6927 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
6929 cancel_lru_locks osc
6930 BEFORE_INODES=$(num_inodes)
6931 echo "before inodes: $BEFORE_INODES"
6933 [ "$SLOW" = "no" ] && COUNT=100
6934 for i in $(seq $COUNT); do
6938 cancel_lru_locks osc
6939 AFTER_INODES=$(num_inodes)
6940 echo "after inodes: $AFTER_INODES"
6942 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
6944 AFTER_INODES=$(num_inodes)
6946 echo "wait $wait seconds inodes: $AFTER_INODES"
6947 if [ $wait -gt 30 ]; then
6948 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
6952 run_test 76 "confirm clients recycle inodes properly ===="
6958 # Note: in sptlrpc modes which enable its own bulk checksum, the
6959 # original crc32_le bulk checksum will be automatically disabled,
6960 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
6961 # will be checked by sptlrpc code against sptlrpc bulk checksum.
6962 # In this case set_checksums() will not be no-op, because sptlrpc
6963 # bulk checksum will be enabled all through the test.
6965 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
6966 lctl set_param -n osc.*.checksums $1
6970 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6971 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
6972 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
6973 tr -d [] | head -n1)}
6976 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
6977 log "set checksum type to $1"
6980 F77_TMP=$TMP/f77-temp
6983 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
6984 error "error writing to $F77_TMP"
6987 test_77a() { # bug 10889
6988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6989 $GSS && skip_env "could not run with gss"
6991 [ ! -f $F77_TMP ] && setup_f77
6993 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
6997 run_test 77a "normal checksum read/write operation"
6999 test_77b() { # bug 10889
7000 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7001 $GSS && skip_env "could not run with gss"
7003 [ ! -f $F77_TMP ] && setup_f77
7004 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7005 $LCTL set_param fail_loc=0x80000409
7008 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7009 error "dd error: $?"
7010 $LCTL set_param fail_loc=0
7012 for algo in $CKSUM_TYPES; do
7013 cancel_lru_locks osc
7014 set_checksum_type $algo
7015 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7016 $LCTL set_param fail_loc=0x80000408
7017 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7018 $LCTL set_param fail_loc=0
7021 set_checksum_type $ORIG_CSUM_TYPE
7024 run_test 77b "checksum error on client write, read"
7029 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7031 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7032 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7033 $check_ost && [ -n "$ost_file_prefix" ] &&
7034 do_facet ost1 rm -f ${ost_file_prefix}\*
7038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7039 $GSS && skip_env "could not run with gss"
7040 remote_ost_nodsh && skip "remote OST with nodsh"
7043 local osc_file_prefix
7045 local check_ost=false
7046 local ost_file_prefix
7052 # ensure corruption will occur on first OSS/OST
7053 $LFS setstripe -i 0 $DIR/$tfile
7055 [ ! -f $F77_TMP ] && setup_f77
7056 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7057 error "dd write error: $?"
7058 fid=$($LFS path2fid $DIR/$tfile)
7060 if [ $(lustre_version_code ost1) -ge $(version_code 2.9.57) ]
7063 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7064 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7066 echo "OSS do not support bulk pages dump upon error"
7069 osc_file_prefix=$($LCTL get_param -n debug_path)
7070 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7072 trap cleanup_77c EXIT
7075 # enable bulk pages dump upon error on Client
7076 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7077 # enable bulk pages dump upon error on OSS
7079 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7081 # flush Client cache to allow next read to reach OSS
7082 cancel_lru_locks osc
7084 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7085 $LCTL set_param fail_loc=0x80000408
7086 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7087 $LCTL set_param fail_loc=0
7091 # check cksum dump on Client
7092 osc_file=$(ls ${osc_file_prefix}*)
7093 [ -n "$osc_file" ] || error "no checksum dump file on Client"
7094 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
7095 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
7096 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
7097 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
7099 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
7100 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7101 error "dump content does not match on Client"
7103 $check_ost || skip "No need to check cksum dump on OSS"
7105 # check cksum dump on OSS
7106 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
7107 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
7108 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
7109 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
7110 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7111 error "dump content does not match on OSS"
7115 run_test 77c "checksum error on client read with debug"
7117 test_77d() { # bug 10889
7118 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7119 $GSS && skip_env "could not run with gss"
7121 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7122 $LCTL set_param fail_loc=0x80000409
7124 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7125 error "direct write: rc=$?"
7126 $LCTL set_param fail_loc=0
7129 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7130 $LCTL set_param fail_loc=0x80000408
7132 cancel_lru_locks osc
7133 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7134 error "direct read: rc=$?"
7135 $LCTL set_param fail_loc=0
7138 run_test 77d "checksum error on OST direct write, read"
7140 test_77f() { # bug 10889
7141 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7142 $GSS && skip_env "could not run with gss"
7145 for algo in $CKSUM_TYPES; do
7146 cancel_lru_locks osc
7147 set_checksum_type $algo
7148 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7149 $LCTL set_param fail_loc=0x409
7150 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
7151 error "direct write succeeded"
7152 $LCTL set_param fail_loc=0
7154 set_checksum_type $ORIG_CSUM_TYPE
7157 run_test 77f "repeat checksum error on write (expect error)"
7159 test_77g() { # bug 10889
7160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7161 $GSS && skip_env "could not run with gss"
7162 remote_ost_nodsh && skip "remote OST with nodsh"
7164 [ ! -f $F77_TMP ] && setup_f77
7166 local file=$DIR/$tfile
7167 stack_trap "rm -f $file" EXIT
7169 $SETSTRIPE -c 1 -i 0 $file
7170 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
7171 do_facet ost1 lctl set_param fail_loc=0x8000021a
7173 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
7174 error "write error: rc=$?"
7175 do_facet ost1 lctl set_param fail_loc=0
7178 cancel_lru_locks osc
7179 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
7180 do_facet ost1 lctl set_param fail_loc=0x8000021b
7182 cmp $F77_TMP $file || error "file compare failed"
7183 do_facet ost1 lctl set_param fail_loc=0
7186 run_test 77g "checksum error on OST write, read"
7188 test_77k() { # LU-10906
7189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7190 $GSS && skip_env "could not run with gss"
7192 local cksum_param="osc.$FSNAME*.checksums"
7193 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
7197 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
7198 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
7199 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
7203 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
7204 error "failed to set checksum=$i on MGS"
7205 wait_update $HOSTNAME "$get_checksum" $i
7207 echo "remount client, checksum should be $i"
7208 remount_client $MOUNT || "failed to remount client"
7209 checksum=$(eval $get_checksum)
7210 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7213 for opt in "checksum" "nochecksum"; do
7214 #remount with mount option
7215 echo "remount client with option $opt, checksum should be $i"
7216 umount_client $MOUNT || "failed to umount client"
7217 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
7218 "failed to mount client with option '$opt'"
7219 checksum=$(eval $get_checksum)
7220 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7224 remount_client $MOUNT || "failed to remount client"
7226 run_test 77k "enable/disable checksum correctly"
7228 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
7237 test_78() { # bug 10901
7238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7239 remote_ost || skip_env "local OST"
7242 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
7243 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
7244 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
7245 echo "MemTotal: $MEMTOTAL"
7247 # reserve 256MB of memory for the kernel and other running processes,
7248 # and then take 1/2 of the remaining memory for the read/write buffers.
7249 if [ $MEMTOTAL -gt 512 ] ;then
7250 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
7252 # for those poor memory-starved high-end clusters...
7253 MEMTOTAL=$((MEMTOTAL / 2))
7255 echo "Mem to use for directio: $MEMTOTAL"
7257 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
7258 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
7259 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
7260 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
7262 echo "Smallest OST: $SMALLESTOST"
7263 [[ $SMALLESTOST -lt 10240 ]] &&
7264 skip "too small OSTSIZE, useless to run large O_DIRECT test"
7266 trap cleanup_test_78 EXIT
7268 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
7269 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
7271 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
7272 echo "File size: $F78SIZE"
7273 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
7274 for i in $(seq 1 $NSEQ); do
7275 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
7276 echo directIO rdwr round $i of $NSEQ
7277 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
7282 run_test 78 "handle large O_DIRECT writes correctly ============"
7284 test_79() { # bug 12743
7285 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7287 wait_delete_completed
7289 BKTOTAL=$(calc_osc_kbytes kbytestotal)
7290 BKFREE=$(calc_osc_kbytes kbytesfree)
7291 BKAVAIL=$(calc_osc_kbytes kbytesavail)
7293 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
7294 DFTOTAL=`echo $STRING | cut -d, -f1`
7295 DFUSED=`echo $STRING | cut -d, -f2`
7296 DFAVAIL=`echo $STRING | cut -d, -f3`
7297 DFFREE=$(($DFTOTAL - $DFUSED))
7299 ALLOWANCE=$((64 * $OSTCOUNT))
7301 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
7302 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
7303 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
7305 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
7306 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
7307 error "df free($DFFREE) mismatch OST free($BKFREE)"
7309 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
7310 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
7311 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
7314 run_test 79 "df report consistency check ======================="
7316 test_80() { # bug 10718
7317 remote_ost_nodsh && skip "remote OST with nodsh"
7318 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7320 # relax strong synchronous semantics for slow backends like ZFS
7321 local soc="obdfilter.*.sync_on_lock_cancel"
7322 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
7324 if [ "$soc_old" != "never" ] &&
7325 [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
7326 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
7327 facet_active_host $host; done | sort -u)
7328 do_nodes $hosts lctl set_param $soc=never
7331 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
7333 local BEFORE=`date +%s`
7334 cancel_lru_locks osc
7335 local AFTER=`date +%s`
7336 local DIFF=$((AFTER-BEFORE))
7337 if [ $DIFF -gt 1 ] ; then
7338 error "elapsed for 1M@1T = $DIFF"
7341 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
7345 run_test 80 "Page eviction is equally fast at high offsets too ===="
7347 test_81a() { # LU-456
7348 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7349 remote_ost_nodsh && skip "remote OST with nodsh"
7351 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7352 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
7353 do_facet ost1 lctl set_param fail_loc=0x80000228
7355 # write should trigger a retry and success
7356 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
7357 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7359 if [ $RC -ne 0 ] ; then
7360 error "write should success, but failed for $RC"
7363 run_test 81a "OST should retry write when get -ENOSPC ==============="
7365 test_81b() { # LU-456
7366 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7367 remote_ost_nodsh && skip "remote OST with nodsh"
7369 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7370 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
7371 do_facet ost1 lctl set_param fail_loc=0x228
7373 # write should retry several times and return -ENOSPC finally
7374 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
7375 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7378 if [ $RC -ne $ENOSPC ] ; then
7379 error "dd should fail for -ENOSPC, but succeed."
7382 run_test 81b "OST should return -ENOSPC when retry still fails ======="
7384 test_82() { # LU-1031
7385 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
7389 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
7391 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
7393 kill -USR1 $MULTIPID2
7395 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
7396 error "First grouplock does not block second one"
7398 echo "Second grouplock blocks first one"
7400 kill -USR1 $MULTIPID1
7404 run_test 82 "Basic grouplock test"
7407 local sfile="/boot/System.map-$(uname -r)"
7408 [ ! -f $sfile ] && skip "No $sfile found"
7409 # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
7410 $LCTL set_param fail_loc=0x140d
7411 cp $sfile $DIR/$tfile || error "write failed"
7412 diff -c $sfile $DIR/$tfile || error "files are different"
7413 $LCTL set_param fail_loc=0
7416 run_test 83 "Short write in ptask ==============================="
7419 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
7421 test_mkdir $DIR/$tdir.cvsroot
7422 chown $RUNAS_ID $DIR/$tdir.cvsroot
7425 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
7428 # some versions of cvs import exit(1) when asked to import links or
7429 # files they can't read. ignore those files.
7430 local toignore=$(find . -type l -printf '-I %f\n' -o \
7431 ! -perm /4 -printf '-I %f\n')
7432 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
7433 $tdir.reposname vtag rtag
7436 test_mkdir $DIR/$tdir.reposname
7437 chown $RUNAS_ID $DIR/$tdir.reposname
7438 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
7440 cd $DIR/$tdir.reposname
7442 $RUNAS cvs add -m 'addmsg' foo99
7444 $RUNAS cvs commit -m 'nomsg' foo99
7445 rm -fr $DIR/$tdir.cvsroot
7447 run_test 99 "cvs strange file/directory operations"
7450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7451 [[ "$NETTYPE" =~ tcp ]] ||
7452 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
7453 remote_ost_nodsh && skip "remote OST with nodsh"
7454 remote_mds_nodsh && skip "remote MDS with nodsh"
7456 skip "useless for local single node setup"
7458 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
7459 [ "$PROT" != "tcp" ] && continue
7460 RPORT=$(echo $REMOTE | cut -d: -f2)
7461 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
7464 LPORT=`echo $LOCAL | cut -d: -f2`
7465 if [ $LPORT -ge 1024 ]; then
7466 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
7468 error_exit "local: $LPORT > 1024, remote: $RPORT"
7471 [ "$rc" = 0 ] || error_exit "privileged port not found" )
7473 run_test 100 "check local port using privileged port ==========="
7475 function get_named_value()
7484 echo $line | sed "s/^$tag[ ]*//"
7491 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
7492 awk '/^max_cached_mb/ { print $2 }')
7495 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
7500 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7501 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
7506 local cache_limit=32
7508 $LCTL set_param -n osc.*-osc*.rpc_stats 0
7509 trap cleanup_101a EXIT
7510 $LCTL set_param -n llite.*.read_ahead_stats 0
7511 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
7514 # randomly read 10000 of 64K chunks from file 3x 32MB in size
7516 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
7517 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
7520 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
7521 get_named_value 'read but discarded' | cut -d" " -f1); do
7522 discard=$(($discard + $s))
7526 if [[ $(($discard * 10)) -gt $nreads ]]; then
7527 $LCTL get_param osc.*-osc*.rpc_stats
7528 $LCTL get_param llite.*.read_ahead_stats
7529 error "too many ($discard) discarded pages"
7531 rm -f $DIR/$tfile || true
7533 run_test 101a "check read-ahead for random reads"
7536 test_mkdir $DIR/$tdir
7537 local STRIPE_SIZE=$1
7538 local FILE_LENGTH=$2
7541 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
7543 local list=$(comma_list $(osts_nodes))
7544 set_osd_param $list '' read_cache_enable 0
7545 set_osd_param $list '' writethrough_cache_enable 0
7547 trap cleanup_test101bc EXIT
7548 # prepare the read-ahead file
7549 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
7551 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
7552 count=$FILE_SIZE_MB 2> /dev/null
7556 cleanup_test101bc() {
7561 local list=$(comma_list $(osts_nodes))
7562 set_osd_param $list '' read_cache_enable 1
7563 set_osd_param $list '' writethrough_cache_enable 1
7567 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
7572 local STRIPE_SIZE=$2
7573 local FILE_LENGTH=$3
7574 local RA_INC=1048576
7575 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
7576 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
7577 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
7578 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
7579 get_named_value 'read but discarded' |
7580 cut -d" " -f1 | calc_total)
7581 if [[ $DISCARD -gt $discard_limit ]]; then
7582 $LCTL get_param llite.*.read_ahead_stats
7583 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
7585 echo "Read-ahead success for size ${READ_SIZE}"
7590 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7591 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7593 local STRIPE_SIZE=1048576
7594 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
7596 if [ $SLOW == "yes" ]; then
7597 local FILE_LENGTH=$((STRIDE_SIZE * 64))
7599 local FILE_LENGTH=$((STRIDE_SIZE * 8))
7602 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
7604 # prepare the read-ahead file
7605 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7606 cancel_lru_locks osc
7607 for BIDX in 2 4 8 16 32 64 128 256
7609 local BSIZE=$((BIDX*4096))
7610 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
7611 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
7612 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
7613 $LCTL set_param -n llite.*.read_ahead_stats 0
7614 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
7615 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
7616 cancel_lru_locks osc
7617 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
7622 run_test 101b "check stride-io mode read-ahead ================="
7625 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7627 local STRIPE_SIZE=1048576
7628 local FILE_LENGTH=$((STRIPE_SIZE*100))
7632 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7634 cancel_lru_locks osc
7635 $LCTL set_param osc.*.rpc_stats 0
7636 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
7637 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
7638 local stats=$($LCTL get_param -n $osc_rpc_stats)
7639 local lines=$(echo "$stats" | awk 'END {print NR;}')
7642 if [ $lines -le 20 ]; then
7645 for size in 1 2 4 8; do
7646 local rpc=$(echo "$stats" |
7647 awk '($1 == "'$size':") {print $2; exit; }')
7649 error "Small $((size*4))k read IO $rpc !"
7651 echo "$osc_rpc_stats check passed!"
7656 run_test 101c "check stripe_size aligned read-ahead ================="
7659 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
7660 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
7664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7666 local file=$DIR/$tfile
7667 local sz_MB=${FILESIZE_101d:-500}
7668 local ra_MB=${READAHEAD_MB:-40}
7670 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
7671 [ $free_MB -lt $sz_MB ] &&
7672 skip "Need free space ${sz_MB}M, have ${free_MB}M"
7674 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
7675 $SETSTRIPE -c -1 $file || error "setstripe failed"
7677 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
7678 echo Cancel LRU locks on lustre client to flush the client cache
7679 cancel_lru_locks osc
7681 echo Disable read-ahead
7682 local old_READAHEAD=$(set_read_ahead 0)
7684 echo Reading the test file $file with read-ahead disabled
7685 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7687 echo Cancel LRU locks on lustre client to flush the client cache
7688 cancel_lru_locks osc
7689 echo Enable read-ahead with ${ra_MB}MB
7690 set_read_ahead $ra_MB
7692 echo Reading the test file $file with read-ahead enabled
7693 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7695 echo "read-ahead disabled time read $raOFF"
7696 echo "read-ahead enabled time read $raON"
7698 set_read_ahead $old_READAHEAD
7700 wait_delete_completed
7702 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
7703 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
7705 run_test 101d "file read with and without read-ahead enabled"
7708 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7710 local file=$DIR/$tfile
7711 local size_KB=500 #KB
7715 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
7716 local need_KB=$((count * size_KB))
7717 [[ $free_KB -le $need_KB ]] &&
7718 skip_env "Need free space $need_KB, have $free_KB"
7720 echo "Creating $count ${size_KB}K test files"
7721 for ((i = 0; i < $count; i++)); do
7722 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
7725 echo "Cancel LRU locks on lustre client to flush the client cache"
7726 cancel_lru_locks $OSC
7728 echo "Reset readahead stats"
7729 $LCTL set_param -n llite.*.read_ahead_stats 0
7731 for ((i = 0; i < $count; i++)); do
7732 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
7735 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7736 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7738 for ((i = 0; i < $count; i++)); do
7739 rm -rf $file.$i 2>/dev/null
7742 #10000 means 20% reads are missing in readahead
7743 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
7745 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
7748 which iozone || skip_env "no iozone installed"
7750 local old_debug=$($LCTL get_param debug)
7751 old_debug=${old_debug#*=}
7752 $LCTL set_param debug="reada mmap"
7754 # create a test file
7755 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
7757 echo Cancel LRU locks on lustre client to flush the client cache
7758 cancel_lru_locks osc
7760 echo Reset readahead stats
7761 $LCTL set_param -n llite.*.read_ahead_stats 0
7763 echo mmap read the file with small block size
7764 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
7767 echo checking missing pages
7768 $LCTL get_param llite.*.read_ahead_stats
7769 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7770 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7772 $LCTL set_param debug="$old_debug"
7773 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7776 run_test 101f "check mmap read performance"
7778 test_101g_brw_size_test() {
7780 local pages=$((mb * 1048576 / $(page_size)))
7781 local file=$DIR/$tfile
7783 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7784 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7785 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7786 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7790 stack_trap "rm -f $file" EXIT
7791 $LCTL set_param -n osc.*.rpc_stats=0
7793 # 10 RPCs should be enough for the test
7795 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
7796 { error "dd write ${mb} MB blocks failed"; return 3; }
7797 cancel_lru_locks osc
7798 dd of=/dev/null if=$file bs=${mb}M count=$count ||
7799 { error "dd write ${mb} MB blocks failed"; return 4; }
7801 # calculate number of full-sized read and write RPCs
7802 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7803 sed -n '/pages per rpc/,/^$/p' |
7804 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7805 END { print reads,writes }'))
7806 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7808 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7815 remote_ost_nodsh && skip "remote OST with nodsh"
7818 local osts=$(get_facets OST)
7819 local list=$(comma_list $(osts_nodes))
7820 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7821 local brw_size="obdfilter.*.brw_size"
7822 local ostver=$(lustre_version_code ost1)
7823 local cliver=$(lustre_version_code client)
7825 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7827 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7828 if [ $ostver -ge $(version_code 2.8.52) -o \
7829 \( $ostver -ge $(version_code 2.7.17) -a \
7830 $ostver -lt $(version_code 2.7.50) \) ] &&
7831 [ $cliver -ge $(version_code 2.8.52) -o \
7832 \( $cliver -ge $(version_code 2.7.17) -a \
7833 $cliver -lt $(version_code 2.7.50) \) ]; then
7834 [ $ostver -ge $(version_code 2.9.52) ] && suffix="M"
7835 if [[ $orig_mb -lt 16 ]]; then
7836 save_lustre_params $osts "$brw_size" > $p
7837 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
7838 error "set 16MB RPC size failed"
7840 echo "remount client to enable new RPC size"
7841 remount_client $MOUNT || error "remount_client failed"
7844 test_101g_brw_size_test 16 || error "16MB RPC test failed"
7845 # should be able to set brw_size=12, but no rpc_stats for that
7846 test_101g_brw_size_test 8 || error "8MB RPC test failed"
7849 test_101g_brw_size_test 4 || error "4MB RPC test failed"
7851 if [[ $orig_mb -lt 16 ]]; then
7852 restore_lustre_params < $p
7853 remount_client $MOUNT || error "remount_client restore failed"
7856 rm -f $p $DIR/$tfile
7858 run_test 101g "Big bulk(4/16 MiB) readahead"
7861 test_mkdir $DIR/$tdir
7862 chown $RUNAS_ID $DIR/$tdir
7865 STRIPE_COUNT=$OSTCOUNT
7866 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
7868 trap cleanup_test102 EXIT
7870 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
7872 for num in 1 2 3 4; do
7873 for count in $(seq 1 $STRIPE_COUNT); do
7874 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
7875 local size=`expr $STRIPE_SIZE \* $num`
7876 local file=file"$num-$idx-$count"
7877 $1 $SETSTRIPE -S $size -i $idx -c $count $file
7883 $1 tar cf $TMP/f102.tar $tdir --xattrs
7889 rm -rf $DIR/d0.sanity/d102
7893 [ "$UID" != 0 ] && skip "must run as root"
7894 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
7895 skip_env "must have user_xattr"
7897 [ -z "$(which setfattr 2>/dev/null)" ] &&
7898 skip_env "could not find setfattr"
7900 local testfile=$DIR/$tfile
7903 echo "set/get xattr..."
7904 setfattr -n trusted.name1 -v value1 $testfile ||
7905 error "setfattr -n trusted.name1=value1 $testfile failed"
7906 getfattr -n trusted.name1 $testfile 2> /dev/null |
7907 grep "trusted.name1=.value1" ||
7908 error "$testfile missing trusted.name1=value1"
7910 setfattr -n user.author1 -v author1 $testfile ||
7911 error "setfattr -n user.author1=author1 $testfile failed"
7912 getfattr -n user.author1 $testfile 2> /dev/null |
7913 grep "user.author1=.author1" ||
7914 error "$testfile missing trusted.author1=author1"
7917 setfattr -n trusted.name2 -v value2 $testfile ||
7918 error "$testfile unable to set trusted.name2"
7919 setfattr -n trusted.name3 -v value3 $testfile ||
7920 error "$testfile unable to set trusted.name3"
7921 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
7922 grep "trusted.name" | wc -l) -eq 3 ] ||
7923 error "$testfile missing 3 trusted.name xattrs"
7925 setfattr -n user.author2 -v author2 $testfile ||
7926 error "$testfile unable to set user.author2"
7927 setfattr -n user.author3 -v author3 $testfile ||
7928 error "$testfile unable to set user.author3"
7929 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
7930 grep "user.author" | wc -l) -eq 3 ] ||
7931 error "$testfile missing 3 user.author xattrs"
7933 echo "remove xattr..."
7934 setfattr -x trusted.name1 $testfile ||
7935 error "$testfile error deleting trusted.name1"
7936 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
7937 error "$testfile did not delete trusted.name1 xattr"
7939 setfattr -x user.author1 $testfile ||
7940 error "$testfile error deleting user.author1"
7941 echo "set lustre special xattr ..."
7942 $LFS setstripe -c1 $testfile
7943 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
7944 awk -F "=" '/trusted.lov/ { print $2 }' )
7945 setfattr -n "trusted.lov" -v $lovea $testfile ||
7946 error "$testfile doesn't ignore setting trusted.lov again"
7947 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
7948 error "$testfile allow setting invalid trusted.lov"
7951 run_test 102a "user xattr test =================================="
7954 [ -z "$(which setfattr 2>/dev/null)" ] &&
7955 skip_env "could not find setfattr"
7956 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7958 # b10930: get/set/list trusted.lov xattr
7959 echo "get/set/list trusted.lov xattr ..."
7960 local testfile=$DIR/$tfile
7961 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7962 error "setstripe failed"
7963 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
7964 error "getstripe failed"
7965 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
7966 error "can't get trusted.lov from $testfile"
7968 local testfile2=${testfile}2
7969 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
7970 grep "trusted.lov" | sed -e 's/[^=]\+=//')
7973 setfattr -n trusted.lov -v $value $testfile2
7974 local stripe_size=$($GETSTRIPE -S $testfile2)
7975 local stripe_count=$($GETSTRIPE -c $testfile2)
7976 [[ $stripe_size -eq 65536 ]] ||
7977 error "stripe size $stripe_size != 65536"
7978 [[ $stripe_count -eq $STRIPECOUNT ]] ||
7979 error "stripe count $stripe_count != $STRIPECOUNT"
7982 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
7985 [ -z "$(which setfattr 2>/dev/null)" ] &&
7986 skip_env "could not find setfattr"
7987 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7989 # b10930: get/set/list lustre.lov xattr
7990 echo "get/set/list lustre.lov xattr ..."
7991 test_mkdir $DIR/$tdir
7992 chown $RUNAS_ID $DIR/$tdir
7993 local testfile=$DIR/$tdir/$tfile
7994 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
7995 error "setstripe failed"
7996 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
7997 error "getstripe failed"
7998 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
7999 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
8001 local testfile2=${testfile}2
8002 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
8003 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8005 $RUNAS $MCREATE $testfile2
8006 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8007 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
8008 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
8009 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8010 [ $stripe_count -eq $STRIPECOUNT ] ||
8011 error "stripe count $stripe_count != $STRIPECOUNT"
8013 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8015 compare_stripe_info1() {
8016 local stripe_index_all_zero=true
8018 for num in 1 2 3 4; do
8019 for count in $(seq 1 $STRIPE_COUNT); do
8020 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8021 local size=$((STRIPE_SIZE * num))
8022 local file=file"$num-$offset-$count"
8023 stripe_size=$($LFS getstripe -S $PWD/$file)
8024 [[ $stripe_size -ne $size ]] &&
8025 error "$file: size $stripe_size != $size"
8026 stripe_count=$($LFS getstripe -c $PWD/$file)
8027 # allow fewer stripes to be created, ORI-601
8028 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8029 error "$file: count $stripe_count != $count"
8030 stripe_index=$($LFS getstripe -i $PWD/$file)
8031 [[ $stripe_index -ne 0 ]] &&
8032 stripe_index_all_zero=false
8036 $stripe_index_all_zero &&
8037 error "all files are being extracted starting from OST index 0"
8041 have_xattrs_include() {
8042 tar --help | grep -q xattrs-include &&
8043 echo --xattrs-include="lustre.*"
8047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8048 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8050 XINC=$(have_xattrs_include)
8052 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8054 compare_stripe_info1
8056 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8059 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8060 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8062 XINC=$(have_xattrs_include)
8064 test_mkdir $DIR/$tdir.restore
8066 tar cf - --xattrs $tdir | tar xf - \
8067 -C $DIR/$tdir.restore --xattrs $XINC
8068 cd $DIR/$tdir.restore/$tdir
8069 compare_stripe_info1
8071 run_test 102f "tar copy files, not keep osts"
8074 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8075 skip "must have user_xattr"
8076 [ -z "$(which setfattr 2>/dev/null)" ] &&
8077 skip_env "could not find setfattr"
8078 [ -z "$(which getfattr 2>/dev/null)" ] &&
8079 skip_env "could not find getfattr"
8081 local xsize=${1:-1024} # in bytes
8082 local file=$DIR/$tfile
8083 local value="$(generate_string $xsize)"
8084 local xbig=trusted.big
8087 log "save $xbig on $file"
8088 setfattr -n $xbig -v $value $file ||
8089 error "saving $xbig on $file failed"
8091 local orig=$(get_xattr_value $xbig $file)
8092 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
8094 local xsml=trusted.sml
8095 log "save $xsml on $file"
8096 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
8098 local new=$(get_xattr_value $xbig $file)
8099 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
8101 log "grow $xsml on $file"
8102 setfattr -n $xsml -v "$value" $file ||
8103 error "growing $xsml on $file failed"
8105 new=$(get_xattr_value $xbig $file)
8106 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
8107 log "$xbig still valid after growing $xsml"
8112 test_102h() { # bug 15777
8115 run_test 102h "grow xattr from inside inode to external block"
8118 large_xattr_enabled || skip_env "large_xattr disabled"
8120 grow_xattr $(max_xattr_size)
8122 run_test 102ha "grow xattr from inside inode to external inode"
8124 test_102i() { # bug 17038
8125 [ -z "$(which getfattr 2>/dev/null)" ] &&
8126 skip "could not find getfattr"
8129 ln -s $DIR/$tfile $DIR/${tfile}link
8130 getfattr -n trusted.lov $DIR/$tfile ||
8131 error "lgetxattr on $DIR/$tfile failed"
8132 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
8133 grep -i "no such attr" ||
8134 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
8135 rm -f $DIR/$tfile $DIR/${tfile}link
8137 run_test 102i "lgetxattr test on symbolic link ============"
8140 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8141 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8143 XINC=$(have_xattrs_include)
8144 setup_test102 "$RUNAS"
8145 chown $RUNAS_ID $DIR/$tdir
8146 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8148 compare_stripe_info1 "$RUNAS"
8150 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
8153 [ -z "$(which setfattr 2>/dev/null)" ] &&
8154 skip "could not find setfattr"
8157 # b22187 just check that does not crash for regular file.
8158 setfattr -n trusted.lov $DIR/$tfile
8159 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
8160 local test_kdir=$DIR/$tdir
8161 test_mkdir $test_kdir
8162 local default_size=$($LFS getstripe -S $test_kdir)
8163 local default_count=$($LFS getstripe -c $test_kdir)
8164 local default_offset=$($LFS getstripe -i $test_kdir)
8165 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
8166 error 'dir setstripe failed'
8167 setfattr -n trusted.lov $test_kdir
8168 local stripe_size=$($LFS getstripe -S $test_kdir)
8169 local stripe_count=$($LFS getstripe -c $test_kdir)
8170 local stripe_offset=$($LFS getstripe -i $test_kdir)
8171 [ $stripe_size -eq $default_size ] ||
8172 error "stripe size $stripe_size != $default_size"
8173 [ $stripe_count -eq $default_count ] ||
8174 error "stripe count $stripe_count != $default_count"
8175 [ $stripe_offset -eq $default_offset ] ||
8176 error "stripe offset $stripe_offset != $default_offset"
8177 rm -rf $DIR/$tfile $test_kdir
8179 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
8182 [ -z "$(which getfattr 2>/dev/null)" ] &&
8183 skip "could not find getfattr"
8185 # LU-532 trusted. xattr is invisible to non-root
8186 local testfile=$DIR/$tfile
8190 echo "listxattr as user..."
8191 chown $RUNAS_ID $testfile
8192 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
8193 grep -q "trusted" &&
8194 error "$testfile trusted xattrs are user visible"
8198 run_test 102l "listxattr size test =================================="
8200 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
8201 local path=$DIR/$tfile
8204 listxattr_size_check $path || error "listattr_size_check $path failed"
8206 run_test 102m "Ensure listxattr fails on small bufffer ========"
8210 getxattr() { # getxattr path name
8211 # Return the base64 encoding of the value of xattr name on path.
8215 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
8217 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8219 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8221 getfattr --absolute-names --encoding=base64 --name=$name $path |
8222 awk -F= -v name=$name '$1 == name {
8223 print substr($0, index($0, "=") + 1);
8227 test_102n() { # LU-4101 mdt: protect internal xattrs
8228 [ -z "$(which setfattr 2>/dev/null)" ] &&
8229 skip "could not find setfattr"
8230 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
8232 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
8235 local file0=$DIR/$tfile.0
8236 local file1=$DIR/$tfile.1
8237 local xattr0=$TMP/$tfile.0
8238 local xattr1=$TMP/$tfile.1
8239 local namelist="lov lma lmv link fid version som hsm"
8243 rm -rf $file0 $file1 $xattr0 $xattr1
8246 # Get 'before' xattrs of $file1.
8247 getfattr --absolute-names --dump --match=- $file1 > $xattr0
8249 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
8250 namelist+=" lfsck_namespace"
8251 for name in $namelist; do
8252 # Try to copy xattr from $file0 to $file1.
8253 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8255 setfattr --name=trusted.$name --value="$value" $file1 ||
8256 error "setxattr 'trusted.$name' failed"
8258 # Try to set a garbage xattr.
8259 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8261 if [[ x$name == "xlov" ]]; then
8262 setfattr --name=trusted.lov --value="$value" $file1 &&
8263 error "setxattr invalid 'trusted.lov' success"
8265 setfattr --name=trusted.$name --value="$value" $file1 ||
8266 error "setxattr invalid 'trusted.$name' failed"
8269 # Try to remove the xattr from $file1. We don't care if this
8270 # appears to succeed or fail, we just don't want there to be
8271 # any changes or crashes.
8272 setfattr --remove=$trusted.$name $file1 2> /dev/null
8275 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
8278 # Try to copy xattr from $file0 to $file1.
8279 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8281 setfattr --name=trusted.$name --value="$value" $file1 ||
8282 error "setxattr 'trusted.$name' failed"
8284 # Try to set a garbage xattr.
8285 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8287 setfattr --name=trusted.$name --value="$value" $file1 ||
8288 error "setxattr 'trusted.$name' failed"
8290 # Try to remove the xattr from $file1. We don't care if this
8291 # appears to succeed or fail, we just don't want there to be
8292 # any changes or crashes.
8293 setfattr --remove=$trusted.$name $file1 2> /dev/null
8296 # Get 'after' xattrs of file1.
8297 getfattr --absolute-names --dump --match=- $file1 > $xattr1
8299 if ! diff $xattr0 $xattr1; then
8300 error "before and after xattrs of '$file1' differ"
8303 rm -rf $file0 $file1 $xattr0 $xattr1
8307 run_test 102n "silently ignore setxattr on internal trusted xattrs"
8309 test_102p() { # LU-4703 setxattr did not check ownership
8310 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
8311 skip "MDS needs to be at least 2.5.56"
8313 local testfile=$DIR/$tfile
8317 echo "setfacl as user..."
8318 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
8319 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
8321 echo "setfattr as user..."
8322 setfacl -m "u:$RUNAS_ID:---" $testfile
8323 $RUNAS setfattr -x system.posix_acl_access $testfile
8324 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
8326 run_test 102p "check setxattr(2) correctly fails without permission"
8329 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
8330 skip "MDS needs to be at least 2.6.92"
8332 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
8334 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
8337 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
8338 skip "MDS needs to be at least 2.6.93"
8340 touch $DIR/$tfile || error "touch"
8341 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
8342 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
8343 rm $DIR/$tfile || error "rm"
8346 mkdir -p $DIR/$tdir || error "mkdir"
8347 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8348 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8349 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8350 error "$testfile error deleting user.author1"
8351 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8352 grep "user.$(basename $tdir)" &&
8353 error "$tdir did not delete user.$(basename $tdir)"
8354 rmdir $DIR/$tdir || error "rmdir"
8357 test_mkdir $DIR/$tdir
8358 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8359 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8360 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8361 error "$testfile error deleting user.author1"
8362 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8363 grep "user.$(basename $tdir)" &&
8364 error "$tdir did not delete user.$(basename $tdir)"
8365 rmdir $DIR/$tdir || error "rm striped dir"
8367 run_test 102r "set EAs with empty values"
8370 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] &&
8371 skip "MDS needs to be at least 2.11.52"
8373 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
8375 save_lustre_params client "llite.*.xattr_cache" > $save
8377 for cache in 0 1; do
8378 lctl set_param llite.*.xattr_cache=$cache
8381 touch $DIR/$tfile || error "touch"
8382 for prefix in lustre security system trusted user; do
8383 # Note getxattr() may fail with 'Operation not
8384 # supported' or 'No such attribute' depending
8385 # on prefix and cache.
8386 getfattr -n $prefix.n102s $DIR/$tfile &&
8387 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
8391 restore_lustre_params < $save
8393 run_test 102s "getting nonexistent xattrs should fail"
8397 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
8402 [ "$UID" != 0 ] && skip "must run as root"
8403 $GSS && skip_env "could not run under gss"
8404 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
8405 skip_env "must have acl enabled"
8406 [ -z "$(which setfacl 2>/dev/null)" ] &&
8407 skip_env "could not find setfacl"
8408 remote_mds_nodsh && skip "remote MDS with nodsh"
8410 gpasswd -a daemon bin # LU-5641
8411 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
8413 declare -a identity_old
8415 for num in $(seq $MDSCOUNT); do
8416 switch_identity $num true || identity_old[$num]=$?
8424 echo "performing cp ..."
8425 run_acl_subtest cp || error "run_acl_subtest cp failed"
8426 echo "performing getfacl-noacl..."
8427 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
8428 echo "performing misc..."
8429 run_acl_subtest misc || error "misc test failed"
8430 echo "performing permissions..."
8431 run_acl_subtest permissions || error "permissions failed"
8432 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
8433 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.8.55) -o \
8434 \( $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6) -a \
8435 $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.29) \) ]
8437 echo "performing permissions xattr..."
8438 run_acl_subtest permissions_xattr ||
8439 error "permissions_xattr failed"
8441 echo "performing setfacl..."
8442 run_acl_subtest setfacl || error "setfacl test failed"
8444 # inheritance test got from HP
8445 echo "performing inheritance..."
8446 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
8447 chmod +x make-tree || error "chmod +x failed"
8448 run_acl_subtest inheritance || error "inheritance test failed"
8451 echo "LU-974 ignore umask when acl is enabled..."
8452 run_acl_subtest 974 || error "LU-974 umask test failed"
8453 if [ $MDSCOUNT -ge 2 ]; then
8454 run_acl_subtest 974_remote ||
8455 error "LU-974 umask test failed under remote dir"
8458 echo "LU-2561 newly created file is same size as directory..."
8459 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
8460 run_acl_subtest 2561 || error "LU-2561 test failed"
8462 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
8465 run_acl_subtest 4924 || error "LU-4924 test failed"
8470 for num in $(seq $MDSCOUNT); do
8471 if [ "${identity_old[$num]}" = 1 ]; then
8472 switch_identity $num false || identity_old[$num]=$?
8476 run_test 103a "acl test"
8481 for U in {0..511}; do
8483 local O=$(printf "%04o" $U)
8485 umask $(printf "%04o" $((511 ^ $O)))
8486 $LFS setstripe -c 1 $DIR/$tfile.s$O
8487 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
8489 (( $S == ($O & 0666) )) ||
8490 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
8492 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
8493 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
8494 (( $S == ($O & 0666) )) ||
8495 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
8497 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
8498 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
8499 (( $S == ($O & 0666) )) ||
8500 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
8501 rm -f $DIR/$tfile.[smp]$0
8506 run_test 103b "umask lfs setstripe"
8510 cp -rp $DIR/$tdir $DIR/$tdir.bak
8512 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
8513 error "$DIR/$tdir shouldn't contain default ACL"
8514 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
8515 error "$DIR/$tdir.bak shouldn't contain default ACL"
8518 run_test 103c "'cp -rp' won't set empty acl"
8521 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8524 lfs df || error "lfs df failed"
8525 lfs df -ih || error "lfs df -ih failed"
8526 lfs df -h $DIR || error "lfs df -h $DIR failed"
8527 lfs df -i $DIR || error "lfs df -i $DIR failed"
8528 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
8529 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
8531 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
8532 lctl --device %$OSC deactivate
8533 lfs df || error "lfs df with deactivated OSC failed"
8534 lctl --device %$OSC activate
8535 # wait the osc back to normal
8536 wait_osc_import_state client ost FULL
8538 lfs df || error "lfs df with reactivated OSC failed"
8541 run_test 104a "lfs df [-ih] [path] test ========================="
8544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8545 [ $RUNAS_ID -eq $UID ] &&
8546 skip_env "RUNAS_ID = UID = $UID -- skipping"
8549 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
8550 grep "Permission denied" | wc -l)))
8551 if [ $denied_cnt -ne 0 ]; then
8552 error "lfs check servers test failed"
8555 run_test 104b "$RUNAS lfs check servers test ===================="
8558 # doesn't work on 2.4 kernels
8560 if $(flock_is_enabled); then
8561 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
8563 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
8567 run_test 105a "flock when mounted without -o flock test ========"
8571 if $(flock_is_enabled); then
8572 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
8574 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
8578 run_test 105b "fcntl when mounted without -o flock test ========"
8582 if $(flock_is_enabled); then
8583 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
8585 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
8589 run_test 105c "lockf when mounted without -o flock test"
8591 test_105d() { # bug 15924
8592 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8594 test_mkdir $DIR/$tdir
8595 flock_is_enabled || skip_env "mount w/o flock enabled"
8596 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
8597 $LCTL set_param fail_loc=0x80000315
8598 flocks_test 2 $DIR/$tdir
8600 run_test 105d "flock race (should not freeze) ========"
8602 test_105e() { # bug 22660 && 22040
8603 flock_is_enabled || skip_env "mount w/o flock enabled"
8606 flocks_test 3 $DIR/$tfile
8608 run_test 105e "Two conflicting flocks from same process"
8610 test_106() { #bug 10921
8611 test_mkdir $DIR/$tdir
8612 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
8613 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
8615 run_test 106 "attempt exec of dir followed by chown of that dir"
8618 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8626 local save_pattern=$(sysctl -n kernel.core_pattern)
8627 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
8628 sysctl -w kernel.core_pattern=$file
8629 sysctl -w kernel.core_uses_pid=0
8637 kill -s 11 $SLEEPPID
8639 if [ -e $file ]; then
8640 size=`stat -c%s $file`
8641 [ $size -eq 0 ] && error "Fail to create core file $file"
8643 error "Fail to create core file $file"
8646 sysctl -w kernel.core_pattern=$save_pattern
8647 sysctl -w kernel.core_uses_pid=$save_uses_pid
8650 run_test 107 "Coredump on SIG"
8653 test_mkdir $DIR/$tdir
8654 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
8655 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
8656 error "mkdir with 256 char should fail, but did not"
8657 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
8658 error "create with 255 char failed"
8659 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
8660 error "create with 256 char should fail, but did not"
8665 run_test 110 "filename length checking"
8668 # Purpose: To verify dynamic thread (OSS) creation.
8671 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8672 remote_ost_nodsh && skip "remote OST with nodsh"
8674 # Lustre does not stop service threads once they are started.
8675 # Reset number of running threads to default.
8680 local save_params="$TMP/sanity-$TESTNAME.parameters"
8682 # Get ll_ost_io count before I/O
8683 OSTIO_pre=$(do_facet ost1 \
8684 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
8685 # Exit if lustre is not running (ll_ost_io not running).
8686 [ -z "$OSTIO_pre" ] && error "no OSS threads"
8688 echo "Starting with $OSTIO_pre threads"
8689 local thread_max=$((OSTIO_pre * 2))
8690 local rpc_in_flight=$((thread_max * 2))
8691 # Number of I/O Process proposed to be started.
8693 local facets=$(get_facets OST)
8695 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
8696 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
8698 # Set in_flight to $rpc_in_flight
8699 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
8700 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
8701 nfiles=${rpc_in_flight}
8702 # Set ost thread_max to $thread_max
8703 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
8705 # 5 Minutes should be sufficient for max number of OSS
8706 # threads(thread_max) to be created.
8710 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
8711 test_mkdir $DIR/$tdir
8712 for i in $(seq $nfiles); do
8713 local file=$DIR/$tdir/${tfile}-$i
8714 $LFS setstripe -c -1 -i 0 $file
8715 ($WTL $file $timeout)&
8718 # I/O Started - Wait for thread_started to reach thread_max or report
8719 # error if thread_started is more than thread_max.
8720 echo "Waiting for thread_started to reach thread_max"
8721 local thread_started=0
8722 local end_time=$((SECONDS + timeout))
8724 while [ $SECONDS -le $end_time ] ; do
8726 # Get ost i/o thread_started count.
8727 thread_started=$(do_facet ost1 \
8729 ost.OSS.ost_io.threads_started | cut -d= -f2")
8730 # Break out if thread_started is equal/greater than thread_max
8731 if [[ $thread_started -ge $thread_max ]]; then
8732 echo ll_ost_io thread_started $thread_started, \
8733 equal/greater than thread_max $thread_max
8739 # Cleanup - We have the numbers, Kill i/o jobs if running.
8740 jobcount=($(jobs -p))
8741 for i in $(seq 0 $((${#jobcount[@]}-1)))
8743 kill -9 ${jobcount[$i]}
8744 if [ $? -ne 0 ] ; then
8746 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
8750 # Cleanup files left by WTL binary.
8751 for i in $(seq $nfiles); do
8752 local file=$DIR/$tdir/${tfile}-$i
8754 if [ $? -ne 0 ] ; then
8755 echo "Warning: Failed to delete file $file"
8759 restore_lustre_params <$save_params
8760 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
8762 # Error out if no new thread has started or Thread started is greater
8764 if [[ $thread_started -le $OSTIO_pre ||
8765 $thread_started -gt $thread_max ]]; then
8766 error "ll_ost_io: thread_started $thread_started" \
8767 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
8768 "No new thread started or thread started greater " \
8772 run_test 115 "verify dynamic thread creation===================="
8775 wait_delete_completed
8776 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
8777 echo "OST kbytes available: ${AVAIL[@]}"
8782 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
8783 #echo OST $i: ${AVAIL[i]}kb
8784 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
8788 if [[ ${AVAIL[i]} -lt $MINV ]]; then
8793 echo "Min free space: OST $MINI: $MINV"
8794 echo "Max free space: OST $MAXI: $MAXV"
8797 test_116a() { # was previously test_116()
8798 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8799 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8800 remote_mds_nodsh && skip "remote MDS with nodsh"
8802 echo -n "Free space priority "
8803 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
8808 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
8809 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
8810 trap simple_cleanup_common EXIT
8812 # Check if we need to generate uneven OSTs
8813 test_mkdir -p $DIR/$tdir/OST${MINI}
8814 local FILL=$((MINV / 4))
8815 local DIFF=$((MAXV - MINV))
8816 local DIFF2=$((DIFF * 100 / MINV))
8818 local threshold=$(do_facet $SINGLEMDS \
8819 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
8820 threshold=${threshold%%%}
8821 echo -n "Check for uneven OSTs: "
8822 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
8824 if [[ $DIFF2 -gt $threshold ]]; then
8826 echo "Don't need to fill OST$MINI"
8828 # generate uneven OSTs. Write 2% over the QOS threshold value
8830 DIFF=$((threshold - DIFF2 + 2))
8831 DIFF2=$((MINV * DIFF / 100))
8832 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
8833 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
8834 error "setstripe failed"
8835 DIFF=$((DIFF2 / 2048))
8837 while [ $i -lt $DIFF ]; do
8839 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
8840 bs=2M count=1 2>/dev/null
8849 DIFF=$((MAXV - MINV))
8850 DIFF2=$((DIFF * 100 / MINV))
8851 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
8852 if [ $DIFF2 -gt $threshold ]; then
8855 echo "failed - QOS mode won't be used"
8856 simple_cleanup_common
8857 skip "QOS imbalance criteria not met"
8865 # now fill using QOS
8866 $SETSTRIPE -c 1 $DIR/$tdir
8867 FILL=$((FILL / 200))
8868 if [ $FILL -gt 600 ]; then
8871 echo "writing $FILL files to QOS-assigned OSTs"
8873 while [ $i -lt $FILL ]; do
8875 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
8879 echo "wrote $i 200k files"
8883 echo "Note: free space may not be updated, so measurements might be off"
8885 DIFF2=$((MAXV - MINV))
8886 echo "free space delta: orig $DIFF final $DIFF2"
8887 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
8888 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
8889 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
8890 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
8891 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
8892 if [[ $DIFF -gt 0 ]]; then
8893 FILL=$((DIFF2 * 100 / DIFF - 100))
8894 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
8897 # Figure out which files were written where
8898 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8899 awk '/'$MINI1': / {print $2; exit}')
8901 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8902 echo "$MINC files created on smaller OST $MINI1"
8903 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
8904 awk '/'$MAXI1': / {print $2; exit}')
8906 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
8907 echo "$MAXC files created on larger OST $MAXI1"
8908 if [[ $MINC -gt 0 ]]; then
8909 FILL=$((MAXC * 100 / MINC - 100))
8910 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
8912 [[ $MAXC -gt $MINC ]] ||
8913 error_ignore LU-9 "stripe QOS didn't balance free space"
8914 simple_cleanup_common
8916 run_test 116a "stripe QOS: free space balance ==================="
8918 test_116b() { # LU-2093
8919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8920 remote_mds_nodsh && skip "remote MDS with nodsh"
8922 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
8923 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
8924 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
8925 [ -z "$old_rr" ] && skip "no QOS"
8926 do_facet $SINGLEMDS lctl set_param \
8927 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
8929 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
8930 createmany -o $DIR/$tdir/f- 20 || error "can't create"
8931 do_facet $SINGLEMDS lctl set_param fail_loc=0
8933 do_facet $SINGLEMDS lctl set_param \
8934 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
8936 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
8938 test_117() # bug 10891
8940 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8942 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
8943 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
8944 lctl set_param fail_loc=0x21e
8945 > $DIR/$tfile || error "truncate failed"
8946 lctl set_param fail_loc=0
8947 echo "Truncate succeeded."
8950 run_test 117 "verify osd extend =========="
8952 NO_SLOW_RESENDCOUNT=4
8953 export OLD_RESENDCOUNT=""
8954 set_resend_count () {
8955 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
8956 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
8957 lctl set_param -n $PROC_RESENDCOUNT $1
8958 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
8961 # for reduce test_118* time (b=14842)
8962 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
8964 # Reset async IO behavior after error case
8966 FILE=$DIR/reset_async
8968 # Ensure all OSCs are cleared
8969 $SETSTRIPE -c -1 $FILE
8970 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
8975 test_118a() #bug 11710
8977 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8981 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8982 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
8983 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
8985 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
8986 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
8991 run_test 118a "verify O_SYNC works =========="
8995 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8996 remote_ost_nodsh && skip "remote OST with nodsh"
9000 #define OBD_FAIL_SRV_ENOENT 0x217
9001 set_nodes_failloc "$(osts_nodes)" 0x217
9002 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9004 set_nodes_failloc "$(osts_nodes)" 0
9005 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9006 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9009 if [[ $RC -eq 0 ]]; then
9010 error "Must return error due to dropped pages, rc=$RC"
9014 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9015 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9019 echo "Dirty pages not leaked on ENOENT"
9021 # Due to the above error the OSC will issue all RPCs syncronously
9022 # until a subsequent RPC completes successfully without error.
9023 $MULTIOP $DIR/$tfile Ow4096yc
9028 run_test 118b "Reclaim dirty pages on fatal error =========="
9032 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9034 # for 118c, restore the original resend count, LU-1940
9035 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
9036 set_resend_count $OLD_RESENDCOUNT
9037 remote_ost_nodsh && skip "remote OST with nodsh"
9041 #define OBD_FAIL_OST_EROFS 0x216
9042 set_nodes_failloc "$(osts_nodes)" 0x216
9044 # multiop should block due to fsync until pages are written
9045 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9049 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9050 error "Multiop failed to block on fsync, pid=$MULTIPID"
9053 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9055 if [[ $WRITEBACK -eq 0 ]]; then
9056 error "No page in writeback, writeback=$WRITEBACK"
9059 set_nodes_failloc "$(osts_nodes)" 0
9062 if [[ $RC -ne 0 ]]; then
9063 error "Multiop fsync failed, rc=$RC"
9066 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9067 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9069 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9070 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9074 echo "Dirty pages flushed via fsync on EROFS"
9077 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
9079 # continue to use small resend count to reduce test_118* time (b=14842)
9080 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9084 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9085 remote_ost_nodsh && skip "remote OST with nodsh"
9089 #define OBD_FAIL_OST_BRW_PAUSE_BULK
9090 set_nodes_failloc "$(osts_nodes)" 0x214
9091 # multiop should block due to fsync until pages are written
9092 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9096 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9097 error "Multiop failed to block on fsync, pid=$MULTIPID"
9100 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9102 if [[ $WRITEBACK -eq 0 ]]; then
9103 error "No page in writeback, writeback=$WRITEBACK"
9106 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
9107 set_nodes_failloc "$(osts_nodes)" 0
9109 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9110 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9112 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9113 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9117 echo "Dirty pages gaurenteed flushed via fsync"
9120 run_test 118d "Fsync validation inject a delay of the bulk =========="
9123 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9127 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
9128 lctl set_param fail_loc=0x8000040a
9130 # Should simulate EINVAL error which is fatal
9131 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9133 if [[ $RC -eq 0 ]]; then
9134 error "Must return error due to dropped pages, rc=$RC"
9137 lctl set_param fail_loc=0x0
9139 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9140 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9141 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9143 if [[ $LOCKED -ne 0 ]]; then
9144 error "Locked pages remain in cache, locked=$LOCKED"
9147 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9148 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9152 echo "No pages locked after fsync"
9157 run_test 118f "Simulate unrecoverable OSC side error =========="
9160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9164 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9165 lctl set_param fail_loc=0x406
9167 # simulate local -ENOMEM
9168 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9171 lctl set_param fail_loc=0
9172 if [[ $RC -eq 0 ]]; then
9173 error "Must return error due to dropped pages, rc=$RC"
9176 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9177 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9178 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9180 if [[ $LOCKED -ne 0 ]]; then
9181 error "Locked pages remain in cache, locked=$LOCKED"
9184 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9185 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9189 echo "No pages locked after fsync"
9194 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
9197 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9198 remote_ost_nodsh && skip "remote OST with nodsh"
9202 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9203 set_nodes_failloc "$(osts_nodes)" 0x20e
9204 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9205 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9208 set_nodes_failloc "$(osts_nodes)" 0
9209 if [[ $RC -eq 0 ]]; then
9210 error "Must return error due to dropped pages, rc=$RC"
9213 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9214 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9215 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9217 if [[ $LOCKED -ne 0 ]]; then
9218 error "Locked pages remain in cache, locked=$LOCKED"
9221 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9222 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9226 echo "No pages locked after fsync"
9230 run_test 118h "Verify timeout in handling recoverables errors =========="
9232 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9235 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9236 remote_ost_nodsh && skip "remote OST with nodsh"
9240 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9241 set_nodes_failloc "$(osts_nodes)" 0x20e
9243 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9244 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9247 set_nodes_failloc "$(osts_nodes)" 0
9251 if [[ $RC -ne 0 ]]; then
9252 error "got error, but should be not, rc=$RC"
9255 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9256 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9257 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9258 if [[ $LOCKED -ne 0 ]]; then
9259 error "Locked pages remain in cache, locked=$LOCKED"
9262 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9263 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9267 echo "No pages locked after fsync"
9271 run_test 118i "Fix error before timeout in recoverable error =========="
9273 [ "$SLOW" = "no" ] && set_resend_count 4
9276 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9277 remote_ost_nodsh && skip "remote OST with nodsh"
9281 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
9282 set_nodes_failloc "$(osts_nodes)" 0x220
9284 # return -EIO from OST
9285 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9287 set_nodes_failloc "$(osts_nodes)" 0x0
9288 if [[ $RC -eq 0 ]]; then
9289 error "Must return error due to dropped pages, rc=$RC"
9292 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9293 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9294 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9295 if [[ $LOCKED -ne 0 ]]; then
9296 error "Locked pages remain in cache, locked=$LOCKED"
9299 # in recoverable error on OST we want resend and stay until it finished
9300 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9301 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9305 echo "No pages locked after fsync"
9309 run_test 118j "Simulate unrecoverable OST side error =========="
9313 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9314 remote_ost_nodsh && skip "remote OSTs with nodsh"
9316 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9317 set_nodes_failloc "$(osts_nodes)" 0x20e
9318 test_mkdir $DIR/$tdir
9320 for ((i=0;i<10;i++)); do
9321 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
9322 error "dd to $DIR/$tdir/$tfile-$i failed" )&
9329 set_nodes_failloc "$(osts_nodes)" 0
9332 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
9334 test_118l() # LU-646
9336 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9338 test_mkdir $DIR/$tdir
9339 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
9342 run_test 118l "fsync dir"
9344 test_118m() # LU-3066
9346 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9348 test_mkdir $DIR/$tdir
9349 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
9352 run_test 118m "fdatasync dir ========="
9354 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9362 remote_ost_nodsh && skip "remote OSTs with nodsh"
9364 # Sleep to avoid a cached response.
9365 #define OBD_STATFS_CACHE_SECONDS 1
9368 # Inject a 10 second delay in the OST_STATFS handler.
9369 #define OBD_FAIL_OST_STATFS_DELAY 0x242
9370 set_nodes_failloc "$(osts_nodes)" 0x242
9373 stat --file-system $MOUNT > /dev/null
9376 set_nodes_failloc "$(osts_nodes)" 0
9378 if ((end - begin > 20)); then
9379 error "statfs took $((end - begin)) seconds, expected 10"
9382 run_test 118n "statfs() sends OST_STATFS requests in parallel"
9384 test_119a() # bug 11737
9386 BSIZE=$((512 * 1024))
9387 directio write $DIR/$tfile 0 1 $BSIZE
9388 # We ask to read two blocks, which is more than a file size.
9389 # directio will indicate an error when requested and actual
9390 # sizes aren't equeal (a normal situation in this case) and
9391 # print actual read amount.
9392 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
9393 if [ "$NOB" != "$BSIZE" ]; then
9394 error "read $NOB bytes instead of $BSIZE"
9398 run_test 119a "Short directIO read must return actual read amount"
9400 test_119b() # bug 11737
9402 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9404 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
9405 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
9407 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
9408 error "direct read failed"
9411 run_test 119b "Sparse directIO read must return actual read amount"
9413 test_119c() # bug 13099
9416 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
9417 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
9420 run_test 119c "Testing for direct read hitting hole"
9422 test_119d() # bug 15950
9424 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9426 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
9427 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
9429 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
9430 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
9431 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
9432 lctl set_param fail_loc=0x40d
9433 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
9436 cat $DIR/$tfile > /dev/null &
9437 lctl set_param fail_loc=0
9440 log "the DIO writes have completed, now wait for the reads (should not block very long)"
9442 [ -n "`ps h -p $pid_reads -o comm`" ] && \
9443 error "the read rpcs have not completed in 2s"
9445 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
9447 run_test 119d "The DIO path should try to send a new rpc once one is completed"
9450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9451 remote_mds_nodsh && skip "remote MDS with nodsh"
9452 test_mkdir $DIR/$tdir
9453 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9454 skip_env "no early lock cancel on server"
9456 lru_resize_disable mdc
9457 lru_resize_disable osc
9458 cancel_lru_locks mdc
9459 # asynchronous object destroy at MDT could cause bl ast to client
9460 cancel_lru_locks osc
9462 stat $DIR/$tdir > /dev/null
9463 can1=$(do_facet $SINGLEMDS \
9464 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9465 awk '/ldlm_cancel/ {print $2}')
9466 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9467 awk '/ldlm_bl_callback/ {print $2}')
9468 test_mkdir -c1 $DIR/$tdir/d1
9469 can2=$(do_facet $SINGLEMDS \
9470 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9471 awk '/ldlm_cancel/ {print $2}')
9472 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9473 awk '/ldlm_bl_callback/ {print $2}')
9474 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9475 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9476 lru_resize_enable mdc
9477 lru_resize_enable osc
9479 run_test 120a "Early Lock Cancel: mkdir test"
9482 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9483 remote_mds_nodsh && skip "remote MDS with nodsh"
9484 test_mkdir $DIR/$tdir
9485 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9486 skip_env "no early lock cancel on server"
9488 lru_resize_disable mdc
9489 lru_resize_disable osc
9490 cancel_lru_locks mdc
9491 stat $DIR/$tdir > /dev/null
9492 can1=$(do_facet $SINGLEMDS \
9493 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9494 awk '/ldlm_cancel/ {print $2}')
9495 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9496 awk '/ldlm_bl_callback/ {print $2}')
9498 can2=$(do_facet $SINGLEMDS \
9499 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9500 awk '/ldlm_cancel/ {print $2}')
9501 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9502 awk '/ldlm_bl_callback/ {print $2}')
9503 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9504 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9505 lru_resize_enable mdc
9506 lru_resize_enable osc
9508 run_test 120b "Early Lock Cancel: create test"
9511 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9512 remote_mds_nodsh && skip "remote MDS with nodsh"
9513 test_mkdir -c1 $DIR/$tdir
9514 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9515 skip "no early lock cancel on server"
9517 lru_resize_disable mdc
9518 lru_resize_disable osc
9519 test_mkdir -c1 $DIR/$tdir/d1
9520 test_mkdir -c1 $DIR/$tdir/d2
9521 touch $DIR/$tdir/d1/f1
9522 cancel_lru_locks mdc
9523 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
9524 can1=$(do_facet $SINGLEMDS \
9525 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9526 awk '/ldlm_cancel/ {print $2}')
9527 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9528 awk '/ldlm_bl_callback/ {print $2}')
9529 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9530 can2=$(do_facet $SINGLEMDS \
9531 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9532 awk '/ldlm_cancel/ {print $2}')
9533 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9534 awk '/ldlm_bl_callback/ {print $2}')
9535 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9536 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9537 lru_resize_enable mdc
9538 lru_resize_enable osc
9540 run_test 120c "Early Lock Cancel: link test"
9543 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9544 remote_mds_nodsh && skip "remote MDS with nodsh"
9545 test_mkdir -c1 $DIR/$tdir
9546 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9547 skip_env "no early lock cancel on server"
9549 lru_resize_disable mdc
9550 lru_resize_disable osc
9552 cancel_lru_locks mdc
9553 stat $DIR/$tdir > /dev/null
9554 can1=$(do_facet $SINGLEMDS \
9555 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9556 awk '/ldlm_cancel/ {print $2}')
9557 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9558 awk '/ldlm_bl_callback/ {print $2}')
9559 chmod a+x $DIR/$tdir
9560 can2=$(do_facet $SINGLEMDS \
9561 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9562 awk '/ldlm_cancel/ {print $2}')
9563 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9564 awk '/ldlm_bl_callback/ {print $2}')
9565 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9566 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9567 lru_resize_enable mdc
9568 lru_resize_enable osc
9570 run_test 120d "Early Lock Cancel: setattr test"
9573 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9574 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9575 skip_env "no early lock cancel on server"
9576 remote_mds_nodsh && skip "remote MDS with nodsh"
9578 local dlmtrace_set=false
9580 test_mkdir -c1 $DIR/$tdir
9581 lru_resize_disable mdc
9582 lru_resize_disable osc
9583 ! $LCTL get_param debug | grep -q dlmtrace &&
9584 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
9585 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
9586 cancel_lru_locks mdc
9587 cancel_lru_locks osc
9588 dd if=$DIR/$tdir/f1 of=/dev/null
9589 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
9590 # XXX client can not do early lock cancel of OST lock
9591 # during unlink (LU-4206), so cancel osc lock now.
9593 cancel_lru_locks osc
9594 can1=$(do_facet $SINGLEMDS \
9595 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9596 awk '/ldlm_cancel/ {print $2}')
9597 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9598 awk '/ldlm_bl_callback/ {print $2}')
9599 unlink $DIR/$tdir/f1
9601 can2=$(do_facet $SINGLEMDS \
9602 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9603 awk '/ldlm_cancel/ {print $2}')
9604 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9605 awk '/ldlm_bl_callback/ {print $2}')
9606 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
9607 $LCTL dk $TMP/cancel.debug.txt
9608 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
9609 $LCTL dk $TMP/blocking.debug.txt
9610 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
9611 lru_resize_enable mdc
9612 lru_resize_enable osc
9614 run_test 120e "Early Lock Cancel: unlink test"
9617 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9618 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9619 skip_env "no early lock cancel on server"
9620 remote_mds_nodsh && skip "remote MDS with nodsh"
9622 test_mkdir -c1 $DIR/$tdir
9623 lru_resize_disable mdc
9624 lru_resize_disable osc
9625 test_mkdir -c1 $DIR/$tdir/d1
9626 test_mkdir -c1 $DIR/$tdir/d2
9627 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
9628 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
9629 cancel_lru_locks mdc
9630 cancel_lru_locks osc
9631 dd if=$DIR/$tdir/d1/f1 of=/dev/null
9632 dd if=$DIR/$tdir/d2/f2 of=/dev/null
9633 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
9634 # XXX client can not do early lock cancel of OST lock
9635 # during rename (LU-4206), so cancel osc lock now.
9637 cancel_lru_locks osc
9638 can1=$(do_facet $SINGLEMDS \
9639 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9640 awk '/ldlm_cancel/ {print $2}')
9641 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9642 awk '/ldlm_bl_callback/ {print $2}')
9643 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9645 can2=$(do_facet $SINGLEMDS \
9646 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9647 awk '/ldlm_cancel/ {print $2}')
9648 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9649 awk '/ldlm_bl_callback/ {print $2}')
9650 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9651 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9652 lru_resize_enable mdc
9653 lru_resize_enable osc
9655 run_test 120f "Early Lock Cancel: rename test"
9658 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9659 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9660 skip_env "no early lock cancel on server"
9661 remote_mds_nodsh && skip "remote MDS with nodsh"
9663 lru_resize_disable mdc
9664 lru_resize_disable osc
9666 echo create $count files
9667 test_mkdir $DIR/$tdir
9668 cancel_lru_locks mdc
9669 cancel_lru_locks osc
9672 can0=$(do_facet $SINGLEMDS \
9673 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9674 awk '/ldlm_cancel/ {print $2}')
9675 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9676 awk '/ldlm_bl_callback/ {print $2}')
9677 createmany -o $DIR/$tdir/f $count
9679 can1=$(do_facet $SINGLEMDS \
9680 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9681 awk '/ldlm_cancel/ {print $2}')
9682 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9683 awk '/ldlm_bl_callback/ {print $2}')
9685 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
9686 echo rm $count files
9689 can2=$(do_facet $SINGLEMDS \
9690 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9691 awk '/ldlm_cancel/ {print $2}')
9692 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9693 awk '/ldlm_bl_callback/ {print $2}')
9695 echo total: $count removes in $((t2-t1))
9696 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
9698 # wait for commitment of removal
9699 lru_resize_enable mdc
9700 lru_resize_enable osc
9702 run_test 120g "Early Lock Cancel: performance test"
9704 test_121() { #bug #10589
9705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9708 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
9709 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
9710 lctl set_param fail_loc=0x310
9711 cancel_lru_locks osc > /dev/null
9712 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
9713 lctl set_param fail_loc=0
9714 [[ $reads -eq $writes ]] ||
9715 error "read $reads blocks, must be $writes blocks"
9717 run_test 121 "read cancel race ========="
9719 test_123a() { # was test 123, statahead(bug 11401)
9720 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9723 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
9724 log "testing UP system. Performance may be lower than expected."
9729 test_mkdir $DIR/$tdir
9730 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
9731 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
9733 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
9734 createmany -o $DIR/$tdir/$tfile $j $((i - j))
9736 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9737 lctl set_param -n llite.*.statahead_max 0
9738 lctl get_param llite.*.statahead_max
9739 cancel_lru_locks mdc
9740 cancel_lru_locks osc
9742 time ls -l $DIR/$tdir | wc -l
9744 delta=$((etime - stime))
9745 log "ls $i files without statahead: $delta sec"
9746 lctl set_param llite.*.statahead_max=$max
9748 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9749 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
9750 cancel_lru_locks mdc
9751 cancel_lru_locks osc
9753 time ls -l $DIR/$tdir | wc -l
9755 delta_sa=$((etime - stime))
9756 log "ls $i files with statahead: $delta_sa sec"
9757 lctl get_param -n llite.*.statahead_stats
9758 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9760 [[ $swrong -lt $ewrong ]] &&
9761 log "statahead was stopped, maybe too many locks held!"
9762 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
9764 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9765 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9766 lctl set_param -n llite.*.statahead_max 0
9767 lctl get_param llite.*.statahead_max
9768 cancel_lru_locks mdc
9769 cancel_lru_locks osc
9771 time ls -l $DIR/$tdir | wc -l
9773 delta=$((etime - stime))
9774 log "ls $i files again without statahead: $delta sec"
9775 lctl set_param llite.*.statahead_max=$max
9776 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9777 if [ $SLOWOK -eq 0 ]; then
9778 error "ls $i files is slower with statahead!"
9780 log "ls $i files is slower with statahead!"
9786 [ $delta -gt 20 ] && break
9787 [ $delta -gt 8 ] && MULT=$((50 / delta))
9788 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
9796 delta=$((etime - stime))
9797 log "rm -r $DIR/$tdir/: $delta seconds"
9799 lctl get_param -n llite.*.statahead_stats
9801 run_test 123a "verify statahead work"
9803 test_123b () { # statahead(bug 15027)
9804 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9806 test_mkdir $DIR/$tdir
9807 createmany -o $DIR/$tdir/$tfile-%d 1000
9809 cancel_lru_locks mdc
9810 cancel_lru_locks osc
9812 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
9813 lctl set_param fail_loc=0x80000803
9814 ls -lR $DIR/$tdir > /dev/null
9816 lctl set_param fail_loc=0x0
9817 lctl get_param -n llite.*.statahead_stats
9822 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
9825 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9826 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9827 skip_env "no lru resize on server"
9831 test_mkdir $DIR/$tdir
9833 log "create $NR files at $DIR/$tdir"
9834 createmany -o $DIR/$tdir/f $NR ||
9835 error "failed to create $NR files in $DIR/$tdir"
9837 cancel_lru_locks mdc
9838 ls -l $DIR/$tdir > /dev/null
9842 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
9843 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
9844 LRU_SIZE=$($LCTL get_param -n $PARAM)
9845 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
9846 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
9848 log "NS=$(basename $NSDIR)"
9853 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
9854 skip "Not enough cached locks created!"
9860 # We know that lru resize allows one client to hold $LIMIT locks
9861 # for 10h. After that locks begin to be killed by client.
9863 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
9865 if [ $LIMIT -lt $LRU_SIZE ]; then
9866 skip "Limit is too small $LIMIT"
9869 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
9870 # killing locks. Some time was spent for creating locks. This means
9871 # that up to the moment of sleep finish we must have killed some of
9872 # them (10-100 locks). This depends on how fast ther were created.
9873 # Many of them were touched in almost the same moment and thus will
9874 # be killed in groups.
9875 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
9877 # Use $LRU_SIZE_B here to take into account real number of locks
9878 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
9879 local LRU_SIZE_B=$LRU_SIZE
9881 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
9882 log "OLD_LVF=$OLD_LVF"
9883 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
9885 # Let's make sure that we really have some margin. Client checks
9886 # cached locks every 10 sec.
9888 log "Sleep ${SLEEP} sec"
9890 while ((SEC<$SLEEP)); do
9894 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
9898 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
9899 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
9901 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
9902 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
9903 unlinkmany $DIR/$tdir/f $NR
9907 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
9908 log "unlink $NR files at $DIR/$tdir"
9909 unlinkmany $DIR/$tdir/f $NR
9911 run_test 124a "lru resize ======================================="
9913 get_max_pool_limit()
9915 local limit=$($LCTL get_param \
9916 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
9919 if [[ $l -gt $max ]]; then
9927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9928 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
9929 skip_env "no lru resize on server"
9931 LIMIT=$(get_max_pool_limit)
9933 NR=$(($(default_lru_size)*20))
9934 if [[ $NR -gt $LIMIT ]]; then
9935 log "Limit lock number by $LIMIT locks"
9939 IFree=$(mdsrate_inodes_available)
9940 if [ $IFree -lt $NR ]; then
9941 log "Limit lock number by $IFree inodes"
9945 lru_resize_disable mdc
9946 test_mkdir -p $DIR/$tdir/disable_lru_resize
9948 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
9949 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
9950 cancel_lru_locks mdc
9953 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9956 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9959 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
9963 nolruresize_delta=$((etime-stime))
9964 log "ls -la time: $nolruresize_delta seconds"
9965 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9966 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
9968 lru_resize_enable mdc
9969 test_mkdir -p $DIR/$tdir/enable_lru_resize
9971 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
9972 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
9973 cancel_lru_locks mdc
9976 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9979 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9982 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
9986 lruresize_delta=$((etime-stime))
9987 log "ls -la time: $lruresize_delta seconds"
9988 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
9990 if [ $lruresize_delta -gt $nolruresize_delta ]; then
9991 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
9992 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
9993 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
9995 log "lru resize performs the same with no lru resize"
9997 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
9999 run_test 124b "lru resize (performance test) ======================="
10002 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10003 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10004 skip_env "no lru resize on server"
10006 # cache ununsed locks on client
10008 cancel_lru_locks mdc
10009 test_mkdir $DIR/$tdir
10010 createmany -o $DIR/$tdir/f $nr ||
10011 error "failed to create $nr files in $DIR/$tdir"
10012 ls -l $DIR/$tdir > /dev/null
10014 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10015 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10016 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10017 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10018 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10020 # set lru_max_age to 1 sec
10021 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10022 echo "sleep $((recalc_p * 2)) seconds..."
10023 sleep $((recalc_p * 2))
10025 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10026 # restore lru_max_age
10027 $LCTL set_param -n $nsdir.lru_max_age $max_age
10028 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10029 unlinkmany $DIR/$tdir/f $nr
10031 run_test 124c "LRUR cancel very aged locks"
10033 test_125() { # 13358
10034 $LCTL get_param -n llite.*.client_type | grep -q local ||
10035 skip "must run as local client"
10036 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
10037 skip_env "must have acl enabled"
10038 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
10040 test_mkdir $DIR/$tdir
10041 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
10042 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
10043 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
10045 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
10047 test_126() { # bug 12829/13455
10048 $GSS && skip_env "must run as gss disabled"
10049 $LCTL get_param -n llite.*.client_type | grep -q local ||
10050 skip "must run as local client"
10051 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
10053 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
10054 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
10056 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
10058 run_test 126 "check that the fsgid provided by the client is taken into account"
10060 test_127a() { # bug 15521
10061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10063 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
10064 $LCTL set_param osc.*.stats=0
10065 FSIZE=$((2048 * 1024))
10066 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10067 cancel_lru_locks osc
10068 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
10070 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
10071 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
10072 echo "got $COUNT $NAME"
10073 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
10074 eval $NAME=$COUNT || error "Wrong proc format"
10077 read_bytes|write_bytes)
10078 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
10079 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
10080 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
10081 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
10082 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
10083 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
10084 error "sumsquare is too small: $SUMSQ"
10085 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
10086 error "sumsquare is too big: $SUMSQ"
10090 done < $DIR/${tfile}.tmp
10092 #check that we actually got some stats
10093 [ "$read_bytes" ] || error "Missing read_bytes stats"
10094 [ "$write_bytes" ] || error "Missing write_bytes stats"
10095 [ "$read_bytes" != 0 ] || error "no read done"
10096 [ "$write_bytes" != 0 ] || error "no write done"
10098 run_test 127a "verify the client stats are sane"
10100 test_127b() { # bug LU-333
10101 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10103 $LCTL set_param llite.*.stats=0
10104 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
10106 # perform 2 reads and writes so MAX is different from SUM.
10107 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10108 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10109 cancel_lru_locks osc
10110 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
10111 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
10113 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
10114 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
10115 echo "got $COUNT $NAME"
10116 eval $NAME=$COUNT || error "Wrong proc format"
10120 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
10121 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
10122 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
10123 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
10126 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
10127 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
10128 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
10129 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
10133 done < $TMP/${tfile}.tmp
10135 #check that we actually got some stats
10136 [ "$read_bytes" ] || error "Missing read_bytes stats"
10137 [ "$write_bytes" ] || error "Missing write_bytes stats"
10138 [ "$read_bytes" != 0 ] || error "no read done"
10139 [ "$write_bytes" != 0 ] || error "no write done"
10141 rm -f $TMP/${tfile}.tmp
10143 run_test 127b "verify the llite client stats are sane"
10145 test_128() { # bug 15212
10147 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
10152 result=$(grep error $TMP/$tfile.log)
10153 rm -f $DIR/$tfile $TMP/$tfile.log
10154 [ -z "$result" ] ||
10155 error "consecutive find's under interactive lfs failed"
10157 run_test 128 "interactive lfs for 2 consecutive find's"
10159 set_dir_limits () {
10164 local ldproc=/proc/fs/ldiskfs
10165 local facets=$(get_facets MDS)
10167 for facet in ${facets//,/ }; do
10168 canondev=$(ldiskfs_canon \
10169 *.$(convert_facet2label $facet).mntdev $facet)
10170 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
10171 ldproc=/sys/fs/ldiskfs
10172 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
10173 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
10177 check_mds_dmesg() {
10178 local facets=$(get_facets MDS)
10179 for facet in ${facets//,/ }; do
10180 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
10186 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10187 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
10188 skip "Need MDS version with at least 2.5.56"
10189 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
10190 skip_env "ldiskfs only test"
10192 remote_mds_nodsh && skip "remote MDS with nodsh"
10196 local has_warning=false
10199 mkdir -p $DIR/$tdir
10201 # block size of mds1
10202 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
10203 set_dir_limits $maxsize $maxsize
10204 local dirsize=$(stat -c%s "$DIR/$tdir")
10206 while [[ $dirsize -le $maxsize ]]; do
10207 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
10209 if ! $has_warning; then
10210 check_mds_dmesg '"is approaching"' && has_warning=true
10212 # check two errors:
10213 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
10214 # EFBIG for previous versions included in ldiskfs series
10215 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
10217 echo "return code $rc received as expected"
10219 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
10220 error_exit "create failed w/o dir size limit"
10222 check_mds_dmesg '"has reached"' ||
10223 error_exit "reached message should be output"
10225 [ $has_warning = "false" ] &&
10226 error_exit "warning message should be output"
10228 dirsize=$(stat -c%s "$DIR/$tdir")
10230 [[ $dirsize -ge $maxsize ]] && return 0
10231 error_exit "current dir size $dirsize, " \
10232 "previous limit $maxsize"
10233 elif [ $rc -ne 0 ]; then
10235 error_exit "return $rc received instead of expected " \
10236 "$EFBIG or $ENOSPC, files in dir $dirsize"
10238 nfiles=$((nfiles + 1))
10239 dirsize=$(stat -c%s "$DIR/$tdir")
10243 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
10245 run_test 129 "test directory size limit ========================"
10254 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10255 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10257 trap cleanup_130 EXIT RETURN
10259 local fm_file=$DIR/$tfile
10260 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
10261 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
10262 error "dd failed for $fm_file"
10264 # LU-1795: test filefrag/FIEMAP once, even if unsupported
10265 filefrag -ves $fm_file
10267 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10268 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10269 [ $RC != 0 ] && error "filefrag $fm_file failed"
10271 filefrag_op=$(filefrag -ve -k $fm_file |
10272 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10273 lun=$($GETSTRIPE -i $fm_file)
10275 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
10278 for line in $filefrag_op
10280 frag_lun=`echo $line | cut -d: -f5`
10281 ext_len=`echo $line | cut -d: -f4`
10282 if (( $frag_lun != $lun )); then
10284 error "FIEMAP on 1-stripe file($fm_file) failed"
10287 (( tot_len += ext_len ))
10290 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
10292 error "FIEMAP on 1-stripe file($fm_file) failed;"
10298 echo "FIEMAP on single striped file succeeded"
10300 run_test 130a "FIEMAP (1-stripe file)"
10303 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
10305 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10306 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10308 trap cleanup_130 EXIT RETURN
10310 local fm_file=$DIR/$tfile
10311 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
10312 error "setstripe on $fm_file"
10313 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10314 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10316 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
10317 error "dd failed on $fm_file"
10319 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10320 filefrag_op=$(filefrag -ve -k $fm_file |
10321 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10323 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10324 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10329 for line in $filefrag_op
10331 frag_lun=$(echo $line | cut -d: -f5 |
10332 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10333 ext_len=$(echo $line | cut -d: -f4)
10334 if (( $frag_lun != $last_lun )); then
10335 if (( tot_len != 1024 )); then
10337 error "FIEMAP on $fm_file failed; returned " \
10338 "len $tot_len for OST $last_lun instead of 1024"
10341 (( num_luns += 1 ))
10345 (( tot_len += ext_len ))
10348 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
10350 error "FIEMAP on $fm_file failed; returned wrong number of " \
10351 "luns or wrong len for OST $last_lun"
10357 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
10359 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
10362 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10364 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10365 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10367 trap cleanup_130 EXIT RETURN
10369 local fm_file=$DIR/$tfile
10370 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
10371 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10372 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10374 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
10375 error "dd failed on $fm_file"
10377 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10378 filefrag_op=$(filefrag -ve -k $fm_file |
10379 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10381 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10382 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10387 for line in $filefrag_op
10389 frag_lun=$(echo $line | cut -d: -f5 |
10390 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10391 ext_len=$(echo $line | cut -d: -f4)
10392 if (( $frag_lun != $last_lun )); then
10393 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
10394 if (( logical != 512 )); then
10396 error "FIEMAP on $fm_file failed; returned " \
10397 "logical start for lun $logical instead of 512"
10400 if (( tot_len != 512 )); then
10402 error "FIEMAP on $fm_file failed; returned " \
10403 "len $tot_len for OST $last_lun instead of 1024"
10406 (( num_luns += 1 ))
10410 (( tot_len += ext_len ))
10413 if (( num_luns != 2 || tot_len != 512 )); then
10415 error "FIEMAP on $fm_file failed; returned wrong number of " \
10416 "luns or wrong len for OST $last_lun"
10422 echo "FIEMAP on 2-stripe file with hole succeeded"
10424 run_test 130c "FIEMAP (2-stripe file with hole)"
10427 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
10429 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10430 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10432 trap cleanup_130 EXIT RETURN
10434 local fm_file=$DIR/$tfile
10435 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
10436 error "setstripe on $fm_file"
10437 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10438 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10440 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
10441 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
10442 error "dd failed on $fm_file"
10444 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10445 filefrag_op=$(filefrag -ve -k $fm_file |
10446 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10448 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10449 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10454 for line in $filefrag_op
10456 frag_lun=$(echo $line | cut -d: -f5 |
10457 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10458 ext_len=$(echo $line | cut -d: -f4)
10459 if (( $frag_lun != $last_lun )); then
10460 if (( tot_len != 1024 )); then
10462 error "FIEMAP on $fm_file failed; returned " \
10463 "len $tot_len for OST $last_lun instead of 1024"
10466 (( num_luns += 1 ))
10470 (( tot_len += ext_len ))
10473 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
10475 error "FIEMAP on $fm_file failed; returned wrong number of " \
10476 "luns or wrong len for OST $last_lun"
10482 echo "FIEMAP on N-stripe file succeeded"
10484 run_test 130d "FIEMAP (N-stripe file)"
10487 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10489 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10490 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10492 trap cleanup_130 EXIT RETURN
10494 local fm_file=$DIR/$tfile
10495 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
10496 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10497 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10500 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
10501 for ((i = 0; i < $NUM_BLKS; i++))
10503 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
10506 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10507 filefrag_op=$(filefrag -ve -k $fm_file |
10508 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10510 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10511 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10516 for line in $filefrag_op
10518 frag_lun=$(echo $line | cut -d: -f5 |
10519 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10520 ext_len=$(echo $line | cut -d: -f4)
10521 if (( $frag_lun != $last_lun )); then
10522 if (( tot_len != $EXPECTED_LEN )); then
10524 error "FIEMAP on $fm_file failed; returned " \
10525 "len $tot_len for OST $last_lun instead " \
10529 (( num_luns += 1 ))
10533 (( tot_len += ext_len ))
10536 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
10538 error "FIEMAP on $fm_file failed; returned wrong number " \
10539 "of luns or wrong len for OST $last_lun"
10545 echo "FIEMAP with continuation calls succeeded"
10547 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
10550 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10551 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10553 local fm_file=$DIR/$tfile
10554 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
10555 error "multiop create with lov_delay_create on $fm_file"
10557 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10558 filefrag_extents=$(filefrag -vek $fm_file |
10559 awk '/extents? found/ { print $2 }')
10560 if [[ "$filefrag_extents" != "0" ]]; then
10561 error "FIEMAP on $fm_file failed; " \
10562 "returned $filefrag_extents expected 0"
10567 run_test 130f "FIEMAP (unstriped file)"
10569 # Test for writev/readv
10571 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
10572 error "writev test failed"
10573 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
10574 error "readv failed"
10577 run_test 131a "test iov's crossing stripe boundary for writev/readv"
10580 local fsize=$((524288 + 1048576 + 1572864))
10581 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
10582 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10583 error "append writev test failed"
10585 ((fsize += 1572864 + 1048576))
10586 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
10587 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10588 error "append writev test failed"
10591 run_test 131b "test append writev"
10594 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
10597 run_test 131c "test read/write on file w/o objects"
10600 rwv -f $DIR/$tfile -w -n 1 1572864
10601 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
10602 if [ "$NOB" != 1572864 ]; then
10603 error "Short read filed: read $NOB bytes instead of 1572864"
10607 run_test 131d "test short read"
10610 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
10611 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
10612 error "read hitting hole failed"
10615 run_test 131e "test read hitting hole"
10624 mds*) res=$(do_facet $facet \
10625 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
10627 ost*) res=$(do_facet $facet \
10628 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
10630 *) error "Wrong facet '$facet'" ;;
10633 [ "$res" ] || error "The counter for $op on $facet was not incremented"
10634 # if the argument $3 is zero, it means any stat increment is ok.
10635 if [[ $want -gt 0 ]]; then
10636 local count=$(echo $res | awk '{ print $2 }')
10637 [[ $count -ne $want ]] &&
10638 error "The $op counter on $facet is $count, not $want"
10643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10644 remote_ost_nodsh && skip "remote OST with nodsh"
10645 remote_mds_nodsh && skip "remote MDS with nodsh"
10646 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10647 skip_env "MDS doesn't support rename stats"
10649 local testdir=$DIR/${tdir}/stats_testdir
10651 mkdir -p $DIR/${tdir}
10654 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10655 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10657 # verify mdt stats first.
10658 mkdir ${testdir} || error "mkdir failed"
10659 check_stats $SINGLEMDS "mkdir" 1
10660 touch ${testdir}/${tfile} || error "touch failed"
10661 check_stats $SINGLEMDS "open" 1
10662 check_stats $SINGLEMDS "close" 1
10663 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.8.54) ] && {
10664 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
10665 check_stats $SINGLEMDS "mknod" 2
10667 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
10668 check_stats $SINGLEMDS "unlink" 1
10669 rm -f ${testdir}/${tfile} || error "file remove failed"
10670 check_stats $SINGLEMDS "unlink" 2
10672 # remove working dir and check mdt stats again.
10673 rmdir ${testdir} || error "rmdir failed"
10674 check_stats $SINGLEMDS "rmdir" 1
10676 local testdir1=$DIR/${tdir}/stats_testdir1
10677 mkdir -p ${testdir}
10678 mkdir -p ${testdir1}
10679 touch ${testdir1}/test1
10680 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
10681 check_stats $SINGLEMDS "crossdir_rename" 1
10683 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
10684 check_stats $SINGLEMDS "samedir_rename" 1
10686 rm -rf $DIR/${tdir}
10688 run_test 133a "Verifying MDT stats ========================================"
10691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10692 remote_ost_nodsh && skip "remote OST with nodsh"
10693 remote_mds_nodsh && skip "remote MDS with nodsh"
10695 local testdir=$DIR/${tdir}/stats_testdir
10697 mkdir -p ${testdir} || error "mkdir failed"
10698 touch ${testdir}/${tfile} || error "touch failed"
10699 cancel_lru_locks mdc
10702 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10703 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10705 # extra mdt stats verification.
10706 chmod 444 ${testdir}/${tfile} || error "chmod failed"
10707 check_stats $SINGLEMDS "setattr" 1
10708 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10709 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
10711 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
10712 check_stats $SINGLEMDS "getattr" 1
10714 $LFS df || error "lfs failed"
10715 check_stats $SINGLEMDS "statfs" 1
10717 rm -rf $DIR/${tdir}
10719 run_test 133b "Verifying extra MDT stats =================================="
10722 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10723 remote_ost_nodsh && skip "remote OST with nodsh"
10724 remote_mds_nodsh && skip "remote MDS with nodsh"
10726 local testdir=$DIR/$tdir/stats_testdir
10728 test_mkdir -p $testdir
10730 # verify obdfilter stats.
10731 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
10733 cancel_lru_locks osc
10734 wait_delete_completed
10737 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10738 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10740 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
10743 cancel_lru_locks osc
10744 check_stats ost1 "write" 1
10746 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
10747 check_stats ost1 "read" 1
10749 > $testdir/$tfile || error "truncate failed"
10750 check_stats ost1 "punch" 1
10752 rm -f $testdir/$tfile || error "file remove failed"
10753 wait_delete_completed
10754 check_stats ost1 "destroy" 1
10758 run_test 133c "Verifying OST stats ========================================"
10765 while [ $value -ge 2 ]; do
10770 if [ $orig -gt $order ]; then
10778 local size=('K' 'M' 'G' 'T');
10780 local size_string=$value
10782 while [ $value -ge 1024 ]; do
10783 if [ $i -gt 3 ]; then
10784 #T is the biggest unit we get here, if that is bigger,
10786 size_string=${value}T
10789 value=$((value >> 10))
10790 if [ $value -lt 1024 ]; then
10791 size_string=${value}${size[$i]}
10800 get_rename_size() {
10802 local context=${2:-.}
10803 local sample=$(do_facet $SINGLEMDS $LCTL \
10804 get_param mdt.$FSNAME-MDT0000.rename_stats |
10805 grep -A1 $context |
10806 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
10811 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10812 remote_ost_nodsh && skip "remote OST with nodsh"
10813 remote_mds_nodsh && skip "remote MDS with nodsh"
10814 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10815 skip_env "MDS doesn't support rename stats"
10817 local testdir1=$DIR/${tdir}/stats_testdir1
10818 local testdir2=$DIR/${tdir}/stats_testdir2
10819 mkdir -p $DIR/${tdir}
10821 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10823 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
10824 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
10826 createmany -o $testdir1/test 512 || error "createmany failed"
10828 # check samedir rename size
10829 mv ${testdir1}/test0 ${testdir1}/test_0
10831 local testdir1_size=$(ls -l $DIR/${tdir} |
10832 awk '/stats_testdir1/ {print $5}')
10833 local testdir2_size=$(ls -l $DIR/${tdir} |
10834 awk '/stats_testdir2/ {print $5}')
10836 testdir1_size=$(order_2 $testdir1_size)
10837 testdir2_size=$(order_2 $testdir2_size)
10839 testdir1_size=$(size_in_KMGT $testdir1_size)
10840 testdir2_size=$(size_in_KMGT $testdir2_size)
10842 echo "source rename dir size: ${testdir1_size}"
10843 echo "target rename dir size: ${testdir2_size}"
10845 local cmd="do_facet $SINGLEMDS $LCTL "
10846 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
10848 eval $cmd || error "$cmd failed"
10849 local samedir=$($cmd | grep 'same_dir')
10850 local same_sample=$(get_rename_size $testdir1_size)
10851 [ -z "$samedir" ] && error "samedir_rename_size count error"
10852 [[ $same_sample -eq 1 ]] ||
10853 error "samedir_rename_size error $same_sample"
10854 echo "Check same dir rename stats success"
10856 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
10858 # check crossdir rename size
10859 mv ${testdir1}/test_0 ${testdir2}/test_0
10861 testdir1_size=$(ls -l $DIR/${tdir} |
10862 awk '/stats_testdir1/ {print $5}')
10863 testdir2_size=$(ls -l $DIR/${tdir} |
10864 awk '/stats_testdir2/ {print $5}')
10866 testdir1_size=$(order_2 $testdir1_size)
10867 testdir2_size=$(order_2 $testdir2_size)
10869 testdir1_size=$(size_in_KMGT $testdir1_size)
10870 testdir2_size=$(size_in_KMGT $testdir2_size)
10872 echo "source rename dir size: ${testdir1_size}"
10873 echo "target rename dir size: ${testdir2_size}"
10875 eval $cmd || error "$cmd failed"
10876 local crossdir=$($cmd | grep 'crossdir')
10877 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
10878 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
10879 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
10880 [[ $src_sample -eq 1 ]] ||
10881 error "crossdir_rename_size error $src_sample"
10882 [[ $tgt_sample -eq 1 ]] ||
10883 error "crossdir_rename_size error $tgt_sample"
10884 echo "Check cross dir rename stats success"
10885 rm -rf $DIR/${tdir}
10887 run_test 133d "Verifying rename_stats ========================================"
10890 remote_mds_nodsh && skip "remote MDS with nodsh"
10891 remote_ost_nodsh && skip "remote OST with nodsh"
10892 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10894 local testdir=$DIR/${tdir}/stats_testdir
10895 local ctr f0 f1 bs=32768 count=42 sum
10897 mkdir -p ${testdir} || error "mkdir failed"
10899 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
10901 for ctr in {write,read}_bytes; do
10903 cancel_lru_locks osc
10905 do_facet ost1 $LCTL set_param -n \
10906 "obdfilter.*.exports.clear=clear"
10908 if [ $ctr = write_bytes ]; then
10910 f1=${testdir}/${tfile}
10912 f0=${testdir}/${tfile}
10916 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
10919 cancel_lru_locks osc
10921 sum=$(do_facet ost1 $LCTL get_param \
10922 "obdfilter.*.exports.*.stats" |
10923 awk -v ctr=$ctr 'BEGIN { sum = 0 }
10924 $1 == ctr { sum += $7 }
10925 END { printf("%0.0f", sum) }')
10927 if ((sum != bs * count)); then
10928 error "Bad $ctr sum, expected $((bs * count)), got $sum"
10932 rm -rf $DIR/${tdir}
10934 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
10936 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
10939 # First without trusting modes.
10940 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
10941 echo "proc_dirs='$proc_dirs'"
10942 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
10943 find $proc_dirs -exec cat '{}' \; &> /dev/null
10945 # Second verifying readability.
10946 $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
10948 # Verifing writability with badarea_io.
10950 -ignore_readdir_race \
10952 -not -name force_lbug \
10953 -not -name changelog_mask \
10954 -exec badarea_io '{}' \; ||
10955 error "find $proc_dirs failed"
10957 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
10960 remote_mds_nodsh && skip "remote MDS with nodsh"
10961 remote_ost_nodsh && skip "remote OST with nodsh"
10963 # eventually, this can also be replaced with "lctl get_param -R",
10964 # but not until that option is always available on the server
10966 for facet in mds1 ost1; do
10967 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
10968 skip_noexit "Too old lustre on $facet"
10969 local facet_proc_dirs=$(do_facet $facet \
10970 \\\ls -d $proc_regexp 2>/dev/null)
10971 echo "${facet}_proc_dirs='$facet_proc_dirs'"
10972 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
10973 do_facet $facet find $facet_proc_dirs \
10974 ! -name req_history \
10975 -exec cat '{}' \\\; &> /dev/null
10977 do_facet $facet find $facet_proc_dirs \
10978 ! -name req_history \
10980 -exec cat '{}' \\\; &> /dev/null ||
10981 error "proc file read failed"
10983 do_facet $facet find $facet_proc_dirs \
10984 -ignore_readdir_race \
10986 -not -name force_lbug \
10987 -not -name changelog_mask \
10988 -exec badarea_io '{}' \\\; ||
10989 error "$facet find $facet_proc_dirs failed"
10992 # remount the FS in case writes/reads /proc break the FS
10993 cleanup || error "failed to unmount"
10994 setup || error "failed to setup"
10997 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
11000 remote_mds_nodsh && skip "remote MDS with nodsh"
11001 remote_ost_nodsh && skip "remote OST with nodsh"
11002 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
11003 skip "Need MDS version at least 2.9.54"
11007 for facet in client mds1 ost1; do
11008 local facet_proc_dirs=$(do_facet $facet \
11009 \\\ls -d $proc_regexp 2> /dev/null)
11010 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11011 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11012 # Get the list of files that are missing the terminating newline
11013 local missing=($(do_facet $facet \
11014 find ${facet_proc_dirs} -type f \| \
11015 while read F\; do \
11016 awk -v FS='\v' -v RS='\v\v' \
11017 "'END { if(NR>0 && \
11018 \\\$NF !~ /.*\\\n\$/) \
11019 print FILENAME}'" \
11022 [ ${#missing[*]} -eq 0 ] ||
11023 error "files do not end with newline: ${missing[*]}"
11026 run_test 133h "Proc files should end with newlines"
11029 remote_mds_nodsh && skip "remote MDS with nodsh"
11030 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
11031 skip "Need MDS version at least 2.7.54"
11033 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11034 cancel_lru_locks mdc
11036 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11037 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11038 [ $unused -eq 0 ] || error "$unused locks are not cleared"
11041 createmany -o $DIR/$tdir/f $nr ||
11042 error "failed to create $nr files in $DIR/$tdir"
11043 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11045 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
11046 do_facet mds1 $LCTL set_param fail_loc=0x327
11047 do_facet mds1 $LCTL set_param fail_val=500
11050 echo "sleep 10 seconds ..."
11052 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
11054 do_facet mds1 $LCTL set_param fail_loc=0
11055 do_facet mds1 $LCTL set_param fail_val=0
11056 [ $lck_cnt -lt $unused ] ||
11057 error "No locks reclaimed, before:$unused, after:$lck_cnt"
11060 unlinkmany $DIR/$tdir/f $nr
11062 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
11065 remote_mds_nodsh && skip "remote MDS with nodsh"
11066 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
11067 skip "Need MDS version at least 2.7.54"
11069 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11070 cancel_lru_locks mdc
11072 local low_wm=$(do_facet mds1 $LCTL get_param -n \
11073 ldlm.lock_reclaim_threshold_mb)
11074 # disable reclaim temporarily
11075 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
11077 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
11078 do_facet mds1 $LCTL set_param fail_loc=0x328
11079 do_facet mds1 $LCTL set_param fail_val=500
11081 $LCTL set_param debug=+trace
11084 createmany -o $DIR/$tdir/f $nr &
11085 local create_pid=$!
11087 echo "Sleep $TIMEOUT seconds ..."
11089 if ! ps -p $create_pid > /dev/null 2>&1; then
11090 do_facet mds1 $LCTL set_param fail_loc=0
11091 do_facet mds1 $LCTL set_param fail_val=0
11092 do_facet mds1 $LCTL set_param \
11093 ldlm.lock_reclaim_threshold_mb=${low_wm}m
11094 error "createmany finished incorrectly!"
11096 do_facet mds1 $LCTL set_param fail_loc=0
11097 do_facet mds1 $LCTL set_param fail_val=0
11098 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
11099 wait $create_pid || return 1
11101 unlinkmany $DIR/$tdir/f $nr
11103 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
11105 test_140() { #bug-17379
11106 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11108 test_mkdir $DIR/$tdir
11109 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
11110 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
11112 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
11113 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
11115 while i=$((i + 1)); do
11117 cd $i || error "Changing to $i"
11118 ln -s ../stat stat || error "Creating stat symlink"
11119 # Read the symlink until ELOOP present,
11120 # not LBUGing the system is considered success,
11121 # we didn't overrun the stack.
11122 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
11123 if [ $ret -ne 0 ]; then
11124 if [ $ret -eq 40 ]; then
11127 error "Open stat symlink"
11133 echo "The symlink depth = $i"
11134 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
11135 error "Invalid symlink depth"
11137 # Test recursive symlink
11138 ln -s symlink_self symlink_self
11139 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
11140 echo "open symlink_self returns $ret"
11141 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
11143 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
11146 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11148 local TF="$TMP/$tfile"
11150 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11152 cancel_lru_locks $OSC
11153 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
11154 remount_client $MOUNT
11156 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
11159 $TRUNCATE $DIR/$tfile 6000
11160 cancel_lru_locks $OSC
11161 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
11164 echo "12345" >>$DIR/$tfile
11165 cancel_lru_locks $OSC
11166 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
11169 echo "12345" >>$DIR/$tfile
11170 cancel_lru_locks $OSC
11171 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
11176 run_test 150 "truncate/append tests"
11178 #LU-2902 roc_hit was not able to read all values from lproc
11179 function roc_hit_init() {
11180 local list=$(comma_list $(osts_nodes))
11181 local dir=$DIR/$tdir-check
11182 local file=$dir/$tfile
11188 #use setstripe to do a write to every ost
11189 for i in $(seq 0 $((OSTCOUNT-1))); do
11190 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
11191 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
11192 idx=$(printf %04x $i)
11193 BEFORE=$(get_osd_param $list *OST*$idx stats |
11194 awk '$1 == "cache_access" {sum += $7}
11195 END { printf("%0.0f", sum) }')
11197 cancel_lru_locks osc
11198 cat $file >/dev/null
11200 AFTER=$(get_osd_param $list *OST*$idx stats |
11201 awk '$1 == "cache_access" {sum += $7}
11202 END { printf("%0.0f", sum) }')
11204 echo BEFORE:$BEFORE AFTER:$AFTER
11205 if ! let "AFTER - BEFORE == 4"; then
11207 error "roc_hit is not safe to use"
11215 function roc_hit() {
11216 local list=$(comma_list $(osts_nodes))
11217 echo $(get_osd_param $list '' stats |
11218 awk '$1 == "cache_hit" {sum += $7}
11219 END { printf("%0.0f", sum) }')
11222 function set_cache() {
11225 if [ "$2" == "off" ]; then
11228 local list=$(comma_list $(osts_nodes))
11229 set_osd_param $list '' $1_cache_enable $on
11231 cancel_lru_locks osc
11235 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11236 remote_ost_nodsh && skip "remote OST with nodsh"
11239 local list=$(comma_list $(osts_nodes))
11241 # check whether obdfilter is cache capable at all
11242 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
11243 skip "not cache-capable obdfilter"
11246 # check cache is enabled on all obdfilters
11247 if get_osd_param $list '' read_cache_enable | grep 0; then
11248 skip "oss cache is disabled"
11251 set_osd_param $list '' writethrough_cache_enable 1
11253 # check write cache is enabled on all obdfilters
11254 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
11255 skip "oss write cache is NOT enabled"
11260 #define OBD_FAIL_OBD_NO_LRU 0x609
11261 do_nodes $list $LCTL set_param fail_loc=0x609
11263 # pages should be in the case right after write
11264 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
11267 local BEFORE=$(roc_hit)
11268 cancel_lru_locks osc
11269 cat $DIR/$tfile >/dev/null
11270 local AFTER=$(roc_hit)
11272 do_nodes $list $LCTL set_param fail_loc=0
11274 if ! let "AFTER - BEFORE == CPAGES"; then
11275 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11278 # the following read invalidates the cache
11279 cancel_lru_locks osc
11280 set_osd_param $list '' read_cache_enable 0
11281 cat $DIR/$tfile >/dev/null
11283 # now data shouldn't be found in the cache
11285 cancel_lru_locks osc
11286 cat $DIR/$tfile >/dev/null
11288 if let "AFTER - BEFORE != 0"; then
11289 error "IN CACHE: before: $BEFORE, after: $AFTER"
11292 set_osd_param $list '' read_cache_enable 1
11295 run_test 151 "test cache on oss and controls ==============================="
11298 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11300 local TF="$TMP/$tfile"
11302 # simulate ENOMEM during write
11303 #define OBD_FAIL_OST_NOMEM 0x226
11304 lctl set_param fail_loc=0x80000226
11305 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11307 sync || error "sync failed"
11308 lctl set_param fail_loc=0
11310 # discard client's cache
11311 cancel_lru_locks osc
11313 # simulate ENOMEM during read
11314 lctl set_param fail_loc=0x80000226
11315 cmp $TF $DIR/$tfile || error "cmp failed"
11316 lctl set_param fail_loc=0
11320 run_test 152 "test read/write with enomem ============================"
11323 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
11325 run_test 153 "test if fdatasync does not crash ======================="
11327 dot_lustre_fid_permission_check() {
11329 local ffid=$MOUNT/.lustre/fid/$fid
11332 echo "stat fid $fid"
11333 stat $ffid > /dev/null || error "stat $ffid failed."
11334 echo "touch fid $fid"
11335 touch $ffid || error "touch $ffid failed."
11336 echo "write to fid $fid"
11337 cat /etc/hosts > $ffid || error "write $ffid failed."
11338 echo "read fid $fid"
11339 diff /etc/hosts $ffid || error "read $ffid failed."
11340 echo "append write to fid $fid"
11341 cat /etc/hosts >> $ffid || error "append write $ffid failed."
11342 echo "rename fid $fid"
11343 mv $ffid $test_dir/$tfile.1 &&
11344 error "rename $ffid to $tfile.1 should fail."
11345 touch $test_dir/$tfile.1
11346 mv $test_dir/$tfile.1 $ffid &&
11347 error "rename $tfile.1 to $ffid should fail."
11348 rm -f $test_dir/$tfile.1
11349 echo "truncate fid $fid"
11350 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
11351 echo "link fid $fid"
11352 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
11353 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
11354 echo "setfacl fid $fid"
11355 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
11356 echo "getfacl fid $fid"
11357 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
11359 echo "unlink fid $fid"
11360 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
11361 echo "mknod fid $fid"
11362 mknod $ffid c 1 3 && error "mknod $ffid should fail."
11364 fid=[0xf00000400:0x1:0x0]
11365 ffid=$MOUNT/.lustre/fid/$fid
11367 echo "stat non-exist fid $fid"
11368 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
11369 echo "write to non-exist fid $fid"
11370 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
11371 echo "link new fid $fid"
11372 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
11374 mkdir -p $test_dir/$tdir
11375 touch $test_dir/$tdir/$tfile
11376 fid=$($LFS path2fid $test_dir/$tdir)
11379 error "error: could not get fid for $test_dir/$dir/$tfile."
11381 ffid=$MOUNT/.lustre/fid/$fid
11384 ls $ffid > /dev/null || error "ls $ffid failed."
11385 echo "touch $fid/$tfile.1"
11386 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
11388 echo "touch $MOUNT/.lustre/fid/$tfile"
11389 touch $MOUNT/.lustre/fid/$tfile && \
11390 error "touch $MOUNT/.lustre/fid/$tfile should fail."
11392 echo "setxattr to $MOUNT/.lustre/fid"
11393 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
11395 echo "listxattr for $MOUNT/.lustre/fid"
11396 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
11398 echo "delxattr from $MOUNT/.lustre/fid"
11399 setfattr -x trusted.name1 $MOUNT/.lustre/fid
11401 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
11402 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
11403 error "touch invalid fid should fail."
11405 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
11406 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
11407 error "touch non-normal fid should fail."
11409 echo "rename $tdir to $MOUNT/.lustre/fid"
11410 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
11411 error "rename to $MOUNT/.lustre/fid should fail."
11413 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
11415 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
11416 local new_obf_mode=777
11418 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
11419 chmod $new_obf_mode $DIR/.lustre/fid ||
11420 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
11422 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
11423 [ $obf_mode -eq $new_obf_mode ] ||
11424 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
11426 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
11427 chmod $old_obf_mode $DIR/.lustre/fid ||
11428 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
11431 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
11432 fid=$($LFS path2fid $test_dir/$tfile-2)
11434 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
11436 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
11437 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
11438 error "create lov data thru .lustre failed"
11440 echo "cp /etc/passwd $test_dir/$tfile-2"
11441 cp /etc/passwd $test_dir/$tfile-2 ||
11442 error "copy to $test_dir/$tfile-2 failed."
11443 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
11444 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
11445 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
11447 rm -rf $test_dir/tfile.lnk
11448 rm -rf $test_dir/$tfile-2
11452 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11453 skip "Need MDS version at least 2.4.1"
11455 local tf=$DIR/$tfile
11458 local fid=$($LFS path2fid $tf)
11459 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
11461 # check that we get the same pathname back
11462 local found=$($LFS fid2path $MOUNT "$fid")
11463 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
11464 [ "$found" == "$tf" ] ||
11465 error "fid2path($fid=path2fid($tf)) = $found != $tf"
11467 run_test 154A "lfs path2fid and fid2path basic checks"
11470 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11471 skip "Need MDS version at least 2.4.1"
11473 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11474 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11475 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
11476 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
11478 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
11479 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
11481 # check that we get the same pathname
11482 echo "PFID: $PFID, name: $name"
11483 local FOUND=$($LFS fid2path $MOUNT "$PFID")
11484 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
11485 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
11486 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
11488 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
11490 run_test 154B "verify the ll_decode_linkea tool"
11493 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11494 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11495 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
11496 skip "Need MDS version at least 2.2.51"
11497 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11499 cp /etc/hosts $DIR/$tfile
11501 fid=$($LFS path2fid $DIR/$tfile)
11503 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
11505 dot_lustre_fid_permission_check "$fid" $DIR ||
11506 error "dot lustre permission check $fid failed"
11508 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
11510 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
11512 touch $MOUNT/.lustre/file &&
11513 error "creation is not allowed under .lustre"
11515 mkdir $MOUNT/.lustre/dir &&
11516 error "mkdir is not allowed under .lustre"
11520 run_test 154a "Open-by-FID"
11523 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11524 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11525 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
11526 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
11527 skip "Need MDS version at least 2.2.51"
11529 local remote_dir=$DIR/$tdir/remote_dir
11533 mkdir -p $DIR/$tdir
11534 $LFS mkdir -i $MDTIDX $remote_dir ||
11535 error "create remote directory failed"
11537 cp /etc/hosts $remote_dir/$tfile
11539 fid=$($LFS path2fid $remote_dir/$tfile)
11541 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
11543 dot_lustre_fid_permission_check "$fid" $remote_dir ||
11544 error "dot lustre permission check $fid failed"
11547 run_test 154b "Open-by-FID for remote directory"
11550 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
11551 skip "Need MDS version at least 2.4.1"
11553 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
11554 local FID1=$($LFS path2fid $DIR/$tfile.1)
11555 local FID2=$($LFS path2fid $DIR/$tfile.2)
11556 local FID3=$($LFS path2fid $DIR/$tfile.3)
11559 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
11560 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
11561 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
11563 [ "$FID" = "${!want}" ] ||
11564 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
11568 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
11570 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
11571 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
11575 run_test 154c "lfs path2fid and fid2path multiple arguments"
11578 remote_mds_nodsh && skip "remote MDS with nodsh"
11579 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
11580 skip "Need MDS version at least 2.5.53"
11582 if remote_mds; then
11583 nid=$($LCTL list_nids | sed "s/\./\\\./g")
11587 local proc_ofile="mdt.*.exports.'$nid'.open_files"
11594 local fid=$($LFS path2fid $DIR/$tfile)
11597 cmd="exec $fd<$DIR/$tfile"
11599 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
11600 echo "$fid_list" | grep "$fid"
11603 cmd="exec $fd>/dev/null"
11605 if [ $rc -ne 0 ]; then
11606 error "FID $fid not found in open files list $fid_list"
11609 run_test 154d "Verify open file fid"
11613 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
11614 skip "Need MDS version at least 2.6.50"
11616 if ls -a $MOUNT | grep -q '^\.lustre$'; then
11617 error ".lustre returned by readdir"
11620 run_test 154e ".lustre is not returned by readdir"
11623 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11625 # create parent directory on a single MDT to avoid cross-MDT hardlinks
11626 test_mkdir -p -c1 $DIR/$tdir/d
11627 # test dirs inherit from its stripe
11628 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
11629 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
11630 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
11631 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
11634 # get fid of parents
11635 local FID0=$($LFS path2fid $DIR/$tdir/d)
11636 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
11637 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
11638 local FID3=$($LFS path2fid $DIR)
11640 # check that path2fid --parents returns expected <parent_fid>/name
11641 # 1) test for a directory (single parent)
11642 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
11643 [ "$parent" == "$FID0/foo1" ] ||
11644 error "expected parent: $FID0/foo1, got: $parent"
11646 # 2) test for a file with nlink > 1 (multiple parents)
11647 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
11648 echo "$parent" | grep -F "$FID1/$tfile" ||
11649 error "$FID1/$tfile not returned in parent list"
11650 echo "$parent" | grep -F "$FID2/link" ||
11651 error "$FID2/link not returned in parent list"
11653 # 3) get parent by fid
11654 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
11655 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11656 echo "$parent" | grep -F "$FID1/$tfile" ||
11657 error "$FID1/$tfile not returned in parent list (by fid)"
11658 echo "$parent" | grep -F "$FID2/link" ||
11659 error "$FID2/link not returned in parent list (by fid)"
11661 # 4) test for entry in root directory
11662 parent=$($LFS path2fid --parents $DIR/f)
11663 echo "$parent" | grep -F "$FID3/f" ||
11664 error "$FID3/f not returned in parent list"
11666 # 5) test it on root directory
11667 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
11668 error "$MOUNT should not have parents"
11670 # enable xattr caching and check that linkea is correctly updated
11671 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11672 save_lustre_params client "llite.*.xattr_cache" > $save
11673 lctl set_param llite.*.xattr_cache 1
11675 # 6.1) linkea update on rename
11676 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
11678 # get parents by fid
11679 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11680 # foo1 should no longer be returned in parent list
11681 echo "$parent" | grep -F "$FID1" &&
11682 error "$FID1 should no longer be in parent list"
11683 # the new path should appear
11684 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
11685 error "$FID2/$tfile.moved is not in parent list"
11687 # 6.2) linkea update on unlink
11688 rm -f $DIR/$tdir/d/foo2/link
11689 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11690 # foo2/link should no longer be returned in parent list
11691 echo "$parent" | grep -F "$FID2/link" &&
11692 error "$FID2/link should no longer be in parent list"
11696 restore_lustre_params < $save
11699 run_test 154f "get parent fids by reading link ea"
11703 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11704 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
11705 $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
11706 skip "Need MDS version at least 2.6.92"
11708 mkdir -p $DIR/$tdir
11709 llapi_fid_test -d $DIR/$tdir
11711 run_test 154g "various llapi FID tests"
11713 test_155_small_load() {
11714 local temp=$TMP/$tfile
11715 local file=$DIR/$tfile
11717 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
11718 error "dd of=$temp bs=6096 count=1 failed"
11720 cancel_lru_locks $OSC
11721 cmp $temp $file || error "$temp $file differ"
11723 $TRUNCATE $temp 6000
11724 $TRUNCATE $file 6000
11725 cmp $temp $file || error "$temp $file differ (truncate1)"
11727 echo "12345" >>$temp
11728 echo "12345" >>$file
11729 cmp $temp $file || error "$temp $file differ (append1)"
11731 echo "12345" >>$temp
11732 echo "12345" >>$file
11733 cmp $temp $file || error "$temp $file differ (append2)"
11739 test_155_big_load() {
11740 remote_ost_nodsh && skip "remote OST with nodsh"
11742 local temp=$TMP/$tfile
11743 local file=$DIR/$tfile
11746 local cache_size=$(do_facet ost$((MAXI+1)) \
11747 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
11748 local large_file_size=$((cache_size * 2))
11750 echo "OSS cache size: $cache_size KB"
11751 echo "Large file size: $large_file_size KB"
11753 [ $MAXV -le $large_file_size ] &&
11754 skip_env "max available OST size needs > $large_file_size KB"
11756 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
11758 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
11759 error "dd of=$temp bs=$large_file_size count=1k failed"
11762 cancel_lru_locks osc
11763 cmp $temp $file || error "$temp $file differ"
11769 save_writethrough() {
11770 local facets=$(get_facets OST)
11772 save_lustre_params $facets "obdfilter.*.writethrough_cache_enable" > $1
11773 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" >> $1
11777 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11779 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11781 save_writethrough $p
11784 set_cache writethrough on
11785 test_155_small_load
11786 restore_lustre_params < $p
11789 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
11792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11794 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11796 save_writethrough $p
11799 set_cache writethrough off
11800 test_155_small_load
11801 restore_lustre_params < $p
11804 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
11807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11809 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11811 save_writethrough $p
11814 set_cache writethrough on
11815 test_155_small_load
11816 restore_lustre_params < $p
11819 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
11822 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11824 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11826 save_writethrough $p
11829 set_cache writethrough off
11830 test_155_small_load
11831 restore_lustre_params < $p
11834 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
11837 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11839 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11841 save_writethrough $p
11844 set_cache writethrough on
11846 restore_lustre_params < $p
11849 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
11852 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11854 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11856 save_writethrough $p
11859 set_cache writethrough off
11861 restore_lustre_params < $p
11864 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
11867 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11869 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11871 save_writethrough $p
11874 set_cache writethrough on
11876 restore_lustre_params < $p
11879 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
11882 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11884 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11886 save_writethrough $p
11889 set_cache writethrough off
11891 restore_lustre_params < $p
11894 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
11897 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11898 remote_ost_nodsh && skip "remote OST with nodsh"
11899 [ "$(facet_fstype ost1)" = "zfs" -a \
11900 $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
11901 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
11906 local file="$DIR/$tfile"
11907 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11909 save_writethrough $p
11912 log "Turn on read and write cache"
11914 set_cache writethrough on
11916 log "Write data and read it back."
11917 log "Read should be satisfied from the cache."
11918 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11920 cancel_lru_locks osc
11921 cat $file >/dev/null
11923 if ! let "AFTER - BEFORE == CPAGES"; then
11924 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11926 log "cache hits:: before: $BEFORE, after: $AFTER"
11929 log "Read again; it should be satisfied from the cache."
11931 cancel_lru_locks osc
11932 cat $file >/dev/null
11934 if ! let "AFTER - BEFORE == CPAGES"; then
11935 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11937 log "cache hits:: before: $BEFORE, after: $AFTER"
11940 log "Turn off the read cache and turn on the write cache"
11942 set_cache writethrough on
11944 log "Read again; it should be satisfied from the cache."
11946 cancel_lru_locks osc
11947 cat $file >/dev/null
11949 if ! let "AFTER - BEFORE == CPAGES"; then
11950 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11952 log "cache hits:: before: $BEFORE, after: $AFTER"
11955 log "Read again; it should not be satisfied from the cache."
11957 cancel_lru_locks osc
11958 cat $file >/dev/null
11960 if ! let "AFTER - BEFORE == 0"; then
11961 error "IN CACHE: before: $BEFORE, after: $AFTER"
11963 log "cache hits:: before: $BEFORE, after: $AFTER"
11966 log "Write data and read it back."
11967 log "Read should be satisfied from the cache."
11968 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11970 cancel_lru_locks osc
11971 cat $file >/dev/null
11973 if ! let "AFTER - BEFORE == CPAGES"; then
11974 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11976 log "cache hits:: before: $BEFORE, after: $AFTER"
11979 log "Read again; it should not be satisfied from the cache."
11981 cancel_lru_locks osc
11982 cat $file >/dev/null
11984 if ! let "AFTER - BEFORE == 0"; then
11985 error "IN CACHE: before: $BEFORE, after: $AFTER"
11987 log "cache hits:: before: $BEFORE, after: $AFTER"
11990 log "Turn off read and write cache"
11992 set_cache writethrough off
11994 log "Write data and read it back"
11995 log "It should not be satisfied from the cache."
11997 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
11998 cancel_lru_locks osc
12000 cat $file >/dev/null
12002 if ! let "AFTER - BEFORE == 0"; then
12003 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12005 log "cache hits:: before: $BEFORE, after: $AFTER"
12008 log "Turn on the read cache and turn off the write cache"
12010 set_cache writethrough off
12012 log "Write data and read it back"
12013 log "It should not be satisfied from the cache."
12015 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12017 cancel_lru_locks osc
12018 cat $file >/dev/null
12020 if ! let "AFTER - BEFORE == 0"; then
12021 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12023 log "cache hits:: before: $BEFORE, after: $AFTER"
12026 log "Read again; it should be satisfied from the cache."
12028 cancel_lru_locks osc
12029 cat $file >/dev/null
12031 if ! let "AFTER - BEFORE == CPAGES"; then
12032 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12034 log "cache hits:: before: $BEFORE, after: $AFTER"
12037 restore_lustre_params < $p
12040 run_test 156 "Verification of tunables"
12043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12044 remote_mds_nodsh && skip "remote MDS with nodsh"
12045 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
12046 skip "Need MDS version at least 2.2.0"
12048 changelog_register || error "changelog_register failed"
12049 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12050 changelog_users $SINGLEMDS | grep -q $cl_user ||
12051 error "User $cl_user not found in changelog_users"
12054 test_mkdir -p $DIR/$tdir/pics/2008/zachy
12055 changelog_clear 0 || error "changelog_clear failed"
12056 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
12057 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
12058 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
12059 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
12060 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
12061 rm $DIR/$tdir/pics/desktop.jpg
12063 changelog_dump | tail -10
12065 echo "verifying changelog mask"
12066 changelog_chmask "-MKDIR"
12067 changelog_chmask "-CLOSE"
12069 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
12070 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
12072 changelog_chmask "+MKDIR"
12073 changelog_chmask "+CLOSE"
12075 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
12076 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
12078 changelog_dump | tail -10
12079 MKDIRS=$(changelog_dump | grep -c "MKDIR")
12080 CLOSES=$(changelog_dump | grep -c "CLOSE")
12081 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
12082 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
12085 echo "verifying target fid"
12086 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
12087 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
12088 [ "$fidc" == "$fidf" ] ||
12089 error "changelog '$tfile' fid $fidc != file fid $fidf"
12090 echo "verifying parent fid"
12091 # The FID returned from the Changelog may be the directory shard on
12092 # a different MDT, and not the FID returned by path2fid on the parent.
12093 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
12094 # since this is what will matter when recreating this file in the tree.
12095 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
12096 local pathp=$($LFS fid2path $MOUNT "$fidp")
12097 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
12098 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
12100 echo "getting records for $cl_user"
12101 changelog_users $SINGLEMDS
12102 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
12104 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
12105 error "changelog_clear failed"
12106 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
12107 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
12108 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
12109 error "user index expect $user_rec1 + $nclr != $user_rec2"
12111 local min0_rec=$(changelog_users $SINGLEMDS |
12112 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
12113 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
12114 awk '{ print $1; exit; }')
12116 changelog_dump | tail -n 5
12117 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
12118 [ $first_rec == $((min0_rec + 1)) ] ||
12119 error "first index should be $min0_rec + 1 not $first_rec"
12121 # LU-3446 changelog index reset on MDT restart
12122 local cur_rec1=$(changelog_users $SINGLEMDS |
12123 awk '/^current.index:/ { print $NF }')
12124 changelog_clear 0 ||
12125 error "clear all changelog records for $cl_user failed"
12126 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
12127 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
12128 error "Fail to start $SINGLEMDS"
12129 local cur_rec2=$(changelog_users $SINGLEMDS |
12130 awk '/^current.index:/ { print $NF }')
12131 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
12132 [ $cur_rec1 == $cur_rec2 ] ||
12133 error "current index should be $cur_rec1 not $cur_rec2"
12135 echo "verifying users from this test are deregistered"
12136 changelog_deregister || error "changelog_deregister failed"
12137 changelog_users $SINGLEMDS | grep -q $cl_user &&
12138 error "User '$cl_user' still in changelog_users"
12140 # lctl get_param -n mdd.*.changelog_users
12141 # current index: 144
12142 # ID index (idle seconds)
12144 if ! changelog_users $SINGLEMDS | grep "^cl"; then
12145 # this is the normal case where all users were deregistered
12146 # make sure no new records are added when no users are present
12147 local last_rec1=$(changelog_users $SINGLEMDS |
12148 awk '/^current.index:/ { print $NF }')
12149 touch $DIR/$tdir/chloe
12150 local last_rec2=$(changelog_users $SINGLEMDS |
12151 awk '/^current.index:/ { print $NF }')
12152 echo "verify changelogs are off: $last_rec1 == $last_rec2"
12153 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
12155 # any changelog users must be leftovers from a previous test
12156 changelog_users $SINGLEMDS
12157 echo "other changelog users; can't verify off"
12160 run_test 160a "changelog sanity"
12162 test_160b() { # LU-3587
12163 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12164 remote_mds_nodsh && skip "remote MDS with nodsh"
12165 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
12166 skip "Need MDS version at least 2.2.0"
12168 changelog_register || error "changelog_register failed"
12169 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12170 changelog_users $SINGLEMDS | grep -q $cl_user ||
12171 error "User '$cl_user' not found in changelog_users"
12173 local longname1=$(str_repeat a 255)
12174 local longname2=$(str_repeat b 255)
12177 echo "creating very long named file"
12178 touch $longname1 || error "create of '$longname1' failed"
12179 echo "renaming very long named file"
12180 mv $longname1 $longname2
12182 changelog_dump | grep RENME | tail -n 5
12185 run_test 160b "Verify that very long rename doesn't crash in changelog"
12188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12189 remote_mds_nodsh && skip "remote MDS with nodsh"
12192 local server_version=$(lustre_version_code $SINGLEMDS)
12194 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12195 [[ $server_version -gt $(version_code 2.5.1) &&
12196 $server_version -lt $(version_code 2.5.50) ]] ||
12197 skip "Need MDS version at least 2.5.58 or 2.5.2+"
12199 # Registration step
12200 changelog_register || error "changelog_register failed"
12203 mkdir -p $DIR/$tdir
12204 $MCREATE $DIR/$tdir/foo_160c
12205 changelog_chmask "-TRUNC"
12206 $TRUNCATE $DIR/$tdir/foo_160c 200
12207 changelog_chmask "+TRUNC"
12208 $TRUNCATE $DIR/$tdir/foo_160c 199
12209 changelog_dump | tail -n 5
12210 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
12211 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
12213 run_test 160c "verify that changelog log catch the truncate event"
12216 remote_mds_nodsh && skip "remote MDS with nodsh"
12217 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12218 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12219 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.60) ]] ||
12220 skip "Need MDS version at least 2.7.60"
12222 # Registration step
12223 changelog_register || error "changelog_register failed"
12225 mkdir -p $DIR/$tdir/migrate_dir
12226 changelog_clear 0 || error "changelog_clear failed"
12228 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
12229 changelog_dump | tail -n 5
12230 local migrates=$(changelog_dump | grep -c "MIGRT")
12231 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
12233 run_test 160d "verify that changelog log catch the migrate event"
12236 remote_mds_nodsh && skip "remote MDS with nodsh"
12239 changelog_register || error "changelog_register failed"
12241 # Delete a future user (expect fail)
12242 local MDT0=$(facet_svc $SINGLEMDS)
12243 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
12246 if [ $rc -eq 0 ]; then
12247 error "Deleted non-existant user cl77"
12248 elif [ $rc -ne 2 ]; then
12249 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
12252 # Clear to a bad index (1 billion should be safe)
12253 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
12256 if [ $rc -eq 0 ]; then
12257 error "Successfully cleared to invalid CL index"
12258 elif [ $rc -ne 22 ]; then
12259 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
12262 run_test 160e "changelog negative testing (should return errors)"
12265 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12266 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
12267 { skip "Need MDS version at least 2.10.56"; return 0; }
12269 local mdts=$(comma_list $(mdts_nodes))
12272 changelog_register || error "first changelog_register failed"
12273 changelog_register || error "second changelog_register failed"
12275 declare -A cl_user1
12276 declare -A cl_user2
12281 # generate some changelog records to accumulate on each MDT
12282 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
12283 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12284 error "create $DIR/$tdir/$tfile failed"
12286 # check changelogs have been generated
12287 local nbcl=$(changelog_dump | wc -l)
12288 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12290 for param in "changelog_max_idle_time=10" \
12292 "changelog_min_gc_interval=2" \
12293 "changelog_min_free_cat_entries=3"; do
12294 local MDT0=$(facet_svc $SINGLEMDS)
12295 local var="${param%=*}"
12296 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12298 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12299 do_nodes $mdts $LCTL set_param mdd.*.$param
12302 # force cl_user2 to be idle (1st part)
12305 # simulate changelog catalog almost full
12306 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12307 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12309 for i in $(seq $MDSCOUNT); do
12310 cl_users=(${CL_USERS[mds$i]})
12311 cl_user1[mds$i]="${cl_users[0]}"
12312 cl_user2[mds$i]="${cl_users[1]}"
12314 [ -n "${cl_user1[mds$i]}" ] ||
12315 error "mds$i: no user registered"
12316 [ -n "${cl_user2[mds$i]}" ] ||
12317 error "mds$i: only ${cl_user2[mds$i]} is registered"
12319 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12320 [ -n "$user_rec1" ] ||
12321 error "mds$i: User ${cl_user1[mds$i]} not registered"
12322 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12323 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12324 [ -n "$user_rec2" ] ||
12325 error "mds$i: User ${cl_user1[mds$i]} not registered"
12326 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12327 "$user_rec1 + 2 == $user_rec2"
12328 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12329 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12330 "$user_rec1 + 2, but is $user_rec2"
12331 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12332 [ -n "$user_rec2" ] ||
12333 error "mds$i: User ${cl_user2[mds$i]} not registered"
12334 [ $user_rec1 == $user_rec2 ] ||
12335 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12336 "$user_rec1, but is $user_rec2"
12339 # force cl_user2 to be idle (2nd part) and to reach
12340 # changelog_max_idle_time
12343 # generate one more changelog to trigger fail_loc
12344 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12345 error "create $DIR/$tdir/${tfile}bis failed"
12347 # ensure gc thread is done
12348 for i in $(mdts_nodes); do
12350 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
12351 error "$i: GC-thread not done"
12355 for i in $(seq $MDSCOUNT); do
12356 # check cl_user1 still registered
12357 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12358 error "mds$i: User ${cl_user1[mds$i]} not registered"
12359 # check cl_user2 unregistered
12360 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12361 error "mds$i: User ${cl_user2[mds$i]} still registered"
12363 # check changelogs are present and starting at $user_rec1 + 1
12364 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12365 [ -n "$user_rec1" ] ||
12366 error "mds$i: User ${cl_user1[mds$i]} not registered"
12367 first_rec=$($LFS changelog $(facet_svc mds$i) |
12368 awk '{ print $1; exit; }')
12370 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12371 [ $((user_rec1 + 1)) == $first_rec ] ||
12372 error "mds$i: first index should be $user_rec1 + 1, " \
12373 "but is $first_rec"
12376 run_test 160f "changelog garbage collect (timestamped users)"
12379 remote_mds_nodsh && skip "remote MDS with nodsh"
12380 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
12381 skip "Need MDS version at least 2.10.56"
12383 local mdts=$(comma_list $(mdts_nodes))
12385 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
12386 do_nodes $mdts $LCTL set_param fail_loc=0x1314
12389 changelog_register || error "first changelog_register failed"
12390 changelog_register || error "second changelog_register failed"
12392 declare -A cl_user1
12393 declare -A cl_user2
12398 # generate some changelog records to accumulate on each MDT
12399 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
12400 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12401 error "create $DIR/$tdir/$tfile failed"
12403 # check changelogs have been generated
12404 local nbcl=$(changelog_dump | wc -l)
12405 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12407 for param in "changelog_max_idle_indexes=$((nbcl / 2))" \
12409 "changelog_min_gc_interval=2" \
12410 "changelog_min_free_cat_entries=3"; do
12411 local MDT0=$(facet_svc $SINGLEMDS)
12412 local var="${param%=*}"
12413 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12415 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12416 do_nodes $mdts $LCTL set_param mdd.*.$param ||
12417 error "unable to set mdd.*.$param"
12420 # simulate changelog catalog almost full
12421 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12422 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12424 for i in $(seq $MDSCOUNT); do
12425 cl_users=(${CL_USERS[mds$i]})
12426 cl_user1[mds$i]="${cl_users[0]}"
12427 cl_user2[mds$i]="${cl_users[1]}"
12429 [ -n "${cl_user1[mds$i]}" ] ||
12430 error "mds$i: no user registered"
12431 [ -n "${cl_user2[mds$i]}" ] ||
12432 error "mds$i: only ${cl_user1[mds$i]} is registered"
12434 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12435 [ -n "$user_rec1" ] ||
12436 error "mds$i: User ${cl_user1[mds$i]} not registered"
12437 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12438 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12439 [ -n "$user_rec2" ] ||
12440 error "mds$i: User ${cl_user1[mds$i]} not registered"
12441 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12442 "$user_rec1 + 2 == $user_rec2"
12443 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12444 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12445 "$user_rec1 + 2, but is $user_rec2"
12446 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12447 [ -n "$user_rec2" ] ||
12448 error "mds$i: User ${cl_user2[mds$i]} not registered"
12449 [ $user_rec1 == $user_rec2 ] ||
12450 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12451 "$user_rec1, but is $user_rec2"
12454 # ensure we are past the previous changelog_min_gc_interval set above
12457 # generate one more changelog to trigger fail_loc
12458 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12459 error "create $DIR/$tdir/${tfile}bis failed"
12461 # ensure gc thread is done
12462 for i in $(mdts_nodes); do
12464 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
12465 error "$i: GC-thread not done"
12469 for i in $(seq $MDSCOUNT); do
12470 # check cl_user1 still registered
12471 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12472 error "mds$i: User ${cl_user1[mds$i]} not registered"
12473 # check cl_user2 unregistered
12474 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12475 error "mds$i: User ${cl_user2[mds$i]} still registered"
12477 # check changelogs are present and starting at $user_rec1 + 1
12478 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12479 [ -n "$user_rec1" ] ||
12480 error "mds$i: User ${cl_user1[mds$i]} not registered"
12481 first_rec=$($LFS changelog $(facet_svc mds$i) |
12482 awk '{ print $1; exit; }')
12484 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12485 [ $((user_rec1 + 1)) == $first_rec ] ||
12486 error "mds$i: first index should be $user_rec1 + 1, " \
12487 "but is $first_rec"
12490 run_test 160g "changelog garbage collect (old users)"
12493 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12494 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
12495 { skip "Need MDS version at least 2.10.56"; return 0; }
12497 local mdts=$(comma_list $(mdts_nodes))
12500 changelog_register || error "first changelog_register failed"
12501 changelog_register || error "second changelog_register failed"
12503 declare -A cl_user1
12504 declare -A cl_user2
12509 # generate some changelog records to accumulate on each MDT
12510 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
12511 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12512 error "create $DIR/$tdir/$tfile failed"
12514 # check changelogs have been generated
12515 local nbcl=$(changelog_dump | wc -l)
12516 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12518 for param in "changelog_max_idle_time=10" \
12520 "changelog_min_gc_interval=2"; do
12521 local MDT0=$(facet_svc $SINGLEMDS)
12522 local var="${param%=*}"
12523 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12525 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12526 do_nodes $mdts $LCTL set_param mdd.*.$param
12529 # force cl_user2 to be idle (1st part)
12532 for i in $(seq $MDSCOUNT); do
12533 cl_users=(${CL_USERS[mds$i]})
12534 cl_user1[mds$i]="${cl_users[0]}"
12535 cl_user2[mds$i]="${cl_users[1]}"
12537 [ -n "${cl_user1[mds$i]}" ] ||
12538 error "mds$i: no user registered"
12539 [ -n "${cl_user2[mds$i]}" ] ||
12540 error "mds$i: only ${cl_user2[mds$i]} is registered"
12542 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12543 [ -n "$user_rec1" ] ||
12544 error "mds$i: User ${cl_user1[mds$i]} not registered"
12545 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12546 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12547 [ -n "$user_rec2" ] ||
12548 error "mds$i: User ${cl_user1[mds$i]} not registered"
12549 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12550 "$user_rec1 + 2 == $user_rec2"
12551 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12552 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12553 "$user_rec1 + 2, but is $user_rec2"
12554 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12555 [ -n "$user_rec2" ] ||
12556 error "mds$i: User ${cl_user2[mds$i]} not registered"
12557 [ $user_rec1 == $user_rec2 ] ||
12558 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12559 "$user_rec1, but is $user_rec2"
12562 # force cl_user2 to be idle (2nd part) and to reach
12563 # changelog_max_idle_time
12566 # force each GC-thread start and block then
12567 # one per MDT/MDD, set fail_val accordingly
12568 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
12569 do_nodes $mdts $LCTL set_param fail_loc=0x1316
12571 # generate more changelogs to trigger fail_loc
12572 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12573 error "create $DIR/$tdir/${tfile}bis failed"
12575 # stop MDT to stop GC-thread, should be done in back-ground as it will
12576 # block waiting for the thread to be released and exit
12577 declare -A stop_pids
12578 for i in $(seq $MDSCOUNT); do
12580 stop_pids[mds$i]=$!
12583 for i in $(mdts_nodes); do
12586 local facets=$(facets_up_on_host $i)
12588 for facet in ${facets//,/ }; do
12589 if [[ $facet == mds* ]]; then
12593 # ensure each MDS's gc threads are still present and all in "R"
12594 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
12595 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
12596 error "$i: expected $nb GC-thread"
12598 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
12600 error "$i: GC-thread not found in R-state"
12601 # check umounts of each MDT on MDS have reached kthread_stop()
12602 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
12603 error "$i: expected $nb umount"
12605 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
12606 error "$i: umount not found in D-state"
12609 # release all GC-threads
12610 do_nodes $mdts $LCTL set_param fail_loc=0
12612 # wait for MDT stop to complete
12613 for i in $(seq $MDSCOUNT); do
12614 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
12618 # may try to check if any orphan changelog records are present
12619 # via ldiskfs/zfs and llog_reader...
12621 # re-start/mount MDTs
12622 for i in $(seq $MDSCOUNT); do
12623 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
12624 error "Fail to start mds$i"
12628 for i in $(seq $MDSCOUNT); do
12629 # check cl_user1 still registered
12630 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12631 error "mds$i: User ${cl_user1[mds$i]} not registered"
12632 # check cl_user2 unregistered
12633 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12634 error "mds$i: User ${cl_user2[mds$i]} still registered"
12636 # check changelogs are present and starting at $user_rec1 + 1
12637 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12638 [ -n "$user_rec1" ] ||
12639 error "mds$i: User ${cl_user1[mds$i]} not registered"
12640 first_rec=$($LFS changelog $(facet_svc mds$i) |
12641 awk '{ print $1; exit; }')
12643 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12644 [ $((user_rec1 + 1)) == $first_rec ] ||
12645 error "mds$i: first index should be $user_rec1 + 1, " \
12646 "but is $first_rec"
12649 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
12654 local mdts=$(comma_list $(mdts_nodes))
12656 changelog_register || error "first changelog_register failed"
12658 # generate some changelog records to accumulate on each MDT
12659 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
12660 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12661 error "create $DIR/$tdir/$tfile failed"
12663 # check changelogs have been generated
12664 local nbcl=$(changelog_dump | wc -l)
12665 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12667 # simulate race between register and unregister
12668 # XXX as fail_loc is set per-MDS, with DNE configs the race
12669 # simulation will only occur for one MDT per MDS and for the
12670 # others the normal race scenario will take place
12671 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
12672 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
12673 do_nodes $mdts $LCTL set_param fail_val=1
12675 # unregister 1st user
12676 changelog_deregister &
12678 # wait some time for deregister work to reach race rdv
12680 # register 2nd user
12681 changelog_register || error "2nd user register failed"
12683 wait $pid1 || error "1st user deregister failed"
12687 declare -A LAST_REC
12688 for i in $(seq $MDSCOUNT); do
12689 if changelog_users mds$i | grep "^cl"; then
12690 # make sure new records are added with one user present
12691 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
12692 awk '/^current.index:/ { print $NF }')
12694 error "mds$i has no user registered"
12698 # generate more changelog records to accumulate on each MDT
12699 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12700 error "create $DIR/$tdir/${tfile}bis failed"
12702 for i in $(seq $MDSCOUNT); do
12703 last_rec=$(changelog_users $SINGLEMDS |
12704 awk '/^current.index:/ { print $NF }')
12705 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
12706 [ $last_rec != ${LAST_REC[mds$i]} ] ||
12707 error "changelogs are off on mds$i"
12710 run_test 160i "changelog user register/unregister race"
12713 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12715 test_mkdir -c1 $DIR/$tdir
12716 cp /etc/hosts $DIR/$tdir/$tfile
12717 test_mkdir -c1 $DIR/$tdir/foo1
12718 test_mkdir -c1 $DIR/$tdir/foo2
12719 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
12720 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
12721 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
12722 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
12723 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
12724 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
12725 $LFS fid2path $DIR $FID
12726 error "bad link ea"
12729 rm $DIR/$tdir/foo2/zachary
12731 rm $DIR/$tdir/foo2/thor
12733 rm $DIR/$tdir/$tfile
12735 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
12736 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
12737 { $LFS fid2path $DIR $FID; error "bad link rename"; }
12738 rm $DIR/$tdir/foo2/maggie
12741 local longname=$tfile.avg_len_is_thirty_two_
12742 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
12743 error_noexit 'failed to unlink many hardlinks'" EXIT
12744 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
12745 error "failed to hardlink many files"
12746 links=$($LFS fid2path $DIR $FID | wc -l)
12747 echo -n "${links}/1000 links in link EA"
12748 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
12750 run_test 161a "link ea sanity"
12753 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12754 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
12757 local remote_dir=$DIR/$tdir/remote_dir
12759 mkdir -p $DIR/$tdir
12760 $LFS mkdir -i $MDTIDX $remote_dir ||
12761 error "create remote directory failed"
12763 cp /etc/hosts $remote_dir/$tfile
12764 mkdir -p $remote_dir/foo1
12765 mkdir -p $remote_dir/foo2
12766 ln $remote_dir/$tfile $remote_dir/foo1/sofia
12767 ln $remote_dir/$tfile $remote_dir/foo2/zachary
12768 ln $remote_dir/$tfile $remote_dir/foo1/luna
12769 ln $remote_dir/$tfile $remote_dir/foo2/thor
12771 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
12773 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
12774 $LFS fid2path $DIR $FID
12775 error "bad link ea"
12778 rm $remote_dir/foo2/zachary
12780 rm $remote_dir/foo2/thor
12782 rm $remote_dir/$tfile
12784 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
12785 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
12786 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
12787 $LFS fid2path $DIR $FID
12788 error "bad link rename"
12790 rm $remote_dir/foo2/maggie
12793 local longname=filename_avg_len_is_thirty_two_
12794 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
12795 error "failed to hardlink many files"
12796 links=$($LFS fid2path $DIR $FID | wc -l)
12797 echo -n "${links}/1000 links in link EA"
12798 [[ ${links} -gt 60 ]] ||
12799 error "expected at least 60 links in link EA"
12800 unlinkmany $remote_dir/foo2/$longname 1000 ||
12801 error "failed to unlink many hardlinks"
12803 run_test 161b "link ea sanity under remote directory"
12806 remote_mds_nodsh && skip "remote MDS with nodsh"
12807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12808 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
12809 skip "Need MDS version at least 2.1.5"
12811 # define CLF_RENAME_LAST 0x0001
12812 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
12813 changelog_register || error "changelog_register failed"
12816 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
12817 touch $DIR/$tdir/foo_161c
12818 touch $DIR/$tdir/bar_161c
12819 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12820 changelog_dump | grep RENME | tail -n 5
12821 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
12822 changelog_clear 0 || error "changelog_clear failed"
12823 if [ x$flags != "x0x1" ]; then
12824 error "flag $flags is not 0x1"
12827 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
12828 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
12829 touch $DIR/$tdir/foo_161c
12830 touch $DIR/$tdir/bar_161c
12831 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12832 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
12833 changelog_dump | grep RENME | tail -n 5
12834 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
12835 changelog_clear 0 || error "changelog_clear failed"
12836 if [ x$flags != "x0x0" ]; then
12837 error "flag $flags is not 0x0"
12839 echo "rename overwrite a target having nlink > 1," \
12840 "changelog record has flags of $flags"
12842 # rename doesn't overwrite a target (changelog flag 0x0)
12843 touch $DIR/$tdir/foo_161c
12844 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
12845 changelog_dump | grep RENME | tail -n 5
12846 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
12847 changelog_clear 0 || error "changelog_clear failed"
12848 if [ x$flags != "x0x0" ]; then
12849 error "flag $flags is not 0x0"
12851 echo "rename doesn't overwrite a target," \
12852 "changelog record has flags of $flags"
12854 # define CLF_UNLINK_LAST 0x0001
12855 # unlink a file having nlink = 1 (changelog flag 0x1)
12856 rm -f $DIR/$tdir/foo2_161c
12857 changelog_dump | grep UNLNK | tail -n 5
12858 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
12859 changelog_clear 0 || error "changelog_clear failed"
12860 if [ x$flags != "x0x1" ]; then
12861 error "flag $flags is not 0x1"
12863 echo "unlink a file having nlink = 1," \
12864 "changelog record has flags of $flags"
12866 # unlink a file having nlink > 1 (changelog flag 0x0)
12867 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
12868 rm -f $DIR/$tdir/foobar_161c
12869 changelog_dump | grep UNLNK | tail -n 5
12870 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
12871 changelog_clear 0 || error "changelog_clear failed"
12872 if [ x$flags != "x0x0" ]; then
12873 error "flag $flags is not 0x0"
12875 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
12877 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
12880 remote_mds_nodsh && skip "remote MDS with nodsh"
12885 changelog_register || error "changelog_register failed"
12887 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
12888 # interfer with $MOUNT/.lustre/fid/ access
12890 [[ $? -eq 0 ]] || error "mkdir failed"
12892 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
12893 $LCTL set_param fail_loc=0x8000140c
12895 $LCTL set_param fail_val=5
12898 echo foofoo > $DIR/$tdir/$tfile &
12901 # wait for create to be delayed
12905 [[ $? -eq 0 ]] || error "create should be blocked"
12907 local tempfile=$(mktemp)
12908 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
12909 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
12910 # some delay may occur during ChangeLog publishing and file read just
12911 # above, that could allow file write to happen finally
12912 [[ -s $tempfile ]] && echo "file should be empty"
12914 $LCTL set_param fail_loc=0
12917 [[ $? -eq 0 ]] || error "create failed"
12919 run_test 161d "create with concurrent .lustre/fid access"
12922 local expected="$1"
12927 path=$($LFS fid2path "$@")
12930 if [ $rc -ne 0 ]; then
12931 error "path looked up of '$expected' failed: rc=$rc"
12932 elif [ "$path" != "$expected" ]; then
12933 error "path looked up '$path' instead of '$expected'"
12935 echo "FID '$fid' resolves to path '$path' as expected"
12939 test_162a() { # was test_162
12940 test_mkdir -p -c1 $DIR/$tdir/d2
12941 touch $DIR/$tdir/d2/$tfile
12942 touch $DIR/$tdir/d2/x1
12943 touch $DIR/$tdir/d2/x2
12944 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
12945 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
12947 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
12948 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
12951 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
12952 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
12953 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
12955 # softlink to wrong file
12956 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
12957 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
12958 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
12961 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
12962 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
12963 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
12964 # fid2path dir/fsname should both work
12965 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
12966 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
12968 # hardlink count: check that there are 2 links
12969 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
12970 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
12972 # hardlink indexing: remove the first link
12973 rm $DIR/$tdir/d2/p/q/r/hlink
12974 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
12976 run_test 162a "path lookup sanity"
12979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12980 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12983 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
12984 error "create striped dir failed"
12986 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
12987 tail -n 1 | awk '{print $2}')
12988 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
12990 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
12991 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
12994 for ((i=0;i<5;i++)); do
12995 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
12996 error "get fid for f$i failed"
12997 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
12999 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
13000 error "get fid for d$i failed"
13001 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
13006 run_test 162b "striped directory path lookup sanity"
13008 # LU-4239: Verify fid2path works with paths 100 or more directories deep
13010 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
13011 skip "Need MDS version at least 2.7.51"
13013 local lpath=$tdir.local
13014 local rpath=$tdir.remote
13016 test_mkdir $DIR/$lpath
13017 test_mkdir $DIR/$rpath
13019 for ((i = 0; i <= 101; i++)); do
13022 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
13023 error "get fid for local directory $DIR/$lpath failed"
13024 check_path "$DIR/$lpath" $MOUNT $FID --link 0
13027 test_mkdir $DIR/$rpath
13028 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
13029 error "get fid for remote directory $DIR/$rpath failed"
13030 check_path "$DIR/$rpath" $MOUNT $FID --link 0
13035 run_test 162c "fid2path works with paths 100 or more directories deep"
13038 # do directio so as not to populate the page cache
13039 log "creating a 10 Mb file"
13040 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13041 log "starting reads"
13042 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13043 log "truncating the file"
13044 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13046 kill %+ || true # reads might have finished
13047 echo "wait until dd is finished"
13049 log "removing the temporary file"
13050 rm -rf $DIR/$tfile || error "tmp file removal failed"
13052 run_test 169 "parallel read and truncate should not deadlock"
13055 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13057 $LCTL clear # bug 18514
13058 $LCTL debug_daemon start $TMP/${tfile}_log_good
13060 $LCTL debug_daemon stop
13061 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
13062 error "sed failed to read log_good"
13064 $LCTL debug_daemon start $TMP/${tfile}_log_good
13066 $LCTL debug_daemon stop
13068 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
13069 error "lctl df log_bad failed"
13071 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13072 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13074 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
13075 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
13077 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
13078 error "bad_line good_line1 good_line2 are empty"
13080 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13081 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
13082 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13084 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
13085 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13086 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13088 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
13089 error "bad_line_new good_line_new are empty"
13091 local expected_good=$((good_line1 + good_line2*2))
13093 rm -f $TMP/${tfile}*
13094 # LU-231, short malformed line may not be counted into bad lines
13095 if [ $bad_line -ne $bad_line_new ] &&
13096 [ $bad_line -ne $((bad_line_new - 1)) ]; then
13097 error "expected $bad_line bad lines, but got $bad_line_new"
13101 if [ $expected_good -ne $good_line_new ]; then
13102 error "expected $expected_good good lines, but got $good_line_new"
13107 run_test 170 "test lctl df to handle corrupted log ====================="
13109 test_171() { # bug20592
13110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13112 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
13113 $LCTL set_param fail_loc=0x50e
13114 $LCTL set_param fail_val=3000
13115 multiop_bg_pause $DIR/$tfile O_s || true
13117 kill -USR1 $MULTIPID
13121 if dmesg | grep "recursive fault"; then
13122 error "caught a recursive fault"
13124 $LCTL set_param fail_loc=0
13127 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
13129 # it would be good to share it with obdfilter-survey/iokit-libecho code
13130 setup_obdecho_osc () {
13133 local obdfilter_name=$2
13134 echo "Creating new osc for $obdfilter_name on $ost_nid"
13135 # make sure we can find loopback nid
13136 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
13138 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
13139 ${obdfilter_name}_osc_UUID || rc=2; }
13140 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
13141 ${obdfilter_name}_UUID $ost_nid || rc=3; }
13145 cleanup_obdecho_osc () {
13146 local obdfilter_name=$1
13147 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
13148 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
13155 local pages=${3:-64}
13160 local obd_size=$(get_obd_size $node $OBD)
13161 local page_size=$(get_page_size $node)
13162 if [[ -n "$obd_size" ]]; then
13163 local new_count=$((obd_size / (pages * page_size / 1024)))
13164 [[ $new_count -ge $count ]] || count=$new_count
13167 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
13168 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
13170 if [ $rc -eq 0 ]; then
13171 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
13172 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
13174 echo "New object id is $id"
13175 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
13177 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
13178 "test_brw $count w v $pages $id" || rc=4; }
13179 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
13181 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
13182 "cleanup" || rc=5; }
13183 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
13184 "detach" || rc=6; }
13185 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
13190 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13192 if ! module_loaded obdecho; then
13193 load_module obdecho/obdecho &&
13194 stack_trap "rmmod obdecho" EXIT ||
13195 error "unable to load obdecho on client"
13198 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
13199 local host=$($LCTL get_param -n osc.$osc.import |
13200 awk '/current_connection:/ { print $2 }' )
13201 local target=$($LCTL get_param -n osc.$osc.import |
13202 awk '/target:/ { print $2 }' )
13203 target=${target%_UUID}
13205 if [ -n "$target" ]; then
13206 setup_obdecho_osc $host $target &&
13207 stack_trap "cleanup_obdecho_osc $target" EXIT ||
13208 { error "obdecho setup failed with $?"; return; }
13210 obdecho_test ${target}_osc client ||
13211 error "obdecho_test failed on ${target}_osc"
13213 $LCTL get_param osc.$osc.import
13214 error "there is no osc.$osc.import target"
13217 run_test 180a "test obdecho on osc"
13220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13221 remote_ost_nodsh && skip "remote OST with nodsh"
13223 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13224 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13225 error "failed to load module obdecho"
13227 local target=$(do_facet ost1 $LCTL dl |
13228 awk '/obdfilter/ { print $4; exit; }')
13230 if [ -n "$target" ]; then
13231 obdecho_test $target ost1 || error "obdecho_test failed with $?"
13233 do_facet ost1 $LCTL dl
13234 error "there is no obdfilter target on ost1"
13237 run_test 180b "test obdecho directly on obdfilter"
13239 test_180c() { # LU-2598
13240 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13241 remote_ost_nodsh && skip "remote OST with nodsh"
13242 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
13243 skip "Need MDS version at least 2.4.0"
13245 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13246 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13247 error "failed to load module obdecho"
13249 local target=$(do_facet ost1 $LCTL dl |
13250 awk '/obdfilter/ { print $4; exit; }')
13252 if [ -n "$target" ]; then
13253 local pages=16384 # 64MB bulk I/O RPC size
13255 obdecho_test "$target" ost1 "$pages" ||
13256 error "obdecho_test with pages=$pages failed with $?"
13258 do_facet ost1 $LCTL dl
13259 error "there is no obdfilter target on ost1"
13262 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
13264 test_181() { # bug 22177
13265 test_mkdir $DIR/$tdir
13266 # create enough files to index the directory
13267 createmany -o $DIR/$tdir/foobar 4000
13268 # print attributes for debug purpose
13271 multiop_bg_pause $DIR/$tdir D_Sc || return 1
13273 # remove the files & current working dir
13274 unlinkmany $DIR/$tdir/foobar 4000
13276 kill -USR1 $MULTIPID
13278 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
13281 run_test 181 "Test open-unlinked dir ========================"
13287 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13289 $LCTL set_param mdc.*.rpc_stats=clear
13291 for (( i = 0; i < $tcount; i++ )) ; do
13292 mkdir $DIR/$tdir/$i
13295 for (( i = 0; i < $tcount; i++ )) ; do
13296 createmany -o $DIR/$tdir/$i/f- $fcount &
13300 for (( i = 0; i < $tcount; i++ )) ; do
13301 unlinkmany $DIR/$tdir/$i/f- $fcount &
13305 $LCTL get_param mdc.*.rpc_stats
13309 run_test 182 "Test parallel modify metadata operations ================"
13311 test_183() { # LU-2275
13312 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13313 remote_mds_nodsh && skip "remote MDS with nodsh"
13314 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
13315 skip "Need MDS version at least 2.3.56"
13317 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13318 echo aaa > $DIR/$tdir/$tfile
13320 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
13321 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
13323 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
13324 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
13326 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13328 # Flush negative dentry cache
13329 touch $DIR/$tdir/$tfile
13331 # We are not checking for any leaked references here, they'll
13332 # become evident next time we do cleanup with module unload.
13335 run_test 183 "No crash or request leak in case of strange dispositions ========"
13337 # test suite 184 is for LU-2016, LU-2017
13339 check_swap_layouts_support
13341 dir0=$DIR/$tdir/$testnum
13342 test_mkdir -p -c1 $dir0
13347 $SETSTRIPE -c1 $file1
13349 $SETSTRIPE -c2 $file2
13351 gen1=$($GETSTRIPE -g $file1)
13352 gen2=$($GETSTRIPE -g $file2)
13354 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
13355 gen=$($GETSTRIPE -g $file1)
13356 [[ $gen1 != $gen ]] ||
13357 "Layout generation on $file1 does not change"
13358 gen=$($GETSTRIPE -g $file2)
13359 [[ $gen2 != $gen ]] ||
13360 "Layout generation on $file2 does not change"
13362 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
13363 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13365 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
13367 run_test 184a "Basic layout swap"
13370 check_swap_layouts_support
13372 dir0=$DIR/$tdir/$testnum
13373 mkdir -p $dir0 || error "creating dir $dir0"
13380 $SETSTRIPE -c1 $file1
13381 $SETSTRIPE -c2 $file2
13382 $SETSTRIPE -c1 $file3
13383 chown $RUNAS_ID $file3
13384 gen1=$($GETSTRIPE -g $file1)
13385 gen2=$($GETSTRIPE -g $file2)
13387 $LFS swap_layouts $dir1 $dir2 &&
13388 error "swap of directories layouts should fail"
13389 $LFS swap_layouts $dir1 $file1 &&
13390 error "swap of directory and file layouts should fail"
13391 $RUNAS $LFS swap_layouts $file1 $file2 &&
13392 error "swap of file we cannot write should fail"
13393 $LFS swap_layouts $file1 $file3 &&
13394 error "swap of file with different owner should fail"
13395 /bin/true # to clear error code
13397 run_test 184b "Forbidden layout swap (will generate errors)"
13400 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
13401 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
13402 check_swap_layouts_support
13404 local dir0=$DIR/$tdir/$testnum
13405 mkdir -p $dir0 || error "creating dir $dir0"
13407 local ref1=$dir0/ref1
13408 local ref2=$dir0/ref2
13409 local file1=$dir0/file1
13410 local file2=$dir0/file2
13411 # create a file large enough for the concurrent test
13412 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
13413 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
13414 echo "ref file size: ref1($(stat -c %s $ref1))," \
13415 "ref2($(stat -c %s $ref2))"
13418 dd if=$ref1 of=$file1 bs=16k &
13421 # Make sure dd starts to copy file
13422 while [ ! -f $file1 ]; do sleep 0.1; done
13424 $LFS swap_layouts $file1 $file2
13427 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
13428 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
13430 # how many bytes copied before swapping layout
13431 local copied=$(stat -c %s $file2)
13432 local remaining=$(stat -c %s $ref1)
13433 remaining=$((remaining - copied))
13434 echo "Copied $copied bytes before swapping layout..."
13436 cmp -n $copied $file1 $ref2 | grep differ &&
13437 error "Content mismatch [0, $copied) of ref2 and file1"
13438 cmp -n $copied $file2 $ref1 ||
13439 error "Content mismatch [0, $copied) of ref1 and file2"
13440 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
13441 error "Content mismatch [$copied, EOF) of ref1 and file1"
13444 rm -f $ref1 $ref2 $file1 $file2
13446 run_test 184c "Concurrent write and layout swap"
13449 check_swap_layouts_support
13450 [ -z "$(which getfattr 2>/dev/null)" ] &&
13451 skip_env "no getfattr command"
13453 local file1=$DIR/$tdir/$tfile-1
13454 local file2=$DIR/$tdir/$tfile-2
13455 local file3=$DIR/$tdir/$tfile-3
13459 mkdir -p $DIR/$tdir
13460 touch $file1 || error "create $file1 failed"
13461 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
13462 error "create $file2 failed"
13463 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
13464 error "create $file3 failed"
13465 lovea1=$(get_layout_param $file1)
13467 $LFS swap_layouts $file2 $file3 ||
13468 error "swap $file2 $file3 layouts failed"
13469 $LFS swap_layouts $file1 $file2 ||
13470 error "swap $file1 $file2 layouts failed"
13472 lovea2=$(get_layout_param $file2)
13475 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
13477 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
13478 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
13480 run_test 184d "allow stripeless layouts swap"
13483 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
13484 skip "Need MDS version at least 2.6.94"
13485 check_swap_layouts_support
13486 [ -z "$(which getfattr 2>/dev/null)" ] &&
13487 skip_env "no getfattr command"
13489 local file1=$DIR/$tdir/$tfile-1
13490 local file2=$DIR/$tdir/$tfile-2
13491 local file3=$DIR/$tdir/$tfile-3
13494 mkdir -p $DIR/$tdir
13495 touch $file1 || error "create $file1 failed"
13496 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
13497 error "create $file2 failed"
13498 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
13499 error "create $file3 failed"
13501 $LFS swap_layouts $file1 $file2 ||
13502 error "swap $file1 $file2 layouts failed"
13504 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
13505 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
13507 echo 123 > $file1 || error "Should be able to write into $file1"
13509 $LFS swap_layouts $file1 $file3 ||
13510 error "swap $file1 $file3 layouts failed"
13512 echo 123 > $file1 || error "Should be able to write into $file1"
13514 rm -rf $file1 $file2 $file3
13516 run_test 184e "Recreate layout after stripeless layout swaps"
13518 test_185() { # LU-2441
13519 # LU-3553 - no volatile file support in old servers
13520 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
13521 skip "Need MDS version at least 2.3.60"
13523 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13524 touch $DIR/$tdir/spoo
13525 local mtime1=$(stat -c "%Y" $DIR/$tdir)
13526 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
13527 error "cannot create/write a volatile file"
13528 [ "$FILESET" == "" ] &&
13529 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
13530 error "FID is still valid after close"
13532 multiop_bg_pause $DIR/$tdir vVw4096_c
13539 # assume that the next FID for this client is sequential, since stdout
13540 # is unfortunately eaten by multiop_bg_pause
13541 local n=$((${fidv[1]} + 1))
13542 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
13543 if [ "$FILESET" == "" ]; then
13544 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
13545 error "FID is missing before close"
13547 kill -USR1 $multi_pid
13548 # 1 second delay, so if mtime change we will see it
13550 local mtime2=$(stat -c "%Y" $DIR/$tdir)
13551 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
13553 run_test 185 "Volatile file support"
13556 remote_mds_nodsh && skip "remote MDS with nodsh"
13557 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
13558 skip "Need MDS version at least 2.3.0"
13560 local dir0=$DIR/$tdir/$testnum
13561 mkdir -p $dir0 || error "creating dir $dir0"
13563 local file=$dir0/file1
13564 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
13565 local dv1=$($LFS data_version $file)
13566 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
13567 local dv2=$($LFS data_version $file)
13568 [[ $dv1 != $dv2 ]] ||
13569 error "data version did not change on write $dv1 == $dv2"
13574 run_test 187a "Test data version change"
13577 remote_mds_nodsh && skip "remote MDS with nodsh"
13578 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
13579 skip "Need MDS version at least 2.3.0"
13581 local dir0=$DIR/$tdir/$testnum
13582 mkdir -p $dir0 || error "creating dir $dir0"
13584 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
13585 [[ ${DV[0]} != ${DV[1]} ]] ||
13586 error "data version did not change on write"\
13587 " ${DV[0]} == ${DV[1]}"
13592 run_test 187b "Test data version change on volatile file"
13595 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13596 remote_mgs_nodsh && skip "remote MGS with nodsh"
13597 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13599 local POOL=${POOL:-cea1}
13600 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
13601 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
13604 local last_ost=$(($OSTCOUNT - 1))
13606 local ost_list=$(seq $first_ost $ost_step $last_ost)
13607 local ost_range="$first_ost $last_ost $ost_step"
13608 local test_path=$POOL_ROOT/$POOL_DIR_NAME
13609 local file_dir=$POOL_ROOT/file_tst
13610 local subdir=$test_path/subdir
13613 if ! combined_mgs_mds ; then
13618 # former test_200a test_200b
13619 pool_add $POOL || { rc=$? ; break; }
13620 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
13621 # former test_200c test_200d
13622 mkdir -p $test_path
13623 pool_set_dir $POOL $test_path || { rc=$? ; break; }
13624 pool_check_dir $POOL $test_path || { rc=$? ; break; }
13626 pool_check_dir $POOL $subdir || { rc=$? ; break; }
13627 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
13628 || { rc=$? ; break; }
13629 # former test_200e test_200f
13630 local files=$((OSTCOUNT*3))
13631 pool_alloc_files $POOL $test_path $files "$ost_list" \
13632 || { rc=$? ; break; }
13633 pool_create_files $POOL $file_dir $files "$ost_list" \
13634 || { rc=$? ; break; }
13635 # former test_200g test_200h
13636 pool_lfs_df $POOL || { rc=$? ; break; }
13637 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
13639 # former test_201a test_201b test_201c
13640 pool_remove_first_target $POOL || { rc=$? ; break; }
13642 local f=$test_path/$tfile
13643 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
13644 pool_remove $POOL $f || { rc=$? ; break; }
13650 if ! combined_mgs_mds ; then
13655 run_test 200 "OST pools"
13657 # usage: default_attr <count | size | offset>
13659 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
13662 # usage: check_default_stripe_attr
13663 check_default_stripe_attr() {
13664 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
13667 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
13669 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
13673 error "unknown getstripe attr '$1'"
13676 [ $ACTUAL == $EXPECTED ] ||
13677 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
13681 test_mkdir $DIR/$tdir
13682 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
13684 check_default_stripe_attr --stripe-count
13685 check_default_stripe_attr --stripe-size
13686 check_default_stripe_attr --stripe-index
13688 run_test 204a "Print default stripe attributes"
13691 test_mkdir $DIR/$tdir
13692 $SETSTRIPE --stripe-count 1 $DIR/$tdir
13694 check_default_stripe_attr --stripe-size
13695 check_default_stripe_attr --stripe-index
13697 run_test 204b "Print default stripe size and offset"
13700 test_mkdir $DIR/$tdir
13701 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
13703 check_default_stripe_attr --stripe-count
13704 check_default_stripe_attr --stripe-index
13706 run_test 204c "Print default stripe count and offset"
13709 test_mkdir $DIR/$tdir
13710 $SETSTRIPE --stripe-index 0 $DIR/$tdir
13712 check_default_stripe_attr --stripe-count
13713 check_default_stripe_attr --stripe-size
13715 run_test 204d "Print default stripe count and size"
13718 test_mkdir $DIR/$tdir
13719 $SETSTRIPE -d $DIR/$tdir
13721 check_default_stripe_attr --stripe-count --raw
13722 check_default_stripe_attr --stripe-size --raw
13723 check_default_stripe_attr --stripe-index --raw
13725 run_test 204e "Print raw stripe attributes"
13728 test_mkdir $DIR/$tdir
13729 $SETSTRIPE --stripe-count 1 $DIR/$tdir
13731 check_default_stripe_attr --stripe-size --raw
13732 check_default_stripe_attr --stripe-index --raw
13734 run_test 204f "Print raw stripe size and offset"
13737 test_mkdir $DIR/$tdir
13738 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
13740 check_default_stripe_attr --stripe-count --raw
13741 check_default_stripe_attr --stripe-index --raw
13743 run_test 204g "Print raw stripe count and offset"
13746 test_mkdir $DIR/$tdir
13747 $SETSTRIPE --stripe-index 0 $DIR/$tdir
13749 check_default_stripe_attr --stripe-count --raw
13750 check_default_stripe_attr --stripe-size --raw
13752 run_test 204h "Print raw stripe count and size"
13754 # Figure out which job scheduler is being used, if any,
13755 # or use a fake one
13756 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
13757 JOBENV=SLURM_JOB_ID
13758 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
13760 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
13762 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
13763 JOBENV=LOADL_STEP_ID
13764 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
13767 $LCTL list_param jobid_name > /dev/null 2>&1
13768 if [ $? -eq 0 ]; then
13774 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
13776 verify_jobstats() {
13781 # we don't really need to clear the stats for this test to work, since each
13782 # command has a unique jobid, but it makes debugging easier if needed.
13783 # for facet in $facets; do
13784 # local dev=$(convert_facet2label $facet)
13785 # # clear old jobstats
13786 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
13789 # use a new JobID for each test, or we might see an old one
13790 [ "$JOBENV" = "FAKE_JOBID" ] &&
13791 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
13793 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
13795 [ "$JOBENV" = "nodelocal" ] && {
13796 FAKE_JOBID=id.$testnum.%e.$RANDOM
13797 $LCTL set_param jobid_name=$FAKE_JOBID
13798 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
13801 log "Test: ${cmd[*]}"
13802 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
13804 if [ $JOBENV = "FAKE_JOBID" ]; then
13805 FAKE_JOBID=$JOBVAL ${cmd[*]}
13810 # all files are created on OST0000
13811 for facet in $facets; do
13812 local stats="*.$(convert_facet2label $facet).job_stats"
13814 # strip out libtool wrappers for in-tree executables
13815 if [ $(do_facet $facet lctl get_param $stats |
13816 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
13817 do_facet $facet lctl get_param $stats
13818 error "No jobstats for $JOBVAL found on $facet::$stats"
13824 local new_jobenv=$1
13826 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$new_jobenv
13827 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $new_jobenv
13830 test_205() { # Job stats
13831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13832 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
13833 skip "Need MDS version with at least 2.7.1"
13834 remote_mgs_nodsh && skip "remote MGS with nodsh"
13835 remote_mds_nodsh && skip "remote MDS with nodsh"
13836 remote_ost_nodsh && skip "remote OST with nodsh"
13837 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
13838 skip "Server doesn't support jobstats"
13839 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
13841 local old_jobenv=$($LCTL get_param -n jobid_var)
13842 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
13843 stack_trap "do_facet mgs \
13844 $LCTL conf_param $FSNAME.sys.jobid_var=$old_jobenv" EXIT
13848 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
13849 mdt.*.job_cleanup_interval | head -n 1)
13850 local new_interval=5
13851 do_facet $SINGLEMDS \
13852 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
13853 stack_trap "do_facet $SINGLEMDS \
13854 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
13855 local start=$SECONDS
13859 cmd="mkdir $DIR/$tdir"
13860 verify_jobstats "$cmd" "$SINGLEMDS"
13862 cmd="rmdir $DIR/$tdir"
13863 verify_jobstats "$cmd" "$SINGLEMDS"
13864 # mkdir on secondary MDT
13865 if [ $MDSCOUNT -gt 1 ]; then
13866 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
13867 verify_jobstats "$cmd" "mds2"
13870 cmd="mknod $DIR/$tfile c 1 3"
13871 verify_jobstats "$cmd" "$SINGLEMDS"
13873 cmd="rm -f $DIR/$tfile"
13874 verify_jobstats "$cmd" "$SINGLEMDS"
13875 # create all files on OST0000 so verify_jobstats can find OST stats
13877 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
13878 verify_jobstats "$cmd" "$SINGLEMDS"
13880 cmd="touch $DIR/$tfile"
13881 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13883 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
13884 verify_jobstats "$cmd" "ost1"
13886 cancel_lru_locks osc
13887 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
13888 verify_jobstats "$cmd" "ost1"
13890 cmd="$TRUNCATE $DIR/$tfile 0"
13891 verify_jobstats "$cmd" "$SINGLEMDS ost1"
13893 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
13894 verify_jobstats "$cmd" "$SINGLEMDS"
13895 # jobstats expiry - sleep until old stats should be expired
13896 local left=$((new_interval + 5 - (SECONDS - start)))
13897 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
13898 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
13900 cmd="mkdir $DIR/$tdir.expire"
13901 verify_jobstats "$cmd" "$SINGLEMDS"
13902 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
13903 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
13905 # Ensure that jobid are present in changelog (if supported by MDS)
13906 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ];then
13907 changelog_dump | tail -10
13908 jobids=$(changelog_dump | tail -9 | grep -c "j=")
13909 [ $jobids -eq 9 ] ||
13910 error "Wrong changelog jobid count $jobids != 9"
13914 jobstats_set $JOBENV
13916 changelog_dump | grep $tfile
13917 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
13918 [ $jobids -eq 0 ] ||
13919 error "Unexpected jobids when jobid_var=$JOBENV"
13922 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
13923 JOBENV="JOBCOMPLEX"
13924 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
13926 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
13928 run_test 205 "Verify job stats"
13930 # LU-1480, LU-1773 and LU-1657
13932 mkdir -p $DIR/$tdir
13933 $SETSTRIPE -c -1 $DIR/$tdir
13934 #define OBD_FAIL_LOV_INIT 0x1403
13935 $LCTL set_param fail_loc=0xa0001403
13936 $LCTL set_param fail_val=1
13937 touch $DIR/$tdir/$tfile || true
13939 run_test 206 "fail lov_init_raid0() doesn't lbug"
13942 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13943 local fsz=`stat -c %s $DIR/$tfile`
13944 cancel_lru_locks mdc
13946 # do not return layout in getattr intent
13947 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
13948 $LCTL set_param fail_loc=0x170
13949 local sz=`stat -c %s $DIR/$tfile`
13951 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
13955 run_test 207a "can refresh layout at glimpse"
13958 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
13959 local cksum=`md5sum $DIR/$tfile`
13960 local fsz=`stat -c %s $DIR/$tfile`
13961 cancel_lru_locks mdc
13962 cancel_lru_locks osc
13964 # do not return layout in getattr intent
13965 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
13966 $LCTL set_param fail_loc=0x171
13968 # it will refresh layout after the file is opened but before read issues
13969 echo checksum is "$cksum"
13970 echo "$cksum" |md5sum -c --quiet || error "file differs"
13974 run_test 207b "can refresh layout at open"
13977 # FIXME: in this test suite, only RD lease is used. This is okay
13978 # for now as only exclusive open is supported. After generic lease
13979 # is done, this test suite should be revised. - Jinshan
13981 remote_mds_nodsh && skip "remote MDS with nodsh"
13982 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
13983 skip "Need MDS version at least 2.4.52"
13985 echo "==== test 1: verify get lease work"
13986 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
13988 echo "==== test 2: verify lease can be broken by upcoming open"
13989 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
13993 $MULTIOP $DIR/$tfile oO_RDONLY:c
13994 kill -USR1 $PID && wait $PID || error "break lease error"
13996 echo "==== test 3: verify lease can't be granted if an open already exists"
13997 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
14001 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
14002 kill -USR1 $PID && wait $PID || error "open file error"
14004 echo "==== test 4: lease can sustain over recovery"
14005 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
14011 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
14013 echo "==== test 5: lease broken can't be regained by replay"
14014 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14018 # open file to break lease and then recovery
14019 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
14022 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
14026 run_test 208 "Exclusive open"
14029 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
14030 skip_env "must have disp_stripe"
14033 sync; sleep 5; sync;
14035 echo 3 > /proc/sys/vm/drop_caches
14036 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14038 # open/close 500 times
14039 for i in $(seq 500); do
14043 echo 3 > /proc/sys/vm/drop_caches
14044 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14046 echo "before: $req_before, after: $req_after"
14047 [ $((req_after - req_before)) -ge 300 ] &&
14048 error "open/close requests are not freed"
14051 run_test 209 "read-only open/close requests should be freed promptly"
14055 size=$((size % 8192 + 1))
14056 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
14057 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
14058 rm -f $DIR/f212 $DIR/f212.xyz
14060 run_test 212 "Sendfile test ============================================"
14063 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
14064 cancel_lru_locks osc
14065 lctl set_param fail_loc=0x8000040f
14066 # generate a read lock
14067 cat $DIR/$tfile > /dev/null
14068 # write to the file, it will try to cancel the above read lock.
14069 cat /etc/hosts >> $DIR/$tfile
14071 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
14073 test_214() { # for bug 20133
14074 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
14075 for (( i=0; i < 340; i++ )) ; do
14076 touch $DIR/$tdir/d214c/a$i
14079 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
14080 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
14081 ls $DIR/d214c || error "ls $DIR/d214c failed"
14082 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
14083 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
14085 run_test 214 "hash-indexed directory test - bug 20133"
14087 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
14088 create_lnet_proc_files() {
14089 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
14092 # counterpart of create_lnet_proc_files
14093 remove_lnet_proc_files() {
14094 rm -f $TMP/lnet_$1.sys
14097 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14098 # 3rd arg as regexp for body
14099 check_lnet_proc_stats() {
14100 local l=$(cat "$TMP/lnet_$1" |wc -l)
14101 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
14103 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
14106 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14107 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
14108 # optional and can be regexp for 2nd line (lnet.routes case)
14109 check_lnet_proc_entry() {
14110 local blp=2 # blp stands for 'position of 1st line of body'
14111 [ -z "$5" ] || blp=3 # lnet.routes case
14113 local l=$(cat "$TMP/lnet_$1" |wc -l)
14114 # subtracting one from $blp because the body can be empty
14115 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
14117 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
14118 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
14120 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
14121 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
14123 # bail out if any unexpected line happened
14124 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
14125 [ "$?" != 0 ] || error "$2 misformatted"
14128 test_215() { # for bugs 18102, 21079, 21517
14129 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14131 local N='(0|[1-9][0-9]*)' # non-negative numeric
14132 local P='[1-9][0-9]*' # positive numeric
14133 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
14134 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
14135 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
14136 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
14138 local L1 # regexp for 1st line
14139 local L2 # regexp for 2nd line (optional)
14140 local BR # regexp for the rest (body)
14142 # lnet.stats should look as 11 space-separated non-negative numerics
14143 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
14144 create_lnet_proc_files "stats"
14145 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
14146 remove_lnet_proc_files "stats"
14148 # lnet.routes should look like this:
14149 # Routing disabled/enabled
14150 # net hops priority state router
14151 # where net is a string like tcp0, hops > 0, priority >= 0,
14152 # state is up/down,
14153 # router is a string like 192.168.1.1@tcp2
14154 L1="^Routing (disabled|enabled)$"
14155 L2="^net +hops +priority +state +router$"
14156 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
14157 create_lnet_proc_files "routes"
14158 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
14159 remove_lnet_proc_files "routes"
14161 # lnet.routers should look like this:
14162 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
14163 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
14164 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
14165 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
14166 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
14167 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
14168 create_lnet_proc_files "routers"
14169 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
14170 remove_lnet_proc_files "routers"
14172 # lnet.peers should look like this:
14173 # nid refs state last max rtr min tx min queue
14174 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
14175 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
14176 # numeric (0 or >0 or <0), queue >= 0.
14177 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
14178 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
14179 create_lnet_proc_files "peers"
14180 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
14181 remove_lnet_proc_files "peers"
14183 # lnet.buffers should look like this:
14184 # pages count credits min
14185 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
14186 L1="^pages +count +credits +min$"
14187 BR="^ +$N +$N +$I +$I$"
14188 create_lnet_proc_files "buffers"
14189 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
14190 remove_lnet_proc_files "buffers"
14192 # lnet.nis should look like this:
14193 # nid status alive refs peer rtr max tx min
14194 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
14195 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
14196 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
14197 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
14198 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
14199 create_lnet_proc_files "nis"
14200 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
14201 remove_lnet_proc_files "nis"
14203 # can we successfully write to lnet.stats?
14204 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
14206 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
14208 test_216() { # bug 20317
14209 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14210 remote_ost_nodsh && skip "remote OST with nodsh"
14213 local facets=$(get_facets OST)
14214 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14216 save_lustre_params client "osc.*.contention_seconds" > $p
14217 save_lustre_params $facets \
14218 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
14219 save_lustre_params $facets \
14220 "ldlm.namespaces.filter-*.contended_locks" >> $p
14221 save_lustre_params $facets \
14222 "ldlm.namespaces.filter-*.contention_seconds" >> $p
14223 clear_stats osc.*.osc_stats
14225 # agressive lockless i/o settings
14226 do_nodes $(comma_list $(osts_nodes)) \
14227 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
14228 ldlm.namespaces.filter-*.contended_locks=0 \
14229 ldlm.namespaces.filter-*.contention_seconds=60"
14230 lctl set_param -n osc.*.contention_seconds=60
14232 $DIRECTIO write $DIR/$tfile 0 10 4096
14233 $CHECKSTAT -s 40960 $DIR/$tfile
14235 # disable lockless i/o
14236 do_nodes $(comma_list $(osts_nodes)) \
14237 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
14238 ldlm.namespaces.filter-*.contended_locks=32 \
14239 ldlm.namespaces.filter-*.contention_seconds=0"
14240 lctl set_param -n osc.*.contention_seconds=0
14241 clear_stats osc.*.osc_stats
14243 dd if=/dev/zero of=$DIR/$tfile count=0
14244 $CHECKSTAT -s 0 $DIR/$tfile
14246 restore_lustre_params <$p
14250 run_test 216 "check lockless direct write updates file size and kms correctly"
14252 test_217() { # bug 22430
14253 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14258 for node in $(nodes_list); do
14259 nid=$(host_nids_address $node $NETTYPE)
14260 if [[ $nid = *-* ]] ; then
14261 echo "lctl ping $(h2nettype $nid)"
14262 lctl ping $(h2nettype $nid)
14264 echo "skipping $node (no hyphen detected)"
14268 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
14271 # do directio so as not to populate the page cache
14272 log "creating a 10 Mb file"
14273 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14274 log "starting reads"
14275 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14276 log "truncating the file"
14277 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14279 kill %+ || true # reads might have finished
14280 echo "wait until dd is finished"
14282 log "removing the temporary file"
14283 rm -rf $DIR/$tfile || error "tmp file removal failed"
14285 run_test 218 "parallel read and truncate should not deadlock"
14288 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14290 # write one partial page
14291 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
14292 # set no grant so vvp_io_commit_write will do sync write
14293 $LCTL set_param fail_loc=0x411
14294 # write a full page at the end of file
14295 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
14297 $LCTL set_param fail_loc=0
14298 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
14299 $LCTL set_param fail_loc=0x411
14300 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
14303 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
14304 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
14306 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
14308 test_220() { #LU-325
14309 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14310 remote_ost_nodsh && skip "remote OST with nodsh"
14311 remote_mds_nodsh && skip "remote MDS with nodsh"
14312 remote_mgs_nodsh && skip "remote MGS with nodsh"
14316 # create on MDT0000 so the last_id and next_id are correct
14318 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
14322 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
14323 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
14324 osc.$mdtosc_proc1.prealloc_last_id)
14325 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
14326 osc.$mdtosc_proc1.prealloc_next_id)
14330 if ! combined_mgs_mds ; then
14334 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
14335 #define OBD_FAIL_OST_ENOINO 0x229
14336 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
14337 create_pool $FSNAME.$TESTNAME || return 1
14338 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
14340 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
14342 MDSOBJS=$((last_id - next_id))
14343 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
14345 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
14346 echo "OST still has $count kbytes free"
14348 echo "create $MDSOBJS files @next_id..."
14349 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
14351 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14352 osc.$mdtosc_proc1.prealloc_last_id)
14353 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14354 osc.$mdtosc_proc1.prealloc_next_id)
14356 echo "after creation, last_id=$last_id2, next_id=$next_id2"
14361 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
14362 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
14364 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
14365 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
14366 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14367 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
14368 echo "unlink $MDSOBJS files @$next_id..."
14369 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
14371 if ! combined_mgs_mds ; then
14375 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
14378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14380 dd if=`which date` of=$MOUNT/date oflag=sync
14381 chmod +x $MOUNT/date
14383 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
14384 $LCTL set_param fail_loc=0x80001401
14386 $MOUNT/date > /dev/null
14389 run_test 221 "make sure fault and truncate race to not cause OOM"
14392 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14395 test_mkdir $DIR/$tdir
14396 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14397 createmany -o $DIR/$tdir/$tfile 10
14398 cancel_lru_locks mdc
14399 cancel_lru_locks osc
14400 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
14401 $LCTL set_param fail_loc=0x31a
14402 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
14403 $LCTL set_param fail_loc=0
14406 run_test 222a "AGL for ls should not trigger CLIO lock failure"
14409 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14412 test_mkdir $DIR/$tdir
14413 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14414 createmany -o $DIR/$tdir/$tfile 10
14415 cancel_lru_locks mdc
14416 cancel_lru_locks osc
14417 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
14418 $LCTL set_param fail_loc=0x31a
14419 rm -r $DIR/$tdir || error "AGL for rmdir failed"
14420 $LCTL set_param fail_loc=0
14422 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
14425 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14428 test_mkdir $DIR/$tdir
14429 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14430 createmany -o $DIR/$tdir/$tfile 10
14431 cancel_lru_locks mdc
14432 cancel_lru_locks osc
14433 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
14434 $LCTL set_param fail_loc=0x31b
14435 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
14436 $LCTL set_param fail_loc=0
14439 run_test 223 "osc reenqueue if without AGL lock granted ======================="
14441 test_224a() { # LU-1039, MRP-303
14442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14444 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
14445 $LCTL set_param fail_loc=0x508
14446 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
14447 $LCTL set_param fail_loc=0
14450 run_test 224a "Don't panic on bulk IO failure"
14452 test_224b() { # LU-1039, MRP-303
14453 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14455 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
14456 cancel_lru_locks osc
14457 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
14458 $LCTL set_param fail_loc=0x515
14459 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
14460 $LCTL set_param fail_loc=0
14463 run_test 224b "Don't panic on bulk IO failure"
14465 test_224c() { # LU-6441
14466 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14467 remote_mds_nodsh && skip "remote MDS with nodsh"
14469 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14470 save_writethrough $p
14471 set_cache writethrough on
14473 local pages_per_rpc=$($LCTL get_param \
14474 osc.*.max_pages_per_rpc)
14475 local at_max=$($LCTL get_param -n at_max)
14476 local timeout=$($LCTL get_param -n timeout)
14477 local test_at="$LCTL get_param -n at_max"
14478 local param_at="$FSNAME.sys.at_max"
14479 local test_timeout="$LCTL get_param -n timeout"
14480 local param_timeout="$FSNAME.sys.timeout"
14482 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
14484 set_conf_param_and_check client "$test_at" "$param_at" 0 ||
14485 error "conf_param at_max=0 failed"
14486 set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
14487 error "conf_param timeout=5 failed"
14489 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
14490 do_facet ost1 $LCTL set_param fail_loc=0x520
14491 $LFS setstripe -c 1 -i 0 $DIR/$tfile
14492 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
14494 do_facet ost1 $LCTL set_param fail_loc=0
14496 set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
14497 error "conf_param at_max=$at_max failed"
14498 set_conf_param_and_check client "$test_timeout" "$param_timeout" \
14499 $timeout || error "conf_param timeout=$timeout failed"
14501 $LCTL set_param -n $pages_per_rpc
14502 restore_lustre_params < $p
14505 run_test 224c "Don't hang if one of md lost during large bulk RPC"
14507 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
14509 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14510 if [ -z ${MDSSURVEY} ]; then
14511 skip_env "mds-survey not found"
14513 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
14514 skip "Need MDS version at least 2.2.51"
14516 local mds=$(facet_host $SINGLEMDS)
14517 local target=$(do_nodes $mds 'lctl dl' |
14518 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
14520 local cmd1="file_count=1000 thrhi=4"
14521 local cmd2="dir_count=2 layer=mdd stripe_count=0"
14522 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
14523 local cmd="$cmd1 $cmd2 $cmd3"
14525 rm -f ${TMP}/mds_survey*
14527 eval $cmd || error "mds-survey with zero-stripe failed"
14528 cat ${TMP}/mds_survey*
14529 rm -f ${TMP}/mds_survey*
14531 run_test 225a "Metadata survey sanity with zero-stripe"
14534 if [ -z ${MDSSURVEY} ]; then
14535 skip_env "mds-survey not found"
14537 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
14538 skip "Need MDS version at least 2.2.51"
14539 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14540 remote_mds_nodsh && skip "remote MDS with nodsh"
14541 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
14542 skip_env "Need to mount OST to test"
14545 local mds=$(facet_host $SINGLEMDS)
14546 local target=$(do_nodes $mds 'lctl dl' |
14547 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
14549 local cmd1="file_count=1000 thrhi=4"
14550 local cmd2="dir_count=2 layer=mdd stripe_count=1"
14551 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
14552 local cmd="$cmd1 $cmd2 $cmd3"
14554 rm -f ${TMP}/mds_survey*
14556 eval $cmd || error "mds-survey with stripe_count failed"
14557 cat ${TMP}/mds_survey*
14558 rm -f ${TMP}/mds_survey*
14560 run_test 225b "Metadata survey sanity with stripe_count = 1"
14562 mcreate_path2fid () {
14568 local path=$DIR/$tdir/$name
14573 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
14574 error "cannot create $desc"
14576 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
14578 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
14580 fid_path=$($LFS fid2path $MOUNT $fid)
14582 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
14584 [ "$path" == "$fid_path" ] ||
14585 error "fid2path returned $fid_path, expected $path"
14587 echo "pass with $path and $fid"
14592 mkdir -p $DIR/$tdir
14594 mcreate_path2fid 0010666 0 0 fifo "FIFO"
14595 mcreate_path2fid 0020666 1 3 null "character special file (null)"
14596 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
14597 mcreate_path2fid 0040666 0 0 dir "directory"
14598 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
14599 mcreate_path2fid 0100666 0 0 file "regular file"
14600 mcreate_path2fid 0120666 0 0 link "symbolic link"
14601 mcreate_path2fid 0140666 0 0 sock "socket"
14603 run_test 226a "call path2fid and fid2path on files of all type"
14606 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14611 mkdir -p $DIR/$tdir
14612 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
14613 error "create remote directory failed"
14614 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
14615 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
14616 "character special file (null)"
14617 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
14618 "character special file (no device)"
14619 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
14620 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
14621 "block special file (loop)"
14622 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
14623 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
14624 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
14626 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
14628 # LU-1299 Executing or running ldd on a truncated executable does not
14629 # cause an out-of-memory condition.
14631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14632 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
14634 dd if=$(which date) of=$MOUNT/date bs=1k count=1
14635 chmod +x $MOUNT/date
14637 $MOUNT/date > /dev/null
14638 ldd $MOUNT/date > /dev/null
14641 run_test 227 "running truncated executable does not cause OOM"
14643 # LU-1512 try to reuse idle OI blocks
14645 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14646 remote_mds_nodsh && skip "remote MDS with nodsh"
14647 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
14648 skip_env "ldiskfs only test"
14650 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14651 local myDIR=$DIR/$tdir
14654 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14655 $LCTL set_param fail_loc=0x80001002
14656 createmany -o $myDIR/t- 10000
14657 $LCTL set_param fail_loc=0
14658 # The guard is current the largest FID holder
14660 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14662 local IDX=$(($SEQ % 64))
14664 do_facet $SINGLEMDS sync
14665 # Make sure journal flushed.
14667 local blk1=$(do_facet $SINGLEMDS \
14668 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14669 grep Blockcount | awk '{print $4}')
14671 # Remove old files, some OI blocks will become idle.
14672 unlinkmany $myDIR/t- 10000
14673 # Create new files, idle OI blocks should be reused.
14674 createmany -o $myDIR/t- 2000
14675 do_facet $SINGLEMDS sync
14676 # Make sure journal flushed.
14678 local blk2=$(do_facet $SINGLEMDS \
14679 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14680 grep Blockcount | awk '{print $4}')
14682 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14684 run_test 228a "try to reuse idle OI blocks"
14687 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14688 remote_mds_nodsh && skip "remote MDS with nodsh"
14689 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
14690 skip_env "ldiskfs only test"
14692 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14693 local myDIR=$DIR/$tdir
14696 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14697 $LCTL set_param fail_loc=0x80001002
14698 createmany -o $myDIR/t- 10000
14699 $LCTL set_param fail_loc=0
14700 # The guard is current the largest FID holder
14702 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14704 local IDX=$(($SEQ % 64))
14706 do_facet $SINGLEMDS sync
14707 # Make sure journal flushed.
14709 local blk1=$(do_facet $SINGLEMDS \
14710 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14711 grep Blockcount | awk '{print $4}')
14713 # Remove old files, some OI blocks will become idle.
14714 unlinkmany $myDIR/t- 10000
14717 stop $SINGLEMDS || error "Fail to stop MDT."
14719 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
14721 df $MOUNT || error "Fail to df."
14722 # Create new files, idle OI blocks should be reused.
14723 createmany -o $myDIR/t- 2000
14724 do_facet $SINGLEMDS sync
14725 # Make sure journal flushed.
14727 local blk2=$(do_facet $SINGLEMDS \
14728 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14729 grep Blockcount | awk '{print $4}')
14731 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14733 run_test 228b "idle OI blocks can be reused after MDT restart"
14737 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14738 remote_mds_nodsh && skip "remote MDS with nodsh"
14739 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
14740 skip_env "ldiskfs only test"
14742 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14743 local myDIR=$DIR/$tdir
14746 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14747 $LCTL set_param fail_loc=0x80001002
14748 # 20000 files can guarantee there are index nodes in the OI file
14749 createmany -o $myDIR/t- 20000
14750 $LCTL set_param fail_loc=0
14751 # The guard is current the largest FID holder
14753 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14755 local IDX=$(($SEQ % 64))
14757 do_facet $SINGLEMDS sync
14758 # Make sure journal flushed.
14760 local blk1=$(do_facet $SINGLEMDS \
14761 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14762 grep Blockcount | awk '{print $4}')
14764 # Remove old files, some OI blocks will become idle.
14765 unlinkmany $myDIR/t- 20000
14767 # The OI file should become empty now
14769 # Create new files, idle OI blocks should be reused.
14770 createmany -o $myDIR/t- 2000
14771 do_facet $SINGLEMDS sync
14772 # Make sure journal flushed.
14774 local blk2=$(do_facet $SINGLEMDS \
14775 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14776 grep Blockcount | awk '{print $4}')
14778 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14780 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
14782 test_229() { # LU-2482, LU-3448
14783 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14784 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
14785 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
14786 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
14790 # Create a file with a released layout and stripe count 2.
14791 $MULTIOP $DIR/$tfile H2c ||
14792 error "failed to create file with released layout"
14794 $GETSTRIPE -v $DIR/$tfile
14796 local pattern=$($GETSTRIPE -L $DIR/$tfile)
14797 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
14799 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
14800 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
14801 stat $DIR/$tfile || error "failed to stat released file"
14803 chown $RUNAS_ID $DIR/$tfile ||
14804 error "chown $RUNAS_ID $DIR/$tfile failed"
14806 chgrp $RUNAS_ID $DIR/$tfile ||
14807 error "chgrp $RUNAS_ID $DIR/$tfile failed"
14809 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
14810 rm $DIR/$tfile || error "failed to remove released file"
14812 run_test 229 "getstripe/stat/rm/attr changes work on released files"
14815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14816 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14820 test_mkdir $DIR/$tdir
14821 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
14822 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
14823 [ $mdt_idx -ne 0 ] &&
14824 error "create local directory on wrong MDT $mdt_idx"
14826 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
14827 error "create remote directory failed"
14828 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
14829 [ $mdt_idx -ne $MDTIDX ] &&
14830 error "create remote directory on wrong MDT $mdt_idx"
14832 createmany -o $DIR/$tdir/test_230/t- 10 ||
14833 error "create files on remote directory failed"
14834 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
14835 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
14836 rm -r $DIR/$tdir || error "unlink remote directory failed"
14838 run_test 230a "Create remote directory and files under the remote directory"
14841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14842 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14850 local migrate_dir=$DIR/$tdir/migrate_dir
14851 local other_dir=$DIR/$tdir/other_dir
14853 test_mkdir $DIR/$tdir
14854 test_mkdir -i0 -c1 $migrate_dir
14855 test_mkdir -i0 -c1 $other_dir
14856 for ((i=0; i<10; i++)); do
14857 mkdir -p $migrate_dir/dir_${i}
14858 createmany -o $migrate_dir/dir_${i}/f 10 ||
14859 error "create files under remote dir failed $i"
14862 cp /etc/passwd $migrate_dir/$tfile
14863 cp /etc/passwd $other_dir/$tfile
14864 chattr +SAD $migrate_dir
14865 chattr +SAD $migrate_dir/$tfile
14867 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14868 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14869 local old_dir_mode=$(stat -c%f $migrate_dir)
14870 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
14872 mkdir -p $migrate_dir/dir_default_stripe2
14873 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
14874 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
14876 mkdir -p $other_dir
14877 ln $migrate_dir/$tfile $other_dir/luna
14878 ln $migrate_dir/$tfile $migrate_dir/sofia
14879 ln $other_dir/$tfile $migrate_dir/david
14880 ln -s $migrate_dir/$tfile $other_dir/zachary
14881 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
14882 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
14884 $LFS migrate -m $MDTIDX $migrate_dir ||
14885 error "fails on migrating remote dir to MDT1"
14887 echo "migratate to MDT1, then checking.."
14888 for ((i = 0; i < 10; i++)); do
14889 for file in $(find $migrate_dir/dir_${i}); do
14890 mdt_index=$($LFS getstripe -m $file)
14891 [ $mdt_index == $MDTIDX ] ||
14892 error "$file is not on MDT${MDTIDX}"
14896 # the multiple link file should still in MDT0
14897 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
14898 [ $mdt_index == 0 ] ||
14899 error "$file is not on MDT${MDTIDX}"
14901 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14902 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14903 error " expect $old_dir_flag get $new_dir_flag"
14905 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14906 [ "$old_file_flag" = "$new_file_flag" ] ||
14907 error " expect $old_file_flag get $new_file_flag"
14909 local new_dir_mode=$(stat -c%f $migrate_dir)
14910 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14911 error "expect mode $old_dir_mode get $new_dir_mode"
14913 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14914 [ "$old_file_mode" = "$new_file_mode" ] ||
14915 error "expect mode $old_file_mode get $new_file_mode"
14917 diff /etc/passwd $migrate_dir/$tfile ||
14918 error "$tfile different after migration"
14920 diff /etc/passwd $other_dir/luna ||
14921 error "luna different after migration"
14923 diff /etc/passwd $migrate_dir/sofia ||
14924 error "sofia different after migration"
14926 diff /etc/passwd $migrate_dir/david ||
14927 error "david different after migration"
14929 diff /etc/passwd $other_dir/zachary ||
14930 error "zachary different after migration"
14932 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14933 error "${tfile}_ln different after migration"
14935 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14936 error "${tfile}_ln_other different after migration"
14938 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
14939 [ $stripe_count = 2 ] ||
14940 error "dir strpe_count $d != 2 after migration."
14942 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
14943 [ $stripe_count = 2 ] ||
14944 error "file strpe_count $d != 2 after migration."
14946 #migrate back to MDT0
14949 $LFS migrate -m $MDTIDX $migrate_dir ||
14950 error "fails on migrating remote dir to MDT0"
14952 echo "migrate back to MDT0, checking.."
14953 for file in $(find $migrate_dir); do
14954 mdt_index=$($LFS getstripe -m $file)
14955 [ $mdt_index == $MDTIDX ] ||
14956 error "$file is not on MDT${MDTIDX}"
14959 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
14960 [ "$old_dir_flag" = "$new_dir_flag" ] ||
14961 error " expect $old_dir_flag get $new_dir_flag"
14963 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
14964 [ "$old_file_flag" = "$new_file_flag" ] ||
14965 error " expect $old_file_flag get $new_file_flag"
14967 local new_dir_mode=$(stat -c%f $migrate_dir)
14968 [ "$old_dir_mode" = "$new_dir_mode" ] ||
14969 error "expect mode $old_dir_mode get $new_dir_mode"
14971 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
14972 [ "$old_file_mode" = "$new_file_mode" ] ||
14973 error "expect mode $old_file_mode get $new_file_mode"
14975 diff /etc/passwd ${migrate_dir}/$tfile ||
14976 error "$tfile different after migration"
14978 diff /etc/passwd ${other_dir}/luna ||
14979 error "luna different after migration"
14981 diff /etc/passwd ${migrate_dir}/sofia ||
14982 error "sofia different after migration"
14984 diff /etc/passwd ${other_dir}/zachary ||
14985 error "zachary different after migration"
14987 diff /etc/passwd $migrate_dir/${tfile}_ln ||
14988 error "${tfile}_ln different after migration"
14990 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
14991 error "${tfile}_ln_other different after migration"
14993 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
14994 [ $stripe_count = 2 ] ||
14995 error "dir strpe_count $d != 2 after migration."
14997 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
14998 [ $stripe_count = 2 ] ||
14999 error "file strpe_count $d != 2 after migration."
15001 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15003 run_test 230b "migrate directory"
15006 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15007 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15008 remote_mds_nodsh && skip "remote MDS with nodsh"
15013 local migrate_dir=$DIR/$tdir/migrate_dir
15015 #If migrating directory fails in the middle, all entries of
15016 #the directory is still accessiable.
15017 test_mkdir $DIR/$tdir
15018 test_mkdir -i0 -c1 $migrate_dir
15020 createmany -o $migrate_dir/f 10 ||
15021 error "create files under ${migrate_dir} failed"
15023 #failed after migrating 5 entries
15024 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
15025 do_facet mds1 lctl set_param fail_loc=0x20001801
15026 do_facet mds1 lctl set_param fail_val=5
15027 local t=$(ls $migrate_dir | wc -l)
15028 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
15029 error "migrate should fail after 5 entries"
15031 mkdir $migrate_dir/dir &&
15032 error "mkdir succeeds under migrating directory"
15033 touch $migrate_dir/file &&
15034 error "touch file succeeds under migrating directory"
15036 local u=$(ls $migrate_dir | wc -l)
15037 [ "$u" == "$t" ] || error "$u != $t during migration"
15039 for file in $(find $migrate_dir); do
15040 stat $file || error "stat $file failed"
15043 do_facet mds1 lctl set_param fail_loc=0
15044 do_facet mds1 lctl set_param fail_val=0
15046 $LFS migrate -m $MDTIDX $migrate_dir ||
15047 error "migrate open files should failed with open files"
15049 echo "Finish migration, then checking.."
15050 for file in $(find $migrate_dir); do
15051 mdt_index=$($LFS getstripe -m $file)
15052 [ $mdt_index == $MDTIDX ] ||
15053 error "$file is not on MDT${MDTIDX}"
15056 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15058 run_test 230c "check directory accessiblity if migration is failed"
15061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15062 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15066 local migrate_dir=$DIR/$tdir/migrate_dir
15070 test_mkdir $DIR/$tdir
15071 test_mkdir -i0 -c1 $migrate_dir
15073 for ((i=0; i<100; i++)); do
15074 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
15075 createmany -o $migrate_dir/dir_${i}/f 100 ||
15076 error "create files under remote dir failed $i"
15079 $LFS migrate -m $MDTIDX $migrate_dir ||
15080 error "migrate remote dir error"
15082 echo "Finish migration, then checking.."
15083 for file in $(find $migrate_dir); do
15084 mdt_index=$($LFS getstripe -m $file)
15085 [ $mdt_index == $MDTIDX ] ||
15086 error "$file is not on MDT${MDTIDX}"
15089 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15091 run_test 230d "check migrate big directory"
15094 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15095 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15102 mkdir -p $DIR/$tdir
15103 mkdir $DIR/$tdir/migrate_dir
15104 mkdir $DIR/$tdir/other_dir
15105 touch $DIR/$tdir/migrate_dir/a
15106 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
15107 ls $DIR/$tdir/other_dir
15109 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15110 error "migrate dir fails"
15112 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15113 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15115 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15116 [ $mdt_index == 0 ] || error "a is not on MDT0"
15118 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
15119 error "migrate dir fails"
15121 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
15122 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
15124 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15125 [ $mdt_index == 1 ] || error "a is not on MDT1"
15127 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
15128 [ $mdt_index == 1 ] || error "b is not on MDT1"
15130 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15131 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
15133 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
15135 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15137 run_test 230e "migrate mulitple local link files"
15140 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15141 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15146 mkdir -p $DIR/$tdir
15147 mkdir $DIR/$tdir/migrate_dir
15148 $LFS mkdir -i1 $DIR/$tdir/other_dir
15149 touch $DIR/$tdir/migrate_dir/a
15150 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
15151 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
15152 ls $DIR/$tdir/other_dir
15154 # a should be migrated to MDT1, since no other links on MDT0
15155 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15156 error "#1 migrate dir fails"
15157 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15158 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15159 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15160 [ $mdt_index == 1 ] || error "a is not on MDT1"
15162 # a should stay on MDT1, because it is a mulitple link file
15163 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15164 error "#2 migrate dir fails"
15165 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15166 [ $mdt_index == 1 ] || error "a is not on MDT1"
15168 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15169 error "#3 migrate dir fails"
15171 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15172 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
15173 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
15175 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
15176 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
15178 # a should be migrated to MDT0, since no other links on MDT1
15179 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15180 error "#4 migrate dir fails"
15181 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15182 [ $mdt_index == 0 ] || error "a is not on MDT0"
15184 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15186 run_test 230f "migrate mulitple remote link files"
15189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15190 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15192 mkdir -p $DIR/$tdir/migrate_dir
15194 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
15195 error "migrating dir to non-exist MDT succeeds"
15198 run_test 230g "migrate dir to non-exist MDT"
15201 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15202 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15203 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
15204 skip "Need MDS version at least 2.7.64"
15208 mkdir -p $DIR/$tdir/migrate_dir
15210 $LFS migrate -m1 $DIR &&
15211 error "migrating mountpoint1 should fail"
15213 $LFS migrate -m1 $DIR/$tdir/.. &&
15214 error "migrating mountpoint2 should fail"
15216 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
15217 error "migrating $tdir fail"
15219 mdt_index=$($LFS getstripe -m $DIR/$tdir)
15220 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
15222 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15223 [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
15226 run_test 230h "migrate .. and root"
15229 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15230 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15232 mkdir -p $DIR/$tdir/migrate_dir
15234 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
15235 error "migration fails with a tailing slash"
15237 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
15238 error "migration fails with two tailing slashes"
15240 run_test 230i "lfs migrate -m tolerates trailing slashes"
15244 # For simplicity this test assumes that max_pages_per_rpc
15245 # is the same across all OSCs
15246 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
15247 local bulk_size=$((max_pages * 4096))
15248 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
15251 mkdir -p $DIR/$tdir
15252 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
15253 error "failed to set stripe with -S ${brw_size}M option"
15255 # clear the OSC stats
15256 $LCTL set_param osc.*.stats=0 &>/dev/null
15259 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
15260 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
15261 oflag=direct &>/dev/null || error "dd failed"
15263 sync; sleep 1; sync # just to be safe
15264 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
15265 if [ x$nrpcs != "x1" ]; then
15266 $LCTL get_param osc.*.stats
15267 error "found $nrpcs ost_write RPCs, not 1 as expected"
15271 # Drop the OSC cache, otherwise we will read from it
15272 cancel_lru_locks osc
15274 # clear the OSC stats
15275 $LCTL set_param osc.*.stats=0 &>/dev/null
15277 # Client reads $bulk_size.
15278 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
15279 iflag=direct &>/dev/null || error "dd failed"
15281 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
15282 if [ x$nrpcs != "x1" ]; then
15283 $LCTL get_param osc.*.stats
15284 error "found $nrpcs ost_read RPCs, not 1 as expected"
15287 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
15290 mkdir -p $DIR/$tdir
15292 for i in {0..1023}; do
15293 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
15294 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
15295 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
15299 run_test 231b "must not assert on fully utilized OST request buffer"
15302 mkdir -p $DIR/$tdir
15303 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
15305 #define OBD_FAIL_LDLM_OST_LVB 0x31c
15306 do_facet ost1 $LCTL set_param fail_loc=0x31c
15308 # ignore dd failure
15309 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
15311 do_facet ost1 $LCTL set_param fail_loc=0
15312 umount_client $MOUNT || error "umount failed"
15313 mount_client $MOUNT || error "mount failed"
15314 stop ost1 || error "cannot stop ost1"
15315 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
15317 run_test 232a "failed lock should not block umount"
15320 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.58) ] ||
15321 skip "Need MDS version at least 2.10.58"
15323 mkdir -p $DIR/$tdir
15324 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
15325 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
15327 cancel_lru_locks osc
15329 #define OBD_FAIL_LDLM_OST_LVB 0x31c
15330 do_facet ost1 $LCTL set_param fail_loc=0x31c
15333 $LFS data_version $DIR/$tdir/$tfile || true
15335 do_facet ost1 $LCTL set_param fail_loc=0
15336 umount_client $MOUNT || error "umount failed"
15337 mount_client $MOUNT || error "mount failed"
15338 stop ost1 || error "cannot stop ost1"
15339 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
15341 run_test 232b "failed data version lock should not block umount"
15344 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
15345 skip "Need MDS version at least 2.3.64"
15346 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
15348 local fid=$($LFS path2fid $MOUNT)
15350 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15351 error "cannot access $MOUNT using its FID '$fid'"
15353 run_test 233a "checking that OBF of the FS root succeeds"
15356 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
15357 skip "Need MDS version at least 2.5.90"
15358 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
15360 local fid=$($LFS path2fid $MOUNT/.lustre)
15362 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15363 error "cannot access $MOUNT/.lustre using its FID '$fid'"
15365 fid=$($LFS path2fid $MOUNT/.lustre/fid)
15366 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15367 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
15369 run_test 233b "checking that OBF of the FS .lustre succeeds"
15372 local p="$TMP/sanityN-$TESTNAME.parameters"
15373 save_lustre_params client "llite.*.xattr_cache" > $p
15374 lctl set_param llite.*.xattr_cache 1 ||
15375 skip_env "xattr cache is not supported"
15377 mkdir -p $DIR/$tdir || error "mkdir failed"
15378 touch $DIR/$tdir/$tfile || error "touch failed"
15379 # OBD_FAIL_LLITE_XATTR_ENOMEM
15380 $LCTL set_param fail_loc=0x1405
15381 getfattr -n user.attr $DIR/$tdir/$tfile &&
15382 error "getfattr should have failed with ENOMEM"
15383 $LCTL set_param fail_loc=0x0
15386 restore_lustre_params < $p
15389 run_test 234 "xattr cache should not crash on ENOMEM"
15392 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
15393 skip "Need MDS version at least 2.4.52"
15395 flock_deadlock $DIR/$tfile
15400 124) error "process hangs on a deadlock"
15402 *) error "error executing flock_deadlock $DIR/$tfile"
15406 run_test 235 "LU-1715: flock deadlock detection does not work properly"
15410 check_swap_layouts_support
15412 local ref1=/etc/passwd
15413 local ref2=/etc/group
15414 local file1=$DIR/$tdir/f1
15415 local file2=$DIR/$tdir/f2
15417 test_mkdir -c1 $DIR/$tdir
15418 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
15419 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
15420 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
15421 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
15422 local fd=$(free_fd)
15423 local cmd="exec $fd<>$file2"
15426 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
15427 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
15430 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
15435 run_test 236 "Layout swap on open unlinked file"
15437 # test to verify file handle related system calls
15438 # (name_to_handle_at/open_by_handle_at)
15439 # The new system calls are supported in glibc >= 2.14.
15442 echo "Test file_handle syscalls" > $DIR/$tfile ||
15443 error "write failed"
15444 check_fhandle_syscalls $DIR/$tfile ||
15445 error "check_fhandle_syscalls failed"
15447 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
15449 # LU-4659 linkea consistency
15451 local server_version=$(lustre_version_code $SINGLEMDS)
15453 [[ $server_version -gt $(version_code 2.5.57) ]] ||
15454 [[ $server_version -gt $(version_code 2.5.1) &&
15455 $server_version -lt $(version_code 2.5.50) ]] ||
15456 skip "Need MDS version at least 2.5.58 or 2.5.2+"
15459 ln $DIR/$tfile $DIR/$tfile.lnk
15460 touch $DIR/$tfile.new
15461 mv $DIR/$tfile.new $DIR/$tfile
15462 local fid1=$($LFS path2fid $DIR/$tfile)
15463 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
15464 local path1=$($LFS fid2path $FSNAME "$fid1")
15465 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
15466 local path2=$($LFS fid2path $FSNAME "$fid2")
15467 [ $tfile.lnk == $path2 ] ||
15468 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
15471 run_test 238 "Verify linkea consistency"
15473 test_239A() { # was test_239
15474 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
15475 skip "Need MDS version at least 2.5.60"
15477 local list=$(comma_list $(mdts_nodes))
15479 mkdir -p $DIR/$tdir
15480 createmany -o $DIR/$tdir/f- 5000
15481 unlinkmany $DIR/$tdir/f- 5000
15482 [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] &&
15483 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
15484 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
15485 osp.*MDT*.sync_in_flight" | calc_sum)
15486 [ "$changes" -eq 0 ] || error "$changes not synced"
15488 run_test 239A "osp_sync test"
15490 test_239a() { #LU-5297
15491 remote_mds_nodsh && skip "remote MDS with nodsh"
15494 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
15495 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
15496 chgrp $RUNAS_GID $DIR/$tfile
15497 wait_delete_completed
15499 run_test 239a "process invalid osp sync record correctly"
15501 test_239b() { #LU-5297
15502 remote_mds_nodsh && skip "remote MDS with nodsh"
15505 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
15506 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
15507 chgrp $RUNAS_GID $DIR/$tfile1
15508 wait_delete_completed
15509 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
15511 chgrp $RUNAS_GID $DIR/$tfile2
15512 wait_delete_completed
15514 run_test 239b "process osp sync record with ENOMEM error correctly"
15517 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15518 remote_mds_nodsh && skip "remote MDS with nodsh"
15520 mkdir -p $DIR/$tdir
15522 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
15523 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
15524 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
15525 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
15527 umount_client $MOUNT || error "umount failed"
15528 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
15529 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
15530 mount_client $MOUNT || error "failed to mount client"
15532 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
15533 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
15535 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
15538 for LOOP in $(seq $1); do
15539 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
15540 cancel_lru_locks $OSC || true
15545 for LOOP in $(seq $1); do
15546 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
15547 iflag=direct 2>/dev/null
15551 test_241a() { # was test_241
15552 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
15554 cancel_lru_locks $OSC
15555 test_241_bio 1000 &
15560 run_test 241a "bio vs dio"
15563 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
15565 test_241_dio 1000 &
15570 run_test 241b "dio vs dio"
15573 remote_mds_nodsh && skip "remote MDS with nodsh"
15575 mkdir -p $DIR/$tdir
15576 touch $DIR/$tdir/$tfile
15578 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
15579 do_facet mds1 lctl set_param fail_loc=0x105
15580 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
15582 do_facet mds1 lctl set_param fail_loc=0
15583 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
15585 run_test 242 "mdt_readpage failure should not cause directory unreadable"
15589 test_mkdir $DIR/$tdir
15590 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
15592 run_test 243 "various group lock tests"
15596 test_mkdir $DIR/$tdir
15597 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
15598 sendfile_grouplock $DIR/$tdir/$tfile || \
15599 error "sendfile+grouplock failed"
15602 run_test 244 "sendfile with group lock tests"
15605 local flagname="multi_mod_rpcs"
15606 local connect_data_name="max_mod_rpcs"
15609 # check if multiple modify RPCs flag is set
15610 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
15611 grep "connect_flags:")
15614 echo "$out" | grep -qw $flagname
15615 if [ $? -ne 0 ]; then
15616 echo "connect flag $flagname is not set"
15620 # check if multiple modify RPCs data is set
15621 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
15624 echo "$out" | grep -qw $connect_data_name ||
15625 error "import should have connect data $connect_data_name"
15627 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
15629 test_246() { # LU-7371
15630 remote_ost_nodsh && skip "remote OST with nodsh"
15631 [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
15632 skip "Need OST version >= 2.7.62"
15634 do_facet ost1 $LCTL set_param fail_val=4095
15635 #define OBD_FAIL_OST_READ_SIZE 0x234
15636 do_facet ost1 $LCTL set_param fail_loc=0x234
15637 $LFS setstripe $DIR/$tfile -i 0 -c 1
15638 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
15639 cancel_lru_locks $FSNAME-OST0000
15640 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
15642 run_test 246 "Read file of size 4095 should return right length"
15648 umount_client $submount
15653 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
15655 skip_env "Fileset feature is not supported"
15657 local submount=${MOUNT}_$tdir
15660 mkdir -p $submount || error "mkdir $submount failed"
15661 FILESET="$FILESET/$tdir" mount_client $submount ||
15662 error "mount $submount failed"
15663 trap "cleanup_247 $submount" EXIT
15664 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
15665 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
15666 error "read $MOUNT/$tdir/$tfile failed"
15667 cleanup_247 $submount
15669 run_test 247a "mount subdir as fileset"
15672 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
15673 skip_env "Fileset feature is not supported"
15675 local submount=${MOUNT}_$tdir
15677 rm -rf $MOUNT/$tdir
15678 mkdir -p $submount || error "mkdir $submount failed"
15680 FILESET="$FILESET/$tdir" mount_client $submount &&
15681 error "mount $submount should fail"
15684 run_test 247b "mount subdir that dose not exist"
15687 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
15688 skip_env "Fileset feature is not supported"
15690 local submount=${MOUNT}_$tdir
15692 mkdir -p $MOUNT/$tdir/dir1
15693 mkdir -p $submount || error "mkdir $submount failed"
15694 trap "cleanup_247 $submount" EXIT
15695 FILESET="$FILESET/$tdir" mount_client $submount ||
15696 error "mount $submount failed"
15697 local fid=$($LFS path2fid $MOUNT/)
15698 $LFS fid2path $submount $fid && error "fid2path should fail"
15699 cleanup_247 $submount
15701 run_test 247c "running fid2path outside root"
15704 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
15705 skip "Fileset feature is not supported"
15707 local submount=${MOUNT}_$tdir
15709 mkdir -p $MOUNT/$tdir/dir1
15710 mkdir -p $submount || error "mkdir $submount failed"
15711 FILESET="$FILESET/$tdir" mount_client $submount ||
15712 error "mount $submount failed"
15713 trap "cleanup_247 $submount" EXIT
15714 local fid=$($LFS path2fid $submount/dir1)
15715 $LFS fid2path $submount $fid || error "fid2path should succeed"
15716 cleanup_247 $submount
15718 run_test 247d "running fid2path inside root"
15722 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
15724 skip "Fileset feature is not supported"
15726 local submount=${MOUNT}_$tdir
15729 mkdir -p $submount || error "mkdir $submount failed"
15730 FILESET="$FILESET/.." mount_client $submount &&
15731 error "mount $submount should fail"
15734 run_test 247e "mount .. as fileset"
15737 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
15738 [ -z "$fast_read_sav" ] && skip "no fast read support"
15740 # create a large file for fast read verification
15741 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
15743 # make sure the file is created correctly
15744 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
15745 { rm -f $DIR/$tfile; skip "file creation error"; }
15747 echo "Test 1: verify that fast read is 4 times faster on cache read"
15749 # small read with fast read enabled
15750 $LCTL set_param -n llite.*.fast_read=1
15751 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
15752 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15753 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15754 # small read with fast read disabled
15755 $LCTL set_param -n llite.*.fast_read=0
15756 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
15757 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15758 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15760 # verify that fast read is 4 times faster for cache read
15761 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
15762 error_not_in_vm "fast read was not 4 times faster: " \
15763 "$t_fast vs $t_slow"
15765 echo "Test 2: verify the performance between big and small read"
15766 $LCTL set_param -n llite.*.fast_read=1
15768 # 1k non-cache read
15769 cancel_lru_locks osc
15770 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15771 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15772 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15774 # 1M non-cache read
15775 cancel_lru_locks osc
15776 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
15777 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
15778 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
15780 # verify that big IO is not 4 times faster than small IO
15781 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
15782 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
15784 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
15787 run_test 248 "fast read verification"
15789 test_249() { # LU-7890
15790 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
15791 skip "Need at least version 2.8.54"
15794 $SETSTRIPE -c 1 $DIR/$tfile
15795 # Offset 2T == 4k * 512M
15796 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
15797 error "dd to 2T offset failed"
15799 run_test 249 "Write above 2T file size"
15802 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
15803 && skip "no 16TB file size limit on ZFS"
15805 $SETSTRIPE -c 1 $DIR/$tfile
15806 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
15807 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
15808 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
15809 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
15810 conv=notrunc,fsync && error "append succeeded"
15813 run_test 250 "Write above 16T limit"
15816 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
15818 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
15819 #Skip once - writing the first stripe will succeed
15820 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15821 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
15822 error "short write happened"
15824 $LCTL set_param fail_loc=0xa0001407 fail_val=1
15825 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
15826 error "short read happened"
15830 run_test 251 "Handling short read and write correctly"
15833 remote_mds_nodsh && skip "remote MDS with nodsh"
15834 remote_ost_nodsh && skip "remote OST with nodsh"
15835 if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
15836 "$(facet_fstype mds1)" != "ldiskfs" ]; then
15837 skip_env "ldiskfs only test"
15847 # check lr_reader on OST0000
15849 dev=$(facet_device $tgt)
15850 out=$(do_facet $tgt $LR_READER $dev)
15851 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15853 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
15854 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
15855 error "Invalid uuid returned by $LR_READER on target $tgt"
15856 echo -e "uuid returned by $LR_READER is '$uuid'\n"
15858 # check lr_reader -c on MDT0000
15860 dev=$(facet_device $tgt)
15861 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
15862 skip "$LR_READER does not support additional options"
15864 out=$(do_facet $tgt $LR_READER -c $dev)
15865 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15867 num=$(echo "$out" | grep -c "mdtlov")
15868 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
15869 error "Invalid number of mdtlov clients returned by $LR_READER"
15870 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
15872 # check lr_reader -cr on MDT0000
15873 out=$(do_facet $tgt $LR_READER -cr $dev)
15874 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
15876 echo "$out" | grep -q "^reply_data:$" ||
15877 error "$LR_READER should have returned 'reply_data' section"
15878 num=$(echo "$out" | grep -c "client_generation")
15879 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
15881 run_test 252 "check lr_reader tool"
15883 test_253_fill_ost() {
15884 local size_mb #how many MB should we write to pass watermark
15885 local lwm=$3 #low watermark
15886 local free_10mb #10% of free space
15888 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15889 size_mb=$((free_kb / 1024 - lwm))
15890 free_10mb=$((free_kb / 10240))
15891 #If 10% of free space cross low watermark use it
15892 if (( free_10mb > size_mb )); then
15895 #At least we need to store 1.1 of difference between
15896 #free space and low watermark
15897 size_mb=$((size_mb + size_mb / 10))
15899 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
15900 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
15901 oflag=append conv=notrunc
15906 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
15907 echo "OST still has $((free_kb / 1024)) mbytes free"
15911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15912 remote_mds_nodsh && skip "remote MDS with nodsh"
15913 remote_mgs_nodsh && skip "remote MGS with nodsh"
15918 local ost_name=$($LFS osts |
15919 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
15921 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
15922 do_facet $SINGLEMDS $LCTL get_param -n \
15923 osp.$mdtosc_proc1.reserved_mb_high ||
15924 skip "remote MDS does not support reserved_mb_high"
15928 wait_delete_completed
15931 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
15932 osp.$mdtosc_proc1.reserved_mb_high)
15933 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
15934 osp.$mdtosc_proc1.reserved_mb_low)
15935 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
15937 if ! combined_mgs_mds ; then
15940 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
15941 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
15942 error "Adding $ost_name to pool failed"
15944 # Wait for client to see a OST at pool
15945 wait_update $HOSTNAME "$LCTL get_param -n
15946 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
15947 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
15948 error "Client can not see the pool"
15949 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
15950 error "Setstripe failed"
15952 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
15953 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
15954 echo "OST still has $((blocks/1024)) mbytes free"
15956 local new_lwm=$((blocks/1024-10))
15957 do_facet $SINGLEMDS $LCTL set_param \
15958 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
15959 do_facet $SINGLEMDS $LCTL set_param \
15960 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
15962 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15964 #First enospc could execute orphan deletion so repeat.
15965 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
15967 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15968 osp.$mdtosc_proc1.prealloc_status)
15969 echo "prealloc_status $oa_status"
15971 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
15972 error "File creation should fail"
15973 #object allocation was stopped, but we still able to append files
15974 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
15975 error "Append failed"
15976 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
15978 wait_delete_completed
15982 for i in $(seq 10 12); do
15983 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
15984 error "File creation failed after rm";
15987 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
15988 osp.$mdtosc_proc1.prealloc_status)
15989 echo "prealloc_status $oa_status"
15991 if (( oa_status != 0 )); then
15992 error "Object allocation still disable after rm"
15994 do_facet $SINGLEMDS $LCTL set_param \
15995 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
15996 do_facet $SINGLEMDS $LCTL set_param \
15997 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
16000 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
16001 error "Remove $ost_name from pool failed"
16002 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
16003 error "Pool destroy fialed"
16005 if ! combined_mgs_mds ; then
16009 run_test 253 "Check object allocation limit"
16012 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16013 remote_mds_nodsh && skip "remote MDS with nodsh"
16014 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
16015 skip "MDS does not support changelog_size"
16018 local MDT0=$(facet_svc $SINGLEMDS)
16020 changelog_register || error "changelog_register failed"
16022 changelog_clear 0 || error "changelog_clear failed"
16024 local size1=$(do_facet $SINGLEMDS \
16025 $LCTL get_param -n mdd.$MDT0.changelog_size)
16026 echo "Changelog size $size1"
16029 $LFS mkdir -i 0 $DIR/$tdir
16031 mkdir -p $DIR/$tdir/pics/2008/zachy
16032 touch $DIR/$tdir/pics/2008/zachy/timestamp
16033 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
16034 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16035 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16036 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16037 rm $DIR/$tdir/pics/desktop.jpg
16039 local size2=$(do_facet $SINGLEMDS \
16040 $LCTL get_param -n mdd.$MDT0.changelog_size)
16041 echo "Changelog size after work $size2"
16043 (( $size2 > $size1 )) ||
16044 error "new Changelog size=$size2 less than old size=$size1"
16046 run_test 254 "Check changelog size"
16053 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
16054 awk -F: '{print $2}' | grep $type > /dev/null
16055 if [ $? -ne 0 ]; then
16065 lfs ladvise -a willread $file > /dev/null 2>&1
16066 if [ $? -eq 0 ]; then
16070 lfs ladvise -a willread $file 2>&1 |
16071 grep "Inappropriate ioctl for device" > /dev/null
16072 if [ $? -eq 0 ]; then
16079 bc <<<"scale=2; ($1 - $2) * 100 / $2"
16082 # run a random read IO workload
16083 # usage: random_read_iops <filename> <filesize> <iosize>
16084 random_read_iops() {
16087 local iosize=${3:-4096}
16089 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
16090 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
16093 drop_file_oss_cache() {
16097 $LFS ladvise -a dontneed $file 2>/dev/null ||
16098 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
16101 ladvise_willread_performance()
16104 local average_origin=0
16105 local average_cache=0
16106 local average_ladvise=0
16108 for ((i = 1; i <= $repeat; i++)); do
16109 echo "Iter $i/$repeat: reading without willread hint"
16110 cancel_lru_locks osc
16111 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16112 local speed_origin=$(random_read_iops $DIR/$tfile $size)
16113 echo "Iter $i/$repeat: uncached speed: $speed_origin"
16114 average_origin=$(bc <<<"$average_origin + $speed_origin")
16116 cancel_lru_locks osc
16117 local speed_cache=$(random_read_iops $DIR/$tfile $size)
16118 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
16119 average_cache=$(bc <<<"$average_cache + $speed_cache")
16121 cancel_lru_locks osc
16122 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16123 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
16124 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
16125 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
16126 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
16128 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
16129 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
16130 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
16132 speedup_cache=$(percent $average_cache $average_origin)
16133 speedup_ladvise=$(percent $average_ladvise $average_origin)
16135 echo "Average uncached read: $average_origin"
16136 echo "Average speedup with OSS cached read: " \
16137 "$average_cache = +$speedup_cache%"
16138 echo "Average speedup with ladvise willread: " \
16139 "$average_ladvise = +$speedup_ladvise%"
16141 local lowest_speedup=20
16142 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
16143 echo "Speedup with OSS cached read less than $lowest_speedup%," \
16144 "got $average_cache%. Skipping ladvise willread check."
16148 # the test won't work on ZFS until it supports 'ladvise dontneed', but
16149 # it is still good to run until then to exercise 'ladvise willread'
16150 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16151 [ "$(facet_fstype ost1)" = "zfs" ] &&
16152 echo "osd-zfs does not support dontneed or drop_caches" &&
16155 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
16156 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
16157 error_not_in_vm "Speedup with willread is less than " \
16158 "$lowest_speedup%, got $average_ladvise%"
16162 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
16163 skip "lustre < 2.8.54 does not support ladvise "
16164 remote_ost_nodsh && skip "remote OST with nodsh"
16166 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
16168 ladvise_no_type willread $DIR/$tfile &&
16169 skip "willread ladvise is not supported"
16171 ladvise_no_ioctl $DIR/$tfile &&
16172 skip "ladvise ioctl is not supported"
16175 local size=$((size_mb * 1048576))
16176 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
16177 error "dd to $DIR/$tfile failed"
16179 lfs ladvise -a willread $DIR/$tfile ||
16180 error "Ladvise failed with no range argument"
16182 lfs ladvise -a willread -s 0 $DIR/$tfile ||
16183 error "Ladvise failed with no -l or -e argument"
16185 lfs ladvise -a willread -e 1 $DIR/$tfile ||
16186 error "Ladvise failed with only -e argument"
16188 lfs ladvise -a willread -l 1 $DIR/$tfile ||
16189 error "Ladvise failed with only -l argument"
16191 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
16192 error "End offset should not be smaller than start offset"
16194 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
16195 error "End offset should not be equal to start offset"
16197 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
16198 error "Ladvise failed with overflowing -s argument"
16200 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
16201 error "Ladvise failed with overflowing -e argument"
16203 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
16204 error "Ladvise failed with overflowing -l argument"
16206 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
16207 error "Ladvise succeeded with conflicting -l and -e arguments"
16209 echo "Synchronous ladvise should wait"
16211 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
16212 do_nodes $(comma_list $(osts_nodes)) \
16213 $LCTL set_param fail_val=$delay fail_loc=0x237
16215 local start_ts=$SECONDS
16216 lfs ladvise -a willread $DIR/$tfile ||
16217 error "Ladvise failed with no range argument"
16218 local end_ts=$SECONDS
16219 local inteval_ts=$((end_ts - start_ts))
16221 if [ $inteval_ts -lt $(($delay - 1)) ]; then
16222 error "Synchronous advice didn't wait reply"
16225 echo "Asynchronous ladvise shouldn't wait"
16226 local start_ts=$SECONDS
16227 lfs ladvise -a willread -b $DIR/$tfile ||
16228 error "Ladvise failed with no range argument"
16229 local end_ts=$SECONDS
16230 local inteval_ts=$((end_ts - start_ts))
16232 if [ $inteval_ts -gt $(($delay / 2)) ]; then
16233 error "Asynchronous advice blocked"
16236 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
16237 ladvise_willread_performance
16239 run_test 255a "check 'lfs ladvise -a willread'"
16245 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
16249 [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
16250 skip "lustre < 2.8.54 does not support ladvise "
16251 remote_ost_nodsh && skip "remote OST with nodsh"
16253 lfs setstripe -c 1 -i 0 $DIR/$tfile
16255 ladvise_no_type dontneed $DIR/$tfile &&
16256 skip "dontneed ladvise is not supported"
16258 ladvise_no_ioctl $DIR/$tfile &&
16259 skip "ladvise ioctl is not supported"
16261 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16262 [ "$(facet_fstype ost1)" = "zfs" ] &&
16263 skip "zfs-osd does not support 'ladvise dontneed'"
16266 local size=$((size_mb * 1048576))
16267 # In order to prevent disturbance of other processes, only check 3/4
16268 # of the memory usage
16269 local kibibytes=$((size_mb * 1024 * 3 / 4))
16271 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
16272 error "dd to $DIR/$tfile failed"
16274 #force write to complete before dropping OST cache & checking memory
16277 local total=$(facet_meminfo ost1 MemTotal)
16278 echo "Total memory: $total KiB"
16280 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
16281 local before_read=$(facet_meminfo ost1 Cached)
16282 echo "Cache used before read: $before_read KiB"
16284 lfs ladvise -a willread $DIR/$tfile ||
16285 error "Ladvise willread failed"
16286 local after_read=$(facet_meminfo ost1 Cached)
16287 echo "Cache used after read: $after_read KiB"
16289 lfs ladvise -a dontneed $DIR/$tfile ||
16290 error "Ladvise dontneed again failed"
16291 local no_read=$(facet_meminfo ost1 Cached)
16292 echo "Cache used after dontneed ladvise: $no_read KiB"
16294 if [ $total -lt $((before_read + kibibytes)) ]; then
16295 echo "Memory is too small, abort checking"
16299 if [ $((before_read + kibibytes)) -gt $after_read ]; then
16300 error "Ladvise willread should use more memory" \
16301 "than $kibibytes KiB"
16304 if [ $((no_read + kibibytes)) -gt $after_read ]; then
16305 error "Ladvise dontneed should release more memory" \
16306 "than $kibibytes KiB"
16309 run_test 255b "check 'lfs ladvise -a dontneed'"
16312 [ $(lustre_version_code ost1) -lt $(version_code 2.10.50) ] &&
16313 skip "lustre < 2.10.53 does not support lockahead"
16321 test_mkdir -p $DIR/$tdir
16322 $SETSTRIPE -i 0 $DIR/$tdir
16324 #test 10 returns only success/failure
16326 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16328 if [ $rc -eq 255 ]; then
16329 error "Ladvise test${i} failed, ${rc}"
16332 #test 11 counts lock enqueue requests, all others count new locks
16334 count=$(do_facet ost1 \
16335 $LCTL get_param -n ost.OSS.ost.stats)
16336 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
16338 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16340 if [ $rc -eq 255 ]; then
16341 error "Ladvise test${i} failed, ${rc}"
16344 new_count=$(do_facet ost1 \
16345 $LCTL get_param -n ost.OSS.ost.stats)
16346 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
16347 awk '{ print $2 }')
16349 difference="$((new_count - count))"
16350 if [ $difference -ne $rc ]; then
16351 error "Ladvise test${i}, bad enqueue count, returned " \
16352 "${rc}, actual ${difference}"
16355 for i in $(seq 12 21); do
16356 # If we do not do this, we run the risk of having too many
16357 # locks and starting lock cancellation while we are checking
16359 cancel_lru_locks osc
16361 count=$($LCTL get_param -n \
16362 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
16364 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16366 if [ $rc -eq 255 ]; then
16367 error "Ladvise test ${i} failed, ${rc}"
16370 new_count=$($LCTL get_param -n \
16371 ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
16372 difference="$((new_count - count))"
16374 # Test 15 output is divided by 100 to map down to valid return
16375 if [ $i -eq 15 ]; then
16379 if [ $difference -ne $rc ]; then
16380 error "Ladvise test ${i}, bad lock count, returned " \
16381 "${rc}, actual ${difference}"
16385 #test 22 returns only success/failure
16387 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16389 if [ $rc -eq 255 ]; then
16390 error "Ladvise test${i} failed, ${rc}"
16393 run_test 255c "suite of ladvise lockahead tests"
16396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16397 remote_mds_nodsh && skip "remote MDS with nodsh"
16398 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
16399 skip "ldiskfs only test"
16400 changelog_users $SINGLEMDS | grep "^cl" &&
16401 skip "active changelog user"
16407 mdt_dev=$(mdsdevname 1)
16410 changelog_register || error "changelog_register failed"
16413 mkdir -p $DIR/$tdir
16415 changelog_clear 0 || error "changelog_clear failed"
16418 touch $DIR/$tdir/{1..10}
16421 stop $SINGLEMDS || error "Fail to stop MDT"
16425 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
16427 #after mount new plainllog is used
16428 touch $DIR/$tdir/{11..19}
16429 local tmpfile=$(mktemp -u $tfile.XXXXXX)
16430 cat_sl=$(do_facet $SINGLEMDS "sync; \
16431 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
16432 llog_reader $tmpfile | grep -c type=1064553b")
16433 do_facet $SINGLEMDS llog_reader $tmpfile
16435 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
16437 changelog_clear 0 || error "changelog_clear failed"
16439 cat_sl=$(do_facet $SINGLEMDS "sync; \
16440 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
16441 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
16443 if (( cat_sl == 2 )); then
16444 error "Empty plain llog was not deleted from changelog catalog"
16445 elif (( cat_sl != 1 )); then
16446 error "Active plain llog shouldn't be deleted from catalog"
16449 run_test 256 "Check llog delete for empty and not full state"
16452 remote_mds_nodsh && skip "remote MDS with nodsh"
16453 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
16454 skip "Need MDS version at least 2.8.55"
16456 test_mkdir $DIR/$tdir
16458 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
16459 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
16462 #define OBD_FAIL_MDS_XATTR_REP 0x161
16463 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
16464 local facet=mds$((mdtidx + 1))
16465 set_nodes_failloc $(facet_active_host $facet) 0x80000161
16466 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
16468 stop $facet || error "stop MDS failed"
16469 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
16470 error "start MDS fail"
16472 run_test 257 "xattr locks are not lost"
16474 # Verify we take the i_mutex when security requires it
16476 #define OBD_FAIL_IMUTEX_SEC 0x141c
16477 $LCTL set_param fail_loc=0x141c
16479 chmod u+s $DIR/$tfile
16480 chmod a+rwx $DIR/$tfile
16481 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
16483 if [ $RC -ne 0 ]; then
16484 error "error, failed to take i_mutex, rc=$?"
16490 # Verify we do NOT take the i_mutex in the normal case
16492 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
16493 $LCTL set_param fail_loc=0x141d
16496 chmod a+rw $DIR/$tfile
16497 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
16499 if [ $RC -ne 0 ]; then
16500 error "error, took i_mutex unnecessarily, rc=$?"
16505 run_test 258b "verify i_mutex security behavior"
16508 local file=$DIR/$tfile
16512 [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
16513 skip "ldiskfs only test" && return
16515 stack_trap "rm -f $file" EXIT
16517 wait_delete_completed
16518 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16519 echo "before: $before"
16521 $LFS setstripe -i 0 -c 1 $file
16522 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
16524 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16525 echo "after write: $after"
16527 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
16528 do_facet ost1 $LCTL set_param fail_loc=0x2301
16530 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16531 echo "after truncate: $after"
16534 do_facet ost1 $LCTL set_param fail_loc=0
16535 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16537 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16538 echo "after restart: $after"
16539 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
16540 error "missing truncate?"
16544 run_test 259 "crash at delayed truncate"
16547 #define OBD_FAIL_MDC_CLOSE 0x806
16548 $LCTL set_param fail_loc=0x80000806
16552 run_test 260 "Check mdc_close fail"
16554 ### Data-on-MDT sanity tests ###
16556 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16557 skip "Need MDS version at least 2.10.55"
16560 local dom=$DIR/$tdir/dom_file
16561 local tmp=$DIR/$tdir/tmp_file
16563 mkdir -p $DIR/$tdir
16565 # basic checks for DoM component creation
16566 $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
16567 error "Can set MDT layout to non-first entry"
16569 $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
16570 error "Can define multiple entries as MDT layout"
16572 $LFS setstripe -E 1M -L mdt $dom ||
16573 error "Can't create DoM layout"
16575 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
16576 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
16577 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
16579 local mdtidx=$($LFS getstripe -m $dom)
16580 local mdtname=MDT$(printf %04x $mdtidx)
16581 local facet=mds$((mdtidx + 1))
16582 local space_check=1
16584 # Skip free space checks with ZFS
16585 if [ "$(facet_fstype $facet)" == "zfs" ]; then
16591 local mdtfree1=$(do_facet $facet \
16592 lctl get_param -n osd*.*$mdtname.kbytesfree)
16593 dd if=/dev/urandom of=$tmp bs=1024 count=100
16594 # check also direct IO along write
16595 dd if=$tmp of=$dom bs=102400 count=1 oflag=direct
16597 cmp $tmp $dom || error "file data is different"
16598 [ $(stat -c%s $dom) == 102400 ] || error "bad size after write"
16599 if [ $space_check == 1 ]; then
16600 local mdtfree2=$(do_facet $facet \
16601 lctl get_param -n osd*.*$mdtname.kbytesfree)
16602 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
16603 error "MDT free space is wrong after write"
16607 $TRUNCATE $dom 10000
16608 [ $(stat -c%s $dom) == 10000 ] || error "bad size after truncate"
16609 if [ $space_check == 1 ]; then
16610 mdtfree1=$(do_facet $facet \
16611 lctl get_param -n osd*.*$mdtname.kbytesfree)
16612 [ $(($mdtfree1 - $mdtfree2)) -ge 92 ] ||
16613 error "MDT free space is wrong after truncate"
16619 [ $(stat -c%s $dom) == 112400 ] || error "bad size after append"
16620 if [ $space_check == 1 ]; then
16621 mdtfree2=$(do_facet $facet \
16622 lctl get_param -n osd*.*$mdtname.kbytesfree)
16623 [ $(($mdtfree1 - $mdtfree2)) -ge 102 ] ||
16624 error "MDT free space is wrong after append"
16629 if [ $space_check == 1 ]; then
16630 mdtfree1=$(do_facet $facet \
16631 lctl get_param -n osd*.*$mdtname.kbytesfree)
16632 [ $(($mdtfree1 - $mdtfree2)) -ge 112 ] ||
16633 error "MDT free space is wrong after removal"
16636 # combined striping
16637 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
16638 error "Can't create DoM + OST striping"
16640 dd if=/dev/urandom of=$tmp bs=1024 count=2000
16641 # check also direct IO along write
16642 dd if=$tmp of=$dom bs=102400 count=20 oflag=direct
16644 cmp $tmp $dom || error "file data is different"
16645 [ $(stat -c%s $dom) == 2048000 ] || error "bad size after write"
16651 run_test 270a "DoM: basic functionality tests"
16654 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16655 skip "Need MDS version at least 2.10.55"
16657 local dom=$DIR/$tdir/dom_file
16658 local max_size=1048576
16660 mkdir -p $DIR/$tdir
16661 $LFS setstripe -E $max_size -L mdt $dom
16663 # truncate over the limit
16664 $TRUNCATE $dom $(($max_size + 1)) &&
16665 error "successful truncate over the maximum size"
16666 # write over the limit
16667 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
16668 error "successful write over the maximum size"
16669 # append over the limit
16670 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
16671 echo "12345" >> $dom && error "successful append over the maximum size"
16676 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
16679 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16680 skip "Need MDS version at least 2.10.55"
16682 mkdir -p $DIR/$tdir
16683 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16685 # check files inherit DoM EA
16686 touch $DIR/$tdir/first
16687 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
16688 error "bad pattern"
16689 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
16690 error "bad stripe count"
16691 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
16692 error "bad stripe size"
16694 # check directory inherits DoM EA and uses it as default
16695 mkdir $DIR/$tdir/subdir
16696 touch $DIR/$tdir/subdir/second
16697 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
16698 error "bad pattern in sub-directory"
16699 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
16700 error "bad stripe count in sub-directory"
16701 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
16702 error "bad stripe size in sub-directory"
16705 run_test 270c "DoM: DoM EA inheritance tests"
16708 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16709 skip "Need MDS version at least 2.10.55"
16711 mkdir -p $DIR/$tdir
16712 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16714 # inherit default DoM striping
16715 mkdir $DIR/$tdir/subdir
16716 touch $DIR/$tdir/subdir/f1
16718 # change default directory striping
16719 $LFS setstripe -c 1 $DIR/$tdir/subdir
16720 touch $DIR/$tdir/subdir/f2
16721 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
16722 error "wrong default striping in file 2"
16723 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
16724 error "bad pattern in file 2"
16727 run_test 270d "DoM: change striping from DoM to RAID0"
16730 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16731 skip "Need MDS version at least 2.10.55"
16733 mkdir -p $DIR/$tdir/dom
16734 mkdir -p $DIR/$tdir/norm
16737 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
16738 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
16740 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
16741 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
16743 # find DoM files by layout
16744 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
16745 [ $NUM -eq $DOMFILES ] ||
16746 error "lfs find -L: found $NUM, expected $DOMFILES"
16747 echo "Test 1: lfs find 20 DOM files by layout: OK"
16749 # there should be 1 dir with default DOM striping
16750 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
16752 error "lfs find -L: found $NUM, expected 1 dir"
16753 echo "Test 2: lfs find 1 DOM dir by layout: OK"
16755 # find DoM files by stripe size
16756 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
16757 [ $NUM -eq $DOMFILES ] ||
16758 error "lfs find -S: found $NUM, expected $DOMFILES"
16759 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
16761 # find files by stripe offset except DoM files
16762 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
16763 [ $NUM -eq $NORMFILES ] ||
16764 error "lfs find -i: found $NUM, expected $NORMFILES"
16765 echo "Test 5: lfs find no DOM files by stripe index: OK"
16768 run_test 270e "DoM: lfs find with DoM files test"
16771 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16772 skip "Need MDS version at least 2.10.55"
16774 local mdtname=${FSNAME}-MDT0000-mdtlov
16775 local dom=$DIR/$tdir/dom_file
16776 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
16777 lod.$mdtname.dom_stripesize)
16778 local dom_limit=131072
16780 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
16781 local dom_current=$(do_facet mds1 $LCTL get_param -n \
16782 lod.$mdtname.dom_stripesize)
16783 [ ${dom_limit} -eq ${dom_current} ] ||
16784 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
16786 $LFS mkdir -i 0 -c 1 $DIR/$tdir
16787 $LFS setstripe -d $DIR/$tdir
16788 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
16789 error "Can't set directory default striping"
16791 # exceed maximum stripe size
16792 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
16793 error "Can't create file with $((dom_limit * 2)) DoM stripe"
16794 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
16795 error "Able to create DoM component size more than LOD limit"
16797 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
16798 dom_current=$(do_facet mds1 $LCTL get_param -n \
16799 lod.$mdtname.dom_stripesize)
16800 [ 0 -eq ${dom_current} ] ||
16801 error "Can't set zero DoM stripe limit"
16804 # attempt to create DoM file on server with disabled DoM should
16805 # remove DoM entry from layout and be succeed
16806 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
16807 error "Can't create DoM file (DoM is disabled)"
16808 [ $($LFS getstripe -L $dom) == "mdt" ] &&
16809 error "File has DoM component while DoM is disabled"
16812 # attempt to create DoM file with only DoM stripe should return error
16813 $LFS setstripe -E $dom_limit -L mdt $dom &&
16814 error "Able to create DoM-only file while DoM is disabled"
16816 # too low values to be aligned with smallest stripe size 64K
16817 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
16818 dom_current=$(do_facet mds1 $LCTL get_param -n \
16819 lod.$mdtname.dom_stripesize)
16820 [ 30000 -eq ${dom_current} ] &&
16821 error "Can set too small DoM stripe limit"
16823 # 64K is a minimal stripe size in Lustre, expect limit of that size
16824 [ 65536 -eq ${dom_current} ] ||
16825 error "Limit is not set to 64K but ${dom_current}"
16827 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
16828 dom_current=$(do_facet mds1 $LCTL get_param -n \
16829 lod.$mdtname.dom_stripesize)
16831 [ 2147483648 -eq ${dom_current} ] &&
16832 error "Can set too large DoM stripe limit"
16834 do_facet mds1 $LCTL set_param -n \
16835 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
16836 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
16837 error "Can't create DoM component size after limit change"
16838 do_facet mds1 $LCTL set_param -n \
16839 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
16840 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
16841 error "Can't create DoM file after limit decrease"
16842 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
16843 error "Can create big DoM component after limit decrease"
16844 touch ${dom}_def ||
16845 error "Can't create file with old default layout"
16847 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
16850 run_test 270f "DoM: maximum DoM stripe size checks"
16853 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16854 skip "Need MDS version at least 2.10.55"
16856 local dom=$DIR/$tdir/dom
16858 mkdir -p $DIR/$tdir
16860 $LFS setstripe -E 1024K -L mdt $dom
16862 lctl set_param -n mdc.*.stats=clear
16863 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16864 cat $dom > /dev/null
16865 local reads=$(lctl get_param -n mdc.*.stats |
16866 awk '/ost_read/ {print $2}')
16867 [ -z $reads ] || error "Unexpected $reads READ RPCs"
16871 run_test 271a "DoM: data is cached for read after write"
16874 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16875 skip "Need MDS version at least 2.10.55"
16877 local dom=$DIR/$tdir/dom
16879 mkdir -p $DIR/$tdir
16881 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16883 lctl set_param -n mdc.*.stats=clear
16884 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
16885 cancel_lru_locks mdc
16886 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
16887 # second stat to check size is cached on client
16888 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
16889 local gls=$(lctl get_param -n mdc.*.stats |
16890 awk '/ldlm_glimpse/ {print $2}')
16891 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16894 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
16897 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16898 skip "Need MDS version at least 2.10.55"
16900 local dom=$DIR/$tdir/dom
16902 mkdir -p $DIR/$tdir
16904 $LFS setstripe -E 1024K -L mdt -E EOF $dom
16906 lctl set_param -n mdc.*.stats=clear
16907 lctl set_param -n osc.*.stats=clear
16908 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
16909 cancel_lru_locks mdc
16910 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16911 # second stat to check size is cached on client
16912 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
16913 local gls=$(lctl get_param -n mdc.*.stats |
16914 awk '/ldlm_glimpse/ {print $2}')
16915 [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
16916 local gls=$(lctl get_param -n osc.*.stats |
16917 awk '/ldlm_glimpse/ {print $2}')
16918 [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
16921 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
16924 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
16925 skip "Need MDS version at least 2.10.55"
16927 local dom=$DIR/$tdir/dom
16929 mkdir -p $DIR/$tdir
16931 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
16933 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
16934 local facet=mds$((mdtidx + 1))
16936 cancel_lru_locks mdc
16937 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
16938 createmany -o $dom 1000
16939 lctl set_param -n mdc.*.stats=clear
16940 smalliomany -w $dom 1000 200
16941 lctl get_param -n mdc.*.stats
16942 local enq=$(lctl get_param -n mdc.*.stats |
16943 awk '/ldlm_ibits_enqueue/ {print $2}')
16944 # Each file has 1 open, 1 IO enqueues, total 2000
16945 # but now we have also +1 getxattr for security.capability, total 3000
16946 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
16947 unlinkmany $dom 1000
16949 cancel_lru_locks mdc
16950 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
16951 createmany -o $dom 1000
16952 lctl set_param -n mdc.*.stats=clear
16953 smalliomany -w $dom 1000 200
16954 lctl get_param -n mdc.*.stats
16955 local enq_2=$(lctl get_param -n mdc.*.stats |
16956 awk '/ldlm_ibits_enqueue/ {print $2}')
16957 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
16958 # for OPEN and IO lock.
16959 [ $((enq - enq_2)) -ge 1000 ] ||
16960 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
16961 unlinkmany $dom 1000
16964 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
16967 remote_ost_nodsh && skip "remote OST with nodsh"
16968 [ $(lustre_version_code ost1) -lt $(version_code 2.10.57) ] &&
16969 skip "Need OST version >= 2.10.57"
16971 local file=$DIR/$tfile
16974 oss=$(comma_list $(osts_nodes))
16976 dd if=/dev/urandom of=$file bs=1M count=2 ||
16977 error "failed to create a file"
16978 cancel_lru_locks osc
16981 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
16982 error "failed to read a file"
16984 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
16985 $LCTL set_param fail_loc=0x8000031f
16987 cancel_lru_locks osc &
16990 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
16991 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
16992 #IO takes another lock, but matches the PENDING one
16993 #and places it to the IO RPC
16994 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
16995 error "failed to read a file with PENDING lock"
16997 run_test 275 "Read on a canceled duplicate lock"
17000 remote_ost_nodsh && skip "remote OST with nodsh"
17003 do_facet ost1 "(while true; do \
17004 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
17005 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
17008 for LOOP in $(seq 20); do
17010 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
17013 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
17014 rm $TMP/sanity_276_pid"
17016 run_test 276 "Race between mount and obd_statfs"
17018 cleanup_test_300() {
17022 test_striped_dir() {
17027 mkdir -p $DIR/$tdir
17029 SAVE_UMASK=$(umask)
17030 trap cleanup_test_300 RETURN EXIT
17032 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
17033 $DIR/$tdir/striped_dir ||
17034 error "set striped dir error"
17036 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
17037 [ "$mode" = "755" ] || error "expect 755 got $mode"
17039 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
17040 error "getdirstripe failed"
17041 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
17042 if [ "$stripe_count" != "2" ]; then
17043 error "1:stripe_count is $stripe_count, expect 2"
17045 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
17046 if [ "$stripe_count" != "2" ]; then
17047 error "2:stripe_count is $stripe_count, expect 2"
17050 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
17051 if [ "$stripe_index" != "$mdt_index" ]; then
17052 error "stripe_index is $stripe_index, expect $mdt_index"
17055 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
17056 error "nlink error after create striped dir"
17058 mkdir $DIR/$tdir/striped_dir/a
17059 mkdir $DIR/$tdir/striped_dir/b
17061 stat $DIR/$tdir/striped_dir/a ||
17062 error "create dir under striped dir failed"
17063 stat $DIR/$tdir/striped_dir/b ||
17064 error "create dir under striped dir failed"
17066 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
17067 error "nlink error after mkdir"
17069 rmdir $DIR/$tdir/striped_dir/a
17070 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
17071 error "nlink error after rmdir"
17073 rmdir $DIR/$tdir/striped_dir/b
17074 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
17075 error "nlink error after rmdir"
17077 chattr +i $DIR/$tdir/striped_dir
17078 createmany -o $DIR/$tdir/striped_dir/f 10 &&
17079 error "immutable flags not working under striped dir!"
17080 chattr -i $DIR/$tdir/striped_dir
17082 rmdir $DIR/$tdir/striped_dir ||
17083 error "rmdir striped dir error"
17091 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
17092 skip "skipped for lustre < 2.7.0"
17093 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17094 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17096 test_striped_dir 0 || error "failed on striped dir on MDT0"
17097 test_striped_dir 1 || error "failed on striped dir on MDT0"
17099 run_test 300a "basic striped dir sanity test"
17102 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
17103 skip "skipped for lustre < 2.7.0"
17104 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17105 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17112 test_mkdir $DIR/$tdir || error "mkdir fail"
17113 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17114 error "set striped dir error"
17115 for i in {0..9}; do
17116 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
17118 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
17119 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
17120 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
17122 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
17123 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
17124 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
17128 run_test 300b "check ctime/mtime for striped dir"
17131 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
17132 skip "skipped for lustre < 2.7.0"
17133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17134 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17138 mkdir -p $DIR/$tdir
17139 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
17140 error "set striped dir error"
17142 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
17143 error "chown striped dir failed"
17145 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
17146 error "create 5k files failed"
17148 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
17150 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
17154 run_test 300c "chown && check ls under striped directory"
17157 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
17158 skip "skipped for lustre < 2.7.0"
17159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17160 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17165 mkdir -p $DIR/$tdir
17166 $SETSTRIPE -c 2 $DIR/$tdir
17168 #local striped directory
17169 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17170 error "set striped dir error"
17171 createmany -o $DIR/$tdir/striped_dir/f 10 ||
17172 error "create 10 files failed"
17174 #remote striped directory
17175 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
17176 error "set striped dir error"
17177 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
17178 error "create 10 files failed"
17180 for file in $(find $DIR/$tdir); do
17181 stripe_count=$($LFS getstripe -c $file)
17182 [ $stripe_count -eq 2 ] ||
17183 error "wrong stripe $stripe_count for $file"
17188 run_test 300d "check default stripe under striped directory"
17191 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17192 skip "Need MDS version at least 2.7.55"
17193 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17194 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17199 mkdir -p $DIR/$tdir
17201 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17202 error "set striped dir error"
17204 touch $DIR/$tdir/striped_dir/a
17205 touch $DIR/$tdir/striped_dir/b
17206 touch $DIR/$tdir/striped_dir/c
17208 mkdir $DIR/$tdir/striped_dir/dir_a
17209 mkdir $DIR/$tdir/striped_dir/dir_b
17210 mkdir $DIR/$tdir/striped_dir/dir_c
17212 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
17213 error "set striped adir under striped dir error"
17215 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
17216 error "set striped bdir under striped dir error"
17218 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
17219 error "set striped cdir under striped dir error"
17221 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
17222 error "rename dir under striped dir fails"
17224 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
17225 error "rename dir under different stripes fails"
17227 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
17228 error "rename file under striped dir should succeed"
17230 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
17231 error "rename dir under striped dir should succeed"
17235 run_test 300e "check rename under striped directory"
17238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17239 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17240 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17241 skip "Need MDS version at least 2.7.55"
17247 mkdir -p $DIR/$tdir
17249 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17250 error "set striped dir error"
17252 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
17253 error "set striped dir error"
17255 touch $DIR/$tdir/striped_dir/a
17256 mkdir $DIR/$tdir/striped_dir/dir_a
17257 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
17258 error "create striped dir under striped dir fails"
17260 touch $DIR/$tdir/striped_dir1/b
17261 mkdir $DIR/$tdir/striped_dir1/dir_b
17262 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
17263 error "create striped dir under striped dir fails"
17265 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
17266 error "rename dir under different striped dir should fail"
17268 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
17269 error "rename striped dir under diff striped dir should fail"
17271 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
17272 error "rename file under diff striped dirs fails"
17276 run_test 300f "check rename cross striped directory"
17278 test_300_check_default_striped_dir()
17281 local default_count=$2
17282 local default_index=$3
17285 local dir_stripe_index
17288 echo "checking $dirname $default_count $default_index"
17289 $LFS setdirstripe -D -c $default_count -i $default_index \
17290 -t all_char $DIR/$tdir/$dirname ||
17291 error "set default stripe on striped dir error"
17292 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
17293 [ $stripe_count -eq $default_count ] ||
17294 error "expect $default_count get $stripe_count for $dirname"
17296 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
17297 [ $stripe_index -eq $default_index ] ||
17298 error "expect $default_index get $stripe_index for $dirname"
17300 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
17301 error "create dirs failed"
17303 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
17304 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
17305 for dir in $(find $DIR/$tdir/$dirname/*); do
17306 stripe_count=$($LFS getdirstripe -c $dir)
17307 [ $stripe_count -eq $default_count ] ||
17308 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
17309 error "stripe count $default_count != $stripe_count for $dir"
17311 stripe_index=$($LFS getdirstripe -i $dir)
17312 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
17313 error "$stripe_index != $default_index for $dir"
17315 #check default stripe
17316 stripe_count=$($LFS getdirstripe -D -c $dir)
17317 [ $stripe_count -eq $default_count ] ||
17318 error "default count $default_count != $stripe_count for $dir"
17320 stripe_index=$($LFS getdirstripe -D -i $dir)
17321 [ $stripe_index -eq $default_index ] ||
17322 error "default index $default_index != $stripe_index for $dir"
17324 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
17328 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17329 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17330 skip "Need MDS version at least 2.7.55"
17337 mkdir $DIR/$tdir/normal_dir
17339 #Checking when client cache stripe index
17340 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
17341 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
17342 error "create striped_dir failed"
17344 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
17345 error "create dir0 fails"
17346 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
17347 [ $stripe_index -eq 0 ] ||
17348 error "dir0 expect index 0 got $stripe_index"
17350 mkdir $DIR/$tdir/striped_dir/dir1 ||
17351 error "create dir1 fails"
17352 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
17353 [ $stripe_index -eq 1 ] ||
17354 error "dir1 expect index 1 got $stripe_index"
17356 #check default stripe count/stripe index
17357 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
17358 test_300_check_default_striped_dir normal_dir 1 0
17359 test_300_check_default_striped_dir normal_dir 2 1
17360 test_300_check_default_striped_dir normal_dir 2 -1
17362 #delete default stripe information
17363 echo "delete default stripeEA"
17364 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
17365 error "set default stripe on striped dir error"
17367 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
17368 for dir in $(find $DIR/$tdir/normal_dir/*); do
17369 stripe_count=$($LFS getdirstripe -c $dir)
17370 [ $stripe_count -eq 0 ] ||
17371 error "expect 1 get $stripe_count for $dir"
17372 stripe_index=$($LFS getdirstripe -i $dir)
17373 [ $stripe_index -eq 0 ] ||
17374 error "expect 0 get $stripe_index for $dir"
17377 run_test 300g "check default striped directory for normal directory"
17380 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17381 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17382 skip "Need MDS version at least 2.7.55"
17388 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17389 error "set striped dir error"
17391 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
17392 test_300_check_default_striped_dir striped_dir 1 0
17393 test_300_check_default_striped_dir striped_dir 2 1
17394 test_300_check_default_striped_dir striped_dir 2 -1
17396 #delete default stripe information
17397 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
17398 error "set default stripe on striped dir error"
17400 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
17401 for dir in $(find $DIR/$tdir/striped_dir/*); do
17402 stripe_count=$($LFS getdirstripe -c $dir)
17403 [ $stripe_count -eq 0 ] ||
17404 error "expect 1 get $stripe_count for $dir"
17407 run_test 300h "check default striped directory for striped directory"
17410 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17411 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17412 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17413 skip "Need MDS version at least 2.7.55"
17420 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17421 error "set striped dir error"
17423 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
17424 error "create files under striped dir failed"
17426 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
17427 error "set striped hashdir error"
17429 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
17430 error "create dir0 under hash dir failed"
17431 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
17432 error "create dir1 under hash dir failed"
17434 # unfortunately, we need to umount to clear dir layout cache for now
17435 # once we fully implement dir layout, we can drop this
17436 umount_client $MOUNT || error "umount failed"
17437 mount_client $MOUNT || error "mount failed"
17439 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
17440 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
17441 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
17443 #set the stripe to be unknown hash type
17444 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
17445 $LCTL set_param fail_loc=0x1901
17446 for ((i = 0; i < 10; i++)); do
17447 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
17448 error "stat f-$i failed"
17449 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
17452 touch $DIR/$tdir/striped_dir/f0 &&
17453 error "create under striped dir with unknown hash should fail"
17455 $LCTL set_param fail_loc=0
17457 umount_client $MOUNT || error "umount failed"
17458 mount_client $MOUNT || error "mount failed"
17462 run_test 300i "client handle unknown hash type striped directory"
17465 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17466 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17467 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17468 skip "Need MDS version at least 2.7.55"
17475 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
17476 $LCTL set_param fail_loc=0x1702
17477 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
17478 error "set striped dir error"
17480 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
17481 error "create files under striped dir failed"
17483 $LCTL set_param fail_loc=0
17485 rm -rf $DIR/$tdir || error "unlink striped dir fails"
17489 run_test 300j "test large update record"
17492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17493 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17494 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17495 skip "Need MDS version at least 2.7.55"
17502 #define OBD_FAIL_LARGE_STRIPE 0x1703
17503 $LCTL set_param fail_loc=0x1703
17504 $LFS setdirstripe -i 0 -c512 $DIR/$tdir/striped_dir ||
17505 error "set striped dir error"
17506 $LCTL set_param fail_loc=0
17508 $LFS getdirstripe $DIR/$tdir/striped_dir ||
17509 error "getstripeddir fails"
17510 rm -rf $DIR/$tdir/striped_dir ||
17511 error "unlink striped dir fails"
17515 run_test 300k "test large striped directory"
17518 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17519 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17520 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17521 skip "Need MDS version at least 2.7.55"
17525 test_mkdir -p $DIR/$tdir/striped_dir
17526 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
17527 error "chown $RUNAS_ID failed"
17528 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
17529 error "set default striped dir failed"
17531 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
17532 $LCTL set_param fail_loc=0x80000158
17533 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
17535 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
17536 [ $stripe_index -eq 1 ] ||
17537 error "expect 1 get $stripe_index for $dir"
17539 run_test 300l "non-root user to create dir under striped dir with stale layout"
17542 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17543 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
17544 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17545 skip "Need MDS version at least 2.7.55"
17547 mkdir -p $DIR/$tdir/striped_dir
17548 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
17549 error "set default stripes dir error"
17551 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
17553 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
17554 [ $stripe_count -eq 0 ] ||
17555 error "expect 0 get $stripe_count for a"
17557 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
17558 error "set default stripes dir error"
17560 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
17562 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
17563 [ $stripe_count -eq 0 ] ||
17564 error "expect 0 get $stripe_count for b"
17566 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
17567 error "set default stripes dir error"
17569 mkdir $DIR/$tdir/striped_dir/c &&
17570 error "default stripe_index is invalid, mkdir c should fails"
17572 rm -rf $DIR/$tdir || error "rmdir fails"
17574 run_test 300m "setstriped directory on single MDT FS"
17577 local list=$(comma_list $(mdts_nodes))
17580 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
17584 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17585 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17586 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17587 skip "Need MDS version at least 2.7.55"
17588 remote_mds_nodsh && skip "remote MDS with nodsh"
17591 local list=$(comma_list $(mdts_nodes))
17593 trap cleanup_300n RETURN EXIT
17594 mkdir -p $DIR/$tdir
17595 chmod 777 $DIR/$tdir
17596 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
17597 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
17598 error "create striped dir succeeds with gid=0"
17600 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
17601 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
17602 error "create striped dir fails with gid=-1"
17604 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
17605 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
17606 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
17607 error "set default striped dir succeeds with gid=0"
17610 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
17611 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
17612 error "set default striped dir fails with gid=-1"
17615 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
17616 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
17617 error "create test_dir fails"
17618 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
17619 error "create test_dir1 fails"
17620 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
17621 error "create test_dir2 fails"
17624 run_test 300n "non-root user to create dir under striped dir with default EA"
17627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17628 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17629 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
17630 skip "Need MDS version at least 2.7.55"
17635 mkdir -p $DIR/$tdir
17637 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
17638 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
17639 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
17640 skip "not enough free inodes $numfree1 $numfree2"
17643 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
17644 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
17645 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
17646 skip "not enough free space $numfree1 $numfree2"
17649 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
17650 error "setdirstripe fails"
17652 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
17653 error "create dirs fails"
17655 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
17656 ls $DIR/$tdir/striped_dir > /dev/null ||
17657 error "ls striped dir fails"
17658 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
17659 error "unlink big striped dir fails"
17661 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
17664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17665 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17666 remote_mds_nodsh && skip "remote MDS with nodsh"
17668 mkdir -p $DIR/$tdir
17670 #define OBD_FAIL_OUT_ENOSPC 0x1704
17671 do_facet mds2 lctl set_param fail_loc=0x80001704
17672 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
17673 && error "create striped directory should fail"
17675 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
17677 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
17680 run_test 300p "create striped directory without space"
17683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17684 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17686 local fd=$(free_fd)
17687 local cmd="exec $fd<$tdir"
17689 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
17692 trap "eval $cmd" EXIT
17693 cd $tdir || error "cd $tdir fails"
17694 rmdir ../$tdir || error "rmdir $tdir fails"
17695 mkdir local_dir && error "create dir succeeds"
17696 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
17700 run_test 300q "create remote directory under orphan directory"
17702 prepare_remote_file() {
17703 mkdir $DIR/$tdir/src_dir ||
17704 error "create remote source failed"
17706 cp /etc/hosts $DIR/$tdir/src_dir/a ||
17707 error "cp to remote source failed"
17708 touch $DIR/$tdir/src_dir/a
17710 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
17711 error "create remote target dir failed"
17713 touch $DIR/$tdir/tgt_dir/b
17715 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
17716 error "rename dir cross MDT failed!"
17718 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
17719 error "src_child still exists after rename"
17721 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
17722 error "missing file(a) after rename"
17724 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
17725 error "diff after rename"
17729 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
17730 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17732 local remote_file=$DIR/$tdir/tgt_dir/b
17734 mkdir -p $DIR/$tdir
17736 prepare_remote_file || error "prepare remote file failed"
17739 $OPENUNLINK $remote_file $remote_file ||
17740 error "openunlink $remote_file failed"
17741 $CHECKSTAT -a $remote_file || error "$remote_file exists"
17743 run_test 310a "open unlink remote file"
17746 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
17747 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17749 local remote_file=$DIR/$tdir/tgt_dir/b
17751 mkdir -p $DIR/$tdir
17753 prepare_remote_file || error "prepare remote file failed"
17755 ln $remote_file $DIR/$tfile || error "link failed for remote file"
17756 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
17757 $CHECKSTAT -t file $remote_file || error "check file failed"
17759 run_test 310b "unlink remote file with multiple links while open"
17762 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17763 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
17765 local remote_file=$DIR/$tdir/tgt_dir/b
17767 mkdir -p $DIR/$tdir
17769 prepare_remote_file || error "prepare remote file failed"
17771 ln $remote_file $DIR/$tfile || error "link failed for remote file"
17772 multiop_bg_pause $remote_file O_uc ||
17773 error "mulitop failed for remote file"
17775 $MULTIOP $DIR/$tfile Ouc
17776 kill -USR1 $MULTIPID
17779 run_test 310c "open-unlink remote file with multiple links"
17783 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17784 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
17785 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
17786 skip "lustre < 2.8.54 does not contain LU-4825 fix"
17787 remote_mds_nodsh && skip "remote MDS with nodsh"
17789 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
17791 mkdir -p $DIR/$tdir
17792 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
17793 createmany -o $DIR/$tdir/$tfile. 1000
17795 # statfs data is not real time, let's just calculate it
17796 old_iused=$((old_iused + 1000))
17798 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
17799 osp.*OST0000*MDT0000.create_count")
17800 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
17801 osp.*OST0000*MDT0000.max_create_count")
17802 for idx in $(seq $MDSCOUNT); do
17803 do_facet mds$idx "lctl set_param -n \
17804 osp.*OST0000*MDT000?.max_create_count=0"
17807 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
17808 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
17809 [ $index -ne 0 ] || error "$tfile stripe index is 0"
17811 unlinkmany $DIR/$tdir/$tfile. 1000
17813 for idx in $(seq $MDSCOUNT); do
17814 do_facet mds$idx "lctl set_param -n \
17815 osp.*OST0000*MDT000?.max_create_count=$max_count"
17816 do_facet mds$idx "lctl set_param -n \
17817 osp.*OST0000*MDT000?.create_count=$count"
17821 for i in $(seq 120); do
17822 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
17823 # system may be too busy to destroy all objs in time, use
17824 # a somewhat small value to not fail autotest
17825 [ $((old_iused - new_iused)) -gt 400 ] && break
17829 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
17830 [ $((old_iused - new_iused)) -gt 400 ] ||
17831 error "objs not destroyed after unlink"
17833 run_test 311 "disable OSP precreate, and unlink should destroy objs"
17840 local vdevdir=$(dirname $(facet_vdevice $ost))
17841 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
17842 local zfs_zapid=$(do_facet $ost $cmd |
17843 grep -w "/O/0/d$((objid%32))" -C 5 |
17844 awk '/Object/{getline; print $1}')
17845 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
17846 awk "/$objid = /"'{printf $3}')
17851 zfs_object_blksz() {
17855 local vdevdir=$(dirname $(facet_vdevice $ost))
17856 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
17857 local blksz=$(do_facet $ost $cmd $objid |
17858 awk '/dblk/{getline; printf $4}')
17860 case "${blksz: -1}" in
17861 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
17862 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
17869 test_312() { # LU-4856
17870 remote_ost_nodsh && skip "remote OST with nodsh"
17871 [ $(facet_fstype ost1) = "zfs" ] ||
17872 skip_env "the test only applies to zfs"
17874 local max_blksz=$(do_facet ost1 \
17875 $ZFS get -p recordsize $(facet_device ost1) |
17876 awk '!/VALUE/{print $3}')
17877 local min_blksz=$(getconf PAGE_SIZE)
17879 # to make life a little bit easier
17880 $LFS mkdir -c 1 -i 0 $DIR/$tdir
17881 $LFS setstripe -c 1 -i 0 $DIR/$tdir
17883 local tf=$DIR/$tdir/$tfile
17885 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17887 # Get ZFS object id
17888 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17890 # block size change by sequential over write
17892 for ((bs=$min_blksz; bs <= max_blksz; bs <<= 2)); do
17893 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
17895 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17896 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
17900 # block size change by sequential append write
17901 dd if=/dev/zero of=$tf bs=$min_blksz count=1 oflag=sync conv=notrunc
17902 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17903 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17905 for ((count = 1; count < $((max_blksz / min_blksz)); count *= 2)); do
17906 dd if=/dev/zero of=$tf bs=$min_blksz count=$count seek=$count \
17907 oflag=sync conv=notrunc
17909 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17910 [ $blksz -eq $((2 * count * min_blksz)) ] ||
17911 error "blksz error, actual $blksz, " \
17912 "expected: 2 * $count * $min_blksz"
17918 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
17919 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
17921 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
17922 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17923 [ $blksz -eq $min_blksz ] ||
17924 error "blksz error: $blksz, expected: $min_blksz"
17926 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
17927 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17928 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
17930 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
17931 blksz=$(zfs_object_blksz ost1 $zfs_objid)
17932 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
17934 run_test 312 "make sure ZFS adjusts its block size by write pattern"
17937 remote_ost_nodsh && skip "remote OST with nodsh"
17939 local file=$DIR/$tfile
17941 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
17943 # define OBD_FAIL_TGT_RCVD_EIO 0x720
17944 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17945 dd if=/dev/zero of=$file bs=4096 oflag=direct count=1 &&
17946 error "write should failed"
17947 do_facet ost1 "$LCTL set_param fail_loc=0"
17950 run_test 313 "io should fail after last_rcvd update fail"
17953 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
17955 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
17956 do_facet ost1 "$LCTL set_param fail_loc=0x720"
17958 wait_delete_completed
17959 do_facet ost1 "$LCTL set_param fail_loc=0"
17961 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
17963 test_315() { # LU-618
17964 local file=$DIR/$tfile
17967 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
17968 $MULTIOP $file oO_RDONLY:r4096000_c &
17973 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
17976 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
17979 run_test 315 "read should be accounted"
17982 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17983 large_xattr_enabled || skip_env "large_xattr disabled"
17985 rm -rf $DIR/$tdir/d
17986 mkdir -p $DIR/$tdir/d
17987 chown nobody $DIR/$tdir/d
17988 touch $DIR/$tdir/d/file
17990 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
17992 run_test 316 "lfs mv"
17996 local grant_blk_size
17998 if [ "$(facet_fstype $facet)" == "zfs" ]; then
17999 skip "LU-10370: no implementation for ZFS" && return
18002 stack_trap "rm -f $DIR/$tfile" EXIT
18003 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
18004 awk '/grant_block_size:/ { print $2; exit; }')
18006 # Create File of size 5M. Truncate it to below size's and verify
18009 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
18010 error "Create file : $DIR/$tfile"
18012 for trunc_sz in 2097152 4097 4000 509 0; do
18013 $TRUNCATE $DIR/$tfile $trunc_sz ||
18014 error "truncate $tfile to $trunc_sz failed"
18015 local sz=$(stat --format=%s $DIR/$tfile)
18016 local blk=$(stat --format=%b $DIR/$tfile)
18017 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
18018 grant_blk_size) * 8))
18020 if [[ $blk -ne $trunc_blk ]]; then
18021 $(which stat) $DIR/$tfile
18022 error "Expected Block $trunc_blk got $blk for $tfile"
18025 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
18026 error "Expected Size $trunc_sz got $sz for $tfile"
18031 # Create file with a hole and write actual two blocks. Block count
18034 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
18035 conv=fsync || error "Create file : $DIR/$tfile"
18037 # Calculate the final truncate size.
18038 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
18041 # truncate to size $trunc_sz bytes. Strip the last block
18042 # The block count must drop to 8
18044 $TRUNCATE $DIR/$tfile $trunc_sz ||
18045 error "truncate $tfile to $trunc_sz failed"
18047 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
18048 sz=$(stat --format=%s $DIR/$tfile)
18049 blk=$(stat --format=%b $DIR/$tfile)
18051 if [[ $blk -ne $trunc_bsz ]]; then
18052 $(which stat) $DIR/$tfile
18053 error "Expected Block $trunc_bsz got $blk for $tfile"
18056 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
18057 error "Expected Size $trunc_sz got $sz for $tfile"
18059 run_test 317 "Verify blocks get correctly update after truncate"
18062 local read_write=$1
18063 if [ "$read_write" = "write" ]; then
18064 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
18065 elif [ "$read_write" = "read" ]; then
18066 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
18068 error "argument error"
18071 # turn off debug for performance testing
18072 local saved_debug=$($LCTL get_param -n debug)
18073 $LCTL set_param debug=0
18075 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
18077 # get ost1 size - lustre-OST0000
18078 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
18079 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
18080 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
18082 if [ "$read_write" = "read" ]; then
18083 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
18086 local start_time=$(date +%s.%N)
18087 $dd_cmd bs=1M count=$blocks oflag=sync ||
18088 error "real dd $read_write error"
18089 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
18091 if [ "$read_write" = "write" ]; then
18095 # define OBD_FAIL_OST_FAKE_RW 0x238
18096 do_facet ost1 $LCTL set_param fail_loc=0x238
18098 local start_time=$(date +%s.%N)
18099 $dd_cmd bs=1M count=$blocks oflag=sync ||
18100 error "fake dd $read_write error"
18101 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
18103 if [ "$read_write" = "write" ]; then
18105 cancel_lru_locks osc
18106 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
18107 error "$tfile size not $blocks MB"
18109 do_facet ost1 $LCTL set_param fail_loc=0
18111 echo "fake $read_write $duration_fake vs. normal $read_write" \
18112 "$duration in seconds"
18113 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
18114 error_not_in_vm "fake write is slower"
18116 $LCTL set_param -n debug="$saved_debug"
18119 test_399a() { # LU-7655 for OST fake write
18120 remote_ost_nodsh && skip "remote OST with nodsh"
18124 run_test 399a "fake write should not be slower than normal write"
18126 test_399b() { # LU-8726 for OST fake read
18127 remote_ost_nodsh && skip "remote OST with nodsh"
18128 if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
18129 skip_env "ldiskfs only test"
18134 run_test 399b "fake read should not be slower than normal read"
18136 test_400a() { # LU-1606, was conf-sanity test_74
18137 if ! which $CC > /dev/null 2>&1; then
18138 skip_env "$CC is not installed"
18141 local extra_flags=''
18142 local out=$TMP/$tfile
18143 local prefix=/usr/include/lustre
18146 if ! [[ -d $prefix ]]; then
18147 # Assume we're running in tree and fixup the include path.
18148 extra_flags+=" -I$LUSTRE/include"
18149 extra_flags+=" -L$LUSTRE/utils"
18152 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
18153 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
18154 error "client api broken"
18158 run_test 400a "Lustre client api program can compile and link"
18160 test_400b() { # LU-1606, LU-5011
18162 local out=$TMP/$tfile
18163 local prefix=/usr/include/linux/lustre
18165 # We use a hard coded prefix so that this test will not fail
18166 # when run in tree. There are headers in lustre/include/lustre/
18167 # that are not packaged (like lustre_idl.h) and have more
18168 # complicated include dependencies (like config.h and lnet/types.h).
18169 # Since this test about correct packaging we just skip them when
18170 # they don't exist (see below) rather than try to fixup cppflags.
18172 if ! which $CC > /dev/null 2>&1; then
18173 skip_env "$CC is not installed"
18176 for header in $prefix/*.h; do
18177 if ! [[ -f "$header" ]]; then
18181 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
18182 continue # lustre_ioctl.h is internal header
18185 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
18186 error "cannot compile '$header'"
18190 run_test 400b "packaged headers can be compiled"
18192 test_401a() { #LU-7437
18193 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
18194 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
18196 #count the number of parameters by "list_param -R"
18197 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
18198 #count the number of parameters by listing proc files
18199 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
18200 echo "proc_dirs='$proc_dirs'"
18201 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
18202 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
18205 [ $params -eq $procs ] ||
18206 error "found $params parameters vs. $procs proc files"
18208 # test the list_param -D option only returns directories
18209 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
18210 #count the number of parameters by listing proc directories
18211 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
18214 [ $params -eq $procs ] ||
18215 error "found $params parameters vs. $procs proc files"
18217 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
18220 local save=$($LCTL get_param -n jobid_var)
18223 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
18224 error "no error returned when setting bad parameters"
18226 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
18227 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
18229 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
18230 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
18231 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
18233 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
18236 local jobid_var_old=$($LCTL get_param -n jobid_var)
18237 local jobid_var_new
18239 $LCTL set_param jobid_var= &&
18240 error "no error returned for 'set_param a='"
18242 jobid_var_new=$($LCTL get_param -n jobid_var)
18243 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
18244 error "jobid_var was changed by setting without value"
18246 $LCTL set_param jobid_var &&
18247 error "no error returned for 'set_param a'"
18249 jobid_var_new=$($LCTL get_param -n jobid_var)
18250 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
18251 error "jobid_var was changed by setting without value"
18253 run_test 401c "Verify 'lctl set_param' without value fails in either format."
18256 local jobid_var_old=$($LCTL get_param -n jobid_var)
18257 local jobid_var_new
18258 local new_value="foo=bar"
18260 $LCTL set_param jobid_var=$new_value ||
18261 error "'set_param a=b' did not accept a value containing '='"
18263 jobid_var_new=$($LCTL get_param -n jobid_var)
18264 [[ "$jobid_var_new" == "$new_value" ]] ||
18265 error "'set_param a=b' failed on a value containing '='"
18267 # Reset the jobid_var to test the other format
18268 $LCTL set_param jobid_var=$jobid_var_old
18269 jobid_var_new=$($LCTL get_param -n jobid_var)
18270 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
18271 error "failed to reset jobid_var"
18273 $LCTL set_param jobid_var $new_value ||
18274 error "'set_param a b' did not accept a value containing '='"
18276 jobid_var_new=$($LCTL get_param -n jobid_var)
18277 [[ "$jobid_var_new" == "$new_value" ]] ||
18278 error "'set_param a b' failed on a value containing '='"
18280 $LCTL set_param jobid_var $jobid_var_old
18281 jobid_var_new=$($LCTL get_param -n jobid_var)
18282 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
18283 error "failed to reset jobid_var"
18285 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
18288 local server_version=$(lustre_version_code $SINGLEMDS)
18289 [[ $server_version -ge $(version_code 2.7.66) ]] ||
18290 [[ $server_version -ge $(version_code 2.7.18.4) &&
18291 $server_version -lt $(version_code 2.7.50) ]] ||
18292 [[ $server_version -ge $(version_code 2.7.2) &&
18293 $server_version -lt $(version_code 2.7.11) ]] ||
18294 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
18295 remote_mds_nodsh && skip "remote MDS with nodsh"
18297 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
18298 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
18299 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
18300 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
18301 echo "Touch failed - OK"
18303 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
18306 local file1=$DIR/$tfile.1
18307 local file2=$DIR/$tfile.2
18308 local tfile=$TMP/$tfile
18310 rm -f $file1 $file2 $tfile
18315 # 30 sec OBD_TIMEOUT in ll_getattr()
18316 # right before populating st_nlink
18317 $LCTL set_param fail_loc=0x80001409
18318 stat -c %h $file1 > $tfile &
18320 # create an alias, drop all locks and reclaim the dentry
18322 cancel_lru_locks mdc
18323 cancel_lru_locks osc
18324 sysctl -w vm.drop_caches=2
18328 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
18330 rm -f $tfile $file1 $file2
18332 run_test 403 "i_nlink should not drop to zero due to aliasing"
18334 test_404() { # LU-6601
18335 local server_version=$(lustre_version_code $SINGLEMDS)
18336 [[ $server_version -ge $(version_code 2.8.53) ]] ||
18337 skip "Need server version newer than 2.8.52"
18338 remote_mds_nodsh && skip "remote MDS with nodsh"
18340 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
18341 awk '/osp .*-osc-MDT/ { print $4}')
18344 for osp in $mosps; do
18345 echo "Deactivate: " $osp
18346 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
18347 local stat=$(do_facet $SINGLEMDS $LCTL dl |
18348 awk -vp=$osp '$4 == p { print $2 }')
18349 [ $stat = IN ] || {
18350 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
18351 error "deactivate error"
18353 echo "Activate: " $osp
18354 do_facet $SINGLEMDS $LCTL --device %$osp activate
18355 local stat=$(do_facet $SINGLEMDS $LCTL dl |
18356 awk -vp=$osp '$4 == p { print $2 }')
18357 [ $stat = UP ] || {
18358 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
18359 error "activate error"
18363 run_test 404 "validate manual {de}activated works properly for OSPs"
18366 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
18367 [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
18368 skip "Layout swap lock is not supported"
18369 check_swap_layouts_support
18371 test_mkdir $DIR/$tdir
18372 swap_lock_test -d $DIR/$tdir ||
18373 error "One layout swap locked test failed"
18375 run_test 405 "Various layout swap lock tests"
18378 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18379 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
18380 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
18381 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18382 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
18383 skip "Need MDS version at least 2.8.50"
18385 local def_stripe_size=$($LFS getstripe -S $MOUNT)
18386 local test_pool=$TESTNAME
18388 if ! combined_mgs_mds ; then
18391 pool_add $test_pool || error "pool_add failed"
18392 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
18393 error "pool_add_targets failed"
18395 save_layout_restore_at_exit $MOUNT
18397 # parent set default stripe count only, child will stripe from both
18398 # parent and fs default
18399 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
18400 error "setstripe $MOUNT failed"
18401 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
18402 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
18403 for i in $(seq 10); do
18404 local f=$DIR/$tdir/$tfile.$i
18405 touch $f || error "touch failed"
18406 local count=$($LFS getstripe -c $f)
18407 [ $count -eq $OSTCOUNT ] ||
18408 error "$f stripe count $count != $OSTCOUNT"
18409 local offset=$($LFS getstripe -i $f)
18410 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
18411 local size=$($LFS getstripe -S $f)
18412 [ $size -eq $((def_stripe_size * 2)) ] ||
18413 error "$f stripe size $size != $((def_stripe_size * 2))"
18414 local pool=$($LFS getstripe -p $f)
18415 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
18418 # change fs default striping, delete parent default striping, now child
18419 # will stripe from new fs default striping only
18420 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
18421 error "change $MOUNT default stripe failed"
18422 $LFS setstripe -c 0 $DIR/$tdir ||
18423 error "delete $tdir default stripe failed"
18424 for i in $(seq 11 20); do
18425 local f=$DIR/$tdir/$tfile.$i
18426 touch $f || error "touch $f failed"
18427 local count=$($LFS getstripe -c $f)
18428 [ $count -eq 1 ] || error "$f stripe count $count != 1"
18429 local offset=$($LFS getstripe -i $f)
18430 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
18431 local size=$($LFS getstripe -S $f)
18432 [ $size -eq $def_stripe_size ] ||
18433 error "$f stripe size $size != $def_stripe_size"
18434 local pool=$($LFS getstripe -p $f)
18435 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
18438 unlinkmany $DIR/$tdir/$tfile. 1 20
18440 local f=$DIR/$tdir/$tfile
18441 pool_remove_all_targets $test_pool $f
18442 pool_remove $test_pool $f
18444 if ! combined_mgs_mds ; then
18448 run_test 406 "DNE support fs default striping"
18451 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18452 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
18453 skip "Need MDS version at least 2.8.55"
18454 remote_mds_nodsh && skip "remote MDS with nodsh"
18456 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
18457 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
18458 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
18459 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
18460 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
18462 #define OBD_FAIL_DT_TXN_STOP 0x2019
18463 for idx in $(seq $MDSCOUNT); do
18464 do_facet mds$idx "lctl set_param fail_loc=0x2019"
18466 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
18467 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
18468 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
18471 run_test 407 "transaction fail should cause operation fail"
18474 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
18476 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
18477 lctl set_param fail_loc=0x8000040a
18478 # let ll_prepare_partial_page() fail
18479 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
18483 # create at least 100 unused inodes so that
18484 # shrink_icache_memory(0) should not return 0
18485 touch $DIR/$tfile-{0..100}
18486 rm -f $DIR/$tfile-{0..100}
18489 echo 2 > /proc/sys/vm/drop_caches
18491 run_test 408 "drop_caches should not hang due to page leaks"
18495 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18496 check_mount_and_prep
18498 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
18499 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
18500 touch $DIR/$tdir/guard || error "(2) Fail to create"
18502 local PREFIX=$(str_repeat 'A' 128)
18503 echo "Create 1K hard links start at $(date)"
18504 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
18505 error "(3) Fail to hard link"
18507 echo "Links count should be right although linkEA overflow"
18508 stat $DIR/$tdir/guard || error "(4) Fail to stat"
18509 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
18510 [ $linkcount -eq 1001 ] ||
18511 error "(5) Unexpected hard links count: $linkcount"
18513 echo "List all links start at $(date)"
18514 ls -l $DIR/$tdir/foo > /dev/null ||
18515 error "(6) Fail to list $DIR/$tdir/foo"
18517 echo "Unlink hard links start at $(date)"
18518 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
18519 error "(7) Fail to unlink"
18521 run_test 409 "Large amount of cross-MDTs hard links on the same file"
18525 [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
18526 skip "Need client version at least 2.9.59"
18528 # Create a file, and stat it from the kernel
18529 local testfile=$DIR/$tfile
18532 local run_id=$RANDOM
18533 local my_ino=$(stat --format "%i" $testfile)
18535 # Try to insert the module. This will always fail as the
18536 # module is designed to not be inserted.
18537 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
18540 # Anything but success is a test failure
18542 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
18543 error "no inode match"
18545 run_test 410 "Test inode number returned from kernel thread"
18547 cleanup_test411_cgroup() {
18553 local cg_basedir=/sys/fs/cgroup/memory
18555 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
18556 skip "no setup for cgroup"
18558 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
18559 error "test file creation failed"
18560 cancel_lru_locks osc
18562 # Create a very small memory cgroup to force a slab allocation error
18563 local cgdir=$cg_basedir/osc_slab_alloc
18564 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
18565 trap "cleanup_test411_cgroup $cgdir" EXIT
18566 echo 2M > $cgdir/memory.kmem.limit_in_bytes
18567 echo 1M > $cgdir/memory.limit_in_bytes
18569 # Should not LBUG, just be killed by oom-killer
18570 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
18571 error "fail to trigger a memory allocation error"
18573 cleanup_test411_cgroup $cgdir
18577 run_test 411 "Slab allocation error with cgroup does not LBUG"
18580 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18581 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
18582 skip "Need server version at least 2.10.55"
18585 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
18586 error "mkdir failed"
18587 $LFS getdirstripe $DIR/$tdir
18588 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
18589 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
18590 error "expect $((MDSCOUT - 1)) get $stripe_index"
18591 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
18592 [ $stripe_count -eq 2 ] ||
18593 error "expect 2 get $stripe_count"
18595 run_test 412 "mkdir on specific MDTs"
18598 [ $MDSCOUNT -lt 2 ] &&
18599 skip "We need at least 2 MDTs for this test"
18601 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
18602 skip "Need server version at least 2.10.55"
18605 mkdir $DIR/$tdir || error "mkdir failed"
18607 # find MDT that is the most full
18608 local max=$($LFS df | grep MDT |
18617 END { split(b, c, ":")
18622 for i in $(seq $((MDSCOUNT - 1))); do
18623 $LFS mkdir -c $i $DIR/$tdir/d$i ||
18624 error "mkdir d$i failed"
18625 $LFS getdirstripe $DIR/$tdir/d$i
18626 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
18627 [ $stripe_index -ne $max ] ||
18628 error "don't expect $max"
18631 run_test 413 "mkdir on less full MDTs"
18634 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
18635 $LCTL set_param fail_loc=0x80000521
18636 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
18639 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
18642 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
18643 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
18644 skip "Need server version at least 2.9.55"
18646 start_full_debug_logging
18650 stop_full_debug_logging
18654 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
18655 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
18656 awk '/The barrier for/ { print $7 }')
18659 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
18664 barrier_expired() {
18667 if [ $(lustre_version_code mgs) -le $(version_code 2.10.0) ]; then
18668 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
18669 awk '/will be expired/ { print $7 }')
18671 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
18680 echo "Start barrier_freeze at: $(date)"
18681 #define OBD_FAIL_BARRIER_DELAY 0x2202
18682 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
18683 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
18686 local b_status=$(barrier_stat)
18687 echo "Got barrier status at: $(date)"
18688 [ "$b_status" = "'freezing_p1'" ] ||
18689 error "(1) unexpected barrier status $b_status"
18691 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
18693 b_status=$(barrier_stat)
18694 [ "$b_status" = "'frozen'" ] ||
18695 error "(2) unexpected barrier status $b_status"
18697 local expired=$(barrier_expired)
18698 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
18699 sleep $((expired + 3))
18701 b_status=$(barrier_stat)
18702 [ "$b_status" = "'expired'" ] ||
18703 error "(3) unexpected barrier status $b_status"
18705 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
18706 error "(4) fail to freeze barrier"
18708 b_status=$(barrier_stat)
18709 [ "$b_status" = "'frozen'" ] ||
18710 error "(5) unexpected barrier status $b_status"
18712 echo "Start barrier_thaw at: $(date)"
18713 #define OBD_FAIL_BARRIER_DELAY 0x2202
18714 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
18715 do_facet mgs $LCTL barrier_thaw $FSNAME &
18718 b_status=$(barrier_stat)
18719 echo "Got barrier status at: $(date)"
18720 [ "$b_status" = "'thawing'" ] ||
18721 error "(6) unexpected barrier status $b_status"
18723 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
18725 b_status=$(barrier_stat)
18726 [ "$b_status" = "'thawed'" ] ||
18727 error "(7) unexpected barrier status $b_status"
18729 #define OBD_FAIL_BARRIER_FAILURE 0x2203
18730 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
18731 do_facet mgs $LCTL barrier_freeze $FSNAME
18733 b_status=$(barrier_stat)
18734 [ "$b_status" = "'failed'" ] ||
18735 error "(8) unexpected barrier status $b_status"
18737 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18738 do_facet mgs $LCTL barrier_thaw $FSNAME
18742 run_test 801a "write barrier user interfaces and stat machine"
18747 mkdir $DIR/$tdir || error "(1) fail to mkdir"
18748 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
18749 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
18750 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
18751 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
18753 cancel_lru_locks mdc
18755 # 180 seconds should be long enough
18756 do_facet mgs $LCTL barrier_freeze $FSNAME 180
18758 local b_status=$(barrier_stat)
18759 [ "$b_status" = "'frozen'" ] ||
18760 error "(6) unexpected barrier status $b_status"
18762 mkdir $DIR/$tdir/d0/d10 &
18765 touch $DIR/$tdir/d1/f13 &
18768 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
18771 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
18774 rm -f $DIR/$tdir/d4/f12 &
18777 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
18779 # To guarantee taht the 'stat' is not blocked
18780 b_status=$(barrier_stat)
18781 [ "$b_status" = "'frozen'" ] ||
18782 error "(8) unexpected barrier status $b_status"
18784 # let above commands to run at background
18787 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
18788 ps -p $touch_pid || error "(10) touch should be blocked"
18789 ps -p $ln_pid || error "(11) link should be blocked"
18790 ps -p $mv_pid || error "(12) rename should be blocked"
18791 ps -p $rm_pid || error "(13) unlink should be blocked"
18793 b_status=$(barrier_stat)
18794 [ "$b_status" = "'frozen'" ] ||
18795 error "(14) unexpected barrier status $b_status"
18797 do_facet mgs $LCTL barrier_thaw $FSNAME
18798 b_status=$(barrier_stat)
18799 [ "$b_status" = "'thawed'" ] ||
18800 error "(15) unexpected barrier status $b_status"
18802 wait $mkdir_pid || error "(16) mkdir should succeed"
18803 wait $touch_pid || error "(17) touch should succeed"
18804 wait $ln_pid || error "(18) link should succeed"
18805 wait $mv_pid || error "(19) rename should succeed"
18806 wait $rm_pid || error "(20) unlink should succeed"
18810 run_test 801b "modification will be blocked by write barrier"
18813 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
18817 stop mds2 || error "(1) Fail to stop mds2"
18819 do_facet mgs $LCTL barrier_freeze $FSNAME 30
18821 local b_status=$(barrier_stat)
18822 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
18823 do_facet mgs $LCTL barrier_thaw $FSNAME
18824 error "(2) unexpected barrier status $b_status"
18827 do_facet mgs $LCTL barrier_rescan $FSNAME ||
18828 error "(3) Fail to rescan barrier bitmap"
18830 do_facet mgs $LCTL barrier_freeze $FSNAME 10
18832 b_status=$(barrier_stat)
18833 [ "$b_status" = "'frozen'" ] ||
18834 error "(4) unexpected barrier status $b_status"
18836 do_facet mgs $LCTL barrier_thaw $FSNAME
18837 b_status=$(barrier_stat)
18838 [ "$b_status" = "'thawed'" ] ||
18839 error "(5) unexpected barrier status $b_status"
18841 local devname=$(mdsdevname 2)
18843 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
18845 do_facet mgs $LCTL barrier_rescan $FSNAME ||
18846 error "(7) Fail to rescan barrier bitmap"
18850 run_test 801c "rescan barrier bitmap"
18852 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
18853 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
18854 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
18860 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
18861 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
18862 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
18868 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
18869 [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
18870 skip "Need server version at least 2.9.55"
18872 mkdir $DIR/$tdir || error "(1) fail to mkdir"
18874 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
18875 error "(2) Fail to copy"
18877 trap cleanup_802 EXIT
18879 # sync by force before remount as readonly
18880 sync; sync_all_data; sleep 3; sync_all_data
18884 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
18885 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
18886 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
18888 echo "Mount the server as read only"
18889 setupall server_only || error "(3) Fail to start servers"
18891 echo "Mount client without ro should fail"
18892 mount_client $MOUNT &&
18893 error "(4) Mount client without 'ro' should fail"
18895 echo "Mount client with ro should succeed"
18896 mount_client $MOUNT ro ||
18897 error "(5) Mount client with 'ro' should succeed"
18899 echo "Modify should be refused"
18900 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
18902 echo "Read should be allowed"
18903 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
18904 error "(7) Read should succeed under ro mode"
18908 run_test 802 "simulate readonly device"
18911 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
18912 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
18913 skip "MDS needs to be newer than 2.10.54"
18915 mkdir -p $DIR/$tdir
18916 # Create some objects on all MDTs to trigger related logs objects
18917 for idx in $(seq $MDSCOUNT); do
18918 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
18919 $DIR/$tdir/dir${idx} ||
18920 error "Fail to create $DIR/$tdir/dir${idx}"
18924 echo "before create:"
18926 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
18928 for ((i=0; i<10; i++)); do
18929 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
18930 error "Fail to create $DIR/$tdir/foo$i"
18934 echo "after create:"
18936 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
18938 [ $after_used -ge $((before_used + 10)) ] ||
18939 error "before ($before_used) + 10 > after ($after_used)"
18941 for ((i=0; i<10; i++)); do
18942 rm -rf $DIR/$tdir/foo$i ||
18943 error "Fail to remove $DIR/$tdir/foo$i"
18946 sleep 3 # avoid MDT return cached statfs
18947 wait_delete_completed
18948 echo "after unlink:"
18950 before_used=$after_used
18951 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
18953 [ $after_used -le $((before_used - 8)) ] ||
18954 error "before ($before_used) - 8 < after ($after_used)"
18956 run_test 803 "verify agent object for remote object"
18959 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
18960 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
18961 skip "MDS needs to be newer than 2.10.54"
18962 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
18963 skip_env "ldiskfs only test"
18965 mkdir -p $DIR/$tdir
18966 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
18967 error "Fail to create $DIR/$tdir/dir0"
18969 local fid=$($LFS path2fid $DIR/$tdir/dir0)
18970 local dev=$(mdsdevname 2)
18972 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18973 grep ${fid} || error "NOT found agent entry for dir0"
18975 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
18976 error "Fail to create $DIR/$tdir/dir1"
18978 touch $DIR/$tdir/dir1/foo0 ||
18979 error "Fail to create $DIR/$tdir/dir1/foo0"
18980 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
18983 for idx in $(seq $MDSCOUNT); do
18984 dev=$(mdsdevname $idx)
18985 do_facet mds${idx} \
18986 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18987 grep ${fid} && rc=$idx
18990 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
18991 error "Fail to rename foo0 to foo1"
18992 if [ $rc -eq 0 ]; then
18993 for idx in $(seq $MDSCOUNT); do
18994 dev=$(mdsdevname $idx)
18995 do_facet mds${idx} \
18996 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
18997 grep ${fid} && rc=$idx
19001 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
19002 error "Fail to rename foo1 to foo2"
19003 if [ $rc -eq 0 ]; then
19004 for idx in $(seq $MDSCOUNT); do
19005 dev=$(mdsdevname $idx)
19006 do_facet mds${idx} \
19007 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
19008 grep ${fid} && rc=$idx
19012 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
19014 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
19015 error "Fail to link to $DIR/$tdir/dir1/foo2"
19016 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
19017 error "Fail to rename foo2 to foo0"
19018 unlink $DIR/$tdir/dir1/foo0 ||
19019 error "Fail to unlink $DIR/$tdir/dir1/foo0"
19020 rm -rf $DIR/$tdir/dir0 ||
19021 error "Fail to rm $DIR/$tdir/dir0"
19023 for idx in $(seq $MDSCOUNT); do
19024 dev=$(mdsdevname $idx)
19028 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
19030 start mds${idx} $dev $MDS_MOUNT_OPTS ||
19031 error "mount mds$idx failed"
19032 df $MOUNT > /dev/null 2>&1
19034 # e2fsck should not return error
19036 error "e2fsck detected error on MDT${idx}: rc=$rc"
19039 run_test 804 "verify agent entry for remote entry"
19042 do_facet $SINGLEMDS zfs set quota=$old $fsset
19043 unlinkmany $DIR/$tdir/f- 1000000
19048 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
19049 [ "$(facet_fstype mds1)" != "zfs" ] &&
19050 skip "ZFS specific test"
19051 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
19052 skip "netfree not implemented before 0.7"
19053 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
19054 skip "Need MDS version at least 2.10.57"
19061 local pref="osd-zfs.lustre-MDT0000."
19063 # limit available space on MDS dataset to meet nospace issue
19064 # quickly. then ZFS 0.7.2 can use reserved space if asked
19065 # properly (using netfree flag in osd_declare_destroy()
19066 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
19067 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
19069 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
19070 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
19071 let "usedkb=usedkb-freekb"
19072 let "freekb=freekb/2"
19073 if let "freekb > 5000"; then
19076 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
19077 trap cleanup_805 EXIT
19079 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
19080 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
19081 rm -rf $DIR/$tdir || error "not able to remove"
19082 do_facet $SINGLEMDS zfs set quota=$old $fsset
19085 run_test 805 "ZFS can remove from full fs"
19088 # tests that do cleanup/setup should be run at the end
19092 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19095 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
19096 $LCTL set_param fail_loc=0x903
19098 cancel_lru_locks MGC
19100 FAIL_ON_ERROR=true cleanup
19101 FAIL_ON_ERROR=true setup
19103 run_test 900 "umount should not race with any mgc requeue thread"
19106 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
19107 check_and_cleanup_lustre
19108 if [ "$I_MOUNTED" != "yes" ]; then
19109 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true