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
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c"
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"
19 # bug number for skipped tests: LU-9795 (all below)
20 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 17n 60a 133g 300f"
23 # Check Grants after these tests
24 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
26 # skip the grant tests for ARM until they are fixed
27 if [[ $(uname -m) = aarch64 ]]; then
28 # bug number: LU-11596 (all below)
29 ALWAYS_EXCEPT+=" $GRANT_CHECK_LIST"
30 # bug number: LU-11671 LU-11594 LU-11667 LU-11729
31 ALWAYS_EXCEPT+=" 45 103a 317 810"
34 SRCDIR=$(cd $(dirname $0); echo $PWD)
35 export PATH=$PATH:/sbin
41 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
42 CREATETEST=${CREATETEST:-createtest}
44 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
46 OPENFILE=${OPENFILE:-openfile}
47 OPENUNLINK=${OPENUNLINK:-openunlink}
48 export MULTIOP=${MULTIOP:-multiop}
49 READS=${READS:-"reads"}
50 MUNLINK=${MUNLINK:-munlink}
51 SOCKETSERVER=${SOCKETSERVER:-socketserver}
52 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
53 MEMHOG=${MEMHOG:-memhog}
54 DIRECTIO=${DIRECTIO:-directio}
55 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
57 CHECK_GRANT=${CHECK_GRANT:-"yes"}
58 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
59 export PARALLEL=${PARALLEL:-"no"}
61 export NAME=${NAME:-local}
68 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
69 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
70 . $LUSTRE/tests/test-framework.sh
72 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
77 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
79 if [ "$mds1_FSTYPE" = "zfs" ]; then
80 # bug number for skipped test: LU-1957
81 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
83 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
86 # Get the SLES distro version
88 # Returns a version string that should only be used in comparing
89 # strings returned by version_code()
92 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
94 # All SuSE Linux versions have one decimal. version_code expects two
95 local sles_version=$version.0
96 version_code $sles_version
99 # Check if we are running on Ubuntu or SLES so we can make decisions on
101 if [ -r /etc/SuSE-release ]; then
102 sles_version=$(sles_version_code)
103 [ $sles_version -lt $(version_code 11.4.0) ] &&
104 # bug number for skipped test: LU-4341
105 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
106 [ $sles_version -lt $(version_code 12.0.0) ] &&
107 # bug number for skipped test: LU-3703
108 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
109 elif [ -r /etc/os-release ]; then
110 if grep -qi ubuntu /etc/os-release; then
111 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
112 -e 's/^VERSION=//p' \
116 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
117 # bug number for skipped test:
119 ALWAYS_EXCEPT+=" 103a 410"
128 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
129 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
138 check_swap_layouts_support()
140 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
141 skip "Does not support layout lock."
144 check_and_setup_lustre
148 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
150 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
151 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
152 rm -rf $DIR/[Rdfs][0-9]*
154 # $RUNAS_ID may get set incorrectly somewhere else
155 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
156 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
158 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
162 if [ "${ONLY}" = "MOUNT" ] ; then
163 echo "Lustre is up, please go on"
167 echo "preparing for tests involving mounts"
168 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
170 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
171 echo # add a newline after mke2fs.
175 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
176 lctl set_param debug=-1 2> /dev/null || true
179 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
181 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
183 run_test 0a "touch; rm ====================="
186 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
187 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
189 run_test 0b "chmod 0755 $DIR ============================="
192 $LCTL get_param mdc.*.import | grep "state: FULL" ||
193 error "import not FULL"
194 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
197 run_test 0c "check import proc"
199 test_0d() { # LU-3397
200 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
201 skip "proc exports not supported before 2.10.57"
203 local mgs_exp="mgs.MGS.exports"
204 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
206 local exp_client_version
209 local temp_imp=$DIR/$tfile.import
210 local temp_exp=$DIR/$tfile.export
212 # save mgc import file to $temp_imp
213 $LCTL get_param mgc.*.import | tee $temp_imp
214 # Check if client uuid is found in MGS export
215 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
216 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
220 # save mgs export file to $temp_exp
221 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
223 # Compare the value of field "connect_flags"
224 imp_val=$(grep "connect_flags" $temp_imp)
225 exp_val=$(grep "connect_flags" $temp_exp)
226 [ "$exp_val" == "$imp_val" ] ||
227 error "export flags '$exp_val' != import flags '$imp_val'"
229 # Compare the value of client version
230 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
231 exp_val=$(version_code $exp_client_version)
232 imp_val=$CLIENT_VERSION
233 [ "$exp_val" == "$imp_val" ] ||
234 error "export client version '$exp_val' != '$imp_val'"
236 run_test 0d "check export proc ============================="
239 test_mkdir $DIR/$tdir
240 test_mkdir $DIR/$tdir/d2
241 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
242 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
245 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
247 run_test 1 "mkdir; remkdir; rmdir"
250 test_mkdir $DIR/$tdir
251 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
252 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
254 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
256 run_test 2 "mkdir; touch; rmdir; check file"
259 test_mkdir $DIR/$tdir
260 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
261 touch $DIR/$tdir/$tfile
262 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
264 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
266 run_test 3 "mkdir; touch; rmdir; check dir"
268 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
270 test_mkdir -i 1 $DIR/$tdir
272 touch $DIR/$tdir/$tfile ||
273 error "Create file under remote directory failed"
276 error "Expect error removing in-use dir $DIR/$tdir"
278 test -d $DIR/$tdir || error "Remote directory disappeared"
280 rm -rf $DIR/$tdir || error "remove remote dir error"
282 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
285 test_mkdir $DIR/$tdir
286 test_mkdir $DIR/$tdir/d2
287 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
288 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
289 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
291 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
294 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
295 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
296 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
297 error "$tfile does not have perm 0666 or UID $UID"
298 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
299 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
300 error "$tfile should be 0666 and owned by UID $UID"
302 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
305 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
308 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
309 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
310 error "$tfile should be owned by UID $RUNAS_ID"
311 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
312 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
313 error "$tfile should be owned by UID $RUNAS_ID"
315 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
318 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
321 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
322 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
323 error "$tfile should be owned by GID $UID"
324 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
325 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
326 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
328 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
331 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
333 test_mkdir $DIR/$tdir
334 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
335 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
336 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
337 test_mkdir $DIR/$tdir/d/subdir
338 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
339 error "$tdir/d/subdir should be GID $RUNAS_GID"
340 if [[ $MDSCOUNT -gt 1 ]]; then
341 # check remote dir sgid inherite
342 $LFS mkdir -i 0 $DIR/$tdir.local ||
343 error "mkdir $tdir.local failed"
344 chmod g+s $DIR/$tdir.local ||
345 error "chmod $tdir.local failed"
346 chgrp $RUNAS_GID $DIR/$tdir.local ||
347 error "chgrp $tdir.local failed"
348 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
349 error "mkdir $tdir.remote failed"
350 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
351 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
352 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
353 error "$tdir.remote should be mode 02755"
356 run_test 6g "verify new dir in sgid dir inherits group"
358 test_6h() { # bug 7331
359 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
361 touch $DIR/$tfile || error "touch failed"
362 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
363 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
364 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
365 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
366 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
368 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
371 test_mkdir $DIR/$tdir
372 $MCREATE $DIR/$tdir/$tfile
373 chmod 0666 $DIR/$tdir/$tfile
374 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
375 error "$tdir/$tfile should be mode 0666"
377 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
380 if [ ! -d $DIR/$tdir ]; then
381 test_mkdir $DIR/$tdir
383 $MCREATE $DIR/$tdir/$tfile
384 echo -n foo > $DIR/$tdir/$tfile
385 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
386 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
388 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
391 test_mkdir $DIR/$tdir
392 touch $DIR/$tdir/$tfile
393 chmod 0666 $DIR/$tdir/$tfile
394 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
395 error "$tfile mode not 0666"
397 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
400 test_mkdir $DIR/$tdir
401 test_mkdir $DIR/$tdir/d2
402 test_mkdir $DIR/$tdir/d2/d3
403 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
405 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
408 test_mkdir $DIR/$tdir
409 test_mkdir $DIR/$tdir/d2
410 touch $DIR/$tdir/d2/$tfile
411 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
412 error "$tdir/d2/$tfile not a file"
414 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
417 test_mkdir $DIR/$tdir
418 test_mkdir $DIR/$tdir/d2
419 chmod 0666 $DIR/$tdir/d2
420 chmod 0705 $DIR/$tdir/d2
421 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
422 error "$tdir/d2 mode not 0705"
424 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
427 test_mkdir $DIR/$tdir
428 touch $DIR/$tdir/$tfile
429 chmod 0666 $DIR/$tdir/$tfile
430 chmod 0654 $DIR/$tdir/$tfile
431 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
432 error "$tdir/d2 mode not 0654"
434 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
437 test_mkdir $DIR/$tdir
438 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
440 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
441 error "$tdir/$tfile size not 0 after truncate"
443 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
446 test_mkdir $DIR/$tdir
447 touch $DIR/$tdir/$tfile
449 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
451 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
454 test_mkdir $DIR/$tdir
455 touch $DIR/$tdir/$tfile
456 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
457 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
458 error "$tdir/${tfile_2} not a file after rename"
459 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
461 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
464 test_mkdir $DIR/$tdir
465 touch $DIR/$tdir/$tfile
466 rm -rf $DIR/$tdir/$tfile
467 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
469 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
472 test_mkdir $DIR/$tdir
473 touch $DIR/$tdir/$tfile
474 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
476 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
477 error "$tdir/l-exist not a symlink"
478 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
479 error "$tdir/l-exist not referencing a file"
480 rm -f $DIR/$tdir/l-exist
481 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
483 run_test 17a "symlinks: create, remove (real)"
486 test_mkdir $DIR/$tdir
487 ln -s no-such-file $DIR/$tdir/l-dangle
489 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
490 error "$tdir/l-dangle not referencing no-such-file"
491 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
492 error "$tdir/l-dangle not referencing non-existent file"
493 rm -f $DIR/$tdir/l-dangle
494 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
496 run_test 17b "symlinks: create, remove (dangling)"
498 test_17c() { # bug 3440 - don't save failed open RPC for replay
499 test_mkdir $DIR/$tdir
500 ln -s foo $DIR/$tdir/$tfile
501 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
503 run_test 17c "symlinks: open dangling (should return error)"
506 test_mkdir $DIR/$tdir
507 ln -s foo $DIR/$tdir/$tfile
508 touch $DIR/$tdir/$tfile || error "creating to new symlink"
510 run_test 17d "symlinks: create dangling"
513 test_mkdir $DIR/$tdir
514 local foo=$DIR/$tdir/$tfile
515 ln -s $foo $foo || error "create symlink failed"
516 ls -l $foo || error "ls -l failed"
517 ls $foo && error "ls not failed" || true
519 run_test 17e "symlinks: create recursive symlink (should return error)"
522 test_mkdir $DIR/$tdir
523 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
524 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
525 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
526 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
527 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
528 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
531 run_test 17f "symlinks: long and very long symlink name"
533 # str_repeat(S, N) generate a string that is string S repeated N times
538 while [ $((n -= 1)) -ge 0 ]; do
544 # Long symlinks and LU-2241
546 test_mkdir $DIR/$tdir
547 local TESTS="59 60 61 4094 4095"
549 # Fix for inode size boundary in 2.1.4
550 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
553 # Patch not applied to 2.2 or 2.3 branches
554 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
555 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
558 # skip long symlink name for rhel6.5.
559 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
560 grep -q '6.5' /etc/redhat-release &>/dev/null &&
561 TESTS="59 60 61 4062 4063"
564 local SYMNAME=$(str_repeat 'x' $i)
565 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
566 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
569 run_test 17g "symlinks: really long symlink name and inode boundaries"
571 test_17h() { #bug 17378
572 [ $PARALLEL == "yes" ] && skip "skip parallel run"
573 remote_mds_nodsh && skip "remote MDS with nodsh"
577 test_mkdir $DIR/$tdir
578 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
579 $LFS setstripe -c -1 $DIR/$tdir
580 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
581 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
582 touch $DIR/$tdir/$tfile || true
584 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
586 test_17i() { #bug 20018
587 [ $PARALLEL == "yes" ] && skip "skip parallel run"
588 remote_mds_nodsh && skip "remote MDS with nodsh"
590 local foo=$DIR/$tdir/$tfile
593 test_mkdir -c1 $DIR/$tdir
594 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
595 ln -s $foo $foo || error "create symlink failed"
596 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
597 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
598 ls -l $foo && error "error not detected"
601 run_test 17i "don't panic on short symlink (should return error)"
603 test_17k() { #bug 22301
604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
605 [[ -z "$(which rsync 2>/dev/null)" ]] &&
606 skip "no rsync command"
607 rsync --help | grep -q xattr ||
608 skip_env "$(rsync --version | head -n1) does not support xattrs"
609 test_mkdir $DIR/$tdir
610 test_mkdir $DIR/$tdir.new
611 touch $DIR/$tdir/$tfile
612 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
613 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
614 error "rsync failed with xattrs enabled"
616 run_test 17k "symlinks: rsync with xattrs enabled"
618 test_17l() { # LU-279
619 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
620 skip "no getfattr command"
622 test_mkdir $DIR/$tdir
623 touch $DIR/$tdir/$tfile
624 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
625 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
626 # -h to not follow symlinks. -m '' to list all the xattrs.
627 # grep to remove first line: '# file: $path'.
628 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
630 lgetxattr_size_check $path $xattr ||
631 error "lgetxattr_size_check $path $xattr failed"
635 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
640 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
641 remote_mds_nodsh && skip "remote MDS with nodsh"
642 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
643 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
644 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
646 local short_sym="0123456789"
647 local wdir=$DIR/$tdir
652 # create a long symlink file
653 for ((i = 0; i < 4; ++i)); do
654 long_sym=${long_sym}${long_sym}
657 echo "create 512 short and long symlink files under $wdir"
658 for ((i = 0; i < 256; ++i)); do
659 ln -sf ${long_sym}"a5a5" $wdir/long-$i
660 ln -sf ${short_sym}"a5a5" $wdir/short-$i
666 wait_delete_completed
668 echo "recreate the 512 symlink files with a shorter string"
669 for ((i = 0; i < 512; ++i)); do
670 # rewrite the symlink file with a shorter string
671 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
672 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
675 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
676 local devname=$(mdsdevname $mds_index)
678 echo "stop and checking mds${mds_index}:"
679 # e2fsck should not return error
681 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
684 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
685 error "start mds${mds_index} failed"
686 df $MOUNT > /dev/null 2>&1
688 error "e2fsck detected error for short/long symlink: rc=$rc"
691 run_test 17m "run e2fsck against MDT which contains short/long symlink"
693 check_fs_consistency_17n() {
697 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
698 # so it only check MDT1/MDT2 instead of all of MDTs.
699 for mdt_index in 1 2; do
700 local devname=$(mdsdevname $mdt_index)
701 # e2fsck should not return error
703 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
706 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
707 error "mount mds$mdt_index failed"
708 df $MOUNT > /dev/null 2>&1
714 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
716 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
717 remote_mds_nodsh && skip "remote MDS with nodsh"
718 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
719 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
720 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
724 test_mkdir $DIR/$tdir
725 for ((i=0; i<10; i++)); do
726 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
727 error "create remote dir error $i"
728 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
729 error "create files under remote dir failed $i"
732 check_fs_consistency_17n ||
733 error "e2fsck report error after create files under remote dir"
735 for ((i = 0; i < 10; i++)); do
736 rm -rf $DIR/$tdir/remote_dir_${i} ||
737 error "destroy remote dir error $i"
740 check_fs_consistency_17n ||
741 error "e2fsck report error after unlink files under remote dir"
743 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
744 skip "lustre < 2.4.50 does not support migrate mv"
746 for ((i = 0; i < 10; i++)); do
747 mkdir -p $DIR/$tdir/remote_dir_${i}
748 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
749 error "create files under remote dir failed $i"
750 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
751 error "migrate remote dir error $i"
753 check_fs_consistency_17n || error "e2fsck report error after migration"
755 for ((i = 0; i < 10; i++)); do
756 rm -rf $DIR/$tdir/remote_dir_${i} ||
757 error "destroy remote dir error $i"
760 check_fs_consistency_17n || error "e2fsck report error after unlink"
762 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
765 remote_mds_nodsh && skip "remote MDS with nodsh"
766 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
767 skip "Need MDS version at least 2.3.64"
769 local wdir=$DIR/${tdir}o
775 mdt_index=$($LFS getstripe -m $wdir/$tfile)
776 mdt_index=$((mdt_index + 1))
779 #fail mds will wait the failover finish then set
780 #following fail_loc to avoid interfer the recovery process.
783 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
784 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
785 ls -l $wdir/$tfile && rc=1
786 do_facet mds${mdt_index} lctl set_param fail_loc=0
787 [[ $rc -eq 0 ]] || error "stat file should fail"
789 run_test 17o "stat file with incompat LMA feature"
792 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
793 ls $DIR || error "Failed to ls $DIR: $?"
795 run_test 18 "touch .../f ; ls ... =============================="
801 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
803 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
806 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
808 run_test 19b "ls -l .../f19 (should return error) =============="
811 [ $RUNAS_ID -eq $UID ] &&
812 skip_env "RUNAS_ID = UID = $UID -- skipping"
814 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
816 run_test 19c "$RUNAS touch .../f19 (should return error) =="
819 cat $DIR/f19 && error || true
821 run_test 19d "cat .../f19 (should return error) =============="
830 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
832 run_test 20 "touch .../f ; ls -l ..."
835 test_mkdir $DIR/$tdir
836 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
837 ln -s dangle $DIR/$tdir/link
838 echo foo >> $DIR/$tdir/link
839 cat $DIR/$tdir/dangle
840 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
841 $CHECKSTAT -f -t file $DIR/$tdir/link ||
842 error "$tdir/link not linked to a file"
844 run_test 21 "write to dangling link"
847 local wdir=$DIR/$tdir
849 chown $RUNAS_ID:$RUNAS_GID $wdir
850 (cd $wdir || error "cd $wdir failed";
851 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
853 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
854 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
855 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
856 error "checkstat -u failed"
858 run_test 22 "unpack tar archive as non-root user"
862 test_mkdir $DIR/$tdir
863 local file=$DIR/$tdir/$tfile
865 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
866 openfile -f O_CREAT:O_EXCL $file &&
867 error "$file recreate succeeded" || true
869 run_test 23a "O_CREAT|O_EXCL in subdir"
871 test_23b() { # bug 18988
872 test_mkdir $DIR/$tdir
873 local file=$DIR/$tdir/$tfile
876 echo foo > $file || error "write filed"
877 echo bar >> $file || error "append filed"
878 $CHECKSTAT -s 8 $file || error "wrong size"
881 run_test 23b "O_APPEND check"
883 # LU-9409, size with O_APPEND and tiny writes
885 local file=$DIR/$tfile
888 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
889 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
893 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
894 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
896 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
899 #racing tiny & normal writes
900 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
901 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
903 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
906 #racing tiny & normal writes 2, ugly numbers
907 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
908 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
910 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
913 run_test 23c "O_APPEND size checks for tiny writes"
915 # LU-11069 file offset is correct after appending writes
917 local file=$DIR/$tfile
920 echo CentaurHauls > $file
921 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
922 if ((offset != 26)); then
923 error "wrong offset, expected 26, got '$offset'"
926 run_test 23d "file offset is correct after appending writes"
930 echo '-- same directory rename'
931 test_mkdir $DIR/$tdir
932 touch $DIR/$tdir/$tfile.1
933 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
934 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
936 run_test 24a "rename file to non-existent target"
939 test_mkdir $DIR/$tdir
940 touch $DIR/$tdir/$tfile.{1,2}
941 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
942 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
943 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
945 run_test 24b "rename file to existing target"
948 test_mkdir $DIR/$tdir
949 test_mkdir $DIR/$tdir/d$testnum.1
950 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
951 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
952 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
954 run_test 24c "rename directory to non-existent target"
957 test_mkdir -c1 $DIR/$tdir
958 test_mkdir -c1 $DIR/$tdir/d$testnum.1
959 test_mkdir -c1 $DIR/$tdir/d$testnum.2
960 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
961 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
962 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
964 run_test 24d "rename directory to existing target"
967 echo '-- cross directory renames --'
971 mv $DIR/R5a/f $DIR/R5b/g
972 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
973 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
975 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
980 touch $DIR/R6a/f $DIR/R6b/g
981 mv $DIR/R6a/f $DIR/R6b/g
982 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
983 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
985 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
990 test_mkdir $DIR/R7a/d
991 mv $DIR/R7a/d $DIR/R7b/e
992 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
993 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
995 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
998 test_mkdir -c1 $DIR/R8a
999 test_mkdir -c1 $DIR/R8b
1000 test_mkdir -c1 $DIR/R8a/d
1001 test_mkdir -c1 $DIR/R8b/e
1002 mrename $DIR/R8a/d $DIR/R8b/e
1003 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1004 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1006 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1009 echo "-- rename error cases"
1011 test_mkdir $DIR/R9/a
1013 mrename $DIR/R9/f $DIR/R9/a
1014 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1015 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1016 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1018 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1022 mrename $DIR/R10/f $DIR/R10/g
1023 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1024 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1025 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1027 run_test 24j "source does not exist ============================"
1030 test_mkdir $DIR/R11a
1031 test_mkdir $DIR/R11a/d
1033 mv $DIR/R11a/f $DIR/R11a/d
1034 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1035 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1037 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1039 # bug 2429 - rename foo foo foo creates invalid file
1042 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1044 run_test 24l "Renaming a file to itself ========================"
1048 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1049 # on ext3 this does not remove either the source or target files
1050 # though the "expected" operation would be to remove the source
1051 $CHECKSTAT -t file ${f} || error "${f} missing"
1052 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1054 run_test 24m "Renaming a file to a hard link to itself ========="
1058 # this stats the old file after it was renamed, so it should fail
1060 $CHECKSTAT ${f} || error "${f} missing"
1062 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1063 $CHECKSTAT -a ${f} || error "${f} exists"
1065 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1068 test_mkdir $DIR/$tdir
1069 rename_many -s random -v -n 10 $DIR/$tdir
1071 run_test 24o "rename of files during htree split"
1074 test_mkdir $DIR/R12a
1075 test_mkdir $DIR/R12b
1076 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1077 mrename $DIR/R12a $DIR/R12b
1078 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1079 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1080 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1081 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1083 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1085 cleanup_multiop_pause() {
1087 kill -USR1 $MULTIPID
1091 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1093 test_mkdir $DIR/R13a
1094 test_mkdir $DIR/R13b
1095 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1096 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1099 trap cleanup_multiop_pause EXIT
1100 mrename $DIR/R13a $DIR/R13b
1101 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1102 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1103 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1104 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1105 cleanup_multiop_pause
1106 wait $MULTIPID || error "multiop close failed"
1108 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1110 test_24r() { #bug 3789
1111 test_mkdir $DIR/R14a
1112 test_mkdir $DIR/R14a/b
1113 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1114 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1115 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1117 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1120 test_mkdir $DIR/R15a
1121 test_mkdir $DIR/R15a/b
1122 test_mkdir $DIR/R15a/b/c
1123 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1124 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1125 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1127 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1129 test_mkdir $DIR/R16a
1130 test_mkdir $DIR/R16a/b
1131 test_mkdir $DIR/R16a/b/c
1132 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1133 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1134 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1136 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1138 test_24u() { # bug12192
1139 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1140 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1142 run_test 24u "create stripe file"
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 [ "$mds1_FSTYPE" = "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 [[ $MDS1_VERSION -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 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1396 [ "$SLOW" = "no" ] && repeats=100
1400 echo "$repeats repeats"
1401 for ((i = 0; i < repeats; i++)); do
1402 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1403 touch $DIR/$tdir/test/a || error "touch fails"
1404 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1405 rm -rf $DIR/$tdir/test || error "rmdir fails"
1410 run_test 24F "hash order vs readdir (LU-11330)"
1413 echo '== symlink sanity ============================================='
1417 touch $DIR/s25/foo ||
1418 error "File creation in symlinked directory failed"
1420 run_test 25a "create file in symlinked directory ==============="
1423 [ ! -d $DIR/d25 ] && test_25a
1424 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1426 run_test 25b "lookup file in symlinked directory ==============="
1430 test_mkdir $DIR/d26/d26-2
1431 ln -s d26/d26-2 $DIR/s26
1432 touch $DIR/s26/foo || error "File creation failed"
1434 run_test 26a "multiple component symlink ======================="
1437 test_mkdir -p $DIR/$tdir/d26-2
1438 ln -s $tdir/d26-2/foo $DIR/s26-2
1439 touch $DIR/s26-2 || error "File creation failed"
1441 run_test 26b "multiple component symlink at end of lookup ======"
1444 test_mkdir $DIR/d26.2
1445 touch $DIR/d26.2/foo
1446 ln -s d26.2 $DIR/s26.2-1
1447 ln -s s26.2-1 $DIR/s26.2-2
1448 ln -s s26.2-2 $DIR/s26.2-3
1449 chmod 0666 $DIR/s26.2-3/foo
1451 run_test 26c "chain of symlinks"
1453 # recursive symlinks (bug 439)
1455 ln -s d26-3/foo $DIR/d26-3
1457 run_test 26d "create multiple component recursive symlink"
1460 [ ! -h $DIR/d26-3 ] && test_26d
1463 run_test 26e "unlink multiple component recursive symlink"
1465 # recursive symlinks (bug 7022)
1467 test_mkdir $DIR/$tdir
1468 test_mkdir $DIR/$tdir/$tfile
1469 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1470 test_mkdir -p lndir/bar1
1471 test_mkdir $DIR/$tdir/$tfile/$tfile
1472 cd $tfile || error "cd $tfile failed"
1473 ln -s .. dotdot || error "ln dotdot failed"
1474 ln -s dotdot/lndir lndir || error "ln lndir failed"
1475 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1476 output=`ls $tfile/$tfile/lndir/bar1`
1477 [ "$output" = bar1 ] && error "unexpected output"
1478 rm -r $tfile || error "rm $tfile failed"
1479 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1481 run_test 26f "rm -r of a directory which has recursive symlink"
1484 test_mkdir $DIR/$tdir
1485 $LFS getstripe $DIR/$tdir
1486 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1487 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1488 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1490 run_test 27a "one stripe file"
1493 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1495 test_mkdir $DIR/$tdir
1496 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1497 $LFS getstripe -c $DIR/$tdir/$tfile
1498 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1499 error "two-stripe file doesn't have two stripes"
1501 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1503 run_test 27b "create and write to two stripe file"
1506 test_mkdir $DIR/$tdir
1507 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1508 error "setstripe failed"
1509 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1510 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1512 run_test 27d "create file with default settings"
1515 # LU-5839 adds check for existed layout before setting it
1516 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1517 skip "Need MDS version at least 2.7.56"
1519 test_mkdir $DIR/$tdir
1520 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1521 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1522 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1524 run_test 27e "setstripe existing file (should return error)"
1527 test_mkdir $DIR/$tdir
1528 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1529 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1530 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1531 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1532 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1533 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1535 run_test 27f "setstripe with bad stripe size (should return error)"
1538 test_mkdir $DIR/$tdir
1539 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1540 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1541 error "$DIR/$tdir/$tfile has object"
1543 run_test 27g "$LFS getstripe with no objects"
1546 test_mkdir $DIR/$tdir
1547 touch $DIR/$tdir/$tfile || error "touch failed"
1548 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1549 error "missing objects"
1551 run_test 27i "$LFS getstripe with some objects"
1554 test_mkdir $DIR/$tdir
1555 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1556 error "setstripe failed" || true
1558 run_test 27j "setstripe with bad stripe offset (should return error)"
1560 test_27k() { # bug 2844
1561 test_mkdir $DIR/$tdir
1562 local file=$DIR/$tdir/$tfile
1563 local ll_max_blksize=$((4 * 1024 * 1024))
1564 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1565 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1566 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1567 dd if=/dev/zero of=$file bs=4k count=1
1568 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1569 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1571 run_test 27k "limit i_blksize for broken user apps"
1574 mcreate $DIR/$tfile || error "creating file"
1575 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1576 error "setstripe should have failed" || true
1578 run_test 27l "check setstripe permissions (should return error)"
1581 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1583 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1585 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1586 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1588 trap simple_cleanup_common EXIT
1589 test_mkdir $DIR/$tdir
1590 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1591 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1592 error "dd should fill OST0"
1594 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1596 [ $i -gt 256 ] && break
1599 touch $DIR/$tdir/$tfile.$i
1600 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1601 awk '{print $1}'| grep -w "0") ] &&
1602 error "OST0 was full but new created file still use it"
1604 touch $DIR/$tdir/$tfile.$i
1605 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1606 awk '{print $1}'| grep -w "0") ] &&
1607 error "OST0 was full but new created file still use it"
1608 simple_cleanup_common
1610 run_test 27m "create file while OST0 was full"
1613 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1614 awk '{ print $1 * 2; exit; }')
1618 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1619 # if the OST isn't full anymore.
1621 local OSTIDX=${1:-""}
1623 local list=$(comma_list $(osts_nodes))
1624 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1626 do_nodes $list lctl set_param fail_loc=0
1627 sync # initiate all OST_DESTROYs from MDS to OST
1631 exhaust_precreations() {
1634 local FAILIDX=${3:-$OSTIDX}
1635 local ofacet=ost$((OSTIDX + 1))
1637 test_mkdir -p -c1 $DIR/$tdir
1638 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1639 local mfacet=mds$((mdtidx + 1))
1640 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1642 local OST=$(ostname_from_index $OSTIDX)
1645 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1646 local last_id=$(do_facet $mfacet lctl get_param -n \
1647 osc.$mdtosc_proc1.prealloc_last_id)
1648 local next_id=$(do_facet $mfacet lctl get_param -n \
1649 osc.$mdtosc_proc1.prealloc_next_id)
1651 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1652 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1654 test_mkdir -p $DIR/$tdir/${OST}
1655 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1656 #define OBD_FAIL_OST_ENOSPC 0x215
1657 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1658 echo "Creating to objid $last_id on ost $OST..."
1659 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1660 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1661 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1665 exhaust_all_precreations() {
1667 for (( i=0; i < OSTCOUNT; i++ )) ; do
1668 exhaust_precreations $i $1 -1
1673 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1675 remote_mds_nodsh && skip "remote MDS with nodsh"
1676 remote_ost_nodsh && skip "remote OST with nodsh"
1679 rm -f $DIR/$tdir/$tfile
1680 exhaust_precreations 0 0x80000215
1681 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1682 touch $DIR/$tdir/$tfile || error "touch failed"
1683 $LFS getstripe $DIR/$tdir/$tfile
1686 run_test 27n "create file with some full OSTs"
1689 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1690 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1691 remote_mds_nodsh && skip "remote MDS with nodsh"
1692 remote_ost_nodsh && skip "remote OST with nodsh"
1695 rm -f $DIR/$tdir/$tfile
1696 exhaust_all_precreations 0x215
1698 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1703 run_test 27o "create file with all full OSTs (should error)"
1706 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1707 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1708 remote_mds_nodsh && skip "remote MDS with nodsh"
1709 remote_ost_nodsh && skip "remote OST with nodsh"
1712 rm -f $DIR/$tdir/$tfile
1713 test_mkdir $DIR/$tdir
1715 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1716 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1717 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1719 exhaust_precreations 0 0x80000215
1720 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1721 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1722 $LFS getstripe $DIR/$tdir/$tfile
1726 run_test 27p "append to a truncated file with some full OSTs"
1729 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1730 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1731 remote_mds_nodsh && skip "remote MDS with nodsh"
1732 remote_ost_nodsh && skip "remote OST with nodsh"
1735 rm -f $DIR/$tdir/$tfile
1737 test_mkdir $DIR/$tdir
1738 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1739 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1740 error "truncate $DIR/$tdir/$tfile failed"
1741 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1743 exhaust_all_precreations 0x215
1745 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1746 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1750 run_test 27q "append to truncated file with all OSTs full (should error)"
1753 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1755 remote_mds_nodsh && skip "remote MDS with nodsh"
1756 remote_ost_nodsh && skip "remote OST with nodsh"
1759 rm -f $DIR/$tdir/$tfile
1760 exhaust_precreations 0 0x80000215
1762 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1766 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1768 test_27s() { # bug 10725
1769 test_mkdir $DIR/$tdir
1770 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1771 local stripe_count=0
1772 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1773 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1774 error "stripe width >= 2^32 succeeded" || true
1777 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1779 test_27t() { # bug 10864
1784 $WLFS getstripe $tfile
1787 run_test 27t "check that utils parse path correctly"
1789 test_27u() { # bug 4900
1790 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1791 remote_mds_nodsh && skip "remote MDS with nodsh"
1794 local list=$(comma_list $(mdts_nodes))
1796 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1797 do_nodes $list $LCTL set_param fail_loc=0x139
1798 test_mkdir -p $DIR/$tdir
1799 trap simple_cleanup_common EXIT
1800 createmany -o $DIR/$tdir/t- 1000
1801 do_nodes $list $LCTL set_param fail_loc=0
1803 TLOG=$TMP/$tfile.getstripe
1804 $LFS getstripe $DIR/$tdir > $TLOG
1805 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1806 unlinkmany $DIR/$tdir/t- 1000
1808 [[ $OBJS -gt 0 ]] &&
1809 error "$OBJS objects created on OST-0. See $TLOG" ||
1812 run_test 27u "skip object creation on OSC w/o objects"
1814 test_27v() { # bug 4900
1815 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1816 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1817 remote_mds_nodsh && skip "remote MDS with nodsh"
1818 remote_ost_nodsh && skip "remote OST with nodsh"
1820 exhaust_all_precreations 0x215
1823 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1825 touch $DIR/$tdir/$tfile
1826 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1828 for (( i=1; i < OSTCOUNT; i++ )); do
1829 do_facet ost$i lctl set_param fail_loc=0x705
1831 local START=`date +%s`
1832 createmany -o $DIR/$tdir/$tfile 32
1834 local FINISH=`date +%s`
1835 local TIMEOUT=`lctl get_param -n timeout`
1836 local PROCESS=$((FINISH - START))
1837 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1838 error "$FINISH - $START >= $TIMEOUT / 2"
1839 sleep $((TIMEOUT / 2 - PROCESS))
1842 run_test 27v "skip object creation on slow OST"
1844 test_27w() { # bug 10997
1845 test_mkdir $DIR/$tdir
1846 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1847 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1848 error "stripe size $size != 65536" || true
1849 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1850 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1852 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1855 [[ $OSTCOUNT -lt 2 ]] &&
1856 skip_env "skipping multiple stripe count/offset test"
1858 test_mkdir $DIR/$tdir
1859 for i in $(seq 1 $OSTCOUNT); do
1861 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1862 error "setstripe -c $i -i $offset failed"
1863 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1864 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1865 [ $count -ne $i ] && error "stripe count $count != $i" || true
1866 [ $index -ne $offset ] &&
1867 error "stripe offset $index != $offset" || true
1870 run_test 27wa "check $LFS setstripe -c -i options"
1873 remote_ost_nodsh && skip "remote OST with nodsh"
1874 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1875 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1877 OFFSET=$(($OSTCOUNT - 1))
1879 local OST=$(ostname_from_index $OSTIDX)
1881 test_mkdir $DIR/$tdir
1882 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1883 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1885 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1886 for i in $(seq 0 $OFFSET); do
1887 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1888 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1889 error "OST0 was degraded but new created file still use it"
1891 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1893 run_test 27x "create files while OST0 is degraded"
1896 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1897 remote_mds_nodsh && skip "remote MDS with nodsh"
1898 remote_ost_nodsh && skip "remote OST with nodsh"
1899 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1901 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1902 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1903 osc.$mdtosc.prealloc_last_id)
1904 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1905 osc.$mdtosc.prealloc_next_id)
1906 local fcount=$((last_id - next_id))
1907 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1908 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1910 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1911 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1912 local OST_DEACTIVE_IDX=-1
1917 for OSC in $MDS_OSCS; do
1918 OST=$(osc_to_ost $OSC)
1919 OSTIDX=$(index_from_ostuuid $OST)
1920 if [ $OST_DEACTIVE_IDX == -1 ]; then
1921 OST_DEACTIVE_IDX=$OSTIDX
1923 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1924 echo $OSC "is Deactivated:"
1925 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1929 OSTIDX=$(index_from_ostuuid $OST)
1930 test_mkdir $DIR/$tdir
1931 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1933 for OSC in $MDS_OSCS; do
1934 OST=$(osc_to_ost $OSC)
1935 OSTIDX=$(index_from_ostuuid $OST)
1936 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1937 echo $OST "is degraded:"
1938 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1939 obdfilter.$OST.degraded=1
1944 createmany -o $DIR/$tdir/$tfile $fcount
1946 for OSC in $MDS_OSCS; do
1947 OST=$(osc_to_ost $OSC)
1948 OSTIDX=$(index_from_ostuuid $OST)
1949 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1950 echo $OST "is recovered from degraded:"
1951 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1952 obdfilter.$OST.degraded=0
1954 do_facet $SINGLEMDS lctl --device %$OSC activate
1958 # all osp devices get activated, hence -1 stripe count restored
1959 local stripe_count=0
1961 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1962 # devices get activated.
1964 $LFS setstripe -c -1 $DIR/$tfile
1965 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1967 [ $stripe_count -ne $OSTCOUNT ] &&
1968 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1971 run_test 27y "create files while OST0 is degraded and the rest inactive"
1977 lmm_count=$($LFS getstripe -c $1)
1978 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
1979 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
1981 local old_ifs="$IFS"
1983 fid=($($LFS path2fid $1))
1986 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1987 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1989 # compare lmm_seq and lu_fid->f_seq
1990 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1991 # compare lmm_object_id and lu_fid->oid
1992 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1994 # check the trusted.fid attribute of the OST objects of the file
1995 local have_obdidx=false
1997 $LFS getstripe $1 | while read obdidx oid hex seq; do
1998 # skip lines up to and including "obdidx"
1999 [ -z "$obdidx" ] && break
2000 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2001 $have_obdidx || continue
2003 local ost=$((obdidx + 1))
2004 local dev=$(ostdevname $ost)
2007 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2009 seq=$(echo $seq | sed -e "s/^0x//g")
2010 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2011 oid_hex=$(echo $oid)
2013 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2015 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2019 # Don't unmount/remount the OSTs if we don't need to do that.
2020 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2021 # update too, until that use mount/ll_decode_filter_fid/mount.
2022 # Re-enable when debugfs will understand new filter_fid.
2024 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2025 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2026 $dev 2>/dev/null" | grep "parent=")
2028 if [ -z "$ff" ]; then
2030 mount_fstype ost$ost
2031 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2032 $(facet_mntpt ost$ost)/$obj_file)
2033 unmount_fstype ost$ost
2034 start ost$ost $dev $OST_MOUNT_OPTS
2038 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2040 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2042 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2043 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2045 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2046 # stripe_size=1048576 component_id=1 component_start=0 \
2047 # component_end=33554432
2048 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2049 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2050 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2052 if grep -q 'stripe=' <<<$ff; then
2053 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2055 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2056 # into f_ver in this case. See comment on ff_parent.
2057 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2060 # compare lmm_seq and filter_fid->ff_parent.f_seq
2061 [ $ff_pseq = $lmm_seq ] ||
2062 error "FF parent SEQ $ff_pseq != $lmm_seq"
2063 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2064 [ $ff_poid = $lmm_oid ] ||
2065 error "FF parent OID $ff_poid != $lmm_oid"
2066 (($ff_pstripe == $stripe_nr)) ||
2067 error "FF stripe $ff_pstripe != $stripe_nr"
2069 stripe_nr=$((stripe_nr + 1))
2070 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2072 if grep -q 'stripe_count=' <<<$ff; then
2073 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2074 -e 's/ .*//' <<<$ff)
2075 [ $lmm_count = $ff_scnt ] ||
2076 error "FF stripe count $lmm_count != $ff_scnt"
2082 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2083 remote_ost_nodsh && skip "remote OST with nodsh"
2085 test_mkdir $DIR/$tdir
2086 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2087 { error "setstripe -c -1 failed"; return 1; }
2088 # We need to send a write to every object to get parent FID info set.
2089 # This _should_ also work for setattr, but does not currently.
2090 # touch $DIR/$tdir/$tfile-1 ||
2091 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2092 { error "dd $tfile-1 failed"; return 2; }
2093 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2094 { error "setstripe -c -1 failed"; return 3; }
2095 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2096 { error "dd $tfile-2 failed"; return 4; }
2098 # make sure write RPCs have been sent to OSTs
2101 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2102 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2104 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2106 test_27A() { # b=19102
2107 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2109 save_layout_restore_at_exit $MOUNT
2110 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2111 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2112 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2113 local default_size=$($LFS getstripe -S $MOUNT)
2114 local default_offset=$($LFS getstripe -i $MOUNT)
2115 local dsize=$(do_facet $SINGLEMDS \
2116 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2117 [ $default_size -eq $dsize ] ||
2118 error "stripe size $default_size != $dsize"
2119 [ $default_offset -eq -1 ] ||
2120 error "stripe offset $default_offset != -1"
2122 run_test 27A "check filesystem-wide default LOV EA values"
2124 test_27B() { # LU-2523
2125 test_mkdir $DIR/$tdir
2126 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2128 # open f1 with O_LOV_DELAY_CREATE
2130 # call setstripe ioctl on open file descriptor for f1
2132 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2136 # open f1 with O_LOV_DELAY_CREATE
2138 # call setstripe ioctl on open file descriptor for f1
2140 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2142 # Allow multiop to fail in imitation of NFS's busted semantics.
2145 run_test 27B "call setstripe on open unlinked file/rename victim"
2147 test_27C() { #LU-2871
2148 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2156 test_mkdir $DIR/$tdir
2158 for i in $(seq 0 $((OSTCOUNT - 1))); do
2159 # set stripe across all OSTs starting from OST$i
2160 $LFS setstripe -i $i -c -1 $tfile$i
2161 # get striping information
2162 ost_idx=($($LFS getstripe $tfile$i |
2163 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2167 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2168 error "${#ost_idx[@]} != $OSTCOUNT"
2170 for index in $(seq 0 $((OSTCOUNT - 1))); do
2172 for j in $(echo ${ost_idx[@]}); do
2173 if [ $index -eq $j ]; then
2179 error "Can not find $index in ${ost_idx[@]}"
2183 run_test 27C "check full striping across all OSTs"
2186 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2187 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2188 remote_mds_nodsh && skip "remote MDS with nodsh"
2190 local POOL=${POOL:-testpool}
2192 local last_ost=$(($OSTCOUNT - 1))
2194 local ost_list=$(seq $first_ost $ost_step $last_ost)
2195 local ost_range="$first_ost $last_ost $ost_step"
2197 if ! combined_mgs_mds ; then
2201 test_mkdir $DIR/$tdir
2202 pool_add $POOL || error "pool_add failed"
2203 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2206 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2208 [ $MDS1_VERSION -lt $(version_code 2.9.55) -o \
2209 $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2210 skip27D+=" -s 30,31"
2211 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2212 error "llapi_layout_test failed"
2214 destroy_test_pools || error "destroy test pools failed"
2216 if ! combined_mgs_mds ; then
2220 run_test 27D "validate llapi_layout API"
2222 # Verify that default_easize is increased from its initial value after
2223 # accessing a widely striped file.
2225 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2226 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2227 skip "client does not have LU-3338 fix"
2229 # 72 bytes is the minimum space required to store striping
2230 # information for a file striped across one OST:
2231 # (sizeof(struct lov_user_md_v3) +
2232 # sizeof(struct lov_user_ost_data_v1))
2234 $LCTL set_param -n llite.*.default_easize $min_easize ||
2235 error "lctl set_param failed"
2236 local easize=$($LCTL get_param -n llite.*.default_easize)
2238 [ $easize -eq $min_easize ] ||
2239 error "failed to set default_easize"
2241 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2242 error "setstripe failed"
2246 easize=$($LCTL get_param -n llite.*.default_easize)
2248 [ $easize -gt $min_easize ] ||
2249 error "default_easize not updated"
2251 run_test 27E "check that default extended attribute size properly increases"
2253 test_27F() { # LU-5346/LU-7975
2254 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2255 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2256 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2257 skip "Need MDS version at least 2.8.51"
2258 remote_ost_nodsh && skip "remote OST with nodsh"
2260 test_mkdir $DIR/$tdir
2262 $LFS setstripe -c 2 $DIR/$tdir
2264 # stop all OSTs to reproduce situation for LU-7975 ticket
2265 for num in $(seq $OSTCOUNT); do
2269 # open/create f0 with O_LOV_DELAY_CREATE
2270 # truncate f0 to a non-0 size
2272 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2274 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2275 # open/write it again to force delayed layout creation
2276 cat /etc/hosts > $DIR/$tdir/f0 &
2280 for num in $(seq $OSTCOUNT); do
2281 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2282 error "ost$num failed to start"
2285 wait $catpid || error "cat failed"
2287 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2288 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2289 error "wrong stripecount"
2292 run_test 27F "Client resend delayed layout creation with non-zero size"
2294 test_27G() { #LU-10629
2295 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2296 skip "Need MDS version at least 2.11.51"
2297 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2298 remote_mds_nodsh && skip "remote MDS with nodsh"
2299 local POOL=${POOL:-testpool}
2300 local ostrange="0 0 1"
2302 test_mkdir $DIR/$tdir
2303 pool_add $POOL || error "pool_add failed"
2304 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2305 $LFS setstripe -p $POOL $DIR/$tdir
2307 local pool=$($LFS getstripe -p $DIR/$tdir)
2309 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2311 $LFS setstripe -d $DIR/$tdir
2313 pool=$($LFS getstripe -p $DIR/$tdir)
2317 [ -z "$pool" ] || error "'$pool' is not empty"
2319 run_test 27G "Clear OST pool from stripe"
2322 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2323 skip "Need MDS version newer than 2.11.54"
2324 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2325 test_mkdir $DIR/$tdir
2326 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2327 touch $DIR/$tdir/$tfile
2328 $LFS getstripe -c $DIR/$tdir/$tfile
2329 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2330 error "two-stripe file doesn't have two stripes"
2332 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2333 $LFS getstripe -y $DIR/$tdir/$tfile
2334 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2335 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2336 error "expected l_ost_idx: [02]$ not matched"
2338 # make sure ost list has been cleared
2339 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2340 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2341 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2343 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2345 run_test 27H "Set specific OSTs stripe"
2347 # createtest also checks that device nodes are created and
2348 # then visible correctly (#2091)
2349 test_28() { # bug 2091
2351 $CREATETEST $DIR/d28/ct || error "createtest failed"
2353 run_test 28 "create/mknod/mkdir with bad file types ============"
2356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2358 sync; sleep 1; sync # flush out any dirty pages from previous tests
2365 declare -i LOCKCOUNTORIG=0
2366 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2367 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2369 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2371 declare -i LOCKUNUSEDCOUNTORIG=0
2372 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2373 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2380 declare -i LOCKCOUNTCURRENT=0
2381 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2382 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2385 declare -i LOCKUNUSEDCOUNTCURRENT=0
2386 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2387 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2390 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2391 $LCTL set_param -n ldlm.dump_namespaces ""
2392 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2393 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2394 log "dumped log to $TMP/test_29.dk (bug 5793)"
2397 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2398 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2399 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2400 log "dumped log to $TMP/test_29.dk (bug 5793)"
2404 run_test 29 "IT_GETATTR regression ============================"
2406 test_30a() { # was test_30
2407 cp $(which ls) $DIR || cp /bin/ls $DIR
2408 $DIR/ls / || error "Can't execute binary from lustre"
2411 run_test 30a "execute binary from Lustre (execve) =============="
2414 cp `which ls` $DIR || cp /bin/ls $DIR
2416 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2419 run_test 30b "execute binary from Lustre as non-root ==========="
2421 test_30c() { # b=22376
2422 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2424 cp `which ls` $DIR || cp /bin/ls $DIR
2426 cancel_lru_locks mdc
2427 cancel_lru_locks osc
2428 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2431 run_test 30c "execute binary from Lustre without read perms ===="
2434 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2435 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2437 run_test 31a "open-unlink file =================================="
2440 touch $DIR/f31 || error "touch $DIR/f31 failed"
2441 ln $DIR/f31 $DIR/f31b || error "ln failed"
2442 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2443 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2445 run_test 31b "unlink file with multiple links while open ======="
2448 touch $DIR/f31 || error "touch $DIR/f31 failed"
2449 ln $DIR/f31 $DIR/f31c || error "ln failed"
2450 multiop_bg_pause $DIR/f31 O_uc ||
2451 error "multiop_bg_pause for $DIR/f31 failed"
2453 $MULTIOP $DIR/f31c Ouc
2454 kill -USR1 $MULTIPID
2457 run_test 31c "open-unlink file with multiple links ============="
2460 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2461 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2463 run_test 31d "remove of open directory ========================="
2465 test_31e() { # bug 2904
2466 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2468 run_test 31e "remove of open non-empty directory ==============="
2470 test_31f() { # bug 4554
2471 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2474 test_mkdir $DIR/d31f
2475 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
2476 cp /etc/hosts $DIR/d31f
2478 $LFS getstripe $DIR/d31f/hosts
2479 multiop_bg_pause $DIR/d31f D_c || return 1
2482 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2483 test_mkdir $DIR/d31f
2484 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
2485 cp /etc/hosts $DIR/d31f
2487 $LFS getstripe $DIR/d31f/hosts
2488 multiop_bg_pause $DIR/d31f D_c || return 1
2491 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2492 wait $MULTIPID || error "first opendir $MULTIPID failed"
2496 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2497 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2500 run_test 31f "remove of open directory with open-unlink file ==="
2503 echo "-- cross directory link --"
2504 test_mkdir -c1 $DIR/${tdir}ga
2505 test_mkdir -c1 $DIR/${tdir}gb
2506 touch $DIR/${tdir}ga/f
2507 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2508 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2509 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2510 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2511 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2513 run_test 31g "cross directory link==============="
2516 echo "-- cross directory link --"
2517 test_mkdir -c1 $DIR/${tdir}
2518 test_mkdir -c1 $DIR/${tdir}/dir
2519 touch $DIR/${tdir}/f
2520 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2521 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2522 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2523 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2524 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2526 run_test 31h "cross directory link under child==============="
2529 echo "-- cross directory link --"
2530 test_mkdir -c1 $DIR/$tdir
2531 test_mkdir -c1 $DIR/$tdir/dir
2532 touch $DIR/$tdir/dir/f
2533 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2534 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2535 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2536 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2537 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2539 run_test 31i "cross directory link under parent==============="
2542 test_mkdir -c1 -p $DIR/$tdir
2543 test_mkdir -c1 -p $DIR/$tdir/dir1
2544 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2545 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2546 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2547 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2550 run_test 31j "link for directory==============="
2553 test_mkdir -c1 -p $DIR/$tdir
2555 touch $DIR/$tdir/exist
2556 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2557 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2558 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2559 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2560 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2561 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2562 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2565 run_test 31k "link to file: the same, non-existing, dir==============="
2571 touch $DIR/d31m2/exist
2572 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2573 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2574 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2575 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2576 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2577 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2580 run_test 31m "link to file: the same, non-existing, dir==============="
2583 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2584 nlink=$(stat --format=%h $DIR/$tfile)
2585 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2587 local cmd="exec $fd<$DIR/$tfile"
2590 trap "eval $cmd" EXIT
2591 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2592 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2593 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2594 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2595 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2598 run_test 31n "check link count of unlinked file"
2601 local TEMPNAME=$(mktemp $1_XXXXXX)
2602 mlink $TEMPNAME $1 2> /dev/null &&
2603 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2607 test_31o() { # LU-2901
2608 test_mkdir $DIR/$tdir
2609 for LOOP in $(seq 100); do
2610 rm -f $DIR/$tdir/$tfile*
2611 for THREAD in $(seq 8); do
2612 link_one $DIR/$tdir/$tfile.$LOOP &
2615 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2616 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2617 error "$LINKS duplicate links to $tfile.$LOOP" &&
2621 run_test 31o "duplicate hard links with same filename"
2624 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2626 test_mkdir $DIR/$tdir
2627 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2628 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2630 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2631 error "open unlink test1 failed"
2632 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2633 error "open unlink test2 failed"
2635 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2636 error "test1 still exists"
2637 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2638 error "test2 still exists"
2640 run_test 31p "remove of open striped directory"
2642 cleanup_test32_mount() {
2645 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2646 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2647 losetup -d $loopdev || true
2653 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2655 echo "== more mountpoints and symlinks ================="
2656 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2657 trap cleanup_test32_mount EXIT
2658 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2659 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2660 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2661 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2662 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2663 cleanup_test32_mount
2665 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2668 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2670 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2671 trap cleanup_test32_mount EXIT
2672 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2673 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2674 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2675 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2676 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2677 cleanup_test32_mount
2679 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2682 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2684 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2685 trap cleanup_test32_mount EXIT
2686 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2687 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2688 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2689 test_mkdir -p $DIR/$tdir/d2/test_dir
2690 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2691 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2692 cleanup_test32_mount
2694 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2697 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2699 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2700 trap cleanup_test32_mount EXIT
2701 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2702 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2703 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2704 test_mkdir -p $DIR/$tdir/d2/test_dir
2705 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2706 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2707 cleanup_test32_mount
2709 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2713 test_mkdir -p $DIR/$tdir/tmp
2714 local tmp_dir=$DIR/$tdir/tmp
2715 ln -s $DIR/$tdir $tmp_dir/symlink11
2716 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2717 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2718 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2720 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2724 test_mkdir -p $DIR/$tdir/tmp
2725 local tmp_dir=$DIR/$tdir/tmp
2726 ln -s $DIR/$tdir $tmp_dir/symlink11
2727 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2728 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2729 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2731 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2734 local tmp_dir=$DIR/$tdir/tmp
2735 test_mkdir -p $tmp_dir
2736 test_mkdir $DIR/${tdir}2
2737 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2738 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2739 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2740 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2741 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2742 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2744 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2747 rm -fr $DIR/$tdir $DIR/${tdir}2
2748 tmp_dir=$DIR/$tdir/tmp
2749 test_mkdir -p $tmp_dir
2750 test_mkdir $DIR/${tdir}2
2751 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2752 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2753 ls $tmp_dir/symlink12 || error "listing symlink12"
2754 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2756 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2759 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2761 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2762 trap cleanup_test32_mount EXIT
2763 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2764 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2765 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2766 touch $DIR/$tdir/test_file
2767 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2768 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2769 cleanup_test32_mount
2771 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2774 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2776 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2777 trap cleanup_test32_mount EXIT
2778 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2779 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2780 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2781 touch $DIR/$tdir/test_file
2782 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2783 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2784 cleanup_test32_mount
2786 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2789 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2792 trap cleanup_test32_mount EXIT
2793 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2794 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2795 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2796 test_mkdir -p $DIR/$tdir/d2
2797 touch $DIR/$tdir/d2/test_file || error "touch failed"
2798 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2799 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
2800 cleanup_test32_mount
2802 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2805 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2808 trap cleanup_test32_mount EXIT
2809 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2810 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2811 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2812 test_mkdir -p $DIR/$tdir/d2
2813 touch $DIR/$tdir/d2/test_file || error "touch failed"
2814 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2815 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
2816 cleanup_test32_mount
2818 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2822 test_mkdir -p $DIR/d32m/tmp
2823 TMP_DIR=$DIR/d32m/tmp
2824 ln -s $DIR $TMP_DIR/symlink11
2825 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2826 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
2827 error "symlink11 not a link"
2828 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
2829 error "symlink01 not a link"
2831 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2835 test_mkdir -p $DIR/d32n/tmp
2836 TMP_DIR=$DIR/d32n/tmp
2837 ln -s $DIR $TMP_DIR/symlink11
2838 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2839 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
2840 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
2842 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2846 test_mkdir -p $DIR/d32o/tmp
2847 TMP_DIR=$DIR/d32o/tmp
2848 ln -s $DIR/$tfile $TMP_DIR/symlink12
2849 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2850 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
2851 error "symlink12 not a link"
2852 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
2853 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
2854 error "$DIR/d32o/tmp/symlink12 not file type"
2855 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
2856 error "$DIR/d32o/symlink02 not file type"
2858 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2868 test_mkdir -p $DIR/d32p/tmp
2870 TMP_DIR=$DIR/d32p/tmp
2872 ln -s $DIR/$tfile $TMP_DIR/symlink12
2874 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2876 cat $DIR/d32p/tmp/symlink12 ||
2877 error "Can't open $DIR/d32p/tmp/symlink12"
2879 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
2882 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2885 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2887 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2888 trap cleanup_test32_mount EXIT
2889 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2890 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2891 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2892 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2893 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2894 cleanup_test32_mount
2896 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2899 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2901 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2902 trap cleanup_test32_mount EXIT
2903 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2904 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2905 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2906 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2907 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2908 cleanup_test32_mount
2910 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2915 chmod 444 $DIR/$tfile
2916 chown $RUNAS_ID $DIR/$tfile
2918 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2921 run_test 33aa "write file with mode 444 (should return error)"
2925 test_mkdir $DIR/$tdir
2926 chown $RUNAS_ID $DIR/$tdir
2927 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2928 error "$RUNAS create $tdir/$tfile failed"
2929 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2930 error "open RDWR" || true
2932 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2936 test_mkdir $DIR/$tdir
2937 chown $RUNAS_ID $DIR/$tdir
2938 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2940 run_test 33b "test open file with malformed flags (No panic)"
2943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2944 remote_ost_nodsh && skip "remote OST with nodsh"
2953 test_mkdir $DIR/$tdir
2954 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2957 for ostnum in $(seq $OSTCOUNT); do
2958 # test-framework's OST numbering is one-based, while Lustre's
2960 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2961 # Parsing llobdstat's output sucks; we could grep the /proc
2962 # path, but that's likely to not be as portable as using the
2963 # llobdstat utility. So we parse lctl output instead.
2964 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2965 obdfilter/$ostname/stats |
2966 awk '/^write_bytes/ {print $7}' )
2967 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2968 if (( ${write_bytes:-0} > 0 ))
2975 $all_zeros || return 0
2978 echo foo > $DIR/$tdir/bar
2982 # Total up write_bytes after writing. We'd better find non-zeros.
2983 for ostnum in $(seq $OSTCOUNT); do
2984 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2985 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2986 obdfilter/$ostname/stats |
2987 awk '/^write_bytes/ {print $7}' )
2988 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2989 if (( ${write_bytes:-0} > 0 ))
2998 for ostnum in $(seq $OSTCOUNT); do
2999 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3000 echo "Check that write_bytes is present in obdfilter/*/stats:"
3001 do_facet ost$ostnum lctl get_param -n \
3002 obdfilter/$ostname/stats
3004 error "OST not keeping write_bytes stats (b22312)"
3007 run_test 33c "test llobdstat and write_bytes"
3010 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3011 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3014 local remote_dir=$DIR/$tdir/remote_dir
3016 test_mkdir $DIR/$tdir
3017 $LFS mkdir -i $MDTIDX $remote_dir ||
3018 error "create remote directory failed"
3020 touch $remote_dir/$tfile
3021 chmod 444 $remote_dir/$tfile
3022 chown $RUNAS_ID $remote_dir/$tfile
3024 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3026 chown $RUNAS_ID $remote_dir
3027 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3028 error "create" || true
3029 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3030 error "open RDWR" || true
3031 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3033 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3036 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3040 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3041 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3042 mkdir $DIR/$tdir/local_dir
3044 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3045 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3046 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3048 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3049 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3051 rmdir $DIR/$tdir/* || error "rmdir failed"
3054 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3055 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3056 mkdir $DIR/$tdir/local_dir
3058 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3059 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3060 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3062 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3063 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3065 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3068 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3069 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3070 mkdir $DIR/$tdir/local_dir
3072 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3073 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3074 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3076 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3077 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3079 run_test 33e "mkdir and striped directory should have same mode"
3083 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3087 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3088 remote_mds_nodsh && skip "remote MDS with nodsh"
3091 chmod go+rwx $DIR/$tdir
3092 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3093 trap cleanup_33f EXIT
3095 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3096 error "cannot create striped directory"
3098 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3099 error "cannot create files in striped directory"
3101 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3102 error "cannot remove files in striped directory"
3104 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3105 error "cannot remove striped directory"
3109 run_test 33f "nonroot user can create, access, and remove a striped directory"
3112 mkdir -p $DIR/$tdir/dir2
3114 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3116 [[ $err =~ "exists" ]] || error "Not exists error"
3118 run_test 33g "nonroot user create already existing root created file"
3120 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3123 $MCREATE $DIR/f34 || error "mcreate failed"
3124 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3125 error "getstripe failed"
3126 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3127 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3128 error "getstripe failed"
3129 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3130 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3132 run_test 34a "truncate file that has not been opened ==========="
3135 [ ! -f $DIR/f34 ] && test_34a
3136 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3137 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3138 $OPENFILE -f O_RDONLY $DIR/f34
3139 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3140 error "getstripe failed"
3141 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3142 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3144 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3147 [ ! -f $DIR/f34 ] && test_34a
3148 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3149 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3150 $OPENFILE -f O_RDWR $DIR/f34
3151 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3152 error "$LFS getstripe failed"
3153 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3154 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3156 run_test 34c "O_RDWR opening file-with-size works =============="
3159 [ ! -f $DIR/f34 ] && test_34a
3160 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3162 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3163 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3166 run_test 34d "write to sparse file ============================="
3170 $MCREATE $DIR/f34e || error "mcreate failed"
3171 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3172 $CHECKSTAT -s 1000 $DIR/f34e ||
3173 error "Size of $DIR/f34e not equal to 1000 bytes"
3174 $OPENFILE -f O_RDWR $DIR/f34e
3175 $CHECKSTAT -s 1000 $DIR/f34e ||
3176 error "Size of $DIR/f34e not equal to 1000 bytes"
3178 run_test 34e "create objects, some with size and some without =="
3180 test_34f() { # bug 6242, 6243
3181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3185 $MCREATE $DIR/f34f || error "mcreate failed"
3186 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3187 dd if=$DIR/f34f of=$TMP/f34f
3188 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3189 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3190 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3191 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3192 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3194 run_test 34f "read from a file with no objects until EOF ======="
3197 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3199 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3201 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3202 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3203 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3204 cancel_lru_locks osc
3205 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3206 error "wrong size after lock cancel"
3208 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3209 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3210 error "expanding truncate failed"
3211 cancel_lru_locks osc
3212 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3213 error "wrong expanded size after lock cancel"
3215 run_test 34g "truncate long file ==============================="
3218 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3223 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3224 sync # Flush the cache so that multiop below does not block on cache
3225 # flush when getting the group lock
3226 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3229 # Since just timed wait is not good enough, let's do a sync write
3230 # that way we are sure enough time for a roundtrip + processing
3231 # passed + 2 seconds of extra margin.
3232 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3236 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3237 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3241 local nsz=`stat -c %s $DIR/$tfile`
3242 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3244 run_test 34h "ftruncate file under grouplock should not block"
3247 cp /bin/sh $DIR/f35a
3249 chown $RUNAS_ID $DIR/f35a
3250 $RUNAS $DIR/f35a && error || true
3253 run_test 35a "exec file with mode 444 (should return and not leak)"
3257 utime $DIR/f36 || error "utime failed for MDS"
3259 run_test 36a "MDS utime check (mknod, utime)"
3263 utime $DIR/f36 || error "utime failed for OST"
3265 run_test 36b "OST utime check (open, utime)"
3270 chown $RUNAS_ID $DIR/d36
3271 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3273 run_test 36c "non-root MDS utime check (mknod, utime)"
3276 [ ! -d $DIR/d36 ] && test_36c
3277 echo "" > $DIR/d36/f36
3278 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3280 run_test 36d "non-root OST utime check (open, utime)"
3283 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3285 test_mkdir $DIR/$tdir
3286 touch $DIR/$tdir/$tfile
3287 $RUNAS utime $DIR/$tdir/$tfile &&
3288 error "utime worked, expected failure" || true
3290 run_test 36e "utime on non-owned file (should return error)"
3294 local LANG_SAVE=$LANG
3295 local LC_LANG_SAVE=$LC_LANG
3296 export LANG=C LC_LANG=C # for date language
3298 DATESTR="Dec 20 2000"
3299 test_mkdir $DIR/$tdir
3300 lctl set_param fail_loc=$fl
3302 cp /etc/hosts $DIR/$tdir/$tfile
3303 sync & # write RPC generated with "current" inode timestamp, but delayed
3305 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3306 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3307 cancel_lru_locks $OSC
3308 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3310 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3311 echo "BEFORE: $LS_BEFORE" && \
3312 echo "AFTER : $LS_AFTER" && \
3313 echo "WANT : $DATESTR" && \
3314 error "$DIR/$tdir/$tfile timestamps changed" || true
3316 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3320 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3322 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3323 subr_36fh "0x80000214"
3325 run_test 36f "utime on file racing with OST BRW write =========="
3328 remote_ost_nodsh && skip "remote OST with nodsh"
3329 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3330 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
3331 skip "Need MDS version at least 2.12.51"
3336 local tgt="obdfilter"
3338 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
3340 test_mkdir $DIR/$tdir
3341 fmd_max_age=$(do_facet $facet \
3342 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
3345 echo "FMD max age: ${fmd_max_age}s"
3346 touch $DIR/$tdir/$tfile
3347 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3348 gawk '{cnt=cnt+$1} END{print cnt}')
3349 echo "FMD before: $fmd"
3351 error "FMD wasn't create by touch"
3352 sleep $((fmd_max_age + 12))
3353 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3354 gawk '{cnt=cnt+$1} END{print cnt}')
3355 echo "FMD after: $fmd"
3357 error "FMD wasn't expired by ping"
3359 run_test 36g "FMD cache expiry ====================="
3362 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3364 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3365 subr_36fh "0x80000227"
3367 run_test 36h "utime on file racing with OST BRW write =========="
3370 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3372 test_mkdir $DIR/$tdir
3373 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3375 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3376 local new_mtime=$((mtime + 200))
3378 #change Modify time of striped dir
3379 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3380 error "change mtime failed"
3382 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3384 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3386 run_test 36i "change mtime on striped directory"
3388 # test_37 - duplicate with tests 32q 32r
3391 local file=$DIR/$tfile
3393 openfile -f O_DIRECTORY $file
3396 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3397 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3399 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3401 test_39a() { # was test_39
3403 touch $DIR/${tfile}2
3404 # ls -l $DIR/$tfile $DIR/${tfile}2
3405 # ls -lu $DIR/$tfile $DIR/${tfile}2
3406 # ls -lc $DIR/$tfile $DIR/${tfile}2
3408 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3409 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3411 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3413 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3415 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3416 error "O_TRUNC didn't change timestamps"
3419 run_test 39a "mtime changed on create"
3422 test_mkdir -c1 $DIR/$tdir
3423 cp -p /etc/passwd $DIR/$tdir/fopen
3424 cp -p /etc/passwd $DIR/$tdir/flink
3425 cp -p /etc/passwd $DIR/$tdir/funlink
3426 cp -p /etc/passwd $DIR/$tdir/frename
3427 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3430 echo "aaaaaa" >> $DIR/$tdir/fopen
3431 echo "aaaaaa" >> $DIR/$tdir/flink
3432 echo "aaaaaa" >> $DIR/$tdir/funlink
3433 echo "aaaaaa" >> $DIR/$tdir/frename
3435 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3436 local link_new=`stat -c %Y $DIR/$tdir/flink`
3437 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3438 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3440 cat $DIR/$tdir/fopen > /dev/null
3441 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3442 rm -f $DIR/$tdir/funlink2
3443 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3445 for (( i=0; i < 2; i++ )) ; do
3446 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3447 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3448 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3449 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3451 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3452 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3453 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3454 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3456 cancel_lru_locks $OSC
3457 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3460 run_test 39b "mtime change on open, link, unlink, rename ======"
3462 # this should be set to past
3463 TEST_39_MTIME=`date -d "1 year ago" +%s`
3469 local mtime0=`stat -c %Y $DIR1/$tfile`
3471 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3472 local mtime1=`stat -c %Y $DIR1/$tfile`
3473 [ "$mtime1" = $TEST_39_MTIME ] || \
3474 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3477 echo hello >> $DIR1/$tfile
3479 local mtime2=`stat -c %Y $DIR1/$tfile`
3480 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3481 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3483 mv $DIR1/$tfile $DIR1/$tfile-1
3485 for (( i=0; i < 2; i++ )) ; do
3486 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3487 [ "$mtime2" = "$mtime3" ] || \
3488 error "mtime ($mtime2) changed (to $mtime3) on rename"
3490 cancel_lru_locks $OSC
3491 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3494 run_test 39c "mtime change on rename ==========================="
3498 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3501 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3503 for (( i=0; i < 2; i++ )) ; do
3504 local mtime=`stat -c %Y $DIR1/$tfile`
3505 [ $mtime = $TEST_39_MTIME ] || \
3506 error "mtime($mtime) is not set to $TEST_39_MTIME"
3508 cancel_lru_locks $OSC
3509 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3512 run_test 39d "create, utime, stat =============================="
3516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3519 local mtime1=`stat -c %Y $DIR1/$tfile`
3521 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3523 for (( i=0; i < 2; i++ )) ; do
3524 local mtime2=`stat -c %Y $DIR1/$tfile`
3525 [ $mtime2 = $TEST_39_MTIME ] || \
3526 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3528 cancel_lru_locks $OSC
3529 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3532 run_test 39e "create, stat, utime, stat ========================"
3536 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3539 mtime1=`stat -c %Y $DIR1/$tfile`
3542 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3544 for (( i=0; i < 2; i++ )) ; do
3545 local mtime2=`stat -c %Y $DIR1/$tfile`
3546 [ $mtime2 = $TEST_39_MTIME ] || \
3547 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3549 cancel_lru_locks $OSC
3550 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3553 run_test 39f "create, stat, sleep, utime, stat ================="
3557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3559 echo hello >> $DIR1/$tfile
3560 local mtime1=`stat -c %Y $DIR1/$tfile`
3563 chmod o+r $DIR1/$tfile
3565 for (( i=0; i < 2; i++ )) ; do
3566 local mtime2=`stat -c %Y $DIR1/$tfile`
3567 [ "$mtime1" = "$mtime2" ] || \
3568 error "lost mtime: $mtime2, should be $mtime1"
3570 cancel_lru_locks $OSC
3571 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3574 run_test 39g "write, chmod, stat ==============================="
3578 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3584 echo hello >> $DIR1/$tfile
3585 local mtime1=`stat -c %Y $DIR1/$tfile`
3587 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3589 if [ "$d1" != "$d2" ]; then
3590 echo "write and touch not within one second"
3592 for (( i=0; i < 2; i++ )) ; do
3593 local mtime2=`stat -c %Y $DIR1/$tfile`
3594 [ "$mtime2" = $TEST_39_MTIME ] || \
3595 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3597 cancel_lru_locks $OSC
3598 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3602 run_test 39h "write, utime within one second, stat ============="
3605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3610 echo hello >> $DIR1/$tfile
3611 local mtime1=`stat -c %Y $DIR1/$tfile`
3613 mv $DIR1/$tfile $DIR1/$tfile-1
3615 for (( i=0; i < 2; i++ )) ; do
3616 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3618 [ "$mtime1" = "$mtime2" ] || \
3619 error "lost mtime: $mtime2, should be $mtime1"
3621 cancel_lru_locks $OSC
3622 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3625 run_test 39i "write, rename, stat =============================="
3628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3630 start_full_debug_logging
3634 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3635 lctl set_param fail_loc=0x80000412
3636 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3637 error "multiop failed"
3639 local mtime1=`stat -c %Y $DIR1/$tfile`
3641 mv $DIR1/$tfile $DIR1/$tfile-1
3643 kill -USR1 $multipid
3644 wait $multipid || error "multiop close failed"
3646 for (( i=0; i < 2; i++ )) ; do
3647 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3648 [ "$mtime1" = "$mtime2" ] ||
3649 error "mtime is lost on close: $mtime2, " \
3652 cancel_lru_locks $OSC
3653 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3655 lctl set_param fail_loc=0
3656 stop_full_debug_logging
3658 run_test 39j "write, rename, close, stat ======================="
3661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3666 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3668 local mtime1=`stat -c %Y $DIR1/$tfile`
3670 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3672 kill -USR1 $multipid
3673 wait $multipid || error "multiop close failed"
3675 for (( i=0; i < 2; i++ )) ; do
3676 local mtime2=`stat -c %Y $DIR1/$tfile`
3678 [ "$mtime2" = $TEST_39_MTIME ] || \
3679 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3681 cancel_lru_locks osc
3682 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3685 run_test 39k "write, utime, close, stat ========================"
3687 # this should be set to future
3688 TEST_39_ATIME=`date -d "1 year" +%s`
3691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3692 remote_mds_nodsh && skip "remote MDS with nodsh"
3694 local atime_diff=$(do_facet $SINGLEMDS \
3695 lctl get_param -n mdd.*MDT0000*.atime_diff)
3699 # test setting directory atime to future
3700 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3701 local atime=$(stat -c %X $DIR/$tdir)
3702 [ "$atime" = $TEST_39_ATIME ] ||
3703 error "atime is not set to future: $atime, $TEST_39_ATIME"
3705 # test setting directory atime from future to now
3706 local now=$(date +%s)
3707 touch -a -d @$now $DIR/$tdir
3709 atime=$(stat -c %X $DIR/$tdir)
3710 [ "$atime" -eq "$now" ] ||
3711 error "atime is not updated from future: $atime, $now"
3713 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3716 # test setting directory atime when now > dir atime + atime_diff
3717 local d1=$(date +%s)
3719 local d2=$(date +%s)
3720 cancel_lru_locks mdc
3721 atime=$(stat -c %X $DIR/$tdir)
3722 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3723 error "atime is not updated : $atime, should be $d2"
3725 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3728 # test not setting directory atime when now < dir atime + atime_diff
3730 cancel_lru_locks mdc
3731 atime=$(stat -c %X $DIR/$tdir)
3732 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3733 error "atime is updated to $atime, should remain $d1<atime<$d2"
3735 do_facet $SINGLEMDS \
3736 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3738 run_test 39l "directory atime update ==========================="
3741 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3745 local far_past_mtime=$(date -d "May 29 1953" +%s)
3746 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3748 touch -m -d @$far_past_mtime $DIR1/$tfile
3749 touch -a -d @$far_past_atime $DIR1/$tfile
3751 for (( i=0; i < 2; i++ )) ; do
3752 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3753 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3754 error "atime or mtime set incorrectly"
3756 cancel_lru_locks $OSC
3757 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3760 run_test 39m "test atime and mtime before 1970"
3762 test_39n() { # LU-3832
3763 remote_mds_nodsh && skip "remote MDS with nodsh"
3765 local atime_diff=$(do_facet $SINGLEMDS \
3766 lctl get_param -n mdd.*MDT0000*.atime_diff)
3771 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3774 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3775 atime0=$(stat -c %X $DIR/$tfile)
3778 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3779 atime1=$(stat -c %X $DIR/$tfile)
3782 cancel_lru_locks mdc
3783 cancel_lru_locks osc
3784 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3785 atime2=$(stat -c %X $DIR/$tfile)
3787 do_facet $SINGLEMDS \
3788 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3790 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3791 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3793 run_test 39n "check that O_NOATIME is honored"
3796 TESTDIR=$DIR/$tdir/$tfile
3797 [ -e $TESTDIR ] && rm -rf $TESTDIR
3804 links2=$(stat -c %h .)
3805 [ $(($links1 + 2)) != $links2 ] &&
3806 error "wrong links count $(($links1 + 2)) != $links2"
3808 links3=$(stat -c %h .)
3809 [ $(($links1 + 1)) != $links3 ] &&
3810 error "wrong links count $links1 != $links3"
3813 run_test 39o "directory cached attributes updated after create"
3816 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3819 TESTDIR=$DIR/$tdir/$tdir
3820 [ -e $TESTDIR ] && rm -rf $TESTDIR
3821 test_mkdir -p $TESTDIR
3825 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3826 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3828 links2=$(stat -c %h .)
3829 [ $(($links1 + 2)) != $links2 ] &&
3830 error "wrong links count $(($links1 + 2)) != $links2"
3832 links3=$(stat -c %h .)
3833 [ $(($links1 + 1)) != $links3 ] &&
3834 error "wrong links count $links1 != $links3"
3837 run_test 39p "remote directory cached attributes updated after create ========"
3840 test_39q() { # LU-8041
3841 local testdir=$DIR/$tdir
3843 multiop_bg_pause $testdir D_c || error "multiop failed"
3845 cancel_lru_locks mdc
3846 kill -USR1 $multipid
3847 local atime=$(stat -c %X $testdir)
3848 [ "$atime" -ne 0 ] || error "atime is zero"
3850 run_test 39q "close won't zero out atime"
3853 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3854 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3855 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3856 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3857 error "$tfile is not 4096 bytes in size"
3859 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3863 small_write $DIR/f41 18
3865 run_test 41 "test small file write + fstat ====================="
3867 count_ost_writes() {
3868 lctl get_param -n ${OSC}.*.stats |
3869 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3870 END { printf("%0.0f", writes) }'
3877 BG_DIRTY_RATIO_SAVE=10
3878 MAX_BG_DIRTY_RATIO=25
3882 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3883 # dirty_ratio, dirty_background_ratio
3884 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3885 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3886 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3887 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3889 # if file not here, we are a 2.4 kernel
3890 kill -CONT `pidof kupdated`
3895 # setup the trap first, so someone cannot exit the test at the
3896 # exact wrong time and mess up a machine
3897 trap start_writeback EXIT
3898 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3899 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3900 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3901 sysctl -w vm.dirty_writeback_centisecs=0
3902 sysctl -w vm.dirty_writeback_centisecs=0
3903 # save and increase /proc/sys/vm/dirty_ratio
3904 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3905 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3906 # save and increase /proc/sys/vm/dirty_background_ratio
3907 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3908 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3910 # if file not here, we are a 2.4 kernel
3911 kill -STOP `pidof kupdated`
3915 # ensure that all stripes have some grant before we test client-side cache
3917 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3918 dd if=/dev/zero of=$i bs=4k count=1
3923 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3924 # file truncation, and file removal.
3926 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3929 cancel_lru_locks $OSC
3931 sync; sleep 1; sync # just to be safe
3932 BEFOREWRITES=`count_ost_writes`
3933 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3934 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3935 AFTERWRITES=`count_ost_writes`
3936 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3937 error "$BEFOREWRITES < $AFTERWRITES"
3940 run_test 42a "ensure that we don't flush on close"
3943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3946 cancel_lru_locks $OSC
3949 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3950 BEFOREWRITES=$(count_ost_writes)
3951 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3952 AFTERWRITES=$(count_ost_writes)
3953 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3954 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3956 BEFOREWRITES=$(count_ost_writes)
3957 sync || error "sync: $?"
3958 AFTERWRITES=$(count_ost_writes)
3959 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3960 error "$BEFOREWRITES < $AFTERWRITES on sync"
3962 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3966 run_test 42b "test destroy of file with cached dirty data ======"
3968 # if these tests just want to test the effect of truncation,
3969 # they have to be very careful. consider:
3970 # - the first open gets a {0,EOF}PR lock
3971 # - the first write conflicts and gets a {0, count-1}PW
3972 # - the rest of the writes are under {count,EOF}PW
3973 # - the open for truncate tries to match a {0,EOF}PR
3974 # for the filesize and cancels the PWs.
3975 # any number of fixes (don't get {0,EOF} on open, match
3976 # composite locks, do smarter file size management) fix
3977 # this, but for now we want these tests to verify that
3978 # the cancellation with truncate intent works, so we
3979 # start the file with a full-file pw lock to match against
3980 # until the truncate.
3985 cancel_lru_locks $OSC
3987 # prime the file with 0,EOF PW to match
3991 # now the real test..
3992 dd if=/dev/zero of=$file bs=1024 count=100
3993 BEFOREWRITES=`count_ost_writes`
3994 $TRUNCATE $file $offset
3995 cancel_lru_locks $OSC
3996 AFTERWRITES=`count_ost_writes`
4001 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4004 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4005 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4008 run_test 42c "test partial truncate of file with cached dirty data"
4011 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4014 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4015 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4018 run_test 42d "test complete truncate of file with cached dirty data"
4020 test_42e() { # bug22074
4021 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4023 local TDIR=$DIR/${tdir}e
4024 local pages=16 # hardcoded 16 pages, don't change it.
4025 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4026 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4030 test_mkdir $DIR/${tdir}e
4031 $LFS setstripe -c 1 $TDIR
4032 createmany -o $TDIR/f $files
4034 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4036 # we assume that with $OSTCOUNT files, at least one of them will
4037 # be allocated on OST0.
4038 warmup_files=$((OSTCOUNT * max_dirty_mb))
4039 createmany -o $TDIR/w $warmup_files
4041 # write a large amount of data into one file and sync, to get good
4042 # avail_grant number from OST.
4043 for ((i=0; i<$warmup_files; i++)); do
4044 idx=$($LFS getstripe -i $TDIR/w$i)
4045 [ $idx -ne 0 ] && continue
4046 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4049 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4051 $LCTL get_param $proc_osc0/cur_dirty_bytes
4052 $LCTL get_param $proc_osc0/cur_grant_bytes
4054 # create as much dirty pages as we can while not to trigger the actual
4055 # RPCs directly. but depends on the env, VFS may trigger flush during this
4056 # period, hopefully we are good.
4057 for ((i=0; i<$warmup_files; i++)); do
4058 idx=$($LFS getstripe -i $TDIR/w$i)
4059 [ $idx -ne 0 ] && continue
4060 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4062 $LCTL get_param $proc_osc0/cur_dirty_bytes
4063 $LCTL get_param $proc_osc0/cur_grant_bytes
4065 # perform the real test
4066 $LCTL set_param $proc_osc0/rpc_stats 0
4067 for ((;i<$files; i++)); do
4068 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
4069 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4072 $LCTL get_param $proc_osc0/rpc_stats
4075 local have_ppr=false
4076 $LCTL get_param $proc_osc0/rpc_stats |
4077 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4078 # skip lines until we are at the RPC histogram data
4079 [ "$PPR" == "pages" ] && have_ppr=true && continue
4080 $have_ppr || continue
4082 # we only want the percent stat for < 16 pages
4083 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4085 percent=$((percent + WPCT))
4086 if [[ $percent -gt 15 ]]; then
4087 error "less than 16-pages write RPCs" \
4094 run_test 42e "verify sub-RPC writes are not done synchronously"
4096 test_43A() { # was test_43
4097 test_mkdir $DIR/$tdir
4098 cp -p /bin/ls $DIR/$tdir/$tfile
4099 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4101 # give multiop a chance to open
4104 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4107 run_test 43A "execution of file opened for write should return -ETXTBSY"
4110 test_mkdir $DIR/$tdir
4111 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
4112 cp -p multiop $DIR/$tdir/multiop
4113 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
4114 error "multiop open $TMP/$tfile.junk failed"
4115 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
4117 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
4118 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
4119 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
4121 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4124 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4126 test_mkdir $DIR/$tdir
4127 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
4128 cp -p multiop $DIR/$tdir/multiop
4129 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
4130 error "multiop open $TMP/$tfile.junk failed"
4131 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
4133 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
4134 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
4135 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
4137 run_test 43b "truncate of file being executed should return -ETXTBSY"
4140 local testdir="$DIR/$tdir"
4143 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4144 ( cd $testdir && md5sum -c )
4146 run_test 43c "md5sum of copy into lustre"
4148 test_44A() { # was test_44
4149 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4151 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4152 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4154 run_test 44A "zero length read from a sparse stripe"
4157 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4159 [ -z "$nstripe" ] && skip "can't get stripe info"
4160 [[ $nstripe -gt $OSTCOUNT ]] &&
4161 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4163 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4165 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4166 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4170 OFFSETS="0 $((stride/2)) $((stride-1))"
4171 for offset in $OFFSETS; do
4172 for i in $(seq 0 $((nstripe-1))); do
4173 local GLOBALOFFSETS=""
4175 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4176 local myfn=$DIR/d44a-$size
4177 echo "--------writing $myfn at $size"
4178 ll_sparseness_write $myfn $size ||
4179 error "ll_sparseness_write"
4180 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4181 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4182 error "ll_sparseness_verify $GLOBALOFFSETS"
4184 for j in $(seq 0 $((nstripe-1))); do
4186 size=$((((j + $nstripe )*$stride + $offset)))
4187 ll_sparseness_write $myfn $size ||
4188 error "ll_sparseness_write"
4189 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4191 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4192 error "ll_sparseness_verify $GLOBALOFFSETS"
4197 run_test 44a "test sparse pwrite ==============================="
4201 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4207 before=`dirty_osc_total`
4208 echo executing "\"$*\""
4210 after=`dirty_osc_total`
4211 echo before $before, after $after
4214 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4217 # Obtain grants from OST if it supports it
4218 echo blah > ${f}_grant
4221 do_dirty_record "echo blah > $f"
4222 [[ $before -eq $after ]] && error "write wasn't cached"
4223 do_dirty_record "> $f"
4224 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4225 do_dirty_record "echo blah > $f"
4226 [[ $before -eq $after ]] && error "write wasn't cached"
4227 do_dirty_record "sync"
4228 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4229 do_dirty_record "echo blah > $f"
4230 [[ $before -eq $after ]] && error "write wasn't cached"
4231 do_dirty_record "cancel_lru_locks osc"
4232 [[ $before -gt $after ]] ||
4233 error "lock cancellation didn't lower dirty count"
4236 run_test 45 "osc io page accounting ============================"
4238 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4239 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4240 # objects offset and an assert hit when an rpc was built with 1023's mapped
4241 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4243 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4248 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4250 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4251 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4255 run_test 46 "dirtying a previously written page ================"
4257 # test_47 is removed "Device nodes check" is moved to test_28
4259 test_48a() { # bug 2399
4260 [ "$mds1_FSTYPE" = "zfs" ] &&
4261 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4262 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4264 test_mkdir $DIR/$tdir
4266 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4267 test_mkdir $DIR/$tdir
4268 touch foo || error "'touch foo' failed after recreating cwd"
4270 touch .foo || error "'touch .foo' failed after recreating cwd"
4272 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4273 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4274 cd . || error "'cd .' failed after recreating cwd"
4275 mkdir . && error "'mkdir .' worked after recreating cwd"
4276 rmdir . && error "'rmdir .' worked after recreating cwd"
4277 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4278 cd .. || error "'cd ..' failed after recreating cwd"
4280 run_test 48a "Access renamed working dir (should return errors)="
4282 test_48b() { # bug 2399
4284 test_mkdir $DIR/$tdir
4286 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4287 touch foo && error "'touch foo' worked after removing cwd"
4288 mkdir foo && error "'mkdir foo' worked after removing cwd"
4289 touch .foo && error "'touch .foo' worked after removing cwd"
4290 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4291 ls . > /dev/null && error "'ls .' worked after removing cwd"
4292 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4293 mkdir . && error "'mkdir .' worked after removing cwd"
4294 rmdir . && error "'rmdir .' worked after removing cwd"
4295 ln -s . foo && error "'ln -s .' worked after removing cwd"
4296 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4298 run_test 48b "Access removed working dir (should return errors)="
4300 test_48c() { # bug 2350
4301 #lctl set_param debug=-1
4304 test_mkdir -p $DIR/$tdir/dir
4306 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4307 $TRACE touch foo && error "touch foo worked after removing cwd"
4308 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4309 touch .foo && error "touch .foo worked after removing cwd"
4310 mkdir .foo && error "mkdir .foo worked after removing cwd"
4311 $TRACE ls . && error "'ls .' worked after removing cwd"
4312 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4313 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4314 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4315 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4316 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4318 run_test 48c "Access removed working subdir (should return errors)"
4320 test_48d() { # bug 2350
4321 #lctl set_param debug=-1
4324 test_mkdir -p $DIR/$tdir/dir
4326 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4327 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4328 $TRACE touch foo && error "'touch foo' worked after removing parent"
4329 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4330 touch .foo && error "'touch .foo' worked after removing parent"
4331 mkdir .foo && error "mkdir .foo worked after removing parent"
4332 $TRACE ls . && error "'ls .' worked after removing parent"
4333 $TRACE ls .. && error "'ls ..' worked after removing parent"
4334 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4335 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4336 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4339 run_test 48d "Access removed parent subdir (should return errors)"
4341 test_48e() { # bug 4134
4342 #lctl set_param debug=-1
4345 test_mkdir -p $DIR/$tdir/dir
4347 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4348 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4349 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4350 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4351 # On a buggy kernel addition of "touch foo" after cd .. will
4352 # produce kernel oops in lookup_hash_it
4353 touch ../foo && error "'cd ..' worked after recreate parent"
4355 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4357 run_test 48e "Access to recreated parent subdir (should return errors)"
4359 test_49() { # LU-1030
4360 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4361 remote_ost_nodsh && skip "remote OST with nodsh"
4363 # get ost1 size - lustre-OST0000
4364 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4366 # write 800M at maximum
4367 [[ $ost1_size -lt 2 ]] && ost1_size=2
4368 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4370 $LFS setstripe -c 1 -i 0 $DIR/$tfile
4371 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4374 # change max_pages_per_rpc while writing the file
4375 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4376 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4377 # loop until dd process exits
4378 while ps ax -opid | grep -wq $dd_pid; do
4379 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4380 sleep $((RANDOM % 5 + 1))
4382 # restore original max_pages_per_rpc
4383 $LCTL set_param $osc1_mppc=$orig_mppc
4384 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4386 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4390 test_mkdir $DIR/$tdir
4392 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4394 run_test 50 "special situations: /proc symlinks ==============="
4396 test_51a() { # was test_51
4397 # bug 1516 - create an empty entry right after ".." then split dir
4398 test_mkdir -c1 $DIR/$tdir
4399 touch $DIR/$tdir/foo
4400 $MCREATE $DIR/$tdir/bar
4402 createmany -m $DIR/$tdir/longfile 201
4404 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4405 $MCREATE $DIR/$tdir/longfile$FNUM
4410 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4412 run_test 51a "special situations: split htree with empty entry =="
4414 cleanup_print_lfs_df () {
4421 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4423 local dir=$DIR/$tdir
4424 local nrdirs=$((65536 + 100))
4426 # cleanup the directory
4433 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
4434 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4435 [[ $numfree -lt $nrdirs ]] &&
4436 skip "not enough free inodes ($numfree) on MDT$mdtidx"
4438 # need to check free space for the directories as well
4439 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4440 numfree=$(( blkfree / $(fs_inode_ksize) ))
4441 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
4443 trap cleanup_print_lfs_df EXIT
4446 createmany -d $dir/d $nrdirs || {
4447 unlinkmany $dir/d $nrdirs
4448 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4452 nrdirs=$(ls -U $dir | wc -l)
4454 # unlink all but 100 subdirectories, then check it still works
4456 local delete=$((nrdirs - left))
4461 # for ldiskfs the nlink count should be 1, but this is OSD specific
4462 # and so this is listed for informational purposes only
4463 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4464 unlinkmany -d $dir/d $delete ||
4465 error "unlink of first $delete subdirs failed"
4467 echo "nlink between: $(stat -c %h $dir)"
4468 local found=$(ls -U $dir | wc -l)
4469 [ $found -ne $left ] &&
4470 error "can't find subdirs: found only $found, expected $left"
4472 unlinkmany -d $dir/d $delete $left ||
4473 error "unlink of second $left subdirs failed"
4474 # regardless of whether the backing filesystem tracks nlink accurately
4475 # or not, the nlink count shouldn't be more than "." and ".." here
4476 local after=$(stat -c %h $dir)
4477 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4478 echo "nlink after: $after"
4480 cleanup_print_lfs_df
4482 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4485 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4486 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
4488 test_mkdir $DIR/$tdir
4489 createmany -o $DIR/$tdir/t- 1000
4490 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4491 for N in $(seq 0 $((OSTCOUNT - 1))); do
4492 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4493 END { printf("%0.0f", objs) }' $TMP/$tfile)
4494 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4495 '($1 == '$N') { objs += 1 } \
4496 END { printf("%0.0f", objs) }')
4497 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4499 unlinkmany $DIR/$tdir/t- 1000
4502 for N in $(seq 1 $((OSTCOUNT - 1))); do
4503 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4504 error "OST $N has less objects vs OST $NLAST" \
4505 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4506 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4507 error "OST $N has less objects vs OST $NLAST" \
4508 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4510 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4511 error "OST $N has less #0 objects vs OST $NLAST" \
4512 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4513 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4514 error "OST $N has less #0 objects vs OST $NLAST" \
4515 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4520 run_test 51d "check object distribution"
4523 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4524 skip_env "ldiskfs only test"
4527 test_mkdir -c1 $DIR/$tdir
4528 test_mkdir -c1 $DIR/$tdir/d0
4530 touch $DIR/$tdir/d0/foo
4531 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4532 error "file exceed 65000 nlink limit!"
4533 unlinkmany $DIR/$tdir/d0/f- 65001
4536 run_test 51e "check file nlink limit"
4539 test_mkdir $DIR/$tdir
4542 local ulimit_old=$(ulimit -n)
4543 local spare=20 # number of spare fd's for scripts/libraries, etc.
4544 local mdt=$($LFS getstripe -m $DIR/$tdir)
4545 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4547 echo "MDT$mdt numfree=$numfree, max=$max"
4548 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4549 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4550 while ! ulimit -n $((numfree + spare)); do
4551 numfree=$((numfree * 3 / 4))
4553 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4555 echo "left ulimit at $ulimit_old"
4558 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4559 unlinkmany $DIR/$tdir/f $numfree
4560 error "create+open $numfree files in $DIR/$tdir failed"
4562 ulimit -n $ulimit_old
4564 # if createmany exits at 120s there will be fewer than $numfree files
4565 unlinkmany $DIR/$tdir/f $numfree || true
4567 run_test 51f "check many open files limit"
4570 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4571 test_mkdir $DIR/$tdir
4572 touch $DIR/$tdir/foo
4573 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4574 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4575 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4576 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4577 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4579 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4580 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4581 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4583 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4584 cp -r $DIR/$tdir $TMP/
4585 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4587 run_test 52a "append-only flag test (should return errors)"
4590 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4591 test_mkdir $DIR/$tdir
4592 touch $DIR/$tdir/foo
4593 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4594 cat test > $DIR/$tdir/foo && error "cat test worked"
4595 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4596 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4597 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4599 echo foo >> $DIR/$tdir/foo && error "echo worked"
4600 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4601 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4602 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4603 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4605 chattr -i $DIR/$tdir/foo || error "chattr failed"
4607 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4609 run_test 52b "immutable flag test (should return errors) ======="
4612 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4613 remote_mds_nodsh && skip "remote MDS with nodsh"
4614 remote_ost_nodsh && skip "remote OST with nodsh"
4627 local support_last_seq=true
4629 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
4630 support_last_seq=false
4633 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4635 for value in $(do_facet $SINGLEMDS \
4636 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4637 param=$(echo ${value[0]} | cut -d "=" -f1)
4638 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4640 if $support_last_seq; then
4641 param_seq=$(echo $param |
4642 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4643 mds_last_seq=$(do_facet $SINGLEMDS \
4644 $LCTL get_param -n $param_seq)
4646 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4648 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4649 node=$(facet_active_host ost$((ostnum+1)))
4650 param="obdfilter.$ostname.last_id"
4651 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4652 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4653 ost_last_id=$ost_last
4655 if $support_last_seq; then
4656 ost_last_id=$(echo $ost_last |
4657 awk -F':' '{print $2}' |
4659 ost_last_seq=$(echo $ost_last |
4660 awk -F':' '{print $1}')
4661 [[ $ost_last_seq = $mds_last_seq ]] || continue
4664 if [[ $ost_last_id != $mds_last ]]; then
4665 error "$ost_last_id != $mds_last"
4672 $found || error "can not match last_seq/last_id for $mdtosc"
4675 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4678 perl -MSocket -e ';' || skip "no Socket perl module installed"
4680 $SOCKETSERVER $DIR/socket ||
4681 error "$SOCKETSERVER $DIR/socket failed: $?"
4682 $SOCKETCLIENT $DIR/socket ||
4683 error "$SOCKETCLIENT $DIR/socket failed: $?"
4684 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4686 run_test 54a "unix domain socket test =========================="
4692 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
4694 run_test 54b "char device works in lustre ======================"
4697 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4698 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4699 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4701 for i in $(seq 3 7); do
4702 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4711 loopdev="$DIR/loop54c"
4714 $UMOUNT $DIR/$tdir || rc=$?
4715 losetup -d $loopdev || true
4716 losetup -d $LOOPDEV || true
4717 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4722 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4724 loopdev="$DIR/loop54c"
4727 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
4728 trap cleanup_54c EXIT
4729 mknod $loopdev b 7 $LOOPNUM
4730 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4731 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
4732 losetup $loopdev $DIR/$tfile ||
4733 error "can't set up $loopdev for $DIR/$tfile"
4734 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4735 test_mkdir $DIR/$tdir
4736 mount -t ext2 $loopdev $DIR/$tdir ||
4737 error "error mounting $loopdev on $DIR/$tdir"
4738 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
4741 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
4745 run_test 54c "block device works in lustre ====================="
4751 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4753 run_test 54d "fifo device works in lustre ======================"
4758 cp -aL /dev/console $f
4759 echo $string > $f || error "echo $string to $f failed"
4761 run_test 54e "console/tty device works in lustre ======================"
4765 local dir=$DIR/$tdir
4768 test_mkdir -p $dir/dir
4769 for i in $(seq $numfiles); do
4771 touch $dir/dir/file$i
4774 local numcomp=$($LFS getstripe --component-count $dir)
4776 [[ $numcomp == 0 ]] && numcomp=1
4778 # test lfs getstripe with --recursive
4779 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
4781 [[ $filenum -eq $((numfiles * 2)) ]] ||
4782 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
4783 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
4784 [[ $filenum -eq $numfiles ]] ||
4785 error "$LFS getstripe $dir: found $filenum, not $numfiles"
4786 echo "$LFS getstripe showed obdidx or l_ost_idx"
4788 # test lfs getstripe with file instead of dir
4789 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
4790 [[ $filenum -eq 1 ]] ||
4791 error "$LFS getstripe $dir/file1: found $filenum, not 1"
4792 echo "$LFS getstripe file1 passed"
4794 #test lfs getstripe with --verbose
4795 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
4796 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4797 error "$LFS getstripe --verbose $dir: "\
4798 "got $filenum want $((numfiles * numcomp)) lmm_magic"
4799 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
4800 error "$LFS getstripe $dir: showed lmm_magic"
4802 #test lfs getstripe with -v prints lmm_fid
4803 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
4804 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4805 error "$LFS getstripe -v $dir: "\
4806 "got $filenum want $((numfiles * numcomp)) lmm_fid"
4807 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
4808 error "$LFS getstripe $dir: showed lmm_fid by default"
4809 echo "$LFS getstripe --verbose passed"
4811 #check for FID information
4812 local fid1=$($LFS getstripe --fid $dir/file1)
4813 local fid2=$($LFS getstripe --verbose $dir/file1 |
4814 awk '/lmm_fid: / { print $2; exit; }')
4815 local fid3=$($LFS path2fid $dir/file1)
4817 [ "$fid1" != "$fid2" ] &&
4818 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
4819 [ "$fid1" != "$fid3" ] &&
4820 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
4821 echo "$LFS getstripe --fid passed"
4823 #test lfs getstripe with --obd
4824 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
4825 error "$LFS getstripe --obd wrong_uuid: should return error"
4827 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4830 local obduuid=$(ostuuid_from_index $ostidx)
4831 local found=$($LFS getstripe -r --obd $obduuid $dir |
4832 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
4834 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
4835 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
4837 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
4840 [[ $found -eq $filenum ]] ||
4841 error "$LFS getstripe --obd: found $found expect $filenum"
4842 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
4843 sed '/^[ ]*'${ostidx}'[ ]/d' |
4844 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4845 error "$LFS getstripe --obd: should not show file on other obd"
4846 echo "$LFS getstripe --obd passed"
4848 run_test 56a "check $LFS getstripe"
4851 local dir=$DIR/$tdir
4855 for i in $(seq $numdirs); do
4856 test_mkdir $dir/dir$i
4859 # test lfs getdirstripe default mode is non-recursion, which is
4860 # different from lfs getstripe
4861 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
4863 [[ $dircnt -eq 1 ]] ||
4864 error "$LFS getdirstripe: found $dircnt, not 1"
4865 dircnt=$($LFS getdirstripe --recursive $dir |
4866 grep -c lmv_stripe_count)
4867 [[ $dircnt -eq $((numdirs + 1)) ]] ||
4868 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
4870 run_test 56b "check $LFS getdirstripe"
4873 remote_ost_nodsh && skip "remote OST with nodsh"
4876 local ost_name=$(ostname_from_index $ost_idx)
4877 local old_status=$(ost_dev_status $ost_idx)
4879 [[ -z "$old_status" ]] ||
4880 skip_env "OST $ost_name is in $old_status status"
4882 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4885 local new_status=$(ost_dev_status $ost_idx)
4887 [[ "$new_status" = "D" ]] ||
4888 error "OST $ost_name is in status of '$new_status', not 'D'"
4890 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4893 new_status=$(ost_dev_status $ost_idx)
4894 [[ -z "$new_status" ]] ||
4895 error "OST $ost_name is in status of '$new_status', not ''"
4897 run_test 56c "check 'lfs df' showing device status"
4902 local local_tdir="$1"
4903 local local_numfiles="$2"
4904 local local_numdirs="$3"
4905 local dir_params="$4"
4906 local dir_stripe_params="$5"
4908 if [ ! -d "$local_tdir" ] ; then
4909 test_mkdir -p $dir_stripe_params $local_tdir
4910 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
4911 for i in $(seq $local_numfiles) ; do
4912 touch $local_tdir/file$i
4914 for i in $(seq $local_numdirs) ; do
4915 test_mkdir $dir_stripe_params $local_tdir/dir$i
4916 for j in $(seq $local_numfiles) ; do
4917 touch $local_tdir/dir$i/file$j
4923 setup_56_special() {
4925 local local_numfiles=$2
4926 local local_numdirs=$3
4928 setup_56 $local_tdir $local_numfiles $local_numdirs
4930 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
4931 for i in $(seq $local_numfiles) ; do
4932 mknod $local_tdir/loop${i}b b 7 $i
4933 mknod $local_tdir/null${i}c c 1 3
4934 ln -s $local_tdir/file1 $local_tdir/link${i}
4936 for i in $(seq $local_numdirs) ; do
4937 mknod $local_tdir/dir$i/loop${i}b b 7 $i
4938 mknod $local_tdir/dir$i/null${i}c c 1 3
4939 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
4945 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4946 local expected=$(($NUMDIRS + 2))
4948 setup_56 $dir $NUMFILES $NUMDIRS
4950 # test lfs find with -name
4951 for i in $(seq $NUMFILES) ; do
4952 local nums=$($LFS find -name "*$i" $dir | wc -l)
4954 [ $nums -eq $expected ] ||
4955 error "lfs find -name '*$i' $dir wrong: "\
4956 "found $nums, expected $expected"
4959 run_test 56g "check lfs find -name"
4962 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4963 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4965 setup_56 $dir $NUMFILES $NUMDIRS
4967 # test lfs find with ! -name
4968 for i in $(seq $NUMFILES) ; do
4969 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
4971 [ $nums -eq $expected ] ||
4972 error "lfs find ! -name '*$i' $dir wrong: "\
4973 "found $nums, expected $expected"
4976 run_test 56h "check lfs find ! -name"
4979 local dir=$DIR/$tdir
4983 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
4986 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
4988 run_test 56i "check 'lfs find -ost UUID' skips directories"
4991 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4993 setup_56_special $dir $NUMFILES $NUMDIRS
4995 local expected=$((NUMDIRS + 1))
4996 local cmd="$LFS find -type d $dir"
4997 local nums=$($cmd | wc -l)
4999 [ $nums -eq $expected ] ||
5000 error "'$cmd' wrong: found $nums, expected $expected"
5002 run_test 56j "check lfs find -type d"
5005 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5007 setup_56_special $dir $NUMFILES $NUMDIRS
5009 local expected=$(((NUMDIRS + 1) * NUMFILES))
5010 local cmd="$LFS find -type f $dir"
5011 local nums=$($cmd | wc -l)
5013 [ $nums -eq $expected ] ||
5014 error "'$cmd' wrong: found $nums, expected $expected"
5016 run_test 56k "check lfs find -type f"
5019 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5021 setup_56_special $dir $NUMFILES $NUMDIRS
5023 local expected=$((NUMDIRS + NUMFILES))
5024 local cmd="$LFS find -type b $dir"
5025 local nums=$($cmd | wc -l)
5027 [ $nums -eq $expected ] ||
5028 error "'$cmd' wrong: found $nums, expected $expected"
5030 run_test 56l "check lfs find -type b"
5033 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5035 setup_56_special $dir $NUMFILES $NUMDIRS
5037 local expected=$((NUMDIRS + NUMFILES))
5038 local cmd="$LFS find -type c $dir"
5039 local nums=$($cmd | wc -l)
5040 [ $nums -eq $expected ] ||
5041 error "'$cmd' wrong: found $nums, expected $expected"
5043 run_test 56m "check lfs find -type c"
5046 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5047 setup_56_special $dir $NUMFILES $NUMDIRS
5049 local expected=$((NUMDIRS + NUMFILES))
5050 local cmd="$LFS find -type l $dir"
5051 local nums=$($cmd | wc -l)
5053 [ $nums -eq $expected ] ||
5054 error "'$cmd' wrong: found $nums, expected $expected"
5056 run_test 56n "check lfs find -type l"
5059 local dir=$DIR/$tdir
5061 setup_56 $dir $NUMFILES $NUMDIRS
5062 utime $dir/file1 > /dev/null || error "utime (1)"
5063 utime $dir/file2 > /dev/null || error "utime (2)"
5064 utime $dir/dir1 > /dev/null || error "utime (3)"
5065 utime $dir/dir2 > /dev/null || error "utime (4)"
5066 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5067 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5070 local nums=$($LFS find -mtime +0 $dir | wc -l)
5072 [ $nums -eq $expected ] ||
5073 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5076 cmd="$LFS find -mtime 0 $dir"
5077 nums=$($cmd | wc -l)
5078 [ $nums -eq $expected ] ||
5079 error "'$cmd' wrong: found $nums, expected $expected"
5081 run_test 56o "check lfs find -mtime for old files"
5084 [ $RUNAS_ID -eq $UID ] &&
5085 skip_env "RUNAS_ID = UID = $UID -- skipping"
5087 local dir=$DIR/$tdir
5089 setup_56 $dir $NUMFILES $NUMDIRS
5090 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5092 local expected=$NUMFILES
5093 local cmd="$LFS find -uid $RUNAS_ID $dir"
5094 local nums=$($cmd | wc -l)
5096 [ $nums -eq $expected ] ||
5097 error "'$cmd' wrong: found $nums, expected $expected"
5099 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5100 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5101 nums=$($cmd | wc -l)
5102 [ $nums -eq $expected ] ||
5103 error "'$cmd' wrong: found $nums, expected $expected"
5105 run_test 56p "check lfs find -uid and ! -uid"
5108 [ $RUNAS_ID -eq $UID ] &&
5109 skip_env "RUNAS_ID = UID = $UID -- skipping"
5111 local dir=$DIR/$tdir
5113 setup_56 $dir $NUMFILES $NUMDIRS
5114 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5116 local expected=$NUMFILES
5117 local cmd="$LFS find -gid $RUNAS_GID $dir"
5118 local nums=$($cmd | wc -l)
5120 [ $nums -eq $expected ] ||
5121 error "'$cmd' wrong: found $nums, expected $expected"
5123 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5124 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5125 nums=$($cmd | wc -l)
5126 [ $nums -eq $expected ] ||
5127 error "'$cmd' wrong: found $nums, expected $expected"
5129 run_test 56q "check lfs find -gid and ! -gid"
5132 local dir=$DIR/$tdir
5134 setup_56 $dir $NUMFILES $NUMDIRS
5137 local cmd="$LFS find -size 0 -type f $dir"
5138 local nums=$($cmd | wc -l)
5140 [ $nums -eq $expected ] ||
5141 error "'$cmd' wrong: found $nums, expected $expected"
5143 cmd="$LFS find ! -size 0 -type f $dir"
5144 nums=$($cmd | wc -l)
5145 [ $nums -eq $expected ] ||
5146 error "'$cmd' wrong: found $nums, expected $expected"
5147 echo "test" > $dir/$tfile
5148 echo "test2" > $dir/$tfile.2 && sync
5150 cmd="$LFS find -size 5 -type f $dir"
5151 nums=$($cmd | wc -l)
5152 [ $nums -eq $expected ] ||
5153 error "'$cmd' wrong: found $nums, expected $expected"
5155 cmd="$LFS find -size +5 -type f $dir"
5156 nums=$($cmd | wc -l)
5157 [ $nums -eq $expected ] ||
5158 error "'$cmd' wrong: found $nums, expected $expected"
5160 cmd="$LFS find -size +0 -type f $dir"
5161 nums=$($cmd | wc -l)
5162 [ $nums -eq $expected ] ||
5163 error "'$cmd' wrong: found $nums, expected $expected"
5165 cmd="$LFS find ! -size -5 -type f $dir"
5166 nums=$($cmd | wc -l)
5167 [ $nums -eq $expected ] ||
5168 error "'$cmd' wrong: found $nums, expected $expected"
5170 cmd="$LFS find -size -5 -type f $dir"
5171 nums=$($cmd | wc -l)
5172 [ $nums -eq $expected ] ||
5173 error "'$cmd' wrong: found $nums, expected $expected"
5175 run_test 56r "check lfs find -size works"
5177 test_56s() { # LU-611 #LU-9369
5178 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
5180 local dir=$DIR/$tdir
5181 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5183 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5184 for i in $(seq $NUMDIRS); do
5185 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5188 local expected=$NUMDIRS
5189 local cmd="$LFS find -c $OSTCOUNT $dir"
5190 local nums=$($cmd | wc -l)
5192 [ $nums -eq $expected ] || {
5193 $LFS getstripe -R $dir
5194 error "'$cmd' wrong: found $nums, expected $expected"
5197 expected=$((NUMDIRS + onestripe))
5198 cmd="$LFS find -stripe-count +0 -type f $dir"
5199 nums=$($cmd | wc -l)
5200 [ $nums -eq $expected ] || {
5201 $LFS getstripe -R $dir
5202 error "'$cmd' wrong: found $nums, expected $expected"
5206 cmd="$LFS find -stripe-count 1 -type f $dir"
5207 nums=$($cmd | wc -l)
5208 [ $nums -eq $expected ] || {
5209 $LFS getstripe -R $dir
5210 error "'$cmd' wrong: found $nums, expected $expected"
5213 cmd="$LFS find -stripe-count -2 -type f $dir"
5214 nums=$($cmd | wc -l)
5215 [ $nums -eq $expected ] || {
5216 $LFS getstripe -R $dir
5217 error "'$cmd' wrong: found $nums, expected $expected"
5221 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5222 nums=$($cmd | wc -l)
5223 [ $nums -eq $expected ] || {
5224 $LFS getstripe -R $dir
5225 error "'$cmd' wrong: found $nums, expected $expected"
5228 run_test 56s "check lfs find -stripe-count works"
5230 test_56t() { # LU-611 #LU-9369
5231 local dir=$DIR/$tdir
5233 setup_56 $dir 0 $NUMDIRS
5234 for i in $(seq $NUMDIRS); do
5235 $LFS setstripe -S 8M $dir/dir$i/$tfile
5238 local expected=$NUMDIRS
5239 local cmd="$LFS find -S 8M $dir"
5240 local nums=$($cmd | wc -l)
5242 [ $nums -eq $expected ] || {
5243 $LFS getstripe -R $dir
5244 error "'$cmd' wrong: found $nums, expected $expected"
5248 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5250 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5252 expected=$(((NUMDIRS + 1) * NUMFILES))
5253 cmd="$LFS find -stripe-size 512k -type f $dir"
5254 nums=$($cmd | wc -l)
5255 [ $nums -eq $expected ] ||
5256 error "'$cmd' wrong: found $nums, expected $expected"
5258 cmd="$LFS find -stripe-size +320k -type f $dir"
5259 nums=$($cmd | wc -l)
5260 [ $nums -eq $expected ] ||
5261 error "'$cmd' wrong: found $nums, expected $expected"
5263 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5264 cmd="$LFS find -stripe-size +200k -type f $dir"
5265 nums=$($cmd | wc -l)
5266 [ $nums -eq $expected ] ||
5267 error "'$cmd' wrong: found $nums, expected $expected"
5269 cmd="$LFS find -stripe-size -640k -type f $dir"
5270 nums=$($cmd | wc -l)
5271 [ $nums -eq $expected ] ||
5272 error "'$cmd' wrong: found $nums, expected $expected"
5275 cmd="$LFS find -stripe-size 256k -type f $dir"
5276 nums=$($cmd | wc -l)
5277 [ $nums -eq $expected ] ||
5278 error "'$cmd' wrong: found $nums, expected $expected"
5280 cmd="$LFS find -stripe-size -320k -type f $dir"
5281 nums=$($cmd | wc -l)
5282 [ $nums -eq $expected ] ||
5283 error "'$cmd' wrong: found $nums, expected $expected"
5286 cmd="$LFS find -stripe-size 1024k -type f $dir"
5287 nums=$($cmd | wc -l)
5288 [ $nums -eq $expected ] ||
5289 error "'$cmd' wrong: found $nums, expected $expected"
5291 run_test 56t "check lfs find -stripe-size works"
5293 test_56u() { # LU-611
5294 local dir=$DIR/$tdir
5296 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5298 if [[ $OSTCOUNT -gt 1 ]]; then
5299 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5305 local expected=$(((NUMDIRS + 1) * NUMFILES))
5306 local cmd="$LFS find -stripe-index 0 -type f $dir"
5307 local nums=$($cmd | wc -l)
5309 [ $nums -eq $expected ] ||
5310 error "'$cmd' wrong: found $nums, expected $expected"
5313 cmd="$LFS find -stripe-index 1 -type f $dir"
5314 nums=$($cmd | wc -l)
5315 [ $nums -eq $expected ] ||
5316 error "'$cmd' wrong: found $nums, expected $expected"
5318 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5319 nums=$($cmd | wc -l)
5320 [ $nums -eq $expected ] ||
5321 error "'$cmd' wrong: found $nums, expected $expected"
5324 # This should produce an error and not return any files
5325 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5326 nums=$($cmd 2>/dev/null | wc -l)
5327 [ $nums -eq $expected ] ||
5328 error "'$cmd' wrong: found $nums, expected $expected"
5330 if [[ $OSTCOUNT -gt 1 ]]; then
5331 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5332 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5333 nums=$($cmd | wc -l)
5334 [ $nums -eq $expected ] ||
5335 error "'$cmd' wrong: found $nums, expected $expected"
5338 run_test 56u "check lfs find -stripe-index works"
5342 local dir=$DIR/$tdir
5344 setup_56 $dir $NUMFILES $NUMDIRS
5346 UUID=$(mdtuuid_from_index $mdt_idx $dir)
5347 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
5349 for file in $($LFS find -m $UUID $dir); do
5350 file_midx=$($LFS getstripe -m $file)
5351 [ $file_midx -eq $mdt_idx ] ||
5352 error "lfs find -m $UUID != getstripe -m $file_midx"
5355 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
5358 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5359 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5361 local dir=$DIR/$tdir
5363 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5365 local stripe_size=$($LFS getstripe -S -d $dir) ||
5366 error "$LFS getstripe -S -d $dir failed"
5367 stripe_size=${stripe_size%% *}
5369 local file_size=$((stripe_size * OSTCOUNT))
5370 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5371 local required_space=$((file_num * file_size))
5372 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5374 [[ $free_space -le $((required_space / 1024)) ]] &&
5375 skip_env "need $required_space, have $free_space kbytes"
5378 local dd_count=$((file_size / dd_bs))
5380 # write data into the files
5385 for i in $(seq $NUMFILES); do
5387 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5388 error "write data into $file failed"
5390 for i in $(seq $NUMDIRS); do
5391 for j in $(seq $NUMFILES); do
5392 file=$dir/dir$i/file$j
5393 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5394 error "write data into $file failed"
5398 # $LFS_MIGRATE will fail if hard link migration is unsupported
5399 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5400 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5401 error "creating links to $dir/dir1/file1 failed"
5406 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5409 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5412 eval $cmd || error "$cmd failed"
5414 check_stripe_count $dir/file1 $expected
5416 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
5418 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5419 # OST 1 if it is on OST 0. This file is small enough to
5420 # be on only one stripe.
5421 file=$dir/migr_1_ost
5422 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5423 error "write data into $file failed"
5424 local obdidx=$($LFS getstripe -i $file)
5425 local oldmd5=$(md5sum $file)
5428 [[ $obdidx -eq 0 ]] && newobdidx=1
5429 cmd="$LFS migrate -i $newobdidx $file"
5431 eval $cmd || error "$cmd failed"
5433 local realobdix=$($LFS getstripe -i $file)
5434 local newmd5=$(md5sum $file)
5436 [[ $newobdidx -ne $realobdix ]] &&
5437 error "new OST is different (was=$obdidx, "\
5438 "wanted=$newobdidx, got=$realobdix)"
5439 [[ "$oldmd5" != "$newmd5" ]] &&
5440 error "md5sum differ: $oldmd5, $newmd5"
5444 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5446 eval $cmd || error "$cmd failed"
5448 for j in $(seq $NUMFILES); do
5449 check_stripe_count $dir/dir1/file$j $expected
5452 # lfs_migrate works with lfs find
5453 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5454 $LFS_MIGRATE -y -c $expected"
5456 eval $cmd || error "$cmd failed"
5458 for i in $(seq 2 $NUMFILES); do
5459 check_stripe_count $dir/file$i $expected
5461 for i in $(seq 2 $NUMDIRS); do
5462 for j in $(seq $NUMFILES); do
5463 check_stripe_count $dir/dir$i/file$j $expected
5467 run_test 56w "check lfs_migrate -c stripe_count works"
5470 local file1=$DIR/$tdir/file1
5471 local create_pool=false
5472 local initial_pool=$($LFS getstripe -p $DIR)
5476 echo -n "Creating test dir..."
5477 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5480 echo -n "Creating test file..."
5481 touch $file1 || error "cannot create file"
5484 echo -n "Detecting existing pools..."
5485 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
5487 if [ ${#pool_list[@]} -gt 0 ]; then
5488 echo "${pool_list[@]}"
5489 for thispool in "${pool_list[@]}"; do
5490 if [[ -z "$initial_pool" ||
5491 "$initial_pool" != "$thispool" ]]; then
5493 echo "Using existing pool '$pool'"
5498 echo "none detected."
5500 if [ -z "$pool" ]; then
5501 pool=${POOL:-testpool}
5502 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5503 echo -n "Creating pool '$pool'..."
5505 pool_add $pool &> /dev/null ||
5506 error "pool_add failed"
5509 echo -n "Adding target to pool..."
5510 pool_add_targets $pool 0 0 1 &> /dev/null ||
5511 error "pool_add_targets failed"
5515 echo -n "Setting pool using -p option..."
5516 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5517 error "migrate failed rc = $?"
5520 echo -n "Verifying test file is in pool after migrating..."
5521 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5522 error "file was not migrated to pool $pool"
5525 echo -n "Removing test file from pool '$pool'..."
5526 $LFS migrate $file1 &> /dev/null ||
5527 error "cannot remove from pool"
5528 [ "$($LFS getstripe -p $file1)" ] &&
5529 error "pool still set"
5532 echo -n "Setting pool using --pool option..."
5533 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5534 error "migrate failed rc = $?"
5539 if $create_pool; then
5540 destroy_test_pools 2> /dev/null ||
5541 error "destroy test pools failed"
5544 run_test 56wb "check lfs_migrate pool support"
5547 local file1="$DIR/$tdir/file1"
5549 echo -n "Creating test dir..."
5550 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5551 local def_stripe_size=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
5552 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5553 error "cannot set stripe"
5556 echo -n "Setting initial stripe for test file..."
5557 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5558 error "cannot set stripe"
5559 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5560 error "stripe size not set"
5563 # File currently set to -S 512K -c 1
5565 # Ensure -c and -S options are rejected when -R is set
5566 echo -n "Verifying incompatible options are detected..."
5567 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5568 error "incompatible -c and -R options not detected"
5569 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5570 error "incompatible -S and -R options not detected"
5573 # Ensure unrecognized options are passed through to 'lfs migrate'
5574 echo -n "Verifying -S option is passed through to lfs migrate..."
5575 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5576 error "migration failed"
5577 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5578 error "file was not restriped"
5581 # File currently set to -S 1M -c 1
5583 # Ensure long options are supported
5584 echo -n "Verifying long options supported..."
5585 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5586 error "long option without argument not supported"
5587 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5588 error "long option with argument not supported"
5589 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5590 error "file not restriped with --stripe-size option"
5593 # File currently set to -S 512K -c 1
5595 if [ "$OSTCOUNT" -gt 1 ]; then
5596 echo -n "Verifying explicit stripe count can be set..."
5597 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5598 error "migrate failed"
5599 [ $($LFS getstripe -c "$file1") -eq 2 ] ||
5600 error "file not restriped to explicit count"
5604 # File currently set to -S 512K -c 1 or -S 512K -c 2
5606 # Ensure parent striping is used if -R is set, and no stripe
5607 # count or size is specified
5608 echo -n "Setting stripe for parent directory..."
5609 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5610 error "cannot set stripe"
5613 echo -n "Verifying restripe option uses parent stripe settings..."
5614 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5615 error "migrate failed"
5616 [ $($LFS getstripe -S "$file1") -eq $def_stripe_size ] ||
5617 error "file not restriped to parent settings"
5618 [ $($LFS getstripe -c "$file1") -eq 1 ] ||
5619 error "file not restriped to parent settings"
5622 # File currently set to -S 1M -c 1
5624 # Ensure striping is preserved if -R is not set, and no stripe
5625 # count or size is specified
5626 echo -n "Verifying striping size preserved when not specified..."
5627 local orig_stripe_size=$($LFS getstripe -S "$file1" 2>/dev/null)
5628 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5629 error "cannot set stripe on parent directory"
5630 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5631 error "migrate failed"
5632 [ $($LFS getstripe -S "$file1") -eq $orig_stripe_size ] ||
5633 error "file was restriped"
5636 # Ensure file name properly detected when final option has no argument
5637 echo -n "Verifying file name properly detected..."
5638 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5639 error "file name interpreted as option argument"
5645 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5648 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5650 local file1=$DIR/$tdir/file1
5652 echo -n "Creating test dir..."
5653 test_mkdir $DIR/$tdir || error "cannot create dir"
5656 echo -n "Creating test file..."
5660 # Ensure 'lfs migrate' will fail by using a non-existent option,
5661 # and make sure rsync is not called to recover
5662 echo -n "Make sure --no-rsync option works..."
5663 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
5664 grep -q 'refusing to fall back to rsync' ||
5665 error "rsync was called with --no-rsync set"
5668 # Ensure rsync is called without trying 'lfs migrate' first
5669 echo -n "Make sure --rsync option works..."
5670 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
5671 grep -q 'falling back to rsync' &&
5672 error "lfs migrate was called with --rsync set"
5675 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
5676 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
5677 grep -q 'at the same time' ||
5678 error "--rsync and --no-rsync accepted concurrently"
5684 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
5687 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5688 check_swap_layouts_support
5690 local dir=$DIR/$tdir
5691 local ref1=/etc/passwd
5692 local file1=$dir/file1
5694 test_mkdir $dir || error "creating dir $dir"
5695 $LFS setstripe -c 2 $file1
5697 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5698 stripe=$($LFS getstripe -c $file1)
5699 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5700 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5705 run_test 56x "lfs migration support"
5708 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5709 check_swap_layouts_support
5711 local dir=$DIR/$tdir/$testnum
5715 local ref1=/etc/passwd
5716 local file1=$dir/file1
5718 $LFS setstripe -c 2 $file1
5720 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5722 local stripe=$($LFS getstripe -c $file1)
5724 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5725 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5730 run_test 56xa "lfs migration --block support"
5732 check_migrate_links() {
5734 local file1="$dir/file1"
5737 local total_count=$(($begin + $count - 1))
5738 local symlink_count=10
5741 if [ ! -f "$file1" ]; then
5742 echo -n "creating initial file..."
5743 $LFS setstripe -c 1 -S "512k" "$file1" ||
5744 error "cannot setstripe initial file"
5747 echo -n "creating symlinks..."
5748 for s in $(seq 1 $symlink_count); do
5749 ln -s "$file1" "$dir/slink$s" ||
5750 error "cannot create symlinks"
5754 echo -n "creating nonlinked files..."
5755 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5756 error "cannot create nonlinked files"
5761 if [ ! -f "$dir/file$total_count" ]; then
5762 echo -n "creating hard links $begin:$total_count..."
5763 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5764 /dev/null || error "cannot create hard links"
5768 echo -n "checking number of hard links listed in xattrs..."
5769 local fid=$($LFS getstripe -F "$file1")
5770 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5773 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5774 skip "hard link list has unexpected size, skipping test"
5776 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5777 error "link names should exceed xattrs size"
5780 echo -n "migrating files..."
5781 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5783 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5786 # make sure all links have been properly migrated
5787 echo -n "verifying files..."
5788 fid=$($LFS getstripe -F "$file1") ||
5789 error "cannot get fid for file $file1"
5790 for i in $(seq 2 $total_count); do
5791 local fid2=$($LFS getstripe -F $dir/file$i)
5793 [ "$fid2" == "$fid" ] ||
5794 error "migrated hard link has mismatched FID"
5797 # make sure hard links were properly detected, and migration was
5798 # performed only once for the entire link set; nonlinked files should
5800 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5801 local expected=$(($uniq_count + 1))
5803 [ "$actual" -eq "$expected" ] ||
5804 error "hard links individually migrated ($actual != $expected)"
5806 # make sure the correct number of hard links are present
5807 local hardlinks=$(stat -c '%h' "$file1")
5809 [ $hardlinks -eq $total_count ] ||
5810 error "num hard links $hardlinks != $total_count"
5817 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
5818 skip "Need MDS version at least 2.10.55"
5820 local dir="$DIR/$tdir"
5822 test_mkdir "$dir" || error "cannot create dir $dir"
5824 echo "testing lfs migrate mode when all links fit within xattrs"
5825 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
5827 echo "testing rsync mode when all links fit within xattrs"
5828 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
5830 echo "testing lfs migrate mode when all links do not fit within xattrs"
5831 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
5833 echo "testing rsync mode when all links do not fit within xattrs"
5834 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
5840 run_test 56xb "lfs migration hard link support"
5843 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5845 local dir="$DIR/$tdir"
5847 test_mkdir "$dir" || error "cannot create dir $dir"
5849 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
5850 echo -n "Setting initial stripe for 20MB test file..."
5851 $LFS setstripe -c 2 -i 0 "$dir/20mb" || error "cannot setstripe"
5853 echo -n "Sizing 20MB test file..."
5854 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
5856 echo -n "Verifying small file autostripe count is 1..."
5857 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" &> /dev/null ||
5858 error "cannot migrate 20MB file"
5859 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
5860 error "cannot get stripe for $dir/20mb"
5861 [ $stripe_count -eq 1 ] ||
5862 error "unexpected stripe count $stripe_count for 20MB file"
5866 # Test 2: File is small enough to fit within the available space on
5867 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
5868 # have at least an additional 1KB for each desired stripe for test 3
5869 echo -n "Setting stripe for 1GB test file..."
5870 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe"
5872 echo -n "Sizing 1GB test file..."
5873 # File size is 1GB + 3KB
5874 truncate "$dir/1gb" 1073744896 &> /dev/null ||
5875 error "cannot create 1GB test file"
5877 echo -n "Migrating 1GB file..."
5878 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" &> /dev/null ||
5879 error "cannot migrate file"
5881 echo -n "Verifying autostripe count is sqrt(n) + 1..."
5882 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
5883 error "cannot get stripe for $dir/1gb"
5884 [ $stripe_count -eq 2 ] ||
5885 error "unexpected stripe count $stripe_count (expected 2)"
5888 # Test 3: File is too large to fit within the available space on
5889 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
5890 if [ $OSTCOUNT -ge 3 ]; then
5891 # The required available space is calculated as
5892 # file size (1GB + 3KB) / OST count (3).
5893 local kb_per_ost=349526
5895 echo -n "Migrating 1GB file..."
5896 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" &>> \
5897 /dev/null || error "cannot migrate file"
5900 stripe_count=$($LFS getstripe -c "$dir/1gb")
5901 echo -n "Verifying autostripe count with limited space..."
5902 [ "$stripe_count" -a $stripe_count -eq 3 ] ||
5903 error "unexpected stripe count $stripe_count (wanted 3)"
5910 run_test 56xc "lfs migration autostripe"
5913 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
5914 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
5917 local dir=$DIR/$tdir
5921 test_mkdir -p $dir || error "creating dir $dir"
5922 touch $f1 || error "creating std file $f1"
5923 $MULTIOP $f2 H2c || error "creating released file $f2"
5925 # a directory can be raid0, so ask only for files
5926 res=$($LFS find $dir -L raid0 -type f | wc -l)
5927 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5929 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
5930 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5932 # only files can be released, so no need to force file search
5933 res=$($LFS find $dir -L released)
5934 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5936 res=$($LFS find $dir -type f \! -L released)
5937 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5939 run_test 56y "lfs find -L raid0|released"
5941 test_56z() { # LU-4824
5942 # This checks to make sure 'lfs find' continues after errors
5943 # There are two classes of errors that should be caught:
5944 # - If multiple paths are provided, all should be searched even if one
5946 # - If errors are encountered during the search, it should not terminate
5948 local dir=$DIR/$tdir
5952 for i in d{0..9}; do
5955 touch $dir/d{0..9}/$tfile
5956 $LFS find $DIR/non_existent_dir $dir &&
5957 error "$LFS find did not return an error"
5958 # Make a directory unsearchable. This should NOT be the last entry in
5959 # directory order. Arbitrarily pick the 6th entry
5960 chmod 700 $($LFS find $dir -type d | sed '6!d')
5962 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
5964 # The user should be able to see 10 directories and 9 files
5965 [ $count == 19 ] || error "$LFS find did not continue after error"
5967 run_test 56z "lfs find should continue after an error"
5969 test_56aa() { # LU-5937
5970 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
5972 local dir=$DIR/$tdir
5975 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
5977 createmany -o $dir/striped_dir/${tfile}- 1024
5978 local dirs=$($LFS find --size +8k $dir/)
5980 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5982 run_test 56aa "lfs find --size under striped dir"
5984 test_56ab() { # LU-10705
5985 test_mkdir $DIR/$tdir
5986 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
5987 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
5988 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
5989 # Flush writes to ensure valid blocks. Need to be more thorough for
5990 # ZFS, since blocks are not allocated/returned to client immediately.
5992 wait_zfs_commit ost1 2
5993 cancel_lru_locks osc
5996 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
5998 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
6000 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
6001 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
6003 rm -f $DIR/$tdir/$tfile.[123]
6005 run_test 56ab "lfs find --blocks"
6008 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
6009 skip "Need MDS version at least 2.10.50"
6011 # Create composite files with one component
6012 local dir=$DIR/$tdir
6014 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
6015 # Create composite files with three components
6016 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
6017 # Create non-composite files
6018 createmany -o $dir/${tfile}- 10
6020 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
6022 [[ $nfiles == 10 ]] ||
6023 error "lfs find -E 1M found $nfiles != 10 files"
6025 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
6026 [[ $nfiles == 25 ]] ||
6027 error "lfs find ! -E 1M found $nfiles != 25 files"
6029 # All files have a component that starts at 0
6030 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
6031 [[ $nfiles == 35 ]] ||
6032 error "lfs find --component-start 0 - $nfiles != 35 files"
6034 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
6035 [[ $nfiles == 15 ]] ||
6036 error "lfs find --component-start 2M - $nfiles != 15 files"
6038 # All files created here have a componenet that does not starts at 2M
6039 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
6040 [[ $nfiles == 35 ]] ||
6041 error "lfs find ! --component-start 2M - $nfiles != 35 files"
6043 # Find files with a specified number of components
6044 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
6045 [[ $nfiles == 15 ]] ||
6046 error "lfs find --component-count 3 - $nfiles != 15 files"
6048 # Remember non-composite files have a component count of zero
6049 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
6050 [[ $nfiles == 10 ]] ||
6051 error "lfs find --component-count 0 - $nfiles != 10 files"
6053 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
6054 [[ $nfiles == 20 ]] ||
6055 error "lfs find ! --component-count 3 - $nfiles != 20 files"
6057 # All files have a flag called "init"
6058 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
6059 [[ $nfiles == 35 ]] ||
6060 error "lfs find --component-flags init - $nfiles != 35 files"
6062 # Multi-component files will have a component not initialized
6063 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
6064 [[ $nfiles == 15 ]] ||
6065 error "lfs find !--component-flags init - $nfiles != 15 files"
6070 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
6073 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
6074 skip "Need MDS version at least 2.10.57"
6084 # create mirrored directories and mirrored files
6085 mkdir $td || error "mkdir $td failed"
6086 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
6087 createmany -o $tf- 10 || error "create $tf- failed"
6089 for i in $(seq 2); do
6091 mkdir $dir || error "mkdir $dir failed"
6092 $LFS mirror create -N$((3 + i)) $dir ||
6093 error "create mirrored dir $dir failed"
6094 createmany -o $dir/$tfile- 10 ||
6095 error "create $dir/$tfile- failed"
6098 # change the states of some mirrored files
6100 for i in $(seq 2); do
6102 for j in $(seq 4 9); do
6103 echo foo > $dir/$tfile-$j
6107 # find mirrored files with specific mirror count
6108 cmd="$LFS find --mirror-count 3 --type f $td"
6109 nfiles=$($cmd | wc -l)
6110 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
6112 cmd="$LFS find ! --mirror-count 3 --type f $td"
6113 nfiles=$($cmd | wc -l)
6114 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
6116 cmd="$LFS find --mirror-count +2 --type f $td"
6117 nfiles=$($cmd | wc -l)
6118 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6120 cmd="$LFS find --mirror-count -6 --type f $td"
6121 nfiles=$($cmd | wc -l)
6122 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6124 # find mirrored files with specific file state
6125 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
6126 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
6128 cmd="$LFS find --mirror-state=ro --type f $td"
6129 nfiles=$($cmd | wc -l)
6130 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
6132 cmd="$LFS find ! --mirror-state=ro --type f $td"
6133 nfiles=$($cmd | wc -l)
6134 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6136 cmd="$LFS find --mirror-state=wp --type f $td"
6137 nfiles=$($cmd | wc -l)
6138 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6140 cmd="$LFS find ! --mirror-state=sp --type f $td"
6141 nfiles=$($cmd | wc -l)
6142 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6144 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6147 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6148 # note test will not do anything if MDS is not local
6149 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6150 skip_env "ldiskfs only test"
6152 remote_mds_nodsh && skip "remote MDS with nodsh"
6154 local MNTDEV="osd*.*MDT*.mntdev"
6155 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6156 [ -z "$DEV" ] && error "can't access $MNTDEV"
6157 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
6158 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
6159 error "can't access $DEV"
6160 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
6161 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
6165 run_test 57a "verify MDS filesystem created with large inodes =="
6168 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6169 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6170 skip_env "ldiskfs only test"
6172 remote_mds_nodsh && skip "remote MDS with nodsh"
6174 local dir=$DIR/$tdir
6177 local fileN=$dir/f$filecount
6179 rm -rf $dir || error "removing $dir"
6181 local mdtidx=$($LFS getstripe -m $dir)
6182 local mdtname=MDT$(printf %04x $mdtidx)
6183 local facet=mds$((mdtidx + 1))
6185 echo "mcreating $filecount files"
6186 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
6188 # verify that files do not have EAs yet
6189 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
6190 error "$file1 has an EA"
6191 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
6192 error "$fileN has an EA"
6196 df $dir #make sure we get new statfs data
6197 local mdsfree=$(do_facet $facet \
6198 lctl get_param -n osd*.*$mdtname.kbytesfree)
6199 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6202 echo "opening files to create objects/EAs"
6203 for file in $(seq -f $dir/f%g 1 $filecount); do
6204 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
6205 error "opening $file"
6208 # verify that files have EAs now
6209 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
6210 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
6212 sleep 1 #make sure we get new statfs data
6214 local mdsfree2=$(do_facet $facet \
6215 lctl get_param -n osd*.*$mdtname.kbytesfree)
6216 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6218 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
6219 if [ "$mdsfree" != "$mdsfree2" ]; then
6220 error "MDC before $mdcfree != after $mdcfree2"
6222 echo "MDC before $mdcfree != after $mdcfree2"
6223 echo "unable to confirm if MDS has large inodes"
6228 run_test 57b "default LOV EAs are stored inside large inodes ==="
6231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6232 [ -z "$(which wiretest 2>/dev/null)" ] &&
6233 skip_env "could not find wiretest"
6237 run_test 58 "verify cross-platform wire constants =============="
6240 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6242 echo "touch 130 files"
6243 createmany -o $DIR/f59- 130
6245 unlinkmany $DIR/f59- 130
6247 # wait for commitment of removal
6248 wait_delete_completed
6250 run_test 59 "verify cancellation of llog records async ========="
6252 TEST60_HEAD="test_60 run $RANDOM"
6254 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6255 remote_mgs_nodsh && skip "remote MGS with nodsh"
6256 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6257 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6258 skip_env "missing subtest run-llog.sh"
6260 log "$TEST60_HEAD - from kernel mode"
6261 do_facet mgs "$LCTL dk > /dev/null"
6262 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
6263 do_facet mgs $LCTL dk > $TMP/$tfile
6265 # LU-6388: test llog_reader
6266 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6267 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6268 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6269 skip_env "missing llog_reader"
6270 local fstype=$(facet_fstype mgs)
6271 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6272 skip_env "Only for ldiskfs or zfs type mgs"
6274 local mntpt=$(facet_mntpt mgs)
6275 local mgsdev=$(mgsdevname 1)
6287 #get fid and record list
6288 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6290 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6292 #remount mgs as ldiskfs or zfs type
6293 stop mgs || error "stop mgs failed"
6294 mount_fstype mgs || error "remount mgs failed"
6295 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6298 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6299 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6304 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6306 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6308 echo "obj_file is $obj_file"
6309 do_facet mgs $llog_reader $obj_file
6311 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6312 awk '{ print $3 }' | sed -e "s/^type=//g")
6313 if [ $rec_type != $rec ]; then
6314 echo "FAILED test_60a wrong record type $rec_type," \
6320 #check obj path if record type is LLOG_LOGID_MAGIC
6321 if [ "$rec" == "1064553b" ]; then
6322 path=$(do_facet mgs $llog_reader $obj_file |
6323 grep "path=" | awk '{ print $NF }' |
6324 sed -e "s/^path=//g")
6325 if [ $obj_file != $mntpt/$path ]; then
6326 echo "FAILED test_60a wrong obj path" \
6327 "$montpt/$path, should be $obj_file"
6334 #restart mgs before "error", otherwise it will block the next test
6335 stop mgs || error "stop mgs failed"
6336 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6337 $pass || error "test failed, see FAILED test_60a messages for specifics"
6339 run_test 60a "llog_test run from kernel module and test llog_reader"
6341 test_60b() { # bug 6411
6342 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6345 LLOG_COUNT=$(do_facet mgs dmesg |
6346 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6347 /llog_[a-z]*.c:[0-9]/ {
6359 [[ $LLOG_COUNT -gt 120 ]] &&
6360 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6362 run_test 60b "limit repeated messages from CERROR/CWARN"
6365 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6367 echo "create 5000 files"
6368 createmany -o $DIR/f60c- 5000
6369 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6370 lctl set_param fail_loc=0x80000137
6371 unlinkmany $DIR/f60c- 5000
6372 lctl set_param fail_loc=0
6374 run_test 60c "unlink file when mds full"
6377 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6379 SAVEPRINTK=$(lctl get_param -n printk)
6380 # verify "lctl mark" is even working"
6381 MESSAGE="test message ID $RANDOM $$"
6382 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6383 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6385 lctl set_param printk=0 || error "set lnet.printk failed"
6386 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6387 MESSAGE="new test message ID $RANDOM $$"
6388 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6389 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6390 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6392 lctl set_param -n printk="$SAVEPRINTK"
6394 run_test 60d "test printk console message masking"
6397 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6398 remote_mds_nodsh && skip "remote MDS with nodsh"
6401 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6402 do_facet mds1 lctl set_param fail_loc=0x15b
6405 run_test 60e "no space while new llog is being created"
6410 test_mkdir -c $MDSCOUNT $DIR/$tdir
6411 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir
6416 mkdir $DIR/$tdir/subdir$index 2>/dev/null
6417 rmdir $DIR/$tdir/subdir$index 2>/dev/null
6418 index=$((index + 1))
6424 for i in $(seq 100); do
6425 # define OBD_FAIL_OSD_TXN_START 0x19a
6426 do_facet mds1 lctl set_param fail_loc=0x8000019a
6432 mkdir $DIR/$tdir/new || error "mkdir failed"
6433 rmdir $DIR/$tdir/new || error "rmdir failed"
6435 run_test 60g "transaction abort won't cause MDT hung"
6438 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6441 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
6442 cancel_lru_locks osc
6443 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6446 run_test 61 "mmap() writes don't make sync hang ================"
6448 # bug 2330 - insufficient obd_match error checking causes LBUG
6450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6454 cancel_lru_locks osc
6455 lctl set_param fail_loc=0x405
6456 cat $f && error "cat succeeded, expect -EIO"
6457 lctl set_param fail_loc=0
6459 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6460 # match every page all of the time.
6461 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6463 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6464 # Though this test is irrelevant anymore, it helped to reveal some
6465 # other grant bugs (LU-4482), let's keep it.
6466 test_63a() { # was test_63
6467 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6469 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
6471 for i in `seq 10` ; do
6472 dd if=/dev/zero of=$DIR/f63 bs=8k &
6478 rm -f $DIR/f63 || true
6480 run_test 63a "Verify oig_wait interruption does not crash ======="
6482 # bug 2248 - async write errors didn't return to application on sync
6483 # bug 3677 - async write errors left page locked
6485 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6488 lctl set_param debug=-1
6490 # ensure we have a grant to do async writes
6491 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6494 sync # sync lest earlier test intercept the fail_loc
6496 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6497 lctl set_param fail_loc=0x80000406
6498 $MULTIOP $DIR/$tfile Owy && \
6499 error "sync didn't return ENOMEM"
6500 sync; sleep 2; sync # do a real sync this time to flush page
6501 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6502 error "locked page left in cache after async error" || true
6505 run_test 63b "async write errors should be returned to fsync ==="
6508 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6511 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6513 run_test 64a "verify filter grant calculations (in kernel) ====="
6516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6518 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6520 run_test 64b "check out-of-space detection on client"
6523 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6525 run_test 64c "verify grant shrink"
6527 # this does exactly what osc_request.c:osc_announce_cached() does in
6528 # order to calculate max amount of grants to ask from server
6532 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
6533 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
6535 ((rpc_in_flight ++));
6536 nrpages=$((nrpages * rpc_in_flight))
6538 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
6540 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
6542 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6543 local undirty=$((nrpages * PAGE_SIZE))
6545 local max_extent_pages
6546 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
6547 grep grant_max_extent_size | awk '{print $2}')
6548 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
6549 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6550 local grant_extent_tax
6551 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6552 grep grant_extent_tax | awk '{print $2}')
6554 undirty=$((undirty + nrextents * grant_extent_tax))
6559 # this is size of unit for grant allocation. It should be equal to
6560 # what tgt_grant.c:tgt_grant_chunk() calculates
6564 local grant_extent_tax
6566 max_brw_size=$($LCTL get_param osc.${tgt}.import |
6567 grep max_brw_size | awk '{print $2}')
6569 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6570 grep grant_extent_tax | awk '{print $2}')
6572 echo $(((max_brw_size + grant_extent_tax) * 2))
6576 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
6577 skip "OST < 2.10.55 doesn't limit grants enough"
6579 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
6580 local file=$DIR/$tfile
6582 [[ $($LCTL get_param osc.${tgt}.import |
6583 grep "connect_flags:.*grant_param") ]] ||
6584 skip "no grant_param connect flag"
6586 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
6588 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
6590 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
6591 stack_trap "rm -f $file" EXIT
6593 $LFS setstripe $file -i 0 -c 1
6594 dd if=/dev/zero of=$file bs=1M count=1000 &
6599 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
6600 if [[ $cur_grant -gt $max_cur_granted ]]
6603 error "cur_grant $cur_grant > $max_cur_granted"
6606 [[ $? -ne 0 ]] && break;
6611 wait_delete_completed
6612 $LCTL set_param debug="$olddebug" 2> /dev/null || true
6614 run_test 64d "check grant limit exceed"
6616 # bug 1414 - set/get directories' stripe info
6618 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6620 test_mkdir $DIR/$tdir
6622 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
6624 run_test 65a "directory with no stripe info"
6627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6629 test_mkdir $DIR/$tdir
6630 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
6632 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6635 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
6637 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
6640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6641 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
6643 test_mkdir $DIR/$tdir
6644 local stripesize=$($LFS getstripe -S $DIR/$tdir)
6646 $LFS setstripe -S $((stripesize * 4)) -i 1 \
6647 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
6649 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
6651 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
6654 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6656 test_mkdir $DIR/$tdir
6657 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
6658 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
6660 if [[ $STRIPECOUNT -le 0 ]]; then
6662 elif [[ $STRIPECOUNT -gt 2000 ]]; then
6663 #LOV_MAX_STRIPE_COUNT is 2000
6664 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
6666 sc=$(($STRIPECOUNT - 1))
6668 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
6669 touch $DIR/$tdir/f4 $DIR/$tdir/f5
6670 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
6671 error "lverify failed"
6673 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
6676 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6678 test_mkdir $DIR/$tdir
6680 $LFS setstripe $DIR/$tdir || error "setstripe"
6681 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6682 error "no stripe info failed"
6684 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
6686 run_test 65e "directory setstripe defaults"
6689 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6691 test_mkdir $DIR/${tdir}f
6692 $RUNAS $LFS setstripe $DIR/${tdir}f &&
6693 error "setstripe succeeded" || true
6695 run_test 65f "dir setstripe permission (should return error) ==="
6698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6700 test_mkdir $DIR/$tdir
6701 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
6703 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6704 error "setstripe -S failed"
6705 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
6706 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6707 error "delete default stripe failed"
6709 run_test 65g "directory setstripe -d"
6712 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6714 test_mkdir $DIR/$tdir
6715 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
6717 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6718 error "setstripe -S failed"
6719 test_mkdir $DIR/$tdir/dd1
6720 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
6721 error "stripe info inherit failed"
6723 run_test 65h "directory stripe info inherit ===================="
6726 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6728 save_layout_restore_at_exit $MOUNT
6730 # bug6367: set non-default striping on root directory
6731 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
6733 # bug12836: getstripe on -1 default directory striping
6734 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
6736 # bug12836: getstripe -v on -1 default directory striping
6737 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
6739 # bug12836: new find on -1 default directory striping
6740 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
6742 run_test 65i "various tests to set root directory striping"
6744 test_65j() { # bug6367
6745 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6749 # if we aren't already remounting for each test, do so for this test
6750 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
6751 cleanup || error "failed to unmount"
6755 save_layout_restore_at_exit $MOUNT
6757 $LFS setstripe -d $MOUNT || error "setstripe failed"
6759 run_test 65j "set default striping on root directory (bug 6367)="
6763 wait_delete_completed
6764 do_facet $SINGLEMDS "lctl set_param -n \
6765 osp.$ost*MDT0000.max_create_count=$max_count"
6766 do_facet $SINGLEMDS "lctl set_param -n \
6767 osp.$ost*MDT0000.create_count=$count"
6768 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6769 echo $INACTIVE_OSC "is Activate"
6771 wait_osc_import_state mds ost$ostnum FULL
6774 test_65k() { # bug11679
6775 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6776 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6777 remote_mds_nodsh && skip "remote MDS with nodsh"
6779 local disable_precreate=true
6780 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
6781 disable_precreate=false
6783 echo "Check OST status: "
6784 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
6785 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
6787 for OSC in $MDS_OSCS; do
6788 echo $OSC "is active"
6789 do_facet $SINGLEMDS lctl --device %$OSC activate
6792 for INACTIVE_OSC in $MDS_OSCS; do
6793 local ost=$(osc_to_ost $INACTIVE_OSC)
6794 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
6795 lov.*md*.target_obd |
6796 awk -F: /$ost/'{ print $1 }' | head -n 1)
6799 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
6800 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
6802 echo "Deactivate: " $INACTIVE_OSC
6803 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
6805 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
6806 osp.$ost*MDT0000.create_count")
6807 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
6808 osp.$ost*MDT0000.max_create_count")
6809 $disable_precreate &&
6810 do_facet $SINGLEMDS "lctl set_param -n \
6811 osp.$ost*MDT0000.max_create_count=0"
6813 for idx in $(seq 0 $((OSTCOUNT - 1))); do
6814 [ -f $DIR/$tdir/$idx ] && continue
6815 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
6816 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
6818 error "setstripe $idx should succeed"; }
6819 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
6821 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
6824 do_facet $SINGLEMDS "lctl set_param -n \
6825 osp.$ost*MDT0000.max_create_count=$max_count"
6826 do_facet $SINGLEMDS "lctl set_param -n \
6827 osp.$ost*MDT0000.create_count=$count"
6828 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6829 echo $INACTIVE_OSC "is Activate"
6831 wait_osc_import_state mds ost$ostnum FULL
6834 run_test 65k "validate manual striping works properly with deactivated OSCs"
6836 test_65l() { # bug 12836
6837 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6839 test_mkdir -p $DIR/$tdir/test_dir
6840 $LFS setstripe -c -1 $DIR/$tdir/test_dir
6841 $LFS find -mtime -1 $DIR/$tdir >/dev/null
6843 run_test 65l "lfs find on -1 stripe dir ========================"
6846 local layout=$(save_layout $MOUNT)
6847 $RUNAS $LFS setstripe -c 2 $MOUNT && {
6848 restore_layout $MOUNT $layout
6849 error "setstripe should fail by non-root users"
6853 run_test 65m "normal user can't set filesystem default stripe"
6856 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
6857 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.12.50) ]] ||
6858 skip "Need MDS version at least 2.12.50"
6859 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
6861 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
6862 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
6863 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
6865 local root_layout=$(save_layout $MOUNT)
6866 stack_trap "restore_layout $MOUNT $root_layout" EXIT
6868 # new subdirectory under root directory should not inherit
6869 # the default layout from root
6870 local dir1=$MOUNT/$tdir-1
6871 mkdir $dir1 || error "mkdir $dir1 failed"
6872 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
6873 error "$dir1 shouldn't have LOV EA"
6875 # delete the default layout on root directory
6876 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
6878 local dir2=$MOUNT/$tdir-2
6879 mkdir $dir2 || error "mkdir $dir2 failed"
6880 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
6881 error "$dir2 shouldn't have LOV EA"
6883 # set a new striping pattern on root directory
6884 local def_stripe_size=$($LFS getstripe -S $MOUNT)
6885 local new_def_stripe_size=$((def_stripe_size * 2))
6886 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
6887 error "set stripe size on $MOUNT failed"
6889 # new file created in $dir2 should inherit the new stripe size from
6890 # the filesystem default
6891 local file2=$dir2/$tfile-2
6892 touch $file2 || error "touch $file2 failed"
6894 local file2_stripe_size=$($LFS getstripe -S $file2)
6895 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
6896 error "$file2 didn't inherit stripe size $new_def_stripe_size"
6898 local dir3=$MOUNT/$tdir-3
6899 mkdir $dir3 || error "mkdir $dir3 failed"
6900 ! getfattr -n trusted.lov $dir3 &> /dev/null ||
6901 error "$dir3 shouldn't have LOV EA"
6903 # set OST pool on root directory
6904 local pool=$TESTNAME
6905 pool_add $pool || error "add $pool failed"
6906 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
6907 error "add targets to $pool failed"
6909 $LFS setstripe -p $pool $MOUNT ||
6910 error "set OST pool on $MOUNT failed"
6912 # new file created in $dir3 should inherit the pool from
6913 # the filesystem default
6914 local file3=$dir3/$tfile-3
6915 touch $file3 || error "touch $file3 failed"
6917 local file3_pool=$($LFS getstripe -p $file3)
6918 [[ "$file3_pool" = "$pool" ]] ||
6919 error "$file3 didn't inherit OST pool $pool"
6921 local dir4=$MOUNT/$tdir-4
6922 mkdir $dir4 || error "mkdir $dir4 failed"
6923 ! getfattr -n trusted.lov $dir4 &> /dev/null ||
6924 error "$dir4 shouldn't have LOV EA"
6926 # new file created in $dir4 should inherit the pool from
6927 # the filesystem default
6928 local file4=$dir4/$tfile-4
6929 touch $file4 || error "touch $file4 failed"
6931 local file4_pool=$($LFS getstripe -p $file4)
6932 [[ "$file4_pool" = "$pool" ]] ||
6933 error "$file4 didn't inherit OST pool $pool"
6935 # new subdirectory under non-root directory should inherit
6936 # the default layout from its parent directory
6937 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
6938 error "set directory layout on $dir4 failed"
6940 local dir5=$dir4/$tdir-5
6941 mkdir $dir5 || error "mkdir $dir5 failed"
6943 local dir4_layout=$(get_layout_param $dir4)
6944 local dir5_layout=$(get_layout_param $dir5)
6945 [[ "$dir4_layout" = "$dir5_layout" ]] ||
6946 error "$dir5 should inherit the default layout from $dir4"
6948 run_test 65n "don't inherit default layout from root for new subdirectories"
6950 # bug 2543 - update blocks count on client
6952 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6955 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6956 sync; sync_all_data; sync; sync_all_data
6957 cancel_lru_locks osc
6958 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6959 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6961 run_test 66 "update inode blocks count on client ==============="
6964 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6968 swapon -s | awk '($1 == "'$1'") { print $4 }'
6971 # bug5265, obdfilter oa2dentry return -ENOENT
6972 # #define OBD_FAIL_SRV_ENOENT 0x217
6974 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6975 remote_ost_nodsh && skip "remote OST with nodsh"
6978 $LFS setstripe -c 1 -i 0 $f
6980 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6982 do_facet ost1 lctl set_param fail_loc=0x217
6983 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6984 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6986 do_facet ost1 lctl set_param fail_loc=0
6987 $DIRECTIO write $f 0 2 || error "write error"
6989 cancel_lru_locks osc
6990 $DIRECTIO read $f 0 1 || error "read error"
6992 do_facet ost1 lctl set_param fail_loc=0x217
6993 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6995 do_facet ost1 lctl set_param fail_loc=0
6998 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
7001 test_mkdir $DIR/$tdir
7002 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
7003 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
7005 run_test 71 "Running dbench on lustre (don't segment fault) ===="
7007 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
7008 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7009 [ "$RUNAS_ID" = "$UID" ] &&
7010 skip_env "RUNAS_ID = UID = $UID -- skipping"
7011 # Check that testing environment is properly set up. Skip if not
7012 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
7013 skip_env "User $RUNAS_ID does not exist - skipping"
7016 chmod 777 $DIR/$tfile
7017 chmod ug+s $DIR/$tfile
7018 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
7019 error "$RUNAS dd $DIR/$tfile failed"
7020 # See if we are still setuid/sgid
7021 test -u $DIR/$tfile -o -g $DIR/$tfile &&
7022 error "S/gid is not dropped on write"
7023 # Now test that MDS is updated too
7024 cancel_lru_locks mdc
7025 test -u $DIR/$tfile -o -g $DIR/$tfile &&
7026 error "S/gid is not dropped on MDS"
7029 run_test 72a "Test that remove suid works properly (bug5695) ===="
7031 test_72b() { # bug 24226 -- keep mode setting when size is not changing
7034 [ "$RUNAS_ID" = "$UID" ] &&
7035 skip_env "RUNAS_ID = UID = $UID -- skipping"
7036 [ "$RUNAS_ID" -eq 0 ] &&
7037 skip_env "RUNAS_ID = 0 -- skipping"
7038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7039 # Check that testing environment is properly set up. Skip if not
7040 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
7041 skip_env "User $RUNAS_ID does not exist - skipping"
7043 touch $DIR/${tfile}-f{g,u}
7044 test_mkdir $DIR/${tfile}-dg
7045 test_mkdir $DIR/${tfile}-du
7046 chmod 770 $DIR/${tfile}-{f,d}{g,u}
7047 chmod g+s $DIR/${tfile}-{f,d}g
7048 chmod u+s $DIR/${tfile}-{f,d}u
7049 for perm in 777 2777 4777; do
7050 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
7051 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
7052 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
7053 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
7057 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
7059 # bug 3462 - multiple simultaneous MDC requests
7061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7063 test_mkdir $DIR/d73-1
7064 test_mkdir $DIR/d73-2
7065 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
7068 lctl set_param fail_loc=0x80000129
7069 $MULTIOP $DIR/d73-1/f73-2 Oc &
7071 lctl set_param fail_loc=0
7073 $MULTIOP $DIR/d73-2/f73-3 Oc &
7077 wait $pid1 || return 1
7081 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
7082 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
7083 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
7087 run_test 73 "multiple MDC requests (should not deadlock)"
7089 test_74a() { # bug 6149, 6184
7090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7093 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7095 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7096 # will spin in a tight reconnection loop
7097 $LCTL set_param fail_loc=0x8000030e
7098 # get any lock that won't be difficult - lookup works.
7100 $LCTL set_param fail_loc=0
7104 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
7106 test_74b() { # bug 13310
7107 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7109 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7111 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7112 # will spin in a tight reconnection loop
7113 $LCTL set_param fail_loc=0x8000030e
7114 # get a "difficult" lock
7116 $LCTL set_param fail_loc=0
7120 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
7123 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7125 #define OBD_FAIL_LDLM_NEW_LOCK
7126 $LCTL set_param fail_loc=0x319
7127 touch $DIR/$tfile && error "touch successful"
7128 $LCTL set_param fail_loc=0
7131 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
7134 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
7137 test_76() { # Now for bug 20433, added originally in bug 1443
7138 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7140 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
7142 cancel_lru_locks osc
7143 BEFORE_INODES=$(num_inodes)
7144 echo "before inodes: $BEFORE_INODES"
7146 [ "$SLOW" = "no" ] && COUNT=100
7147 for i in $(seq $COUNT); do
7151 cancel_lru_locks osc
7152 AFTER_INODES=$(num_inodes)
7153 echo "after inodes: $AFTER_INODES"
7155 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
7157 AFTER_INODES=$(num_inodes)
7159 echo "wait $wait seconds inodes: $AFTER_INODES"
7160 if [ $wait -gt 30 ]; then
7161 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
7165 run_test 76 "confirm clients recycle inodes properly ===="
7171 # Note: in sptlrpc modes which enable its own bulk checksum, the
7172 # original crc32_le bulk checksum will be automatically disabled,
7173 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
7174 # will be checked by sptlrpc code against sptlrpc bulk checksum.
7175 # In this case set_checksums() will not be no-op, because sptlrpc
7176 # bulk checksum will be enabled all through the test.
7178 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
7179 lctl set_param -n osc.*.checksums $1
7183 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7184 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
7185 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7186 tr -d [] | head -n1)}
7189 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
7190 log "set checksum type to $1"
7193 F77_TMP=$TMP/f77-temp
7196 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
7197 error "error writing to $F77_TMP"
7200 test_77a() { # bug 10889
7201 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7202 $GSS && skip_env "could not run with gss"
7204 [ ! -f $F77_TMP ] && setup_f77
7206 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
7210 run_test 77a "normal checksum read/write operation"
7212 test_77b() { # bug 10889
7213 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7214 $GSS && skip_env "could not run with gss"
7216 [ ! -f $F77_TMP ] && setup_f77
7217 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7218 $LCTL set_param fail_loc=0x80000409
7221 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7222 error "dd error: $?"
7223 $LCTL set_param fail_loc=0
7225 for algo in $CKSUM_TYPES; do
7226 cancel_lru_locks osc
7227 set_checksum_type $algo
7228 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7229 $LCTL set_param fail_loc=0x80000408
7230 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7231 $LCTL set_param fail_loc=0
7234 set_checksum_type $ORIG_CSUM_TYPE
7237 run_test 77b "checksum error on client write, read"
7242 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7244 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7245 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7246 $check_ost && [ -n "$ost_file_prefix" ] &&
7247 do_facet ost1 rm -f ${ost_file_prefix}\*
7251 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7252 $GSS && skip_env "could not run with gss"
7253 remote_ost_nodsh && skip "remote OST with nodsh"
7256 local osc_file_prefix
7258 local check_ost=false
7259 local ost_file_prefix
7265 # ensure corruption will occur on first OSS/OST
7266 $LFS setstripe -i 0 $DIR/$tfile
7268 [ ! -f $F77_TMP ] && setup_f77
7269 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7270 error "dd write error: $?"
7271 fid=$($LFS path2fid $DIR/$tfile)
7273 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
7276 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7277 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7279 echo "OSS do not support bulk pages dump upon error"
7282 osc_file_prefix=$($LCTL get_param -n debug_path)
7283 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7285 trap cleanup_77c EXIT
7288 # enable bulk pages dump upon error on Client
7289 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7290 # enable bulk pages dump upon error on OSS
7292 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7294 # flush Client cache to allow next read to reach OSS
7295 cancel_lru_locks osc
7297 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7298 $LCTL set_param fail_loc=0x80000408
7299 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7300 $LCTL set_param fail_loc=0
7304 # check cksum dump on Client
7305 osc_file=$(ls ${osc_file_prefix}*)
7306 [ -n "$osc_file" ] || error "no checksum dump file on Client"
7307 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
7308 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
7309 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
7310 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
7312 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
7313 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7314 error "dump content does not match on Client"
7316 $check_ost || skip "No need to check cksum dump on OSS"
7318 # check cksum dump on OSS
7319 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
7320 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
7321 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
7322 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
7323 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7324 error "dump content does not match on OSS"
7328 run_test 77c "checksum error on client read with debug"
7330 test_77d() { # bug 10889
7331 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7332 $GSS && skip_env "could not run with gss"
7334 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7335 $LCTL set_param fail_loc=0x80000409
7337 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7338 error "direct write: rc=$?"
7339 $LCTL set_param fail_loc=0
7342 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7343 $LCTL set_param fail_loc=0x80000408
7345 cancel_lru_locks osc
7346 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7347 error "direct read: rc=$?"
7348 $LCTL set_param fail_loc=0
7351 run_test 77d "checksum error on OST direct write, read"
7353 test_77f() { # bug 10889
7354 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7355 $GSS && skip_env "could not run with gss"
7358 for algo in $CKSUM_TYPES; do
7359 cancel_lru_locks osc
7360 set_checksum_type $algo
7361 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7362 $LCTL set_param fail_loc=0x409
7363 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
7364 error "direct write succeeded"
7365 $LCTL set_param fail_loc=0
7367 set_checksum_type $ORIG_CSUM_TYPE
7370 run_test 77f "repeat checksum error on write (expect error)"
7372 test_77g() { # bug 10889
7373 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7374 $GSS && skip_env "could not run with gss"
7375 remote_ost_nodsh && skip "remote OST with nodsh"
7377 [ ! -f $F77_TMP ] && setup_f77
7379 local file=$DIR/$tfile
7380 stack_trap "rm -f $file" EXIT
7382 $LFS setstripe -c 1 -i 0 $file
7383 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
7384 do_facet ost1 lctl set_param fail_loc=0x8000021a
7386 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
7387 error "write error: rc=$?"
7388 do_facet ost1 lctl set_param fail_loc=0
7391 cancel_lru_locks osc
7392 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
7393 do_facet ost1 lctl set_param fail_loc=0x8000021b
7395 cmp $F77_TMP $file || error "file compare failed"
7396 do_facet ost1 lctl set_param fail_loc=0
7399 run_test 77g "checksum error on OST write, read"
7401 test_77k() { # LU-10906
7402 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7403 $GSS && skip_env "could not run with gss"
7405 local cksum_param="osc.$FSNAME*.checksums"
7406 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
7410 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
7411 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
7412 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
7416 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
7417 error "failed to set checksum=$i on MGS"
7418 wait_update $HOSTNAME "$get_checksum" $i
7420 echo "remount client, checksum should be $i"
7421 remount_client $MOUNT || "failed to remount client"
7422 checksum=$(eval $get_checksum)
7423 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7425 # remove persistent param to avoid races with checksum mountopt below
7426 do_facet mgs $LCTL set_param -P -d $cksum_param ||
7427 error "failed to delete checksum on MGS"
7429 for opt in "checksum" "nochecksum"; do
7430 #remount with mount option
7431 echo "remount client with option $opt, checksum should be $i"
7432 umount_client $MOUNT || "failed to umount client"
7433 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
7434 "failed to mount client with option '$opt'"
7435 checksum=$(eval $get_checksum)
7436 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7440 remount_client $MOUNT || "failed to remount client"
7442 run_test 77k "enable/disable checksum correctly"
7444 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
7453 test_78() { # bug 10901
7454 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7455 remote_ost || skip_env "local OST"
7458 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
7459 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
7460 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
7461 echo "MemTotal: $MEMTOTAL"
7463 # reserve 256MB of memory for the kernel and other running processes,
7464 # and then take 1/2 of the remaining memory for the read/write buffers.
7465 if [ $MEMTOTAL -gt 512 ] ;then
7466 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
7468 # for those poor memory-starved high-end clusters...
7469 MEMTOTAL=$((MEMTOTAL / 2))
7471 echo "Mem to use for directio: $MEMTOTAL"
7473 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
7474 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
7475 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
7476 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
7478 echo "Smallest OST: $SMALLESTOST"
7479 [[ $SMALLESTOST -lt 10240 ]] &&
7480 skip "too small OSTSIZE, useless to run large O_DIRECT test"
7482 trap cleanup_test_78 EXIT
7484 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
7485 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
7487 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
7488 echo "File size: $F78SIZE"
7489 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
7490 for i in $(seq 1 $NSEQ); do
7491 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
7492 echo directIO rdwr round $i of $NSEQ
7493 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
7498 run_test 78 "handle large O_DIRECT writes correctly ============"
7500 test_79() { # bug 12743
7501 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7503 wait_delete_completed
7505 BKTOTAL=$(calc_osc_kbytes kbytestotal)
7506 BKFREE=$(calc_osc_kbytes kbytesfree)
7507 BKAVAIL=$(calc_osc_kbytes kbytesavail)
7509 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
7510 DFTOTAL=`echo $STRING | cut -d, -f1`
7511 DFUSED=`echo $STRING | cut -d, -f2`
7512 DFAVAIL=`echo $STRING | cut -d, -f3`
7513 DFFREE=$(($DFTOTAL - $DFUSED))
7515 ALLOWANCE=$((64 * $OSTCOUNT))
7517 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
7518 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
7519 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
7521 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
7522 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
7523 error "df free($DFFREE) mismatch OST free($BKFREE)"
7525 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
7526 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
7527 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
7530 run_test 79 "df report consistency check ======================="
7532 test_80() { # bug 10718
7533 remote_ost_nodsh && skip "remote OST with nodsh"
7534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7536 # relax strong synchronous semantics for slow backends like ZFS
7537 local soc="obdfilter.*.sync_on_lock_cancel"
7538 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
7540 if [ "$soc_old" != "never" ] &&
7541 [ "$ost1_FSTYPE" != "ldiskfs" ]; then
7542 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
7543 facet_active_host $host; done | sort -u)
7544 do_nodes $hosts lctl set_param $soc=never
7547 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
7549 local BEFORE=`date +%s`
7550 cancel_lru_locks osc
7551 local AFTER=`date +%s`
7552 local DIFF=$((AFTER-BEFORE))
7553 if [ $DIFF -gt 1 ] ; then
7554 error "elapsed for 1M@1T = $DIFF"
7557 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
7561 run_test 80 "Page eviction is equally fast at high offsets too ===="
7563 test_81a() { # LU-456
7564 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7565 remote_ost_nodsh && skip "remote OST with nodsh"
7567 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7568 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
7569 do_facet ost1 lctl set_param fail_loc=0x80000228
7571 # write should trigger a retry and success
7572 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7573 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7575 if [ $RC -ne 0 ] ; then
7576 error "write should success, but failed for $RC"
7579 run_test 81a "OST should retry write when get -ENOSPC ==============="
7581 test_81b() { # LU-456
7582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7583 remote_ost_nodsh && skip "remote OST with nodsh"
7585 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7586 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
7587 do_facet ost1 lctl set_param fail_loc=0x228
7589 # write should retry several times and return -ENOSPC finally
7590 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7591 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7594 if [ $RC -ne $ENOSPC ] ; then
7595 error "dd should fail for -ENOSPC, but succeed."
7598 run_test 81b "OST should return -ENOSPC when retry still fails ======="
7600 test_82() { # LU-1031
7601 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
7605 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
7607 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
7609 kill -USR1 $MULTIPID2
7611 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
7612 error "First grouplock does not block second one"
7614 echo "Second grouplock blocks first one"
7616 kill -USR1 $MULTIPID1
7620 run_test 82 "Basic grouplock test"
7623 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
7625 test_mkdir $DIR/$tdir.cvsroot
7626 chown $RUNAS_ID $DIR/$tdir.cvsroot
7629 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
7632 # some versions of cvs import exit(1) when asked to import links or
7633 # files they can't read. ignore those files.
7634 local toignore=$(find . -type l -printf '-I %f\n' -o \
7635 ! -perm /4 -printf '-I %f\n')
7636 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
7637 $tdir.reposname vtag rtag
7640 test_mkdir $DIR/$tdir.reposname
7641 chown $RUNAS_ID $DIR/$tdir.reposname
7642 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
7644 cd $DIR/$tdir.reposname
7646 $RUNAS cvs add -m 'addmsg' foo99
7648 $RUNAS cvs commit -m 'nomsg' foo99
7649 rm -fr $DIR/$tdir.cvsroot
7651 run_test 99 "cvs strange file/directory operations"
7654 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7655 [[ "$NETTYPE" =~ tcp ]] ||
7656 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
7657 remote_ost_nodsh && skip "remote OST with nodsh"
7658 remote_mds_nodsh && skip "remote MDS with nodsh"
7660 skip "useless for local single node setup"
7662 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
7663 [ "$PROT" != "tcp" ] && continue
7664 RPORT=$(echo $REMOTE | cut -d: -f2)
7665 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
7668 LPORT=`echo $LOCAL | cut -d: -f2`
7669 if [ $LPORT -ge 1024 ]; then
7670 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
7672 error_exit "local: $LPORT > 1024, remote: $RPORT"
7675 [ "$rc" = 0 ] || error_exit "privileged port not found" )
7677 run_test 100 "check local port using privileged port ==========="
7679 function get_named_value()
7688 echo $line | sed "s/^$tag[ ]*//"
7695 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
7696 awk '/^max_cached_mb/ { print $2 }')
7699 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
7704 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7705 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
7710 local cache_limit=32
7712 $LCTL set_param -n osc.*-osc*.rpc_stats 0
7713 trap cleanup_101a EXIT
7714 $LCTL set_param -n llite.*.read_ahead_stats 0
7715 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
7718 # randomly read 10000 of 64K chunks from file 3x 32MB in size
7720 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
7721 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
7724 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
7725 get_named_value 'read but discarded' | cut -d" " -f1); do
7726 discard=$(($discard + $s))
7730 if [[ $(($discard * 10)) -gt $nreads ]]; then
7731 $LCTL get_param osc.*-osc*.rpc_stats
7732 $LCTL get_param llite.*.read_ahead_stats
7733 error "too many ($discard) discarded pages"
7735 rm -f $DIR/$tfile || true
7737 run_test 101a "check read-ahead for random reads"
7740 test_mkdir $DIR/$tdir
7742 local FILE_LENGTH=$2
7745 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
7747 local list=$(comma_list $(osts_nodes))
7748 set_osd_param $list '' read_cache_enable 0
7749 set_osd_param $list '' writethrough_cache_enable 0
7751 trap cleanup_test101bc EXIT
7752 # prepare the read-ahead file
7753 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
7755 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
7756 count=$FILE_SIZE_MB 2> /dev/null
7760 cleanup_test101bc() {
7765 local list=$(comma_list $(osts_nodes))
7766 set_osd_param $list '' read_cache_enable 1
7767 set_osd_param $list '' writethrough_cache_enable 1
7771 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
7776 local STRIPE_SIZE=$2
7777 local FILE_LENGTH=$3
7778 local RA_INC=1048576
7779 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
7780 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
7781 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
7782 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
7783 get_named_value 'read but discarded' |
7784 cut -d" " -f1 | calc_total)
7785 if [[ $DISCARD -gt $discard_limit ]]; then
7786 $LCTL get_param llite.*.read_ahead_stats
7787 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
7789 echo "Read-ahead success for size ${READ_SIZE}"
7794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7795 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7797 local STRIPE_SIZE=1048576
7798 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
7800 if [ $SLOW == "yes" ]; then
7801 local FILE_LENGTH=$((STRIDE_SIZE * 64))
7803 local FILE_LENGTH=$((STRIDE_SIZE * 8))
7806 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
7808 # prepare the read-ahead file
7809 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7810 cancel_lru_locks osc
7811 for BIDX in 2 4 8 16 32 64 128 256
7813 local BSIZE=$((BIDX*4096))
7814 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
7815 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
7816 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
7817 $LCTL set_param -n llite.*.read_ahead_stats 0
7818 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
7819 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
7820 cancel_lru_locks osc
7821 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
7826 run_test 101b "check stride-io mode read-ahead ================="
7829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7831 local STRIPE_SIZE=1048576
7832 local FILE_LENGTH=$((STRIPE_SIZE*100))
7837 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7839 cancel_lru_locks osc
7840 $LCTL set_param osc.*.rpc_stats 0
7841 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
7842 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
7843 local stats=$($LCTL get_param -n $osc_rpc_stats)
7844 local lines=$(echo "$stats" | awk 'END {print NR;}')
7847 if [ $lines -le 20 ]; then
7850 for size in 1 2 4 8; do
7851 local rpc=$(echo "$stats" |
7852 awk '($1 == "'$size':") {print $2; exit; }')
7853 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
7854 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
7856 echo "$osc_rpc_stats check passed!"
7861 run_test 101c "check stripe_size aligned read-ahead ================="
7864 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
7865 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
7869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7871 local file=$DIR/$tfile
7872 local sz_MB=${FILESIZE_101d:-500}
7873 local ra_MB=${READAHEAD_MB:-40}
7875 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
7876 [ $free_MB -lt $sz_MB ] &&
7877 skip "Need free space ${sz_MB}M, have ${free_MB}M"
7879 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
7880 $LFS setstripe -c -1 $file || error "setstripe failed"
7882 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
7883 echo Cancel LRU locks on lustre client to flush the client cache
7884 cancel_lru_locks osc
7886 echo Disable read-ahead
7887 local old_READAHEAD=$(set_read_ahead 0)
7889 echo Reading the test file $file with read-ahead disabled
7890 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7892 echo Cancel LRU locks on lustre client to flush the client cache
7893 cancel_lru_locks osc
7894 echo Enable read-ahead with ${ra_MB}MB
7895 set_read_ahead $ra_MB
7897 echo Reading the test file $file with read-ahead enabled
7898 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7900 echo "read-ahead disabled time read $raOFF"
7901 echo "read-ahead enabled time read $raON"
7903 set_read_ahead $old_READAHEAD
7905 wait_delete_completed
7907 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
7908 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
7910 run_test 101d "file read with and without read-ahead enabled"
7913 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7915 local file=$DIR/$tfile
7916 local size_KB=500 #KB
7920 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
7921 local need_KB=$((count * size_KB))
7922 [[ $free_KB -le $need_KB ]] &&
7923 skip_env "Need free space $need_KB, have $free_KB"
7925 echo "Creating $count ${size_KB}K test files"
7926 for ((i = 0; i < $count; i++)); do
7927 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
7930 echo "Cancel LRU locks on lustre client to flush the client cache"
7931 cancel_lru_locks $OSC
7933 echo "Reset readahead stats"
7934 $LCTL set_param -n llite.*.read_ahead_stats 0
7936 for ((i = 0; i < $count; i++)); do
7937 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
7940 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7941 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7943 for ((i = 0; i < $count; i++)); do
7944 rm -rf $file.$i 2>/dev/null
7947 #10000 means 20% reads are missing in readahead
7948 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
7950 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
7953 which iozone || skip_env "no iozone installed"
7955 local old_debug=$($LCTL get_param debug)
7956 old_debug=${old_debug#*=}
7957 $LCTL set_param debug="reada mmap"
7959 # create a test file
7960 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
7962 echo Cancel LRU locks on lustre client to flush the client cache
7963 cancel_lru_locks osc
7965 echo Reset readahead stats
7966 $LCTL set_param -n llite.*.read_ahead_stats 0
7968 echo mmap read the file with small block size
7969 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
7972 echo checking missing pages
7973 $LCTL get_param llite.*.read_ahead_stats
7974 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7975 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7977 $LCTL set_param debug="$old_debug"
7978 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7981 run_test 101f "check mmap read performance"
7983 test_101g_brw_size_test() {
7985 local pages=$((mb * 1048576 / PAGE_SIZE))
7986 local file=$DIR/$tfile
7988 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7989 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7990 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7991 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7995 stack_trap "rm -f $file" EXIT
7996 $LCTL set_param -n osc.*.rpc_stats=0
7998 # 10 RPCs should be enough for the test
8000 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
8001 { error "dd write ${mb} MB blocks failed"; return 3; }
8002 cancel_lru_locks osc
8003 dd of=/dev/null if=$file bs=${mb}M count=$count ||
8004 { error "dd write ${mb} MB blocks failed"; return 4; }
8006 # calculate number of full-sized read and write RPCs
8007 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
8008 sed -n '/pages per rpc/,/^$/p' |
8009 awk '/'$pages':/ { reads += $2; writes += $6 }; \
8010 END { print reads,writes }'))
8011 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
8013 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
8020 remote_ost_nodsh && skip "remote OST with nodsh"
8023 local osts=$(get_facets OST)
8024 local list=$(comma_list $(osts_nodes))
8025 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8026 local brw_size="obdfilter.*.brw_size"
8028 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8030 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
8031 if [ $OST1_VERSION -ge $(version_code 2.8.52) -o \
8032 \( $OST1_VERSION -ge $(version_code 2.7.17) -a \
8033 $OST1_VERSION -lt $(version_code 2.7.50) \) ] &&
8034 [ $CLIENT_VERSION -ge $(version_code 2.8.52) -o \
8035 \( $CLIENT_VERSION -ge $(version_code 2.7.17) -a \
8036 $CLIENT_VERSION -lt $(version_code 2.7.50) \) ]; then
8037 [ $OST1_VERSION -ge $(version_code 2.9.52) ] && suffix="M"
8038 if [[ $orig_mb -lt 16 ]]; then
8039 save_lustre_params $osts "$brw_size" > $p
8040 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
8041 error "set 16MB RPC size failed"
8043 echo "remount client to enable new RPC size"
8044 remount_client $MOUNT || error "remount_client failed"
8047 test_101g_brw_size_test 16 || error "16MB RPC test failed"
8048 # should be able to set brw_size=12, but no rpc_stats for that
8049 test_101g_brw_size_test 8 || error "8MB RPC test failed"
8052 test_101g_brw_size_test 4 || error "4MB RPC test failed"
8054 if [[ $orig_mb -lt 16 ]]; then
8055 restore_lustre_params < $p
8056 remount_client $MOUNT || error "remount_client restore failed"
8059 rm -f $p $DIR/$tfile
8061 run_test 101g "Big bulk(4/16 MiB) readahead"
8064 test_mkdir $DIR/$tdir
8065 chown $RUNAS_ID $DIR/$tdir
8068 STRIPE_COUNT=$OSTCOUNT
8069 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
8071 trap cleanup_test102 EXIT
8073 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
8075 for num in 1 2 3 4; do
8076 for count in $(seq 1 $STRIPE_COUNT); do
8077 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
8078 local size=`expr $STRIPE_SIZE \* $num`
8079 local file=file"$num-$idx-$count"
8080 $1 $LFS setstripe -S $size -i $idx -c $count $file
8086 $1 tar cf $TMP/f102.tar $tdir --xattrs
8092 rm -rf $DIR/d0.sanity/d102
8096 [ "$UID" != 0 ] && skip "must run as root"
8097 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
8098 skip_env "must have user_xattr"
8100 [ -z "$(which setfattr 2>/dev/null)" ] &&
8101 skip_env "could not find setfattr"
8103 local testfile=$DIR/$tfile
8106 echo "set/get xattr..."
8107 setfattr -n trusted.name1 -v value1 $testfile ||
8108 error "setfattr -n trusted.name1=value1 $testfile failed"
8109 getfattr -n trusted.name1 $testfile 2> /dev/null |
8110 grep "trusted.name1=.value1" ||
8111 error "$testfile missing trusted.name1=value1"
8113 setfattr -n user.author1 -v author1 $testfile ||
8114 error "setfattr -n user.author1=author1 $testfile failed"
8115 getfattr -n user.author1 $testfile 2> /dev/null |
8116 grep "user.author1=.author1" ||
8117 error "$testfile missing trusted.author1=author1"
8120 setfattr -n trusted.name2 -v value2 $testfile ||
8121 error "$testfile unable to set trusted.name2"
8122 setfattr -n trusted.name3 -v value3 $testfile ||
8123 error "$testfile unable to set trusted.name3"
8124 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
8125 grep "trusted.name" | wc -l) -eq 3 ] ||
8126 error "$testfile missing 3 trusted.name xattrs"
8128 setfattr -n user.author2 -v author2 $testfile ||
8129 error "$testfile unable to set user.author2"
8130 setfattr -n user.author3 -v author3 $testfile ||
8131 error "$testfile unable to set user.author3"
8132 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
8133 grep "user.author" | wc -l) -eq 3 ] ||
8134 error "$testfile missing 3 user.author xattrs"
8136 echo "remove xattr..."
8137 setfattr -x trusted.name1 $testfile ||
8138 error "$testfile error deleting trusted.name1"
8139 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
8140 error "$testfile did not delete trusted.name1 xattr"
8142 setfattr -x user.author1 $testfile ||
8143 error "$testfile error deleting user.author1"
8144 echo "set lustre special xattr ..."
8145 $LFS setstripe -c1 $testfile
8146 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
8147 awk -F "=" '/trusted.lov/ { print $2 }' )
8148 setfattr -n "trusted.lov" -v $lovea $testfile ||
8149 error "$testfile doesn't ignore setting trusted.lov again"
8150 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
8151 error "$testfile allow setting invalid trusted.lov"
8154 run_test 102a "user xattr test =================================="
8157 [ -z "$(which setfattr 2>/dev/null)" ] &&
8158 skip_env "could not find setfattr"
8159 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8161 # b10930: get/set/list trusted.lov xattr
8162 echo "get/set/list trusted.lov xattr ..."
8163 local testfile=$DIR/$tfile
8164 $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8165 error "setstripe failed"
8166 local STRIPECOUNT=$($LFS getstripe -c $testfile) ||
8167 error "getstripe failed"
8168 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
8169 error "can't get trusted.lov from $testfile"
8171 local testfile2=${testfile}2
8172 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
8173 grep "trusted.lov" | sed -e 's/[^=]\+=//')
8176 setfattr -n trusted.lov -v $value $testfile2
8177 local stripe_size=$($LFS getstripe -S $testfile2)
8178 local stripe_count=$($LFS getstripe -c $testfile2)
8179 [[ $stripe_size -eq 65536 ]] ||
8180 error "stripe size $stripe_size != 65536"
8181 [[ $stripe_count -eq $STRIPECOUNT ]] ||
8182 error "stripe count $stripe_count != $STRIPECOUNT"
8185 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
8188 [ -z "$(which setfattr 2>/dev/null)" ] &&
8189 skip_env "could not find setfattr"
8190 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8192 # b10930: get/set/list lustre.lov xattr
8193 echo "get/set/list lustre.lov xattr ..."
8194 test_mkdir $DIR/$tdir
8195 chown $RUNAS_ID $DIR/$tdir
8196 local testfile=$DIR/$tdir/$tfile
8197 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8198 error "setstripe failed"
8199 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
8200 error "getstripe failed"
8201 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
8202 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
8204 local testfile2=${testfile}2
8205 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
8206 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8208 $RUNAS $MCREATE $testfile2
8209 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8210 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
8211 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
8212 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8213 [ $stripe_count -eq $STRIPECOUNT ] ||
8214 error "stripe count $stripe_count != $STRIPECOUNT"
8216 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8218 compare_stripe_info1() {
8219 local stripe_index_all_zero=true
8221 for num in 1 2 3 4; do
8222 for count in $(seq 1 $STRIPE_COUNT); do
8223 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8224 local size=$((STRIPE_SIZE * num))
8225 local file=file"$num-$offset-$count"
8226 stripe_size=$($LFS getstripe -S $PWD/$file)
8227 [[ $stripe_size -ne $size ]] &&
8228 error "$file: size $stripe_size != $size"
8229 stripe_count=$($LFS getstripe -c $PWD/$file)
8230 # allow fewer stripes to be created, ORI-601
8231 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8232 error "$file: count $stripe_count != $count"
8233 stripe_index=$($LFS getstripe -i $PWD/$file)
8234 [[ $stripe_index -ne 0 ]] &&
8235 stripe_index_all_zero=false
8239 $stripe_index_all_zero &&
8240 error "all files are being extracted starting from OST index 0"
8244 have_xattrs_include() {
8245 tar --help | grep -q xattrs-include &&
8246 echo --xattrs-include="lustre.*"
8250 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8251 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8253 XINC=$(have_xattrs_include)
8255 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8257 compare_stripe_info1
8259 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8262 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8263 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8265 XINC=$(have_xattrs_include)
8267 test_mkdir $DIR/$tdir.restore
8269 tar cf - --xattrs $tdir | tar xf - \
8270 -C $DIR/$tdir.restore --xattrs $XINC
8271 cd $DIR/$tdir.restore/$tdir
8272 compare_stripe_info1
8274 run_test 102f "tar copy files, not keep osts"
8277 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8278 skip "must have user_xattr"
8279 [ -z "$(which setfattr 2>/dev/null)" ] &&
8280 skip_env "could not find setfattr"
8281 [ -z "$(which getfattr 2>/dev/null)" ] &&
8282 skip_env "could not find getfattr"
8284 local xsize=${1:-1024} # in bytes
8285 local file=$DIR/$tfile
8286 local value="$(generate_string $xsize)"
8287 local xbig=trusted.big
8290 log "save $xbig on $file"
8291 setfattr -n $xbig -v $value $file ||
8292 error "saving $xbig on $file failed"
8294 local orig=$(get_xattr_value $xbig $file)
8295 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
8297 local xsml=trusted.sml
8298 log "save $xsml on $file"
8299 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
8301 local new=$(get_xattr_value $xbig $file)
8302 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
8304 log "grow $xsml on $file"
8305 setfattr -n $xsml -v "$value" $file ||
8306 error "growing $xsml on $file failed"
8308 new=$(get_xattr_value $xbig $file)
8309 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
8310 log "$xbig still valid after growing $xsml"
8315 test_102h() { # bug 15777
8318 run_test 102h "grow xattr from inside inode to external block"
8321 large_xattr_enabled || skip_env "ea_inode feature disabled"
8323 grow_xattr $(max_xattr_size)
8325 run_test 102ha "grow xattr from inside inode to external inode"
8327 test_102i() { # bug 17038
8328 [ -z "$(which getfattr 2>/dev/null)" ] &&
8329 skip "could not find getfattr"
8332 ln -s $DIR/$tfile $DIR/${tfile}link
8333 getfattr -n trusted.lov $DIR/$tfile ||
8334 error "lgetxattr on $DIR/$tfile failed"
8335 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
8336 grep -i "no such attr" ||
8337 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
8338 rm -f $DIR/$tfile $DIR/${tfile}link
8340 run_test 102i "lgetxattr test on symbolic link ============"
8343 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8344 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8346 XINC=$(have_xattrs_include)
8347 setup_test102 "$RUNAS"
8348 chown $RUNAS_ID $DIR/$tdir
8349 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8351 compare_stripe_info1 "$RUNAS"
8353 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
8356 [ -z "$(which setfattr 2>/dev/null)" ] &&
8357 skip "could not find setfattr"
8360 # b22187 just check that does not crash for regular file.
8361 setfattr -n trusted.lov $DIR/$tfile
8362 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
8363 local test_kdir=$DIR/$tdir
8364 test_mkdir $test_kdir
8365 local default_size=$($LFS getstripe -S $test_kdir)
8366 local default_count=$($LFS getstripe -c $test_kdir)
8367 local default_offset=$($LFS getstripe -i $test_kdir)
8368 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
8369 error 'dir setstripe failed'
8370 setfattr -n trusted.lov $test_kdir
8371 local stripe_size=$($LFS getstripe -S $test_kdir)
8372 local stripe_count=$($LFS getstripe -c $test_kdir)
8373 local stripe_offset=$($LFS getstripe -i $test_kdir)
8374 [ $stripe_size -eq $default_size ] ||
8375 error "stripe size $stripe_size != $default_size"
8376 [ $stripe_count -eq $default_count ] ||
8377 error "stripe count $stripe_count != $default_count"
8378 [ $stripe_offset -eq $default_offset ] ||
8379 error "stripe offset $stripe_offset != $default_offset"
8380 rm -rf $DIR/$tfile $test_kdir
8382 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
8385 [ -z "$(which getfattr 2>/dev/null)" ] &&
8386 skip "could not find getfattr"
8388 # LU-532 trusted. xattr is invisible to non-root
8389 local testfile=$DIR/$tfile
8393 echo "listxattr as user..."
8394 chown $RUNAS_ID $testfile
8395 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
8396 grep -q "trusted" &&
8397 error "$testfile trusted xattrs are user visible"
8401 run_test 102l "listxattr size test =================================="
8403 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
8404 local path=$DIR/$tfile
8407 listxattr_size_check $path || error "listattr_size_check $path failed"
8409 run_test 102m "Ensure listxattr fails on small bufffer ========"
8413 getxattr() { # getxattr path name
8414 # Return the base64 encoding of the value of xattr name on path.
8418 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
8420 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8422 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8424 getfattr --absolute-names --encoding=base64 --name=$name $path |
8425 awk -F= -v name=$name '$1 == name {
8426 print substr($0, index($0, "=") + 1);
8430 test_102n() { # LU-4101 mdt: protect internal xattrs
8431 [ -z "$(which setfattr 2>/dev/null)" ] &&
8432 skip "could not find setfattr"
8433 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
8435 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
8438 local file0=$DIR/$tfile.0
8439 local file1=$DIR/$tfile.1
8440 local xattr0=$TMP/$tfile.0
8441 local xattr1=$TMP/$tfile.1
8442 local namelist="lov lma lmv link fid version som hsm"
8446 rm -rf $file0 $file1 $xattr0 $xattr1
8449 # Get 'before' xattrs of $file1.
8450 getfattr --absolute-names --dump --match=- $file1 > $xattr0
8452 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
8453 namelist+=" lfsck_namespace"
8454 for name in $namelist; do
8455 # Try to copy xattr from $file0 to $file1.
8456 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8458 setfattr --name=trusted.$name --value="$value" $file1 ||
8459 error "setxattr 'trusted.$name' failed"
8461 # Try to set a garbage xattr.
8462 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8464 if [[ x$name == "xlov" ]]; then
8465 setfattr --name=trusted.lov --value="$value" $file1 &&
8466 error "setxattr invalid 'trusted.lov' success"
8468 setfattr --name=trusted.$name --value="$value" $file1 ||
8469 error "setxattr invalid 'trusted.$name' failed"
8472 # Try to remove the xattr from $file1. We don't care if this
8473 # appears to succeed or fail, we just don't want there to be
8474 # any changes or crashes.
8475 setfattr --remove=$trusted.$name $file1 2> /dev/null
8478 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
8481 # Try to copy xattr from $file0 to $file1.
8482 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8484 setfattr --name=trusted.$name --value="$value" $file1 ||
8485 error "setxattr 'trusted.$name' failed"
8487 # Try to set a garbage xattr.
8488 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8490 setfattr --name=trusted.$name --value="$value" $file1 ||
8491 error "setxattr 'trusted.$name' failed"
8493 # Try to remove the xattr from $file1. We don't care if this
8494 # appears to succeed or fail, we just don't want there to be
8495 # any changes or crashes.
8496 setfattr --remove=$trusted.$name $file1 2> /dev/null
8499 # Get 'after' xattrs of file1.
8500 getfattr --absolute-names --dump --match=- $file1 > $xattr1
8502 if ! diff $xattr0 $xattr1; then
8503 error "before and after xattrs of '$file1' differ"
8506 rm -rf $file0 $file1 $xattr0 $xattr1
8510 run_test 102n "silently ignore setxattr on internal trusted xattrs"
8512 test_102p() { # LU-4703 setxattr did not check ownership
8513 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
8514 skip "MDS needs to be at least 2.5.56"
8516 local testfile=$DIR/$tfile
8520 echo "setfacl as user..."
8521 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
8522 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
8524 echo "setfattr as user..."
8525 setfacl -m "u:$RUNAS_ID:---" $testfile
8526 $RUNAS setfattr -x system.posix_acl_access $testfile
8527 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
8529 run_test 102p "check setxattr(2) correctly fails without permission"
8532 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
8533 skip "MDS needs to be at least 2.6.92"
8535 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
8537 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
8540 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
8541 skip "MDS needs to be at least 2.6.93"
8543 touch $DIR/$tfile || error "touch"
8544 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
8545 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
8546 rm $DIR/$tfile || error "rm"
8549 mkdir -p $DIR/$tdir || error "mkdir"
8550 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8551 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8552 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8553 error "$testfile error deleting user.author1"
8554 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8555 grep "user.$(basename $tdir)" &&
8556 error "$tdir did not delete user.$(basename $tdir)"
8557 rmdir $DIR/$tdir || error "rmdir"
8560 test_mkdir $DIR/$tdir
8561 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8562 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8563 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8564 error "$testfile error deleting user.author1"
8565 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8566 grep "user.$(basename $tdir)" &&
8567 error "$tdir did not delete user.$(basename $tdir)"
8568 rmdir $DIR/$tdir || error "rm striped dir"
8570 run_test 102r "set EAs with empty values"
8573 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
8574 skip "MDS needs to be at least 2.11.52"
8576 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
8578 save_lustre_params client "llite.*.xattr_cache" > $save
8580 for cache in 0 1; do
8581 lctl set_param llite.*.xattr_cache=$cache
8584 touch $DIR/$tfile || error "touch"
8585 for prefix in lustre security system trusted user; do
8586 # Note getxattr() may fail with 'Operation not
8587 # supported' or 'No such attribute' depending
8588 # on prefix and cache.
8589 getfattr -n $prefix.n102s $DIR/$tfile &&
8590 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
8594 restore_lustre_params < $save
8596 run_test 102s "getting nonexistent xattrs should fail"
8599 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
8600 skip "MDS needs to be at least 2.11.52"
8602 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
8604 save_lustre_params client "llite.*.xattr_cache" > $save
8606 for cache in 0 1; do
8607 lctl set_param llite.*.xattr_cache=$cache
8609 for buf_size in 0 256; do
8611 touch $DIR/$tfile || error "touch"
8612 setfattr -n user.multiop $DIR/$tfile
8613 $MULTIOP $DIR/$tfile oa$buf_size ||
8614 error "cannot get zero length xattr value (buf_size = $buf_size)"
8618 restore_lustre_params < $save
8620 run_test 102t "zero length xattr values handled correctly"
8624 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
8629 [ "$UID" != 0 ] && skip "must run as root"
8630 $GSS && skip_env "could not run under gss"
8631 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
8632 skip_env "must have acl enabled"
8633 [ -z "$(which setfacl 2>/dev/null)" ] &&
8634 skip_env "could not find setfacl"
8635 remote_mds_nodsh && skip "remote MDS with nodsh"
8637 gpasswd -a daemon bin # LU-5641
8638 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
8640 declare -a identity_old
8642 for num in $(seq $MDSCOUNT); do
8643 switch_identity $num true || identity_old[$num]=$?
8651 echo "performing cp ..."
8652 run_acl_subtest cp || error "run_acl_subtest cp failed"
8653 echo "performing getfacl-noacl..."
8654 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
8655 echo "performing misc..."
8656 run_acl_subtest misc || error "misc test failed"
8657 echo "performing permissions..."
8658 run_acl_subtest permissions || error "permissions failed"
8659 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
8660 if [ $MDS1_VERSION -gt $(version_code 2.8.55) -o \
8661 \( $MDS1_VERSION -lt $(version_code 2.6) -a \
8662 $MDS1_VERSION -ge $(version_code 2.5.29) \) ]
8664 echo "performing permissions xattr..."
8665 run_acl_subtest permissions_xattr ||
8666 error "permissions_xattr failed"
8668 echo "performing setfacl..."
8669 run_acl_subtest setfacl || error "setfacl test failed"
8671 # inheritance test got from HP
8672 echo "performing inheritance..."
8673 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
8674 chmod +x make-tree || error "chmod +x failed"
8675 run_acl_subtest inheritance || error "inheritance test failed"
8678 echo "LU-974 ignore umask when acl is enabled..."
8679 run_acl_subtest 974 || error "LU-974 umask test failed"
8680 if [ $MDSCOUNT -ge 2 ]; then
8681 run_acl_subtest 974_remote ||
8682 error "LU-974 umask test failed under remote dir"
8685 echo "LU-2561 newly created file is same size as directory..."
8686 if [ "$mds1_FSTYPE" != "zfs" ]; then
8687 run_acl_subtest 2561 || error "LU-2561 test failed"
8689 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
8692 run_acl_subtest 4924 || error "LU-4924 test failed"
8697 for num in $(seq $MDSCOUNT); do
8698 if [ "${identity_old[$num]}" = 1 ]; then
8699 switch_identity $num false || identity_old[$num]=$?
8703 run_test 103a "acl test"
8709 for U in {0..511}; do
8711 local O=$(printf "%04o" $U)
8713 umask $(printf "%04o" $((511 ^ $O)))
8714 $LFS setstripe -c 1 $DIR/$tfile.s$O
8715 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
8717 (( $S == ($O & 0666) )) ||
8718 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
8720 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
8721 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
8722 (( $S == ($O & 0666) )) ||
8723 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
8725 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
8726 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
8727 (( $S == ($O & 0666) )) ||
8728 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
8729 rm -f $DIR/$tfile.[smp]$0
8733 # limit the concurrently running threads to 64. LU-11878
8734 local idx=$((U % 64))
8735 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
8740 run_test 103b "umask lfs setstripe"
8744 cp -rp $DIR/$tdir $DIR/$tdir.bak
8746 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
8747 error "$DIR/$tdir shouldn't contain default ACL"
8748 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
8749 error "$DIR/$tdir.bak shouldn't contain default ACL"
8752 run_test 103c "'cp -rp' won't set empty acl"
8755 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8758 lfs df || error "lfs df failed"
8759 lfs df -ih || error "lfs df -ih failed"
8760 lfs df -h $DIR || error "lfs df -h $DIR failed"
8761 lfs df -i $DIR || error "lfs df -i $DIR failed"
8762 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
8763 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
8765 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
8766 lctl --device %$OSC deactivate
8767 lfs df || error "lfs df with deactivated OSC failed"
8768 lctl --device %$OSC activate
8769 # wait the osc back to normal
8770 wait_osc_import_ready client ost
8772 lfs df || error "lfs df with reactivated OSC failed"
8775 run_test 104a "lfs df [-ih] [path] test ========================="
8778 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8779 [ $RUNAS_ID -eq $UID ] &&
8780 skip_env "RUNAS_ID = UID = $UID -- skipping"
8782 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
8783 grep "Permission denied" | wc -l)))
8784 if [ $denied_cnt -ne 0 ]; then
8785 error "lfs check servers test failed"
8788 run_test 104b "$RUNAS lfs check servers test ===================="
8791 # doesn't work on 2.4 kernels
8793 if $(flock_is_enabled); then
8794 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
8796 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
8800 run_test 105a "flock when mounted without -o flock test ========"
8804 if $(flock_is_enabled); then
8805 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
8807 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
8811 run_test 105b "fcntl when mounted without -o flock test ========"
8815 if $(flock_is_enabled); then
8816 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
8818 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
8822 run_test 105c "lockf when mounted without -o flock test"
8824 test_105d() { # bug 15924
8825 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8827 test_mkdir $DIR/$tdir
8828 flock_is_enabled || skip_env "mount w/o flock enabled"
8829 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
8830 $LCTL set_param fail_loc=0x80000315
8831 flocks_test 2 $DIR/$tdir
8833 run_test 105d "flock race (should not freeze) ========"
8835 test_105e() { # bug 22660 && 22040
8836 flock_is_enabled || skip_env "mount w/o flock enabled"
8839 flocks_test 3 $DIR/$tfile
8841 run_test 105e "Two conflicting flocks from same process"
8843 test_106() { #bug 10921
8844 test_mkdir $DIR/$tdir
8845 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
8846 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
8848 run_test 106 "attempt exec of dir followed by chown of that dir"
8851 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8859 local save_pattern=$(sysctl -n kernel.core_pattern)
8860 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
8861 sysctl -w kernel.core_pattern=$file
8862 sysctl -w kernel.core_uses_pid=0
8870 kill -s 11 $SLEEPPID
8872 if [ -e $file ]; then
8873 size=`stat -c%s $file`
8874 [ $size -eq 0 ] && error "Fail to create core file $file"
8876 error "Fail to create core file $file"
8879 sysctl -w kernel.core_pattern=$save_pattern
8880 sysctl -w kernel.core_uses_pid=$save_uses_pid
8883 run_test 107 "Coredump on SIG"
8886 test_mkdir $DIR/$tdir
8887 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
8888 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
8889 error "mkdir with 256 char should fail, but did not"
8890 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
8891 error "create with 255 char failed"
8892 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
8893 error "create with 256 char should fail, but did not"
8898 run_test 110 "filename length checking"
8901 # Purpose: To verify dynamic thread (OSS) creation.
8904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8905 remote_ost_nodsh && skip "remote OST with nodsh"
8907 # Lustre does not stop service threads once they are started.
8908 # Reset number of running threads to default.
8913 local save_params="$TMP/sanity-$TESTNAME.parameters"
8915 # Get ll_ost_io count before I/O
8916 OSTIO_pre=$(do_facet ost1 \
8917 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
8918 # Exit if lustre is not running (ll_ost_io not running).
8919 [ -z "$OSTIO_pre" ] && error "no OSS threads"
8921 echo "Starting with $OSTIO_pre threads"
8922 local thread_max=$((OSTIO_pre * 2))
8923 local rpc_in_flight=$((thread_max * 2))
8924 # Number of I/O Process proposed to be started.
8926 local facets=$(get_facets OST)
8928 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
8929 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
8931 # Set in_flight to $rpc_in_flight
8932 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
8933 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
8934 nfiles=${rpc_in_flight}
8935 # Set ost thread_max to $thread_max
8936 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
8938 # 5 Minutes should be sufficient for max number of OSS
8939 # threads(thread_max) to be created.
8943 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
8944 test_mkdir $DIR/$tdir
8945 for i in $(seq $nfiles); do
8946 local file=$DIR/$tdir/${tfile}-$i
8947 $LFS setstripe -c -1 -i 0 $file
8948 ($WTL $file $timeout)&
8951 # I/O Started - Wait for thread_started to reach thread_max or report
8952 # error if thread_started is more than thread_max.
8953 echo "Waiting for thread_started to reach thread_max"
8954 local thread_started=0
8955 local end_time=$((SECONDS + timeout))
8957 while [ $SECONDS -le $end_time ] ; do
8959 # Get ost i/o thread_started count.
8960 thread_started=$(do_facet ost1 \
8962 ost.OSS.ost_io.threads_started | cut -d= -f2")
8963 # Break out if thread_started is equal/greater than thread_max
8964 if [[ $thread_started -ge $thread_max ]]; then
8965 echo ll_ost_io thread_started $thread_started, \
8966 equal/greater than thread_max $thread_max
8972 # Cleanup - We have the numbers, Kill i/o jobs if running.
8973 jobcount=($(jobs -p))
8974 for i in $(seq 0 $((${#jobcount[@]}-1)))
8976 kill -9 ${jobcount[$i]}
8977 if [ $? -ne 0 ] ; then
8979 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
8983 # Cleanup files left by WTL binary.
8984 for i in $(seq $nfiles); do
8985 local file=$DIR/$tdir/${tfile}-$i
8987 if [ $? -ne 0 ] ; then
8988 echo "Warning: Failed to delete file $file"
8992 restore_lustre_params <$save_params
8993 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
8995 # Error out if no new thread has started or Thread started is greater
8997 if [[ $thread_started -le $OSTIO_pre ||
8998 $thread_started -gt $thread_max ]]; then
8999 error "ll_ost_io: thread_started $thread_started" \
9000 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
9001 "No new thread started or thread started greater " \
9005 run_test 115 "verify dynamic thread creation===================="
9008 wait_delete_completed
9009 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
9010 echo "OST kbytes available: ${AVAIL[@]}"
9015 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
9016 #echo OST $i: ${AVAIL[i]}kb
9017 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
9021 if [[ ${AVAIL[i]} -lt $MINV ]]; then
9026 echo "Min free space: OST $MINI: $MINV"
9027 echo "Max free space: OST $MAXI: $MAXV"
9030 test_116a() { # was previously test_116()
9031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9032 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9033 remote_mds_nodsh && skip "remote MDS with nodsh"
9035 echo -n "Free space priority "
9036 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
9041 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
9042 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
9043 trap simple_cleanup_common EXIT
9045 # Check if we need to generate uneven OSTs
9046 test_mkdir -p $DIR/$tdir/OST${MINI}
9047 local FILL=$((MINV / 4))
9048 local DIFF=$((MAXV - MINV))
9049 local DIFF2=$((DIFF * 100 / MINV))
9051 local threshold=$(do_facet $SINGLEMDS \
9052 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
9053 threshold=${threshold%%%}
9054 echo -n "Check for uneven OSTs: "
9055 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
9057 if [[ $DIFF2 -gt $threshold ]]; then
9059 echo "Don't need to fill OST$MINI"
9061 # generate uneven OSTs. Write 2% over the QOS threshold value
9063 DIFF=$((threshold - DIFF2 + 2))
9064 DIFF2=$((MINV * DIFF / 100))
9065 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
9066 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
9067 error "setstripe failed"
9068 DIFF=$((DIFF2 / 2048))
9070 while [ $i -lt $DIFF ]; do
9072 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
9073 bs=2M count=1 2>/dev/null
9082 DIFF=$((MAXV - MINV))
9083 DIFF2=$((DIFF * 100 / MINV))
9084 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
9085 if [ $DIFF2 -gt $threshold ]; then
9088 echo "failed - QOS mode won't be used"
9089 simple_cleanup_common
9090 skip "QOS imbalance criteria not met"
9098 # now fill using QOS
9099 $LFS setstripe -c 1 $DIR/$tdir
9100 FILL=$((FILL / 200))
9101 if [ $FILL -gt 600 ]; then
9104 echo "writing $FILL files to QOS-assigned OSTs"
9106 while [ $i -lt $FILL ]; do
9108 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
9112 echo "wrote $i 200k files"
9116 echo "Note: free space may not be updated, so measurements might be off"
9118 DIFF2=$((MAXV - MINV))
9119 echo "free space delta: orig $DIFF final $DIFF2"
9120 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
9121 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
9122 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
9123 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
9124 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
9125 if [[ $DIFF -gt 0 ]]; then
9126 FILL=$((DIFF2 * 100 / DIFF - 100))
9127 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
9130 # Figure out which files were written where
9131 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9132 awk '/'$MINI1': / {print $2; exit}')
9134 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9135 echo "$MINC files created on smaller OST $MINI1"
9136 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9137 awk '/'$MAXI1': / {print $2; exit}')
9139 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9140 echo "$MAXC files created on larger OST $MAXI1"
9141 if [[ $MINC -gt 0 ]]; then
9142 FILL=$((MAXC * 100 / MINC - 100))
9143 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
9145 [[ $MAXC -gt $MINC ]] ||
9146 error_ignore LU-9 "stripe QOS didn't balance free space"
9147 simple_cleanup_common
9149 run_test 116a "stripe QOS: free space balance ==================="
9151 test_116b() { # LU-2093
9152 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9153 remote_mds_nodsh && skip "remote MDS with nodsh"
9155 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
9156 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
9157 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
9158 [ -z "$old_rr" ] && skip "no QOS"
9159 do_facet $SINGLEMDS lctl set_param \
9160 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
9162 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
9163 createmany -o $DIR/$tdir/f- 20 || error "can't create"
9164 do_facet $SINGLEMDS lctl set_param fail_loc=0
9166 do_facet $SINGLEMDS lctl set_param \
9167 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
9169 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
9171 test_117() # bug 10891
9173 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9175 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
9176 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
9177 lctl set_param fail_loc=0x21e
9178 > $DIR/$tfile || error "truncate failed"
9179 lctl set_param fail_loc=0
9180 echo "Truncate succeeded."
9183 run_test 117 "verify osd extend =========="
9185 NO_SLOW_RESENDCOUNT=4
9186 export OLD_RESENDCOUNT=""
9187 set_resend_count () {
9188 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
9189 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
9190 lctl set_param -n $PROC_RESENDCOUNT $1
9191 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
9194 # for reduce test_118* time (b=14842)
9195 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9197 # Reset async IO behavior after error case
9199 FILE=$DIR/reset_async
9201 # Ensure all OSCs are cleared
9202 $LFS setstripe -c -1 $FILE
9203 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
9208 test_118a() #bug 11710
9210 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9214 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9215 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9216 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9218 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9219 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9224 run_test 118a "verify O_SYNC works =========="
9228 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9229 remote_ost_nodsh && skip "remote OST with nodsh"
9233 #define OBD_FAIL_SRV_ENOENT 0x217
9234 set_nodes_failloc "$(osts_nodes)" 0x217
9235 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9237 set_nodes_failloc "$(osts_nodes)" 0
9238 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9239 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9242 if [[ $RC -eq 0 ]]; then
9243 error "Must return error due to dropped pages, rc=$RC"
9247 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9248 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9252 echo "Dirty pages not leaked on ENOENT"
9254 # Due to the above error the OSC will issue all RPCs syncronously
9255 # until a subsequent RPC completes successfully without error.
9256 $MULTIOP $DIR/$tfile Ow4096yc
9261 run_test 118b "Reclaim dirty pages on fatal error =========="
9265 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9267 # for 118c, restore the original resend count, LU-1940
9268 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
9269 set_resend_count $OLD_RESENDCOUNT
9270 remote_ost_nodsh && skip "remote OST with nodsh"
9274 #define OBD_FAIL_OST_EROFS 0x216
9275 set_nodes_failloc "$(osts_nodes)" 0x216
9277 # multiop should block due to fsync until pages are written
9278 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9282 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9283 error "Multiop failed to block on fsync, pid=$MULTIPID"
9286 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9288 if [[ $WRITEBACK -eq 0 ]]; then
9289 error "No page in writeback, writeback=$WRITEBACK"
9292 set_nodes_failloc "$(osts_nodes)" 0
9295 if [[ $RC -ne 0 ]]; then
9296 error "Multiop fsync failed, rc=$RC"
9299 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9300 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9302 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9303 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9307 echo "Dirty pages flushed via fsync on EROFS"
9310 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
9312 # continue to use small resend count to reduce test_118* time (b=14842)
9313 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9317 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9318 remote_ost_nodsh && skip "remote OST with nodsh"
9322 #define OBD_FAIL_OST_BRW_PAUSE_BULK
9323 set_nodes_failloc "$(osts_nodes)" 0x214
9324 # multiop should block due to fsync until pages are written
9325 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9329 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9330 error "Multiop failed to block on fsync, pid=$MULTIPID"
9333 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9335 if [[ $WRITEBACK -eq 0 ]]; then
9336 error "No page in writeback, writeback=$WRITEBACK"
9339 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
9340 set_nodes_failloc "$(osts_nodes)" 0
9342 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9343 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9345 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9346 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9350 echo "Dirty pages gaurenteed flushed via fsync"
9353 run_test 118d "Fsync validation inject a delay of the bulk =========="
9356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9360 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
9361 lctl set_param fail_loc=0x8000040a
9363 # Should simulate EINVAL error which is fatal
9364 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9366 if [[ $RC -eq 0 ]]; then
9367 error "Must return error due to dropped pages, rc=$RC"
9370 lctl set_param fail_loc=0x0
9372 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9373 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9374 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9376 if [[ $LOCKED -ne 0 ]]; then
9377 error "Locked pages remain in cache, locked=$LOCKED"
9380 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9381 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9385 echo "No pages locked after fsync"
9390 run_test 118f "Simulate unrecoverable OSC side error =========="
9393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9397 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9398 lctl set_param fail_loc=0x406
9400 # simulate local -ENOMEM
9401 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9404 lctl set_param fail_loc=0
9405 if [[ $RC -eq 0 ]]; then
9406 error "Must return error due to dropped pages, rc=$RC"
9409 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9410 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9411 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9413 if [[ $LOCKED -ne 0 ]]; then
9414 error "Locked pages remain in cache, locked=$LOCKED"
9417 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9418 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9422 echo "No pages locked after fsync"
9427 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
9430 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9431 remote_ost_nodsh && skip "remote OST with nodsh"
9435 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9436 set_nodes_failloc "$(osts_nodes)" 0x20e
9437 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9438 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9441 set_nodes_failloc "$(osts_nodes)" 0
9442 if [[ $RC -eq 0 ]]; then
9443 error "Must return error due to dropped pages, rc=$RC"
9446 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9447 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9448 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9450 if [[ $LOCKED -ne 0 ]]; then
9451 error "Locked pages remain in cache, locked=$LOCKED"
9454 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9455 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9459 echo "No pages locked after fsync"
9463 run_test 118h "Verify timeout in handling recoverables errors =========="
9465 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9468 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9469 remote_ost_nodsh && skip "remote OST with nodsh"
9473 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9474 set_nodes_failloc "$(osts_nodes)" 0x20e
9476 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9477 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9480 set_nodes_failloc "$(osts_nodes)" 0
9484 if [[ $RC -ne 0 ]]; then
9485 error "got error, but should be not, rc=$RC"
9488 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9489 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9490 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9491 if [[ $LOCKED -ne 0 ]]; then
9492 error "Locked pages remain in cache, locked=$LOCKED"
9495 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9496 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9500 echo "No pages locked after fsync"
9504 run_test 118i "Fix error before timeout in recoverable error =========="
9506 [ "$SLOW" = "no" ] && set_resend_count 4
9509 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9510 remote_ost_nodsh && skip "remote OST with nodsh"
9514 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
9515 set_nodes_failloc "$(osts_nodes)" 0x220
9517 # return -EIO from OST
9518 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9520 set_nodes_failloc "$(osts_nodes)" 0x0
9521 if [[ $RC -eq 0 ]]; then
9522 error "Must return error due to dropped pages, rc=$RC"
9525 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9526 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9527 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9528 if [[ $LOCKED -ne 0 ]]; then
9529 error "Locked pages remain in cache, locked=$LOCKED"
9532 # in recoverable error on OST we want resend and stay until it finished
9533 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9534 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9538 echo "No pages locked after fsync"
9542 run_test 118j "Simulate unrecoverable OST side error =========="
9546 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9547 remote_ost_nodsh && skip "remote OSTs with nodsh"
9549 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9550 set_nodes_failloc "$(osts_nodes)" 0x20e
9551 test_mkdir $DIR/$tdir
9553 for ((i=0;i<10;i++)); do
9554 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
9555 error "dd to $DIR/$tdir/$tfile-$i failed" )&
9562 set_nodes_failloc "$(osts_nodes)" 0
9565 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
9567 test_118l() # LU-646
9569 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9571 test_mkdir $DIR/$tdir
9572 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
9575 run_test 118l "fsync dir"
9577 test_118m() # LU-3066
9579 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9581 test_mkdir $DIR/$tdir
9582 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
9585 run_test 118m "fdatasync dir ========="
9587 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9595 remote_ost_nodsh && skip "remote OSTs with nodsh"
9597 # Sleep to avoid a cached response.
9598 #define OBD_STATFS_CACHE_SECONDS 1
9601 # Inject a 10 second delay in the OST_STATFS handler.
9602 #define OBD_FAIL_OST_STATFS_DELAY 0x242
9603 set_nodes_failloc "$(osts_nodes)" 0x242
9606 stat --file-system $MOUNT > /dev/null
9609 set_nodes_failloc "$(osts_nodes)" 0
9611 if ((end - begin > 20)); then
9612 error "statfs took $((end - begin)) seconds, expected 10"
9615 run_test 118n "statfs() sends OST_STATFS requests in parallel"
9617 test_119a() # bug 11737
9619 BSIZE=$((512 * 1024))
9620 directio write $DIR/$tfile 0 1 $BSIZE
9621 # We ask to read two blocks, which is more than a file size.
9622 # directio will indicate an error when requested and actual
9623 # sizes aren't equeal (a normal situation in this case) and
9624 # print actual read amount.
9625 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
9626 if [ "$NOB" != "$BSIZE" ]; then
9627 error "read $NOB bytes instead of $BSIZE"
9631 run_test 119a "Short directIO read must return actual read amount"
9633 test_119b() # bug 11737
9635 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9637 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
9638 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
9640 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
9641 error "direct read failed"
9644 run_test 119b "Sparse directIO read must return actual read amount"
9646 test_119c() # bug 13099
9649 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
9650 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
9653 run_test 119c "Testing for direct read hitting hole"
9655 test_119d() # bug 15950
9657 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9659 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
9660 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
9662 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
9663 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
9664 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
9665 lctl set_param fail_loc=0x40d
9666 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
9669 cat $DIR/$tfile > /dev/null &
9670 lctl set_param fail_loc=0
9673 log "the DIO writes have completed, now wait for the reads (should not block very long)"
9675 [ -n "`ps h -p $pid_reads -o comm`" ] && \
9676 error "the read rpcs have not completed in 2s"
9678 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
9680 run_test 119d "The DIO path should try to send a new rpc once one is completed"
9683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9684 remote_mds_nodsh && skip "remote MDS with nodsh"
9685 test_mkdir -i0 -c1 $DIR/$tdir
9686 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9687 skip_env "no early lock cancel on server"
9689 lru_resize_disable mdc
9690 lru_resize_disable osc
9691 cancel_lru_locks mdc
9692 # asynchronous object destroy at MDT could cause bl ast to client
9693 cancel_lru_locks osc
9695 stat $DIR/$tdir > /dev/null
9696 can1=$(do_facet mds1 \
9697 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9698 awk '/ldlm_cancel/ {print $2}')
9699 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9700 awk '/ldlm_bl_callback/ {print $2}')
9701 test_mkdir -i0 -c1 $DIR/$tdir/d1
9702 can2=$(do_facet mds1 \
9703 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9704 awk '/ldlm_cancel/ {print $2}')
9705 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9706 awk '/ldlm_bl_callback/ {print $2}')
9707 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9708 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9709 lru_resize_enable mdc
9710 lru_resize_enable osc
9712 run_test 120a "Early Lock Cancel: mkdir test"
9715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9716 remote_mds_nodsh && skip "remote MDS with nodsh"
9717 test_mkdir $DIR/$tdir
9718 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9719 skip_env "no early lock cancel on server"
9721 lru_resize_disable mdc
9722 lru_resize_disable osc
9723 cancel_lru_locks mdc
9724 stat $DIR/$tdir > /dev/null
9725 can1=$(do_facet $SINGLEMDS \
9726 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9727 awk '/ldlm_cancel/ {print $2}')
9728 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9729 awk '/ldlm_bl_callback/ {print $2}')
9731 can2=$(do_facet $SINGLEMDS \
9732 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9733 awk '/ldlm_cancel/ {print $2}')
9734 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9735 awk '/ldlm_bl_callback/ {print $2}')
9736 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9737 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9738 lru_resize_enable mdc
9739 lru_resize_enable osc
9741 run_test 120b "Early Lock Cancel: create test"
9744 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9745 remote_mds_nodsh && skip "remote MDS with nodsh"
9746 test_mkdir -i0 -c1 $DIR/$tdir
9747 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9748 skip "no early lock cancel on server"
9750 lru_resize_disable mdc
9751 lru_resize_disable osc
9752 test_mkdir -i0 -c1 $DIR/$tdir/d1
9753 test_mkdir -i0 -c1 $DIR/$tdir/d2
9754 touch $DIR/$tdir/d1/f1
9755 cancel_lru_locks mdc
9756 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
9757 can1=$(do_facet mds1 \
9758 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9759 awk '/ldlm_cancel/ {print $2}')
9760 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9761 awk '/ldlm_bl_callback/ {print $2}')
9762 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9763 can2=$(do_facet mds1 \
9764 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9765 awk '/ldlm_cancel/ {print $2}')
9766 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9767 awk '/ldlm_bl_callback/ {print $2}')
9768 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9769 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9770 lru_resize_enable mdc
9771 lru_resize_enable osc
9773 run_test 120c "Early Lock Cancel: link test"
9776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9777 remote_mds_nodsh && skip "remote MDS with nodsh"
9778 test_mkdir -i0 -c1 $DIR/$tdir
9779 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9780 skip_env "no early lock cancel on server"
9782 lru_resize_disable mdc
9783 lru_resize_disable osc
9785 cancel_lru_locks mdc
9786 stat $DIR/$tdir > /dev/null
9787 can1=$(do_facet mds1 \
9788 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9789 awk '/ldlm_cancel/ {print $2}')
9790 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9791 awk '/ldlm_bl_callback/ {print $2}')
9792 chmod a+x $DIR/$tdir
9793 can2=$(do_facet mds1 \
9794 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9795 awk '/ldlm_cancel/ {print $2}')
9796 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9797 awk '/ldlm_bl_callback/ {print $2}')
9798 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9799 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9800 lru_resize_enable mdc
9801 lru_resize_enable osc
9803 run_test 120d "Early Lock Cancel: setattr test"
9806 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9807 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9808 skip_env "no early lock cancel on server"
9809 remote_mds_nodsh && skip "remote MDS with nodsh"
9811 local dlmtrace_set=false
9813 test_mkdir -i0 -c1 $DIR/$tdir
9814 lru_resize_disable mdc
9815 lru_resize_disable osc
9816 ! $LCTL get_param debug | grep -q dlmtrace &&
9817 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
9818 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
9819 cancel_lru_locks mdc
9820 cancel_lru_locks osc
9821 dd if=$DIR/$tdir/f1 of=/dev/null
9822 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
9823 # XXX client can not do early lock cancel of OST lock
9824 # during unlink (LU-4206), so cancel osc lock now.
9826 cancel_lru_locks osc
9827 can1=$(do_facet mds1 \
9828 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9829 awk '/ldlm_cancel/ {print $2}')
9830 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9831 awk '/ldlm_bl_callback/ {print $2}')
9832 unlink $DIR/$tdir/f1
9834 can2=$(do_facet mds1 \
9835 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9836 awk '/ldlm_cancel/ {print $2}')
9837 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9838 awk '/ldlm_bl_callback/ {print $2}')
9839 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
9840 $LCTL dk $TMP/cancel.debug.txt
9841 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
9842 $LCTL dk $TMP/blocking.debug.txt
9843 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
9844 lru_resize_enable mdc
9845 lru_resize_enable osc
9847 run_test 120e "Early Lock Cancel: unlink test"
9850 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9851 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9852 skip_env "no early lock cancel on server"
9853 remote_mds_nodsh && skip "remote MDS with nodsh"
9855 test_mkdir -i0 -c1 $DIR/$tdir
9856 lru_resize_disable mdc
9857 lru_resize_disable osc
9858 test_mkdir -i0 -c1 $DIR/$tdir/d1
9859 test_mkdir -i0 -c1 $DIR/$tdir/d2
9860 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
9861 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
9862 cancel_lru_locks mdc
9863 cancel_lru_locks osc
9864 dd if=$DIR/$tdir/d1/f1 of=/dev/null
9865 dd if=$DIR/$tdir/d2/f2 of=/dev/null
9866 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
9867 # XXX client can not do early lock cancel of OST lock
9868 # during rename (LU-4206), so cancel osc lock now.
9870 cancel_lru_locks osc
9871 can1=$(do_facet mds1 \
9872 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9873 awk '/ldlm_cancel/ {print $2}')
9874 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9875 awk '/ldlm_bl_callback/ {print $2}')
9876 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9878 can2=$(do_facet mds1 \
9879 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9880 awk '/ldlm_cancel/ {print $2}')
9881 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9882 awk '/ldlm_bl_callback/ {print $2}')
9883 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9884 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9885 lru_resize_enable mdc
9886 lru_resize_enable osc
9888 run_test 120f "Early Lock Cancel: rename test"
9891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9892 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9893 skip_env "no early lock cancel on server"
9894 remote_mds_nodsh && skip "remote MDS with nodsh"
9896 lru_resize_disable mdc
9897 lru_resize_disable osc
9899 echo create $count files
9900 test_mkdir $DIR/$tdir
9901 cancel_lru_locks mdc
9902 cancel_lru_locks osc
9905 can0=$(do_facet $SINGLEMDS \
9906 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9907 awk '/ldlm_cancel/ {print $2}')
9908 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9909 awk '/ldlm_bl_callback/ {print $2}')
9910 createmany -o $DIR/$tdir/f $count
9912 can1=$(do_facet $SINGLEMDS \
9913 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9914 awk '/ldlm_cancel/ {print $2}')
9915 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9916 awk '/ldlm_bl_callback/ {print $2}')
9918 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
9919 echo rm $count files
9922 can2=$(do_facet $SINGLEMDS \
9923 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9924 awk '/ldlm_cancel/ {print $2}')
9925 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9926 awk '/ldlm_bl_callback/ {print $2}')
9928 echo total: $count removes in $((t2-t1))
9929 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
9931 # wait for commitment of removal
9932 lru_resize_enable mdc
9933 lru_resize_enable osc
9935 run_test 120g "Early Lock Cancel: performance test"
9937 test_121() { #bug #10589
9938 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9941 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
9942 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
9943 lctl set_param fail_loc=0x310
9944 cancel_lru_locks osc > /dev/null
9945 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
9946 lctl set_param fail_loc=0
9947 [[ $reads -eq $writes ]] ||
9948 error "read $reads blocks, must be $writes blocks"
9950 run_test 121 "read cancel race ========="
9952 test_123a() { # was test 123, statahead(bug 11401)
9953 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9956 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
9957 log "testing UP system. Performance may be lower than expected."
9962 test_mkdir $DIR/$tdir
9963 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
9964 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
9966 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
9967 createmany -o $DIR/$tdir/$tfile $j $((i - j))
9969 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9970 lctl set_param -n llite.*.statahead_max 0
9971 lctl get_param llite.*.statahead_max
9972 cancel_lru_locks mdc
9973 cancel_lru_locks osc
9975 time ls -l $DIR/$tdir | wc -l
9977 delta=$((etime - stime))
9978 log "ls $i files without statahead: $delta sec"
9979 lctl set_param llite.*.statahead_max=$max
9981 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9982 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
9983 cancel_lru_locks mdc
9984 cancel_lru_locks osc
9986 time ls -l $DIR/$tdir | wc -l
9988 delta_sa=$((etime - stime))
9989 log "ls $i files with statahead: $delta_sa sec"
9990 lctl get_param -n llite.*.statahead_stats
9991 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9993 [[ $swrong -lt $ewrong ]] &&
9994 log "statahead was stopped, maybe too many locks held!"
9995 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
9997 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9998 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9999 lctl set_param -n llite.*.statahead_max 0
10000 lctl get_param llite.*.statahead_max
10001 cancel_lru_locks mdc
10002 cancel_lru_locks osc
10004 time ls -l $DIR/$tdir | wc -l
10006 delta=$((etime - stime))
10007 log "ls $i files again without statahead: $delta sec"
10008 lctl set_param llite.*.statahead_max=$max
10009 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10010 if [ $SLOWOK -eq 0 ]; then
10011 error "ls $i files is slower with statahead!"
10013 log "ls $i files is slower with statahead!"
10019 [ $delta -gt 20 ] && break
10020 [ $delta -gt 8 ] && MULT=$((50 / delta))
10021 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
10029 delta=$((etime - stime))
10030 log "rm -r $DIR/$tdir/: $delta seconds"
10032 lctl get_param -n llite.*.statahead_stats
10034 run_test 123a "verify statahead work"
10036 test_123b () { # statahead(bug 15027)
10037 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10039 test_mkdir $DIR/$tdir
10040 createmany -o $DIR/$tdir/$tfile-%d 1000
10042 cancel_lru_locks mdc
10043 cancel_lru_locks osc
10045 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
10046 lctl set_param fail_loc=0x80000803
10047 ls -lR $DIR/$tdir > /dev/null
10049 lctl set_param fail_loc=0x0
10050 lctl get_param -n llite.*.statahead_stats
10055 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
10058 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10059 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10060 skip_env "no lru resize on server"
10064 test_mkdir $DIR/$tdir
10066 log "create $NR files at $DIR/$tdir"
10067 createmany -o $DIR/$tdir/f $NR ||
10068 error "failed to create $NR files in $DIR/$tdir"
10070 cancel_lru_locks mdc
10071 ls -l $DIR/$tdir > /dev/null
10075 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
10076 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
10077 LRU_SIZE=$($LCTL get_param -n $PARAM)
10078 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
10079 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
10081 log "NS=$(basename $NSDIR)"
10086 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
10087 skip "Not enough cached locks created!"
10089 log "LRU=$LRU_SIZE"
10093 # We know that lru resize allows one client to hold $LIMIT locks
10094 # for 10h. After that locks begin to be killed by client.
10096 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
10098 if [ $LIMIT -lt $LRU_SIZE ]; then
10099 skip "Limit is too small $LIMIT"
10102 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
10103 # killing locks. Some time was spent for creating locks. This means
10104 # that up to the moment of sleep finish we must have killed some of
10105 # them (10-100 locks). This depends on how fast ther were created.
10106 # Many of them were touched in almost the same moment and thus will
10107 # be killed in groups.
10108 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
10110 # Use $LRU_SIZE_B here to take into account real number of locks
10111 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
10112 local LRU_SIZE_B=$LRU_SIZE
10114 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
10115 log "OLD_LVF=$OLD_LVF"
10116 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
10118 # Let's make sure that we really have some margin. Client checks
10119 # cached locks every 10 sec.
10120 SLEEP=$((SLEEP+20))
10121 log "Sleep ${SLEEP} sec"
10123 while ((SEC<$SLEEP)); do
10127 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
10128 echo -n "$LRU_SIZE"
10131 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
10132 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
10134 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
10135 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
10136 unlinkmany $DIR/$tdir/f $NR
10140 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
10141 log "unlink $NR files at $DIR/$tdir"
10142 unlinkmany $DIR/$tdir/f $NR
10144 run_test 124a "lru resize ======================================="
10146 get_max_pool_limit()
10148 local limit=$($LCTL get_param \
10149 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
10151 for l in $limit; do
10152 if [[ $l -gt $max ]]; then
10160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10161 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10162 skip_env "no lru resize on server"
10164 LIMIT=$(get_max_pool_limit)
10166 NR=$(($(default_lru_size)*20))
10167 if [[ $NR -gt $LIMIT ]]; then
10168 log "Limit lock number by $LIMIT locks"
10172 IFree=$(mdsrate_inodes_available)
10173 if [ $IFree -lt $NR ]; then
10174 log "Limit lock number by $IFree inodes"
10178 lru_resize_disable mdc
10179 test_mkdir -p $DIR/$tdir/disable_lru_resize
10181 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
10182 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
10183 cancel_lru_locks mdc
10186 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10189 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10192 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10196 nolruresize_delta=$((etime-stime))
10197 log "ls -la time: $nolruresize_delta seconds"
10198 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10199 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
10201 lru_resize_enable mdc
10202 test_mkdir -p $DIR/$tdir/enable_lru_resize
10204 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
10205 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
10206 cancel_lru_locks mdc
10209 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10212 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10215 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10219 lruresize_delta=$((etime-stime))
10220 log "ls -la time: $lruresize_delta seconds"
10221 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10223 if [ $lruresize_delta -gt $nolruresize_delta ]; then
10224 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
10225 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
10226 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
10228 log "lru resize performs the same with no lru resize"
10230 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
10232 run_test 124b "lru resize (performance test) ======================="
10235 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10236 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10237 skip_env "no lru resize on server"
10239 # cache ununsed locks on client
10241 cancel_lru_locks mdc
10242 test_mkdir $DIR/$tdir
10243 createmany -o $DIR/$tdir/f $nr ||
10244 error "failed to create $nr files in $DIR/$tdir"
10245 ls -l $DIR/$tdir > /dev/null
10247 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10248 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10249 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10250 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10251 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10253 # set lru_max_age to 1 sec
10254 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10255 echo "sleep $((recalc_p * 2)) seconds..."
10256 sleep $((recalc_p * 2))
10258 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10259 # restore lru_max_age
10260 $LCTL set_param -n $nsdir.lru_max_age $max_age
10261 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10262 unlinkmany $DIR/$tdir/f $nr
10264 run_test 124c "LRUR cancel very aged locks"
10266 test_125() { # 13358
10267 $LCTL get_param -n llite.*.client_type | grep -q local ||
10268 skip "must run as local client"
10269 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
10270 skip_env "must have acl enabled"
10271 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
10273 test_mkdir $DIR/$tdir
10274 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
10275 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
10276 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
10278 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
10280 test_126() { # bug 12829/13455
10281 $GSS && skip_env "must run as gss disabled"
10282 $LCTL get_param -n llite.*.client_type | grep -q local ||
10283 skip "must run as local client"
10284 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
10286 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
10287 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
10289 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
10291 run_test 126 "check that the fsgid provided by the client is taken into account"
10293 test_127a() { # bug 15521
10294 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10296 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
10297 $LCTL set_param osc.*.stats=0
10298 FSIZE=$((2048 * 1024))
10299 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10300 cancel_lru_locks osc
10301 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
10303 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
10304 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
10305 echo "got $COUNT $NAME"
10306 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
10307 eval $NAME=$COUNT || error "Wrong proc format"
10310 read_bytes|write_bytes)
10311 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
10312 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
10313 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
10314 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
10315 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
10316 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
10317 error "sumsquare is too small: $SUMSQ"
10318 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
10319 error "sumsquare is too big: $SUMSQ"
10323 done < $DIR/${tfile}.tmp
10325 #check that we actually got some stats
10326 [ "$read_bytes" ] || error "Missing read_bytes stats"
10327 [ "$write_bytes" ] || error "Missing write_bytes stats"
10328 [ "$read_bytes" != 0 ] || error "no read done"
10329 [ "$write_bytes" != 0 ] || error "no write done"
10331 run_test 127a "verify the client stats are sane"
10333 test_127b() { # bug LU-333
10334 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10335 local name count samp unit min max sum sumsq
10337 $LCTL set_param llite.*.stats=0
10339 # perform 2 reads and writes so MAX is different from SUM.
10340 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
10341 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
10342 cancel_lru_locks osc
10343 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
10344 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
10346 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
10347 while read name count samp unit min max sum sumsq; do
10348 echo "got $count $name"
10349 eval $name=$count || error "Wrong proc format"
10353 [ $count -ne 2 ] && error "count is not 2: $count"
10354 [ $min -ne $PAGE_SIZE ] &&
10355 error "min is not $PAGE_SIZE: $min"
10356 [ $max -ne $PAGE_SIZE ] &&
10357 error "max is incorrect: $max"
10358 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
10359 error "sum is wrong: $sum"
10362 [ $count -ne 2 ] && error "count is not 2: $count"
10363 [ $min -ne $PAGE_SIZE ] &&
10364 error "min is not $PAGE_SIZE: $min"
10365 [ $max -ne $PAGE_SIZE ] &&
10366 error "max is incorrect: $max"
10367 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
10368 error "sum is wrong: $sum"
10372 done < $TMP/$tfile.tmp
10374 #check that we actually got some stats
10375 [ "$read_bytes" ] || error "Missing read_bytes stats"
10376 [ "$write_bytes" ] || error "Missing write_bytes stats"
10377 [ "$read_bytes" != 0 ] || error "no read done"
10378 [ "$write_bytes" != 0 ] || error "no write done"
10380 rm -f $TMP/${tfile}.tmp
10382 run_test 127b "verify the llite client stats are sane"
10384 test_128() { # bug 15212
10386 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
10391 result=$(grep error $TMP/$tfile.log)
10392 rm -f $DIR/$tfile $TMP/$tfile.log
10393 [ -z "$result" ] ||
10394 error "consecutive find's under interactive lfs failed"
10396 run_test 128 "interactive lfs for 2 consecutive find's"
10398 set_dir_limits () {
10403 local ldproc=/proc/fs/ldiskfs
10404 local facets=$(get_facets MDS)
10406 for facet in ${facets//,/ }; do
10407 canondev=$(ldiskfs_canon \
10408 *.$(convert_facet2label $facet).mntdev $facet)
10409 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
10410 ldproc=/sys/fs/ldiskfs
10411 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
10412 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
10416 check_mds_dmesg() {
10417 local facets=$(get_facets MDS)
10418 for facet in ${facets//,/ }; do
10419 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
10425 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10426 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
10427 skip "Need MDS version with at least 2.5.56"
10428 if [ "$mds1_FSTYPE" != ldiskfs ]; then
10429 skip_env "ldiskfs only test"
10431 remote_mds_nodsh && skip "remote MDS with nodsh"
10435 local has_warning=false
10438 mkdir -p $DIR/$tdir
10440 # block size of mds1
10441 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
10442 set_dir_limits $maxsize $maxsize
10443 local dirsize=$(stat -c%s "$DIR/$tdir")
10445 while [[ $dirsize -le $maxsize ]]; do
10446 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
10448 if ! $has_warning; then
10449 check_mds_dmesg '"is approaching"' && has_warning=true
10451 # check two errors:
10452 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
10453 # EFBIG for previous versions included in ldiskfs series
10454 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
10456 echo "return code $rc received as expected"
10458 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
10459 error_exit "create failed w/o dir size limit"
10461 check_mds_dmesg '"has reached"' ||
10462 error_exit "reached message should be output"
10464 [ $has_warning = "false" ] &&
10465 error_exit "warning message should be output"
10467 dirsize=$(stat -c%s "$DIR/$tdir")
10469 [[ $dirsize -ge $maxsize ]] && return 0
10470 error_exit "current dir size $dirsize, " \
10471 "previous limit $maxsize"
10472 elif [ $rc -ne 0 ]; then
10474 error_exit "return $rc received instead of expected " \
10475 "$EFBIG or $ENOSPC, files in dir $dirsize"
10477 nfiles=$((nfiles + 1))
10478 dirsize=$(stat -c%s "$DIR/$tdir")
10482 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
10484 run_test 129 "test directory size limit ========================"
10493 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10494 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10496 trap cleanup_130 EXIT RETURN
10498 local fm_file=$DIR/$tfile
10499 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
10500 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
10501 error "dd failed for $fm_file"
10503 # LU-1795: test filefrag/FIEMAP once, even if unsupported
10504 filefrag -ves $fm_file
10506 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10507 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10508 [ $RC != 0 ] && error "filefrag $fm_file failed"
10510 filefrag_op=$(filefrag -ve -k $fm_file |
10511 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10512 lun=$($LFS getstripe -i $fm_file)
10514 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
10517 for line in $filefrag_op
10519 frag_lun=`echo $line | cut -d: -f5`
10520 ext_len=`echo $line | cut -d: -f4`
10521 if (( $frag_lun != $lun )); then
10523 error "FIEMAP on 1-stripe file($fm_file) failed"
10526 (( tot_len += ext_len ))
10529 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
10531 error "FIEMAP on 1-stripe file($fm_file) failed;"
10537 echo "FIEMAP on single striped file succeeded"
10539 run_test 130a "FIEMAP (1-stripe file)"
10542 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
10544 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10545 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10547 trap cleanup_130 EXIT RETURN
10549 local fm_file=$DIR/$tfile
10550 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
10551 error "setstripe on $fm_file"
10552 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10553 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10555 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
10556 error "dd failed on $fm_file"
10558 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10559 filefrag_op=$(filefrag -ve -k $fm_file |
10560 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10562 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10563 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10568 for line in $filefrag_op
10570 frag_lun=$(echo $line | cut -d: -f5 |
10571 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10572 ext_len=$(echo $line | cut -d: -f4)
10573 if (( $frag_lun != $last_lun )); then
10574 if (( tot_len != 1024 )); then
10576 error "FIEMAP on $fm_file failed; returned " \
10577 "len $tot_len for OST $last_lun instead of 1024"
10580 (( num_luns += 1 ))
10584 (( tot_len += ext_len ))
10587 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
10589 error "FIEMAP on $fm_file failed; returned wrong number of " \
10590 "luns or wrong len for OST $last_lun"
10596 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
10598 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
10601 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10603 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10604 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10606 trap cleanup_130 EXIT RETURN
10608 local fm_file=$DIR/$tfile
10609 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
10610 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10611 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10613 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
10614 error "dd failed on $fm_file"
10616 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10617 filefrag_op=$(filefrag -ve -k $fm_file |
10618 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10620 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10621 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10626 for line in $filefrag_op
10628 frag_lun=$(echo $line | cut -d: -f5 |
10629 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10630 ext_len=$(echo $line | cut -d: -f4)
10631 if (( $frag_lun != $last_lun )); then
10632 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
10633 if (( logical != 512 )); then
10635 error "FIEMAP on $fm_file failed; returned " \
10636 "logical start for lun $logical instead of 512"
10639 if (( tot_len != 512 )); then
10641 error "FIEMAP on $fm_file failed; returned " \
10642 "len $tot_len for OST $last_lun instead of 1024"
10645 (( num_luns += 1 ))
10649 (( tot_len += ext_len ))
10652 if (( num_luns != 2 || tot_len != 512 )); then
10654 error "FIEMAP on $fm_file failed; returned wrong number of " \
10655 "luns or wrong len for OST $last_lun"
10661 echo "FIEMAP on 2-stripe file with hole succeeded"
10663 run_test 130c "FIEMAP (2-stripe file with hole)"
10666 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
10668 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10669 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10671 trap cleanup_130 EXIT RETURN
10673 local fm_file=$DIR/$tfile
10674 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
10675 error "setstripe on $fm_file"
10676 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10677 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10679 local actual_stripe_count=$($LFS getstripe -c $fm_file)
10680 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
10681 error "dd failed on $fm_file"
10683 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10684 filefrag_op=$(filefrag -ve -k $fm_file |
10685 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10687 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10688 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10693 for line in $filefrag_op
10695 frag_lun=$(echo $line | cut -d: -f5 |
10696 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10697 ext_len=$(echo $line | cut -d: -f4)
10698 if (( $frag_lun != $last_lun )); then
10699 if (( tot_len != 1024 )); then
10701 error "FIEMAP on $fm_file failed; returned " \
10702 "len $tot_len for OST $last_lun instead of 1024"
10705 (( num_luns += 1 ))
10709 (( tot_len += ext_len ))
10712 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
10714 error "FIEMAP on $fm_file failed; returned wrong number of " \
10715 "luns or wrong len for OST $last_lun"
10721 echo "FIEMAP on N-stripe file succeeded"
10723 run_test 130d "FIEMAP (N-stripe file)"
10726 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10728 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10729 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10731 trap cleanup_130 EXIT RETURN
10733 local fm_file=$DIR/$tfile
10734 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
10735 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10736 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10739 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
10740 for ((i = 0; i < $NUM_BLKS; i++))
10742 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
10745 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10746 filefrag_op=$(filefrag -ve -k $fm_file |
10747 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10749 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10750 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10755 for line in $filefrag_op
10757 frag_lun=$(echo $line | cut -d: -f5 |
10758 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10759 ext_len=$(echo $line | cut -d: -f4)
10760 if (( $frag_lun != $last_lun )); then
10761 if (( tot_len != $EXPECTED_LEN )); then
10763 error "FIEMAP on $fm_file failed; returned " \
10764 "len $tot_len for OST $last_lun instead " \
10768 (( num_luns += 1 ))
10772 (( tot_len += ext_len ))
10775 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
10777 error "FIEMAP on $fm_file failed; returned wrong number " \
10778 "of luns or wrong len for OST $last_lun"
10784 echo "FIEMAP with continuation calls succeeded"
10786 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
10789 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10790 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10792 local fm_file=$DIR/$tfile
10793 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
10794 error "multiop create with lov_delay_create on $fm_file"
10796 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10797 filefrag_extents=$(filefrag -vek $fm_file |
10798 awk '/extents? found/ { print $2 }')
10799 if [[ "$filefrag_extents" != "0" ]]; then
10800 error "FIEMAP on $fm_file failed; " \
10801 "returned $filefrag_extents expected 0"
10806 run_test 130f "FIEMAP (unstriped file)"
10808 # Test for writev/readv
10810 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
10811 error "writev test failed"
10812 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
10813 error "readv failed"
10816 run_test 131a "test iov's crossing stripe boundary for writev/readv"
10819 local fsize=$((524288 + 1048576 + 1572864))
10820 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
10821 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10822 error "append writev test failed"
10824 ((fsize += 1572864 + 1048576))
10825 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
10826 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10827 error "append writev test failed"
10830 run_test 131b "test append writev"
10833 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
10836 run_test 131c "test read/write on file w/o objects"
10839 rwv -f $DIR/$tfile -w -n 1 1572864
10840 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
10841 if [ "$NOB" != 1572864 ]; then
10842 error "Short read filed: read $NOB bytes instead of 1572864"
10846 run_test 131d "test short read"
10849 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
10850 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
10851 error "read hitting hole failed"
10854 run_test 131e "test read hitting hole"
10863 mds*) res=$(do_facet $facet \
10864 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
10866 ost*) res=$(do_facet $facet \
10867 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
10869 *) error "Wrong facet '$facet'" ;;
10871 [ "$res" ] || error "The counter for $op on $facet was not incremented"
10872 # if the argument $3 is zero, it means any stat increment is ok.
10873 if [[ $want -gt 0 ]]; then
10874 local count=$(echo $res | awk '{ print $2 }')
10875 [[ $count -ne $want ]] &&
10876 error "The $op counter on $facet is $count, not $want"
10881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10882 remote_ost_nodsh && skip "remote OST with nodsh"
10883 remote_mds_nodsh && skip "remote MDS with nodsh"
10884 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10885 skip_env "MDS doesn't support rename stats"
10887 local testdir=$DIR/${tdir}/stats_testdir
10889 mkdir -p $DIR/${tdir}
10892 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10893 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10895 # verify mdt stats first.
10896 mkdir ${testdir} || error "mkdir failed"
10897 check_stats $SINGLEMDS "mkdir" 1
10898 touch ${testdir}/${tfile} || error "touch failed"
10899 check_stats $SINGLEMDS "open" 1
10900 check_stats $SINGLEMDS "close" 1
10901 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
10902 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
10903 check_stats $SINGLEMDS "mknod" 2
10905 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
10906 check_stats $SINGLEMDS "unlink" 1
10907 rm -f ${testdir}/${tfile} || error "file remove failed"
10908 check_stats $SINGLEMDS "unlink" 2
10910 # remove working dir and check mdt stats again.
10911 rmdir ${testdir} || error "rmdir failed"
10912 check_stats $SINGLEMDS "rmdir" 1
10914 local testdir1=$DIR/${tdir}/stats_testdir1
10915 mkdir -p ${testdir}
10916 mkdir -p ${testdir1}
10917 touch ${testdir1}/test1
10918 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
10919 check_stats $SINGLEMDS "crossdir_rename" 1
10921 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
10922 check_stats $SINGLEMDS "samedir_rename" 1
10924 rm -rf $DIR/${tdir}
10926 run_test 133a "Verifying MDT stats ========================================"
10931 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10932 remote_ost_nodsh && skip "remote OST with nodsh"
10933 remote_mds_nodsh && skip "remote MDS with nodsh"
10935 local testdir=$DIR/${tdir}/stats_testdir
10937 mkdir -p ${testdir} || error "mkdir failed"
10938 touch ${testdir}/${tfile} || error "touch failed"
10939 cancel_lru_locks mdc
10942 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10943 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10945 # extra mdt stats verification.
10946 chmod 444 ${testdir}/${tfile} || error "chmod failed"
10947 check_stats $SINGLEMDS "setattr" 1
10948 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10949 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
10951 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
10952 check_stats $SINGLEMDS "getattr" 1
10954 rm -rf $DIR/${tdir}
10956 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
10957 # so the check below is not reliable
10958 [ $MDSCOUNT -eq 1 ] || return 0
10960 # Sleep to avoid a cached response.
10961 #define OBD_STATFS_CACHE_SECONDS 1
10963 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10964 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
10965 $LFS df || error "lfs failed"
10966 check_stats $SINGLEMDS "statfs" 1
10968 # check aggregated statfs (LU-10018)
10969 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
10971 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
10974 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10975 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
10977 check_stats $SINGLEMDS "statfs" 1
10979 # We want to check that the client didn't send OST_STATFS to
10980 # ost1 but the MDT also uses OST_STATFS for precreate. So some
10981 # extra care is needed here.
10982 if remote_mds; then
10983 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
10984 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
10986 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
10987 [ "$res" ] && error "OST got STATFS"
10992 run_test 133b "Verifying extra MDT stats =================================="
10995 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10996 remote_ost_nodsh && skip "remote OST with nodsh"
10997 remote_mds_nodsh && skip "remote MDS with nodsh"
10999 local testdir=$DIR/$tdir/stats_testdir
11001 test_mkdir -p $testdir
11003 # verify obdfilter stats.
11004 $LFS setstripe -c 1 -i 0 $testdir/$tfile
11006 cancel_lru_locks osc
11007 wait_delete_completed
11010 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11011 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11013 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
11016 cancel_lru_locks osc
11017 check_stats ost1 "write" 1
11019 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
11020 check_stats ost1 "read" 1
11022 > $testdir/$tfile || error "truncate failed"
11023 check_stats ost1 "punch" 1
11025 rm -f $testdir/$tfile || error "file remove failed"
11026 wait_delete_completed
11027 check_stats ost1 "destroy" 1
11031 run_test 133c "Verifying OST stats ========================================"
11038 while [ $value -ge 2 ]; do
11043 if [ $orig -gt $order ]; then
11051 local size=('K' 'M' 'G' 'T');
11053 local size_string=$value
11055 while [ $value -ge 1024 ]; do
11056 if [ $i -gt 3 ]; then
11057 #T is the biggest unit we get here, if that is bigger,
11059 size_string=${value}T
11062 value=$((value >> 10))
11063 if [ $value -lt 1024 ]; then
11064 size_string=${value}${size[$i]}
11073 get_rename_size() {
11075 local context=${2:-.}
11076 local sample=$(do_facet $SINGLEMDS $LCTL \
11077 get_param mdt.$FSNAME-MDT0000.rename_stats |
11078 grep -A1 $context |
11079 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
11084 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11085 remote_ost_nodsh && skip "remote OST with nodsh"
11086 remote_mds_nodsh && skip "remote MDS with nodsh"
11087 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11088 skip_env "MDS doesn't support rename stats"
11090 local testdir1=$DIR/${tdir}/stats_testdir1
11091 local testdir2=$DIR/${tdir}/stats_testdir2
11092 mkdir -p $DIR/${tdir}
11094 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11096 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
11097 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
11099 createmany -o $testdir1/test 512 || error "createmany failed"
11101 # check samedir rename size
11102 mv ${testdir1}/test0 ${testdir1}/test_0
11104 local testdir1_size=$(ls -l $DIR/${tdir} |
11105 awk '/stats_testdir1/ {print $5}')
11106 local testdir2_size=$(ls -l $DIR/${tdir} |
11107 awk '/stats_testdir2/ {print $5}')
11109 testdir1_size=$(order_2 $testdir1_size)
11110 testdir2_size=$(order_2 $testdir2_size)
11112 testdir1_size=$(size_in_KMGT $testdir1_size)
11113 testdir2_size=$(size_in_KMGT $testdir2_size)
11115 echo "source rename dir size: ${testdir1_size}"
11116 echo "target rename dir size: ${testdir2_size}"
11118 local cmd="do_facet $SINGLEMDS $LCTL "
11119 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
11121 eval $cmd || error "$cmd failed"
11122 local samedir=$($cmd | grep 'same_dir')
11123 local same_sample=$(get_rename_size $testdir1_size)
11124 [ -z "$samedir" ] && error "samedir_rename_size count error"
11125 [[ $same_sample -eq 1 ]] ||
11126 error "samedir_rename_size error $same_sample"
11127 echo "Check same dir rename stats success"
11129 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11131 # check crossdir rename size
11132 mv ${testdir1}/test_0 ${testdir2}/test_0
11134 testdir1_size=$(ls -l $DIR/${tdir} |
11135 awk '/stats_testdir1/ {print $5}')
11136 testdir2_size=$(ls -l $DIR/${tdir} |
11137 awk '/stats_testdir2/ {print $5}')
11139 testdir1_size=$(order_2 $testdir1_size)
11140 testdir2_size=$(order_2 $testdir2_size)
11142 testdir1_size=$(size_in_KMGT $testdir1_size)
11143 testdir2_size=$(size_in_KMGT $testdir2_size)
11145 echo "source rename dir size: ${testdir1_size}"
11146 echo "target rename dir size: ${testdir2_size}"
11148 eval $cmd || error "$cmd failed"
11149 local crossdir=$($cmd | grep 'crossdir')
11150 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
11151 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
11152 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
11153 [[ $src_sample -eq 1 ]] ||
11154 error "crossdir_rename_size error $src_sample"
11155 [[ $tgt_sample -eq 1 ]] ||
11156 error "crossdir_rename_size error $tgt_sample"
11157 echo "Check cross dir rename stats success"
11158 rm -rf $DIR/${tdir}
11160 run_test 133d "Verifying rename_stats ========================================"
11163 remote_mds_nodsh && skip "remote MDS with nodsh"
11164 remote_ost_nodsh && skip "remote OST with nodsh"
11165 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11167 local testdir=$DIR/${tdir}/stats_testdir
11168 local ctr f0 f1 bs=32768 count=42 sum
11170 mkdir -p ${testdir} || error "mkdir failed"
11172 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
11174 for ctr in {write,read}_bytes; do
11176 cancel_lru_locks osc
11178 do_facet ost1 $LCTL set_param -n \
11179 "obdfilter.*.exports.clear=clear"
11181 if [ $ctr = write_bytes ]; then
11183 f1=${testdir}/${tfile}
11185 f0=${testdir}/${tfile}
11189 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
11192 cancel_lru_locks osc
11194 sum=$(do_facet ost1 $LCTL get_param \
11195 "obdfilter.*.exports.*.stats" |
11196 awk -v ctr=$ctr 'BEGIN { sum = 0 }
11197 $1 == ctr { sum += $7 }
11198 END { printf("%0.0f", sum) }')
11200 if ((sum != bs * count)); then
11201 error "Bad $ctr sum, expected $((bs * count)), got $sum"
11205 rm -rf $DIR/${tdir}
11207 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
11209 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
11211 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
11212 # not honor the -ignore_readdir_race option correctly. So we call
11213 # error_ignore() rather than error() in these cases. See LU-11152.
11215 if (find --version; do_facet mds1 find --version) |
11216 grep -q '\b4\.5\.1[1-4]\b'; then
11217 error_ignore LU-11152 "$@"
11224 # First without trusting modes.
11225 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
11226 echo "proc_dirs='$proc_dirs'"
11227 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
11228 find $proc_dirs -exec cat '{}' \; &> /dev/null
11230 # Second verifying readability.
11231 $LCTL get_param -R '*' &> /dev/null
11233 # Verifing writability with badarea_io.
11235 -ignore_readdir_race \
11237 -not -name force_lbug \
11238 -not -name changelog_mask \
11239 -exec badarea_io '{}' \; ||
11240 error_133 "find $proc_dirs failed"
11242 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
11245 remote_mds_nodsh && skip "remote MDS with nodsh"
11246 remote_ost_nodsh && skip "remote OST with nodsh"
11248 # eventually, this can also be replaced with "lctl get_param -R",
11249 # but not until that option is always available on the server
11251 for facet in mds1 ost1; do
11252 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
11253 skip_noexit "Too old lustre on $facet"
11254 local facet_proc_dirs=$(do_facet $facet \
11255 \\\ls -d $proc_regexp 2>/dev/null)
11256 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11257 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11258 do_facet $facet find $facet_proc_dirs \
11259 ! -name req_history \
11260 -exec cat '{}' \\\; &> /dev/null
11262 do_facet $facet find $facet_proc_dirs \
11263 ! -name req_history \
11265 -exec cat '{}' \\\; &> /dev/null ||
11266 error "proc file read failed"
11268 do_facet $facet find $facet_proc_dirs \
11269 -ignore_readdir_race \
11271 -not -name force_lbug \
11272 -not -name changelog_mask \
11273 -exec badarea_io '{}' \\\; ||
11274 error_133 "$facet find $facet_proc_dirs failed"
11277 # remount the FS in case writes/reads /proc break the FS
11278 cleanup || error "failed to unmount"
11279 setup || error "failed to setup"
11282 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
11285 remote_mds_nodsh && skip "remote MDS with nodsh"
11286 remote_ost_nodsh && skip "remote OST with nodsh"
11287 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
11288 skip "Need MDS version at least 2.9.54"
11292 for facet in client mds1 ost1; do
11293 local facet_proc_dirs=$(do_facet $facet \
11294 \\\ls -d $proc_regexp 2> /dev/null)
11295 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11296 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11297 # Get the list of files that are missing the terminating newline
11298 local missing=($(do_facet $facet \
11299 find ${facet_proc_dirs} -type f \| \
11300 while read F\; do \
11301 awk -v FS='\v' -v RS='\v\v' \
11302 "'END { if(NR>0 && \
11303 \\\$NF !~ /.*\\\n\$/) \
11304 print FILENAME}'" \
11307 [ ${#missing[*]} -eq 0 ] ||
11308 error "files do not end with newline: ${missing[*]}"
11311 run_test 133h "Proc files should end with newlines"
11314 remote_mds_nodsh && skip "remote MDS with nodsh"
11315 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
11316 skip "Need MDS version at least 2.7.54"
11318 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11319 cancel_lru_locks mdc
11321 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11322 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11323 [ $unused -eq 0 ] || error "$unused locks are not cleared"
11326 createmany -o $DIR/$tdir/f $nr ||
11327 error "failed to create $nr files in $DIR/$tdir"
11328 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11330 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
11331 do_facet mds1 $LCTL set_param fail_loc=0x327
11332 do_facet mds1 $LCTL set_param fail_val=500
11335 echo "sleep 10 seconds ..."
11337 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
11339 do_facet mds1 $LCTL set_param fail_loc=0
11340 do_facet mds1 $LCTL set_param fail_val=0
11341 [ $lck_cnt -lt $unused ] ||
11342 error "No locks reclaimed, before:$unused, after:$lck_cnt"
11345 unlinkmany $DIR/$tdir/f $nr
11347 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
11350 remote_mds_nodsh && skip "remote MDS with nodsh"
11351 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
11352 skip "Need MDS version at least 2.7.54"
11354 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11355 cancel_lru_locks mdc
11357 local low_wm=$(do_facet mds1 $LCTL get_param -n \
11358 ldlm.lock_reclaim_threshold_mb)
11359 # disable reclaim temporarily
11360 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
11362 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
11363 do_facet mds1 $LCTL set_param fail_loc=0x328
11364 do_facet mds1 $LCTL set_param fail_val=500
11366 $LCTL set_param debug=+trace
11369 createmany -o $DIR/$tdir/f $nr &
11370 local create_pid=$!
11372 echo "Sleep $TIMEOUT seconds ..."
11374 if ! ps -p $create_pid > /dev/null 2>&1; then
11375 do_facet mds1 $LCTL set_param fail_loc=0
11376 do_facet mds1 $LCTL set_param fail_val=0
11377 do_facet mds1 $LCTL set_param \
11378 ldlm.lock_reclaim_threshold_mb=${low_wm}m
11379 error "createmany finished incorrectly!"
11381 do_facet mds1 $LCTL set_param fail_loc=0
11382 do_facet mds1 $LCTL set_param fail_val=0
11383 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
11384 wait $create_pid || return 1
11386 unlinkmany $DIR/$tdir/f $nr
11388 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
11390 test_140() { #bug-17379
11391 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11393 test_mkdir $DIR/$tdir
11394 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
11395 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
11397 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
11398 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
11400 while i=$((i + 1)); do
11402 cd $i || error "Changing to $i"
11403 ln -s ../stat stat || error "Creating stat symlink"
11404 # Read the symlink until ELOOP present,
11405 # not LBUGing the system is considered success,
11406 # we didn't overrun the stack.
11407 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
11408 if [ $ret -ne 0 ]; then
11409 if [ $ret -eq 40 ]; then
11412 error "Open stat symlink"
11418 echo "The symlink depth = $i"
11419 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
11420 error "Invalid symlink depth"
11422 # Test recursive symlink
11423 ln -s symlink_self symlink_self
11424 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
11425 echo "open symlink_self returns $ret"
11426 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
11428 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
11431 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11433 local TF="$TMP/$tfile"
11435 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11437 cancel_lru_locks $OSC
11438 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
11439 remount_client $MOUNT
11441 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
11444 $TRUNCATE $DIR/$tfile 6000
11445 cancel_lru_locks $OSC
11446 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
11449 echo "12345" >>$DIR/$tfile
11450 cancel_lru_locks $OSC
11451 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
11454 echo "12345" >>$DIR/$tfile
11455 cancel_lru_locks $OSC
11456 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
11461 run_test 150 "truncate/append tests"
11463 #LU-2902 roc_hit was not able to read all values from lproc
11464 function roc_hit_init() {
11465 local list=$(comma_list $(osts_nodes))
11466 local dir=$DIR/$tdir-check
11467 local file=$dir/$tfile
11473 #use setstripe to do a write to every ost
11474 for i in $(seq 0 $((OSTCOUNT-1))); do
11475 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
11476 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
11477 idx=$(printf %04x $i)
11478 BEFORE=$(get_osd_param $list *OST*$idx stats |
11479 awk '$1 == "cache_access" {sum += $7}
11480 END { printf("%0.0f", sum) }')
11482 cancel_lru_locks osc
11483 cat $file >/dev/null
11485 AFTER=$(get_osd_param $list *OST*$idx stats |
11486 awk '$1 == "cache_access" {sum += $7}
11487 END { printf("%0.0f", sum) }')
11489 echo BEFORE:$BEFORE AFTER:$AFTER
11490 if ! let "AFTER - BEFORE == 4"; then
11492 error "roc_hit is not safe to use"
11500 function roc_hit() {
11501 local list=$(comma_list $(osts_nodes))
11502 echo $(get_osd_param $list '' stats |
11503 awk '$1 == "cache_hit" {sum += $7}
11504 END { printf("%0.0f", sum) }')
11507 function set_cache() {
11510 if [ "$2" == "off" ]; then
11513 local list=$(comma_list $(osts_nodes))
11514 set_osd_param $list '' $1_cache_enable $on
11516 cancel_lru_locks osc
11520 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11521 remote_ost_nodsh && skip "remote OST with nodsh"
11524 local list=$(comma_list $(osts_nodes))
11526 # check whether obdfilter is cache capable at all
11527 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
11528 skip "not cache-capable obdfilter"
11531 # check cache is enabled on all obdfilters
11532 if get_osd_param $list '' read_cache_enable | grep 0; then
11533 skip "oss cache is disabled"
11536 set_osd_param $list '' writethrough_cache_enable 1
11538 # check write cache is enabled on all obdfilters
11539 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
11540 skip "oss write cache is NOT enabled"
11545 #define OBD_FAIL_OBD_NO_LRU 0x609
11546 do_nodes $list $LCTL set_param fail_loc=0x609
11548 # pages should be in the case right after write
11549 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
11552 local BEFORE=$(roc_hit)
11553 cancel_lru_locks osc
11554 cat $DIR/$tfile >/dev/null
11555 local AFTER=$(roc_hit)
11557 do_nodes $list $LCTL set_param fail_loc=0
11559 if ! let "AFTER - BEFORE == CPAGES"; then
11560 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11563 # the following read invalidates the cache
11564 cancel_lru_locks osc
11565 set_osd_param $list '' read_cache_enable 0
11566 cat $DIR/$tfile >/dev/null
11568 # now data shouldn't be found in the cache
11570 cancel_lru_locks osc
11571 cat $DIR/$tfile >/dev/null
11573 if let "AFTER - BEFORE != 0"; then
11574 error "IN CACHE: before: $BEFORE, after: $AFTER"
11577 set_osd_param $list '' read_cache_enable 1
11580 run_test 151 "test cache on oss and controls ==============================="
11583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11585 local TF="$TMP/$tfile"
11587 # simulate ENOMEM during write
11588 #define OBD_FAIL_OST_NOMEM 0x226
11589 lctl set_param fail_loc=0x80000226
11590 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11592 sync || error "sync failed"
11593 lctl set_param fail_loc=0
11595 # discard client's cache
11596 cancel_lru_locks osc
11598 # simulate ENOMEM during read
11599 lctl set_param fail_loc=0x80000226
11600 cmp $TF $DIR/$tfile || error "cmp failed"
11601 lctl set_param fail_loc=0
11605 run_test 152 "test read/write with enomem ============================"
11608 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
11610 run_test 153 "test if fdatasync does not crash ======================="
11612 dot_lustre_fid_permission_check() {
11614 local ffid=$MOUNT/.lustre/fid/$fid
11617 echo "stat fid $fid"
11618 stat $ffid > /dev/null || error "stat $ffid failed."
11619 echo "touch fid $fid"
11620 touch $ffid || error "touch $ffid failed."
11621 echo "write to fid $fid"
11622 cat /etc/hosts > $ffid || error "write $ffid failed."
11623 echo "read fid $fid"
11624 diff /etc/hosts $ffid || error "read $ffid failed."
11625 echo "append write to fid $fid"
11626 cat /etc/hosts >> $ffid || error "append write $ffid failed."
11627 echo "rename fid $fid"
11628 mv $ffid $test_dir/$tfile.1 &&
11629 error "rename $ffid to $tfile.1 should fail."
11630 touch $test_dir/$tfile.1
11631 mv $test_dir/$tfile.1 $ffid &&
11632 error "rename $tfile.1 to $ffid should fail."
11633 rm -f $test_dir/$tfile.1
11634 echo "truncate fid $fid"
11635 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
11636 echo "link fid $fid"
11637 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
11638 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
11639 echo "setfacl fid $fid"
11640 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
11641 echo "getfacl fid $fid"
11642 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
11644 echo "unlink fid $fid"
11645 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
11646 echo "mknod fid $fid"
11647 mknod $ffid c 1 3 && error "mknod $ffid should fail."
11649 fid=[0xf00000400:0x1:0x0]
11650 ffid=$MOUNT/.lustre/fid/$fid
11652 echo "stat non-exist fid $fid"
11653 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
11654 echo "write to non-exist fid $fid"
11655 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
11656 echo "link new fid $fid"
11657 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
11659 mkdir -p $test_dir/$tdir
11660 touch $test_dir/$tdir/$tfile
11661 fid=$($LFS path2fid $test_dir/$tdir)
11664 error "error: could not get fid for $test_dir/$dir/$tfile."
11666 ffid=$MOUNT/.lustre/fid/$fid
11669 ls $ffid > /dev/null || error "ls $ffid failed."
11670 echo "touch $fid/$tfile.1"
11671 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
11673 echo "touch $MOUNT/.lustre/fid/$tfile"
11674 touch $MOUNT/.lustre/fid/$tfile && \
11675 error "touch $MOUNT/.lustre/fid/$tfile should fail."
11677 echo "setxattr to $MOUNT/.lustre/fid"
11678 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
11680 echo "listxattr for $MOUNT/.lustre/fid"
11681 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
11683 echo "delxattr from $MOUNT/.lustre/fid"
11684 setfattr -x trusted.name1 $MOUNT/.lustre/fid
11686 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
11687 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
11688 error "touch invalid fid should fail."
11690 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
11691 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
11692 error "touch non-normal fid should fail."
11694 echo "rename $tdir to $MOUNT/.lustre/fid"
11695 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
11696 error "rename to $MOUNT/.lustre/fid should fail."
11698 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
11700 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
11701 local new_obf_mode=777
11703 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
11704 chmod $new_obf_mode $DIR/.lustre/fid ||
11705 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
11707 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
11708 [ $obf_mode -eq $new_obf_mode ] ||
11709 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
11711 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
11712 chmod $old_obf_mode $DIR/.lustre/fid ||
11713 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
11716 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
11717 fid=$($LFS path2fid $test_dir/$tfile-2)
11719 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
11721 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
11722 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
11723 error "create lov data thru .lustre failed"
11725 echo "cp /etc/passwd $test_dir/$tfile-2"
11726 cp /etc/passwd $test_dir/$tfile-2 ||
11727 error "copy to $test_dir/$tfile-2 failed."
11728 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
11729 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
11730 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
11732 rm -rf $test_dir/tfile.lnk
11733 rm -rf $test_dir/$tfile-2
11737 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
11738 skip "Need MDS version at least 2.4.1"
11740 local tf=$DIR/$tfile
11743 local fid=$($LFS path2fid $tf)
11744 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
11746 # check that we get the same pathname back
11747 local found=$($LFS fid2path $MOUNT "$fid")
11748 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
11749 [ "$found" == "$tf" ] ||
11750 error "fid2path($fid=path2fid($tf)) = $found != $tf"
11752 run_test 154A "lfs path2fid and fid2path basic checks"
11755 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
11756 skip "Need MDS version at least 2.4.1"
11758 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11759 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11760 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
11761 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
11763 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
11764 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
11766 # check that we get the same pathname
11767 echo "PFID: $PFID, name: $name"
11768 local FOUND=$($LFS fid2path $MOUNT "$PFID")
11769 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
11770 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
11771 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
11773 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
11775 run_test 154B "verify the ll_decode_linkea tool"
11778 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11779 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11780 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
11781 skip "Need MDS version at least 2.2.51"
11782 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11784 cp /etc/hosts $DIR/$tfile
11786 fid=$($LFS path2fid $DIR/$tfile)
11788 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
11790 dot_lustre_fid_permission_check "$fid" $DIR ||
11791 error "dot lustre permission check $fid failed"
11793 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
11795 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
11797 touch $MOUNT/.lustre/file &&
11798 error "creation is not allowed under .lustre"
11800 mkdir $MOUNT/.lustre/dir &&
11801 error "mkdir is not allowed under .lustre"
11805 run_test 154a "Open-by-FID"
11808 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11809 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11810 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
11811 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
11812 skip "Need MDS version at least 2.2.51"
11814 local remote_dir=$DIR/$tdir/remote_dir
11818 mkdir -p $DIR/$tdir
11819 $LFS mkdir -i $MDTIDX $remote_dir ||
11820 error "create remote directory failed"
11822 cp /etc/hosts $remote_dir/$tfile
11824 fid=$($LFS path2fid $remote_dir/$tfile)
11826 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
11828 dot_lustre_fid_permission_check "$fid" $remote_dir ||
11829 error "dot lustre permission check $fid failed"
11832 run_test 154b "Open-by-FID for remote directory"
11835 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
11836 skip "Need MDS version at least 2.4.1"
11838 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
11839 local FID1=$($LFS path2fid $DIR/$tfile.1)
11840 local FID2=$($LFS path2fid $DIR/$tfile.2)
11841 local FID3=$($LFS path2fid $DIR/$tfile.3)
11844 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
11845 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
11846 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
11848 [ "$FID" = "${!want}" ] ||
11849 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
11853 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
11855 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
11856 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
11860 run_test 154c "lfs path2fid and fid2path multiple arguments"
11863 remote_mds_nodsh && skip "remote MDS with nodsh"
11864 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
11865 skip "Need MDS version at least 2.5.53"
11867 if remote_mds; then
11868 nid=$($LCTL list_nids | sed "s/\./\\\./g")
11872 local proc_ofile="mdt.*.exports.'$nid'.open_files"
11879 local fid=$($LFS path2fid $DIR/$tfile)
11882 cmd="exec $fd<$DIR/$tfile"
11884 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
11885 echo "$fid_list" | grep "$fid"
11888 cmd="exec $fd>/dev/null"
11890 if [ $rc -ne 0 ]; then
11891 error "FID $fid not found in open files list $fid_list"
11894 run_test 154d "Verify open file fid"
11898 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
11899 skip "Need MDS version at least 2.6.50"
11901 if ls -a $MOUNT | grep -q '^\.lustre$'; then
11902 error ".lustre returned by readdir"
11905 run_test 154e ".lustre is not returned by readdir"
11908 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11910 # create parent directory on a single MDT to avoid cross-MDT hardlinks
11911 test_mkdir -p -c1 $DIR/$tdir/d
11912 # test dirs inherit from its stripe
11913 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
11914 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
11915 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
11916 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
11919 # get fid of parents
11920 local FID0=$($LFS path2fid $DIR/$tdir/d)
11921 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
11922 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
11923 local FID3=$($LFS path2fid $DIR)
11925 # check that path2fid --parents returns expected <parent_fid>/name
11926 # 1) test for a directory (single parent)
11927 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
11928 [ "$parent" == "$FID0/foo1" ] ||
11929 error "expected parent: $FID0/foo1, got: $parent"
11931 # 2) test for a file with nlink > 1 (multiple parents)
11932 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
11933 echo "$parent" | grep -F "$FID1/$tfile" ||
11934 error "$FID1/$tfile not returned in parent list"
11935 echo "$parent" | grep -F "$FID2/link" ||
11936 error "$FID2/link not returned in parent list"
11938 # 3) get parent by fid
11939 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
11940 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11941 echo "$parent" | grep -F "$FID1/$tfile" ||
11942 error "$FID1/$tfile not returned in parent list (by fid)"
11943 echo "$parent" | grep -F "$FID2/link" ||
11944 error "$FID2/link not returned in parent list (by fid)"
11946 # 4) test for entry in root directory
11947 parent=$($LFS path2fid --parents $DIR/f)
11948 echo "$parent" | grep -F "$FID3/f" ||
11949 error "$FID3/f not returned in parent list"
11951 # 5) test it on root directory
11952 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
11953 error "$MOUNT should not have parents"
11955 # enable xattr caching and check that linkea is correctly updated
11956 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11957 save_lustre_params client "llite.*.xattr_cache" > $save
11958 lctl set_param llite.*.xattr_cache 1
11960 # 6.1) linkea update on rename
11961 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
11963 # get parents by fid
11964 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11965 # foo1 should no longer be returned in parent list
11966 echo "$parent" | grep -F "$FID1" &&
11967 error "$FID1 should no longer be in parent list"
11968 # the new path should appear
11969 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
11970 error "$FID2/$tfile.moved is not in parent list"
11972 # 6.2) linkea update on unlink
11973 rm -f $DIR/$tdir/d/foo2/link
11974 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11975 # foo2/link should no longer be returned in parent list
11976 echo "$parent" | grep -F "$FID2/link" &&
11977 error "$FID2/link should no longer be in parent list"
11981 restore_lustre_params < $save
11984 run_test 154f "get parent fids by reading link ea"
11988 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11989 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
11990 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
11991 skip "Need MDS version at least 2.6.92"
11993 mkdir -p $DIR/$tdir
11994 llapi_fid_test -d $DIR/$tdir
11996 run_test 154g "various llapi FID tests"
11998 test_155_small_load() {
11999 local temp=$TMP/$tfile
12000 local file=$DIR/$tfile
12002 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
12003 error "dd of=$temp bs=6096 count=1 failed"
12005 cancel_lru_locks $OSC
12006 cmp $temp $file || error "$temp $file differ"
12008 $TRUNCATE $temp 6000
12009 $TRUNCATE $file 6000
12010 cmp $temp $file || error "$temp $file differ (truncate1)"
12012 echo "12345" >>$temp
12013 echo "12345" >>$file
12014 cmp $temp $file || error "$temp $file differ (append1)"
12016 echo "12345" >>$temp
12017 echo "12345" >>$file
12018 cmp $temp $file || error "$temp $file differ (append2)"
12024 test_155_big_load() {
12025 remote_ost_nodsh && skip "remote OST with nodsh"
12027 local temp=$TMP/$tfile
12028 local file=$DIR/$tfile
12031 local cache_size=$(do_facet ost$((MAXI+1)) \
12032 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
12033 local large_file_size=$((cache_size * 2))
12035 echo "OSS cache size: $cache_size KB"
12036 echo "Large file size: $large_file_size KB"
12038 [ $MAXV -le $large_file_size ] &&
12039 skip_env "max available OST size needs > $large_file_size KB"
12041 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
12043 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
12044 error "dd of=$temp bs=$large_file_size count=1k failed"
12047 cancel_lru_locks osc
12048 cmp $temp $file || error "$temp $file differ"
12054 save_writethrough() {
12055 local facets=$(get_facets OST)
12057 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
12061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12063 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12065 save_writethrough $p
12068 set_cache writethrough on
12069 test_155_small_load
12070 restore_lustre_params < $p
12073 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
12076 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12078 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12080 save_writethrough $p
12083 set_cache writethrough off
12084 test_155_small_load
12085 restore_lustre_params < $p
12088 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
12091 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12093 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12095 save_writethrough $p
12098 set_cache writethrough on
12099 test_155_small_load
12100 restore_lustre_params < $p
12103 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
12106 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12108 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12110 save_writethrough $p
12113 set_cache writethrough off
12114 test_155_small_load
12115 restore_lustre_params < $p
12118 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
12121 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12123 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12125 save_writethrough $p
12128 set_cache writethrough on
12130 restore_lustre_params < $p
12133 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
12136 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12138 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12140 save_writethrough $p
12143 set_cache writethrough off
12145 restore_lustre_params < $p
12148 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
12151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12153 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12155 save_writethrough $p
12158 set_cache writethrough on
12160 restore_lustre_params < $p
12163 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
12166 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12168 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12170 save_writethrough $p
12173 set_cache writethrough off
12175 restore_lustre_params < $p
12178 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
12181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12182 remote_ost_nodsh && skip "remote OST with nodsh"
12183 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
12184 skip "stats not implemented on old servers"
12185 [ "$ost1_FSTYPE" = "zfs" ] &&
12186 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
12191 local file="$DIR/$tfile"
12192 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12194 save_writethrough $p
12197 log "Turn on read and write cache"
12199 set_cache writethrough on
12201 log "Write data and read it back."
12202 log "Read should be satisfied from the cache."
12203 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12205 cancel_lru_locks osc
12206 cat $file >/dev/null
12208 if ! let "AFTER - BEFORE == CPAGES"; then
12209 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12211 log "cache hits:: before: $BEFORE, after: $AFTER"
12214 log "Read again; it should be satisfied from the cache."
12216 cancel_lru_locks osc
12217 cat $file >/dev/null
12219 if ! let "AFTER - BEFORE == CPAGES"; then
12220 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12222 log "cache hits:: before: $BEFORE, after: $AFTER"
12225 log "Turn off the read cache and turn on the write cache"
12227 set_cache writethrough on
12229 log "Read again; it should be satisfied from the cache."
12231 cancel_lru_locks osc
12232 cat $file >/dev/null
12234 if ! let "AFTER - BEFORE == CPAGES"; then
12235 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12237 log "cache hits:: before: $BEFORE, after: $AFTER"
12240 log "Read again; it should not be satisfied from the cache."
12242 cancel_lru_locks osc
12243 cat $file >/dev/null
12245 if ! let "AFTER - BEFORE == 0"; then
12246 error "IN CACHE: before: $BEFORE, after: $AFTER"
12248 log "cache hits:: before: $BEFORE, after: $AFTER"
12251 log "Write data and read it back."
12252 log "Read should be satisfied from the cache."
12253 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12255 cancel_lru_locks osc
12256 cat $file >/dev/null
12258 if ! let "AFTER - BEFORE == CPAGES"; then
12259 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12261 log "cache hits:: before: $BEFORE, after: $AFTER"
12264 log "Read again; it should not be satisfied from the cache."
12266 cancel_lru_locks osc
12267 cat $file >/dev/null
12269 if ! let "AFTER - BEFORE == 0"; then
12270 error "IN CACHE: before: $BEFORE, after: $AFTER"
12272 log "cache hits:: before: $BEFORE, after: $AFTER"
12275 log "Turn off read and write cache"
12277 set_cache writethrough off
12279 log "Write data and read it back"
12280 log "It should not be satisfied from the cache."
12282 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12283 cancel_lru_locks osc
12285 cat $file >/dev/null
12287 if ! let "AFTER - BEFORE == 0"; then
12288 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12290 log "cache hits:: before: $BEFORE, after: $AFTER"
12293 log "Turn on the read cache and turn off the write cache"
12295 set_cache writethrough off
12297 log "Write data and read it back"
12298 log "It should not be satisfied from the cache."
12300 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12302 cancel_lru_locks osc
12303 cat $file >/dev/null
12305 if ! let "AFTER - BEFORE == 0"; then
12306 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12308 log "cache hits:: before: $BEFORE, after: $AFTER"
12311 log "Read again; it should be satisfied from the cache."
12313 cancel_lru_locks osc
12314 cat $file >/dev/null
12316 if ! let "AFTER - BEFORE == CPAGES"; then
12317 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12319 log "cache hits:: before: $BEFORE, after: $AFTER"
12322 restore_lustre_params < $p
12325 run_test 156 "Verification of tunables"
12328 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12329 remote_mds_nodsh && skip "remote MDS with nodsh"
12330 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
12331 skip "Need MDS version at least 2.2.0"
12333 changelog_register || error "changelog_register failed"
12334 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12335 changelog_users $SINGLEMDS | grep -q $cl_user ||
12336 error "User $cl_user not found in changelog_users"
12339 test_mkdir -p $DIR/$tdir/pics/2008/zachy
12340 changelog_clear 0 || error "changelog_clear failed"
12341 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
12342 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
12343 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
12344 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
12345 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
12346 rm $DIR/$tdir/pics/desktop.jpg
12348 changelog_dump | tail -10
12350 echo "verifying changelog mask"
12351 changelog_chmask "-MKDIR"
12352 changelog_chmask "-CLOSE"
12354 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
12355 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
12357 changelog_chmask "+MKDIR"
12358 changelog_chmask "+CLOSE"
12360 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
12361 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
12363 changelog_dump | tail -10
12364 MKDIRS=$(changelog_dump | grep -c "MKDIR")
12365 CLOSES=$(changelog_dump | grep -c "CLOSE")
12366 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
12367 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
12370 echo "verifying target fid"
12371 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
12372 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
12373 [ "$fidc" == "$fidf" ] ||
12374 error "changelog '$tfile' fid $fidc != file fid $fidf"
12375 echo "verifying parent fid"
12376 # The FID returned from the Changelog may be the directory shard on
12377 # a different MDT, and not the FID returned by path2fid on the parent.
12378 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
12379 # since this is what will matter when recreating this file in the tree.
12380 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
12381 local pathp=$($LFS fid2path $MOUNT "$fidp")
12382 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
12383 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
12385 echo "getting records for $cl_user"
12386 changelog_users $SINGLEMDS
12387 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
12389 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
12390 error "changelog_clear failed"
12391 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
12392 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
12393 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
12394 error "user index expect $user_rec1 + $nclr != $user_rec2"
12396 local min0_rec=$(changelog_users $SINGLEMDS |
12397 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
12398 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
12399 awk '{ print $1; exit; }')
12401 changelog_dump | tail -n 5
12402 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
12403 [ $first_rec == $((min0_rec + 1)) ] ||
12404 error "first index should be $min0_rec + 1 not $first_rec"
12406 # LU-3446 changelog index reset on MDT restart
12407 local cur_rec1=$(changelog_users $SINGLEMDS |
12408 awk '/^current.index:/ { print $NF }')
12409 changelog_clear 0 ||
12410 error "clear all changelog records for $cl_user failed"
12411 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
12412 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
12413 error "Fail to start $SINGLEMDS"
12414 local cur_rec2=$(changelog_users $SINGLEMDS |
12415 awk '/^current.index:/ { print $NF }')
12416 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
12417 [ $cur_rec1 == $cur_rec2 ] ||
12418 error "current index should be $cur_rec1 not $cur_rec2"
12420 echo "verifying users from this test are deregistered"
12421 changelog_deregister || error "changelog_deregister failed"
12422 changelog_users $SINGLEMDS | grep -q $cl_user &&
12423 error "User '$cl_user' still in changelog_users"
12425 # lctl get_param -n mdd.*.changelog_users
12426 # current index: 144
12427 # ID index (idle seconds)
12429 if ! changelog_users $SINGLEMDS | grep "^cl"; then
12430 # this is the normal case where all users were deregistered
12431 # make sure no new records are added when no users are present
12432 local last_rec1=$(changelog_users $SINGLEMDS |
12433 awk '/^current.index:/ { print $NF }')
12434 touch $DIR/$tdir/chloe
12435 local last_rec2=$(changelog_users $SINGLEMDS |
12436 awk '/^current.index:/ { print $NF }')
12437 echo "verify changelogs are off: $last_rec1 == $last_rec2"
12438 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
12440 # any changelog users must be leftovers from a previous test
12441 changelog_users $SINGLEMDS
12442 echo "other changelog users; can't verify off"
12445 run_test 160a "changelog sanity"
12447 test_160b() { # LU-3587
12448 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12449 remote_mds_nodsh && skip "remote MDS with nodsh"
12450 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
12451 skip "Need MDS version at least 2.2.0"
12453 changelog_register || error "changelog_register failed"
12454 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12455 changelog_users $SINGLEMDS | grep -q $cl_user ||
12456 error "User '$cl_user' not found in changelog_users"
12458 local longname1=$(str_repeat a 255)
12459 local longname2=$(str_repeat b 255)
12462 echo "creating very long named file"
12463 touch $longname1 || error "create of '$longname1' failed"
12464 echo "renaming very long named file"
12465 mv $longname1 $longname2
12467 changelog_dump | grep RENME | tail -n 5
12470 run_test 160b "Verify that very long rename doesn't crash in changelog"
12473 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12474 remote_mds_nodsh && skip "remote MDS with nodsh"
12476 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
12477 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
12478 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
12479 skip "Need MDS version at least 2.5.58 or 2.5.2+"
12483 # Registration step
12484 changelog_register || error "changelog_register failed"
12487 mkdir -p $DIR/$tdir
12488 $MCREATE $DIR/$tdir/foo_160c
12489 changelog_chmask "-TRUNC"
12490 $TRUNCATE $DIR/$tdir/foo_160c 200
12491 changelog_chmask "+TRUNC"
12492 $TRUNCATE $DIR/$tdir/foo_160c 199
12493 changelog_dump | tail -n 5
12494 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
12495 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
12497 run_test 160c "verify that changelog log catch the truncate event"
12500 remote_mds_nodsh && skip "remote MDS with nodsh"
12501 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12502 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12503 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
12504 skip "Need MDS version at least 2.7.60"
12506 # Registration step
12507 changelog_register || error "changelog_register failed"
12509 mkdir -p $DIR/$tdir/migrate_dir
12510 changelog_clear 0 || error "changelog_clear failed"
12512 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
12513 changelog_dump | tail -n 5
12514 local migrates=$(changelog_dump | grep -c "MIGRT")
12515 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
12517 run_test 160d "verify that changelog log catch the migrate event"
12520 remote_mds_nodsh && skip "remote MDS with nodsh"
12523 changelog_register || error "changelog_register failed"
12525 # Delete a future user (expect fail)
12526 local MDT0=$(facet_svc $SINGLEMDS)
12527 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
12530 if [ $rc -eq 0 ]; then
12531 error "Deleted non-existant user cl77"
12532 elif [ $rc -ne 2 ]; then
12533 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
12536 # Clear to a bad index (1 billion should be safe)
12537 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
12540 if [ $rc -eq 0 ]; then
12541 error "Successfully cleared to invalid CL index"
12542 elif [ $rc -ne 22 ]; then
12543 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
12546 run_test 160e "changelog negative testing (should return errors)"
12549 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12550 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
12551 skip "Need MDS version at least 2.10.56"
12553 local mdts=$(comma_list $(mdts_nodes))
12556 changelog_register || error "first changelog_register failed"
12557 changelog_register || error "second changelog_register failed"
12559 declare -A cl_user1
12560 declare -A cl_user2
12565 # generate some changelog records to accumulate on each MDT
12566 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
12567 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12568 error "create $DIR/$tdir/$tfile failed"
12570 # check changelogs have been generated
12571 local nbcl=$(changelog_dump | wc -l)
12572 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12574 for param in "changelog_max_idle_time=10" \
12576 "changelog_min_gc_interval=2" \
12577 "changelog_min_free_cat_entries=3"; do
12578 local MDT0=$(facet_svc $SINGLEMDS)
12579 local var="${param%=*}"
12580 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12582 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12583 do_nodes $mdts $LCTL set_param mdd.*.$param
12586 # force cl_user2 to be idle (1st part)
12589 # simulate changelog catalog almost full
12590 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12591 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12593 for i in $(seq $MDSCOUNT); do
12594 cl_users=(${CL_USERS[mds$i]})
12595 cl_user1[mds$i]="${cl_users[0]}"
12596 cl_user2[mds$i]="${cl_users[1]}"
12598 [ -n "${cl_user1[mds$i]}" ] ||
12599 error "mds$i: no user registered"
12600 [ -n "${cl_user2[mds$i]}" ] ||
12601 error "mds$i: only ${cl_user2[mds$i]} is registered"
12603 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12604 [ -n "$user_rec1" ] ||
12605 error "mds$i: User ${cl_user1[mds$i]} not registered"
12606 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12607 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12608 [ -n "$user_rec2" ] ||
12609 error "mds$i: User ${cl_user1[mds$i]} not registered"
12610 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12611 "$user_rec1 + 2 == $user_rec2"
12612 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12613 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12614 "$user_rec1 + 2, but is $user_rec2"
12615 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12616 [ -n "$user_rec2" ] ||
12617 error "mds$i: User ${cl_user2[mds$i]} not registered"
12618 [ $user_rec1 == $user_rec2 ] ||
12619 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12620 "$user_rec1, but is $user_rec2"
12623 # force cl_user2 to be idle (2nd part) and to reach
12624 # changelog_max_idle_time
12627 # generate one more changelog to trigger fail_loc
12628 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12629 error "create $DIR/$tdir/${tfile}bis failed"
12631 # ensure gc thread is done
12632 for i in $(mdts_nodes); do
12634 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
12635 error "$i: GC-thread not done"
12639 for i in $(seq $MDSCOUNT); do
12640 # check cl_user1 still registered
12641 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12642 error "mds$i: User ${cl_user1[mds$i]} not registered"
12643 # check cl_user2 unregistered
12644 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12645 error "mds$i: User ${cl_user2[mds$i]} still registered"
12647 # check changelogs are present and starting at $user_rec1 + 1
12648 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12649 [ -n "$user_rec1" ] ||
12650 error "mds$i: User ${cl_user1[mds$i]} not registered"
12651 first_rec=$($LFS changelog $(facet_svc mds$i) |
12652 awk '{ print $1; exit; }')
12654 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12655 [ $((user_rec1 + 1)) == $first_rec ] ||
12656 error "mds$i: first index should be $user_rec1 + 1, " \
12657 "but is $first_rec"
12660 run_test 160f "changelog garbage collect (timestamped users)"
12663 remote_mds_nodsh && skip "remote MDS with nodsh"
12664 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
12665 skip "Need MDS version at least 2.10.56"
12667 local mdts=$(comma_list $(mdts_nodes))
12669 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
12670 do_nodes $mdts $LCTL set_param fail_loc=0x1314
12673 changelog_register || error "first changelog_register failed"
12674 changelog_register || error "second changelog_register failed"
12676 declare -A cl_user1
12677 declare -A cl_user2
12682 # generate some changelog records to accumulate on each MDT
12683 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
12684 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12685 error "create $DIR/$tdir/$tfile failed"
12687 # check changelogs have been generated
12688 local nbcl=$(changelog_dump | wc -l)
12689 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12691 # reduce the max_idle_indexes value to make sure we exceed it
12692 max_ndx=$((nbcl / 2 - 1))
12694 for param in "changelog_max_idle_indexes=$max_ndx" \
12696 "changelog_min_gc_interval=2" \
12697 "changelog_min_free_cat_entries=3"; do
12698 local MDT0=$(facet_svc $SINGLEMDS)
12699 local var="${param%=*}"
12700 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12702 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12703 do_nodes $mdts $LCTL set_param mdd.*.$param ||
12704 error "unable to set mdd.*.$param"
12707 # simulate changelog catalog almost full
12708 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12709 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12711 for i in $(seq $MDSCOUNT); do
12712 cl_users=(${CL_USERS[mds$i]})
12713 cl_user1[mds$i]="${cl_users[0]}"
12714 cl_user2[mds$i]="${cl_users[1]}"
12716 [ -n "${cl_user1[mds$i]}" ] ||
12717 error "mds$i: no user registered"
12718 [ -n "${cl_user2[mds$i]}" ] ||
12719 error "mds$i: only ${cl_user1[mds$i]} is registered"
12721 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12722 [ -n "$user_rec1" ] ||
12723 error "mds$i: User ${cl_user1[mds$i]} not registered"
12724 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12725 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12726 [ -n "$user_rec2" ] ||
12727 error "mds$i: User ${cl_user1[mds$i]} not registered"
12728 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12729 "$user_rec1 + 2 == $user_rec2"
12730 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12731 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12732 "$user_rec1 + 2, but is $user_rec2"
12733 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12734 [ -n "$user_rec2" ] ||
12735 error "mds$i: User ${cl_user2[mds$i]} not registered"
12736 [ $user_rec1 == $user_rec2 ] ||
12737 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12738 "$user_rec1, but is $user_rec2"
12741 # ensure we are past the previous changelog_min_gc_interval set above
12744 # generate one more changelog to trigger fail_loc
12745 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12746 error "create $DIR/$tdir/${tfile}bis failed"
12748 # ensure gc thread is done
12749 for i in $(mdts_nodes); do
12751 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
12752 error "$i: GC-thread not done"
12756 for i in $(seq $MDSCOUNT); do
12757 # check cl_user1 still registered
12758 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12759 error "mds$i: User ${cl_user1[mds$i]} not registered"
12760 # check cl_user2 unregistered
12761 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12762 error "mds$i: User ${cl_user2[mds$i]} still registered"
12764 # check changelogs are present and starting at $user_rec1 + 1
12765 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12766 [ -n "$user_rec1" ] ||
12767 error "mds$i: User ${cl_user1[mds$i]} not registered"
12768 first_rec=$($LFS changelog $(facet_svc mds$i) |
12769 awk '{ print $1; exit; }')
12771 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12772 [ $((user_rec1 + 1)) == $first_rec ] ||
12773 error "mds$i: first index should be $user_rec1 + 1, " \
12774 "but is $first_rec"
12777 run_test 160g "changelog garbage collect (old users)"
12780 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12781 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
12782 skip "Need MDS version at least 2.10.56"
12784 local mdts=$(comma_list $(mdts_nodes))
12787 changelog_register || error "first changelog_register failed"
12788 changelog_register || error "second changelog_register failed"
12790 declare -A cl_user1
12791 declare -A cl_user2
12796 # generate some changelog records to accumulate on each MDT
12797 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
12798 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12799 error "create $DIR/$tdir/$tfile failed"
12801 # check changelogs have been generated
12802 local nbcl=$(changelog_dump | wc -l)
12803 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12805 for param in "changelog_max_idle_time=10" \
12807 "changelog_min_gc_interval=2"; do
12808 local MDT0=$(facet_svc $SINGLEMDS)
12809 local var="${param%=*}"
12810 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12812 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12813 do_nodes $mdts $LCTL set_param mdd.*.$param
12816 # force cl_user2 to be idle (1st part)
12819 for i in $(seq $MDSCOUNT); do
12820 cl_users=(${CL_USERS[mds$i]})
12821 cl_user1[mds$i]="${cl_users[0]}"
12822 cl_user2[mds$i]="${cl_users[1]}"
12824 [ -n "${cl_user1[mds$i]}" ] ||
12825 error "mds$i: no user registered"
12826 [ -n "${cl_user2[mds$i]}" ] ||
12827 error "mds$i: only ${cl_user2[mds$i]} is registered"
12829 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12830 [ -n "$user_rec1" ] ||
12831 error "mds$i: User ${cl_user1[mds$i]} not registered"
12832 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12833 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12834 [ -n "$user_rec2" ] ||
12835 error "mds$i: User ${cl_user1[mds$i]} not registered"
12836 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12837 "$user_rec1 + 2 == $user_rec2"
12838 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12839 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12840 "$user_rec1 + 2, but is $user_rec2"
12841 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12842 [ -n "$user_rec2" ] ||
12843 error "mds$i: User ${cl_user2[mds$i]} not registered"
12844 [ $user_rec1 == $user_rec2 ] ||
12845 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12846 "$user_rec1, but is $user_rec2"
12849 # force cl_user2 to be idle (2nd part) and to reach
12850 # changelog_max_idle_time
12853 # force each GC-thread start and block then
12854 # one per MDT/MDD, set fail_val accordingly
12855 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
12856 do_nodes $mdts $LCTL set_param fail_loc=0x1316
12858 # generate more changelogs to trigger fail_loc
12859 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12860 error "create $DIR/$tdir/${tfile}bis failed"
12862 # stop MDT to stop GC-thread, should be done in back-ground as it will
12863 # block waiting for the thread to be released and exit
12864 declare -A stop_pids
12865 for i in $(seq $MDSCOUNT); do
12867 stop_pids[mds$i]=$!
12870 for i in $(mdts_nodes); do
12873 local facets=$(facets_up_on_host $i)
12875 for facet in ${facets//,/ }; do
12876 if [[ $facet == mds* ]]; then
12880 # ensure each MDS's gc threads are still present and all in "R"
12881 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
12882 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
12883 error "$i: expected $nb GC-thread"
12885 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
12887 error "$i: GC-thread not found in R-state"
12888 # check umounts of each MDT on MDS have reached kthread_stop()
12889 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
12890 error "$i: expected $nb umount"
12892 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
12893 error "$i: umount not found in D-state"
12896 # release all GC-threads
12897 do_nodes $mdts $LCTL set_param fail_loc=0
12899 # wait for MDT stop to complete
12900 for i in $(seq $MDSCOUNT); do
12901 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
12905 # may try to check if any orphan changelog records are present
12906 # via ldiskfs/zfs and llog_reader...
12908 # re-start/mount MDTs
12909 for i in $(seq $MDSCOUNT); do
12910 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
12911 error "Fail to start mds$i"
12915 for i in $(seq $MDSCOUNT); do
12916 # check cl_user1 still registered
12917 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12918 error "mds$i: User ${cl_user1[mds$i]} not registered"
12919 # check cl_user2 unregistered
12920 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12921 error "mds$i: User ${cl_user2[mds$i]} still registered"
12923 # check changelogs are present and starting at $user_rec1 + 1
12924 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12925 [ -n "$user_rec1" ] ||
12926 error "mds$i: User ${cl_user1[mds$i]} not registered"
12927 first_rec=$($LFS changelog $(facet_svc mds$i) |
12928 awk '{ print $1; exit; }')
12930 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12931 [ $((user_rec1 + 1)) == $first_rec ] ||
12932 error "mds$i: first index should be $user_rec1 + 1, " \
12933 "but is $first_rec"
12936 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
12941 local mdts=$(comma_list $(mdts_nodes))
12943 changelog_register || error "first changelog_register failed"
12945 # generate some changelog records to accumulate on each MDT
12946 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
12947 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12948 error "create $DIR/$tdir/$tfile failed"
12950 # check changelogs have been generated
12951 local nbcl=$(changelog_dump | wc -l)
12952 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12954 # simulate race between register and unregister
12955 # XXX as fail_loc is set per-MDS, with DNE configs the race
12956 # simulation will only occur for one MDT per MDS and for the
12957 # others the normal race scenario will take place
12958 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
12959 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
12960 do_nodes $mdts $LCTL set_param fail_val=1
12962 # unregister 1st user
12963 changelog_deregister &
12965 # wait some time for deregister work to reach race rdv
12967 # register 2nd user
12968 changelog_register || error "2nd user register failed"
12970 wait $pid1 || error "1st user deregister failed"
12974 declare -A LAST_REC
12975 for i in $(seq $MDSCOUNT); do
12976 if changelog_users mds$i | grep "^cl"; then
12977 # make sure new records are added with one user present
12978 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
12979 awk '/^current.index:/ { print $NF }')
12981 error "mds$i has no user registered"
12985 # generate more changelog records to accumulate on each MDT
12986 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12987 error "create $DIR/$tdir/${tfile}bis failed"
12989 for i in $(seq $MDSCOUNT); do
12990 last_rec=$(changelog_users $SINGLEMDS |
12991 awk '/^current.index:/ { print $NF }')
12992 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
12993 [ $last_rec != ${LAST_REC[mds$i]} ] ||
12994 error "changelogs are off on mds$i"
12997 run_test 160i "changelog user register/unregister race"
13000 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13002 test_mkdir -c1 $DIR/$tdir
13003 cp /etc/hosts $DIR/$tdir/$tfile
13004 test_mkdir -c1 $DIR/$tdir/foo1
13005 test_mkdir -c1 $DIR/$tdir/foo2
13006 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
13007 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
13008 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
13009 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
13010 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
13011 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13012 $LFS fid2path $DIR $FID
13013 error "bad link ea"
13016 rm $DIR/$tdir/foo2/zachary
13018 rm $DIR/$tdir/foo2/thor
13020 rm $DIR/$tdir/$tfile
13022 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
13023 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
13024 { $LFS fid2path $DIR $FID; error "bad link rename"; }
13025 rm $DIR/$tdir/foo2/maggie
13028 local longname=$tfile.avg_len_is_thirty_two_
13029 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
13030 error_noexit 'failed to unlink many hardlinks'" EXIT
13031 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
13032 error "failed to hardlink many files"
13033 links=$($LFS fid2path $DIR $FID | wc -l)
13034 echo -n "${links}/1000 links in link EA"
13035 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
13037 run_test 161a "link ea sanity"
13040 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13041 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
13044 local remote_dir=$DIR/$tdir/remote_dir
13046 mkdir -p $DIR/$tdir
13047 $LFS mkdir -i $MDTIDX $remote_dir ||
13048 error "create remote directory failed"
13050 cp /etc/hosts $remote_dir/$tfile
13051 mkdir -p $remote_dir/foo1
13052 mkdir -p $remote_dir/foo2
13053 ln $remote_dir/$tfile $remote_dir/foo1/sofia
13054 ln $remote_dir/$tfile $remote_dir/foo2/zachary
13055 ln $remote_dir/$tfile $remote_dir/foo1/luna
13056 ln $remote_dir/$tfile $remote_dir/foo2/thor
13058 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
13060 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13061 $LFS fid2path $DIR $FID
13062 error "bad link ea"
13065 rm $remote_dir/foo2/zachary
13067 rm $remote_dir/foo2/thor
13069 rm $remote_dir/$tfile
13071 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
13072 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
13073 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
13074 $LFS fid2path $DIR $FID
13075 error "bad link rename"
13077 rm $remote_dir/foo2/maggie
13080 local longname=filename_avg_len_is_thirty_two_
13081 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
13082 error "failed to hardlink many files"
13083 links=$($LFS fid2path $DIR $FID | wc -l)
13084 echo -n "${links}/1000 links in link EA"
13085 [[ ${links} -gt 60 ]] ||
13086 error "expected at least 60 links in link EA"
13087 unlinkmany $remote_dir/foo2/$longname 1000 ||
13088 error "failed to unlink many hardlinks"
13090 run_test 161b "link ea sanity under remote directory"
13093 remote_mds_nodsh && skip "remote MDS with nodsh"
13094 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13095 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
13096 skip "Need MDS version at least 2.1.5"
13098 # define CLF_RENAME_LAST 0x0001
13099 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
13100 changelog_register || error "changelog_register failed"
13103 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
13104 touch $DIR/$tdir/foo_161c
13105 touch $DIR/$tdir/bar_161c
13106 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13107 changelog_dump | grep RENME | tail -n 5
13108 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13109 changelog_clear 0 || error "changelog_clear failed"
13110 if [ x$flags != "x0x1" ]; then
13111 error "flag $flags is not 0x1"
13114 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
13115 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
13116 touch $DIR/$tdir/foo_161c
13117 touch $DIR/$tdir/bar_161c
13118 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13119 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13120 changelog_dump | grep RENME | tail -n 5
13121 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13122 changelog_clear 0 || error "changelog_clear failed"
13123 if [ x$flags != "x0x0" ]; then
13124 error "flag $flags is not 0x0"
13126 echo "rename overwrite a target having nlink > 1," \
13127 "changelog record has flags of $flags"
13129 # rename doesn't overwrite a target (changelog flag 0x0)
13130 touch $DIR/$tdir/foo_161c
13131 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
13132 changelog_dump | grep RENME | tail -n 5
13133 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
13134 changelog_clear 0 || error "changelog_clear failed"
13135 if [ x$flags != "x0x0" ]; then
13136 error "flag $flags is not 0x0"
13138 echo "rename doesn't overwrite a target," \
13139 "changelog record has flags of $flags"
13141 # define CLF_UNLINK_LAST 0x0001
13142 # unlink a file having nlink = 1 (changelog flag 0x1)
13143 rm -f $DIR/$tdir/foo2_161c
13144 changelog_dump | grep UNLNK | tail -n 5
13145 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13146 changelog_clear 0 || error "changelog_clear failed"
13147 if [ x$flags != "x0x1" ]; then
13148 error "flag $flags is not 0x1"
13150 echo "unlink a file having nlink = 1," \
13151 "changelog record has flags of $flags"
13153 # unlink a file having nlink > 1 (changelog flag 0x0)
13154 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13155 rm -f $DIR/$tdir/foobar_161c
13156 changelog_dump | grep UNLNK | tail -n 5
13157 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13158 changelog_clear 0 || error "changelog_clear failed"
13159 if [ x$flags != "x0x0" ]; then
13160 error "flag $flags is not 0x0"
13162 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
13164 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
13167 remote_mds_nodsh && skip "remote MDS with nodsh"
13168 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
13173 changelog_register || error "changelog_register failed"
13175 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
13176 # interfer with $MOUNT/.lustre/fid/ access
13178 [[ $? -eq 0 ]] || error "mkdir failed"
13180 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
13181 $LCTL set_param fail_loc=0x8000140c
13183 $LCTL set_param fail_val=5
13186 echo foofoo > $DIR/$tdir/$tfile &
13189 # wait for create to be delayed
13193 [[ $? -eq 0 ]] || error "create should be blocked"
13195 local tempfile=$(mktemp)
13196 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
13197 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
13198 # some delay may occur during ChangeLog publishing and file read just
13199 # above, that could allow file write to happen finally
13200 [[ -s $tempfile ]] && echo "file should be empty"
13202 $LCTL set_param fail_loc=0
13205 [[ $? -eq 0 ]] || error "create failed"
13207 run_test 161d "create with concurrent .lustre/fid access"
13210 local expected="$1"
13215 path=$($LFS fid2path "$@")
13218 if [ $rc -ne 0 ]; then
13219 error "path looked up of '$expected' failed: rc=$rc"
13220 elif [ "$path" != "$expected" ]; then
13221 error "path looked up '$path' instead of '$expected'"
13223 echo "FID '$fid' resolves to path '$path' as expected"
13227 test_162a() { # was test_162
13228 test_mkdir -p -c1 $DIR/$tdir/d2
13229 touch $DIR/$tdir/d2/$tfile
13230 touch $DIR/$tdir/d2/x1
13231 touch $DIR/$tdir/d2/x2
13232 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
13233 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
13235 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
13236 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
13239 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
13240 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
13241 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
13243 # softlink to wrong file
13244 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
13245 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
13246 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
13249 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
13250 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
13251 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
13252 # fid2path dir/fsname should both work
13253 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
13254 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
13256 # hardlink count: check that there are 2 links
13257 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
13258 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
13260 # hardlink indexing: remove the first link
13261 rm $DIR/$tdir/d2/p/q/r/hlink
13262 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
13264 run_test 162a "path lookup sanity"
13267 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13268 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13271 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
13272 error "create striped dir failed"
13274 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
13275 tail -n 1 | awk '{print $2}')
13276 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
13278 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
13279 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
13282 for ((i=0;i<5;i++)); do
13283 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
13284 error "get fid for f$i failed"
13285 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
13287 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
13288 error "get fid for d$i failed"
13289 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
13294 run_test 162b "striped directory path lookup sanity"
13296 # LU-4239: Verify fid2path works with paths 100 or more directories deep
13298 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
13299 skip "Need MDS version at least 2.7.51"
13301 local lpath=$tdir.local
13302 local rpath=$tdir.remote
13304 test_mkdir $DIR/$lpath
13305 test_mkdir $DIR/$rpath
13307 for ((i = 0; i <= 101; i++)); do
13310 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
13311 error "get fid for local directory $DIR/$lpath failed"
13312 check_path "$DIR/$lpath" $MOUNT $FID --link 0
13315 test_mkdir $DIR/$rpath
13316 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
13317 error "get fid for remote directory $DIR/$rpath failed"
13318 check_path "$DIR/$rpath" $MOUNT $FID --link 0
13323 run_test 162c "fid2path works with paths 100 or more directories deep"
13326 # do directio so as not to populate the page cache
13327 log "creating a 10 Mb file"
13328 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13329 log "starting reads"
13330 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13331 log "truncating the file"
13332 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13334 kill %+ || true # reads might have finished
13335 echo "wait until dd is finished"
13337 log "removing the temporary file"
13338 rm -rf $DIR/$tfile || error "tmp file removal failed"
13340 run_test 169 "parallel read and truncate should not deadlock"
13343 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13345 $LCTL clear # bug 18514
13346 $LCTL debug_daemon start $TMP/${tfile}_log_good
13348 $LCTL debug_daemon stop
13349 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
13350 error "sed failed to read log_good"
13352 $LCTL debug_daemon start $TMP/${tfile}_log_good
13354 $LCTL debug_daemon stop
13356 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
13357 error "lctl df log_bad failed"
13359 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13360 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13362 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
13363 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
13365 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
13366 error "bad_line good_line1 good_line2 are empty"
13368 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13369 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
13370 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13372 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
13373 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13374 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13376 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
13377 error "bad_line_new good_line_new are empty"
13379 local expected_good=$((good_line1 + good_line2*2))
13381 rm -f $TMP/${tfile}*
13382 # LU-231, short malformed line may not be counted into bad lines
13383 if [ $bad_line -ne $bad_line_new ] &&
13384 [ $bad_line -ne $((bad_line_new - 1)) ]; then
13385 error "expected $bad_line bad lines, but got $bad_line_new"
13389 if [ $expected_good -ne $good_line_new ]; then
13390 error "expected $expected_good good lines, but got $good_line_new"
13395 run_test 170 "test lctl df to handle corrupted log ====================="
13397 test_171() { # bug20592
13398 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13400 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
13401 $LCTL set_param fail_loc=0x50e
13402 $LCTL set_param fail_val=3000
13403 multiop_bg_pause $DIR/$tfile O_s || true
13405 kill -USR1 $MULTIPID
13409 if dmesg | grep "recursive fault"; then
13410 error "caught a recursive fault"
13412 $LCTL set_param fail_loc=0
13415 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
13417 # it would be good to share it with obdfilter-survey/iokit-libecho code
13418 setup_obdecho_osc () {
13421 local obdfilter_name=$2
13422 echo "Creating new osc for $obdfilter_name on $ost_nid"
13423 # make sure we can find loopback nid
13424 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
13426 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
13427 ${obdfilter_name}_osc_UUID || rc=2; }
13428 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
13429 ${obdfilter_name}_UUID $ost_nid || rc=3; }
13433 cleanup_obdecho_osc () {
13434 local obdfilter_name=$1
13435 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
13436 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
13443 local pages=${3:-64}
13448 local obd_size=$(get_obd_size $node $OBD)
13449 local page_size=$(get_page_size $node)
13450 if [[ -n "$obd_size" ]]; then
13451 local new_count=$((obd_size / (pages * page_size / 1024)))
13452 [[ $new_count -ge $count ]] || count=$new_count
13455 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
13456 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
13458 if [ $rc -eq 0 ]; then
13459 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
13460 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
13462 echo "New object id is $id"
13463 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
13465 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
13466 "test_brw $count w v $pages $id" || rc=4; }
13467 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
13469 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
13470 "cleanup" || rc=5; }
13471 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
13472 "detach" || rc=6; }
13473 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
13478 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13480 if ! module_loaded obdecho; then
13481 load_module obdecho/obdecho &&
13482 stack_trap "rmmod obdecho" EXIT ||
13483 error "unable to load obdecho on client"
13486 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
13487 local host=$($LCTL get_param -n osc.$osc.import |
13488 awk '/current_connection:/ { print $2 }' )
13489 local target=$($LCTL get_param -n osc.$osc.import |
13490 awk '/target:/ { print $2 }' )
13491 target=${target%_UUID}
13493 if [ -n "$target" ]; then
13494 setup_obdecho_osc $host $target &&
13495 stack_trap "cleanup_obdecho_osc $target" EXIT ||
13496 { error "obdecho setup failed with $?"; return; }
13498 obdecho_test ${target}_osc client ||
13499 error "obdecho_test failed on ${target}_osc"
13501 $LCTL get_param osc.$osc.import
13502 error "there is no osc.$osc.import target"
13505 run_test 180a "test obdecho on osc"
13508 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13509 remote_ost_nodsh && skip "remote OST with nodsh"
13511 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13512 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13513 error "failed to load module obdecho"
13515 local target=$(do_facet ost1 $LCTL dl |
13516 awk '/obdfilter/ { print $4; exit; }')
13518 if [ -n "$target" ]; then
13519 obdecho_test $target ost1 || error "obdecho_test failed with $?"
13521 do_facet ost1 $LCTL dl
13522 error "there is no obdfilter target on ost1"
13525 run_test 180b "test obdecho directly on obdfilter"
13527 test_180c() { # LU-2598
13528 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13529 remote_ost_nodsh && skip "remote OST with nodsh"
13530 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
13531 skip "Need MDS version at least 2.4.0"
13533 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13534 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13535 error "failed to load module obdecho"
13537 local target=$(do_facet ost1 $LCTL dl |
13538 awk '/obdfilter/ { print $4; exit; }')
13540 if [ -n "$target" ]; then
13541 local pages=16384 # 64MB bulk I/O RPC size
13543 obdecho_test "$target" ost1 "$pages" ||
13544 error "obdecho_test with pages=$pages failed with $?"
13546 do_facet ost1 $LCTL dl
13547 error "there is no obdfilter target on ost1"
13550 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
13552 test_181() { # bug 22177
13553 test_mkdir $DIR/$tdir
13554 # create enough files to index the directory
13555 createmany -o $DIR/$tdir/foobar 4000
13556 # print attributes for debug purpose
13559 multiop_bg_pause $DIR/$tdir D_Sc || return 1
13561 # remove the files & current working dir
13562 unlinkmany $DIR/$tdir/foobar 4000
13564 kill -USR1 $MULTIPID
13566 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
13569 run_test 181 "Test open-unlinked dir ========================"
13575 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13577 $LCTL set_param mdc.*.rpc_stats=clear
13579 for (( i = 0; i < $tcount; i++ )) ; do
13580 mkdir $DIR/$tdir/$i
13583 for (( i = 0; i < $tcount; i++ )) ; do
13584 createmany -o $DIR/$tdir/$i/f- $fcount &
13588 for (( i = 0; i < $tcount; i++ )) ; do
13589 unlinkmany $DIR/$tdir/$i/f- $fcount &
13593 $LCTL get_param mdc.*.rpc_stats
13597 run_test 182 "Test parallel modify metadata operations ================"
13599 test_183() { # LU-2275
13600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13601 remote_mds_nodsh && skip "remote MDS with nodsh"
13602 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
13603 skip "Need MDS version at least 2.3.56"
13605 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13606 echo aaa > $DIR/$tdir/$tfile
13608 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
13609 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
13611 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
13612 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
13614 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13616 # Flush negative dentry cache
13617 touch $DIR/$tdir/$tfile
13619 # We are not checking for any leaked references here, they'll
13620 # become evident next time we do cleanup with module unload.
13623 run_test 183 "No crash or request leak in case of strange dispositions ========"
13625 # test suite 184 is for LU-2016, LU-2017
13627 check_swap_layouts_support
13629 dir0=$DIR/$tdir/$testnum
13630 test_mkdir -p -c1 $dir0
13635 $LFS setstripe -c1 $file1
13637 $LFS setstripe -c2 $file2
13639 gen1=$($LFS getstripe -g $file1)
13640 gen2=$($LFS getstripe -g $file2)
13642 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
13643 gen=$($LFS getstripe -g $file1)
13644 [[ $gen1 != $gen ]] ||
13645 "Layout generation on $file1 does not change"
13646 gen=$($LFS getstripe -g $file2)
13647 [[ $gen2 != $gen ]] ||
13648 "Layout generation on $file2 does not change"
13650 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
13651 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13653 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
13655 run_test 184a "Basic layout swap"
13658 check_swap_layouts_support
13660 dir0=$DIR/$tdir/$testnum
13661 mkdir -p $dir0 || error "creating dir $dir0"
13668 $LFS setstripe -c1 $file1
13669 $LFS setstripe -c2 $file2
13670 $LFS setstripe -c1 $file3
13671 chown $RUNAS_ID $file3
13672 gen1=$($LFS getstripe -g $file1)
13673 gen2=$($LFS getstripe -g $file2)
13675 $LFS swap_layouts $dir1 $dir2 &&
13676 error "swap of directories layouts should fail"
13677 $LFS swap_layouts $dir1 $file1 &&
13678 error "swap of directory and file layouts should fail"
13679 $RUNAS $LFS swap_layouts $file1 $file2 &&
13680 error "swap of file we cannot write should fail"
13681 $LFS swap_layouts $file1 $file3 &&
13682 error "swap of file with different owner should fail"
13683 /bin/true # to clear error code
13685 run_test 184b "Forbidden layout swap (will generate errors)"
13688 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
13689 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
13690 check_swap_layouts_support
13692 local dir0=$DIR/$tdir/$testnum
13693 mkdir -p $dir0 || error "creating dir $dir0"
13695 local ref1=$dir0/ref1
13696 local ref2=$dir0/ref2
13697 local file1=$dir0/file1
13698 local file2=$dir0/file2
13699 # create a file large enough for the concurrent test
13700 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
13701 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
13702 echo "ref file size: ref1($(stat -c %s $ref1))," \
13703 "ref2($(stat -c %s $ref2))"
13706 dd if=$ref1 of=$file1 bs=16k &
13709 # Make sure dd starts to copy file
13710 while [ ! -f $file1 ]; do sleep 0.1; done
13712 $LFS swap_layouts $file1 $file2
13715 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
13716 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
13718 # how many bytes copied before swapping layout
13719 local copied=$(stat -c %s $file2)
13720 local remaining=$(stat -c %s $ref1)
13721 remaining=$((remaining - copied))
13722 echo "Copied $copied bytes before swapping layout..."
13724 cmp -n $copied $file1 $ref2 | grep differ &&
13725 error "Content mismatch [0, $copied) of ref2 and file1"
13726 cmp -n $copied $file2 $ref1 ||
13727 error "Content mismatch [0, $copied) of ref1 and file2"
13728 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
13729 error "Content mismatch [$copied, EOF) of ref1 and file1"
13732 rm -f $ref1 $ref2 $file1 $file2
13734 run_test 184c "Concurrent write and layout swap"
13737 check_swap_layouts_support
13738 [ -z "$(which getfattr 2>/dev/null)" ] &&
13739 skip_env "no getfattr command"
13741 local file1=$DIR/$tdir/$tfile-1
13742 local file2=$DIR/$tdir/$tfile-2
13743 local file3=$DIR/$tdir/$tfile-3
13747 mkdir -p $DIR/$tdir
13748 touch $file1 || error "create $file1 failed"
13749 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
13750 error "create $file2 failed"
13751 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
13752 error "create $file3 failed"
13753 lovea1=$(get_layout_param $file1)
13755 $LFS swap_layouts $file2 $file3 ||
13756 error "swap $file2 $file3 layouts failed"
13757 $LFS swap_layouts $file1 $file2 ||
13758 error "swap $file1 $file2 layouts failed"
13760 lovea2=$(get_layout_param $file2)
13763 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
13765 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
13766 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
13768 run_test 184d "allow stripeless layouts swap"
13771 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
13772 skip "Need MDS version at least 2.6.94"
13773 check_swap_layouts_support
13774 [ -z "$(which getfattr 2>/dev/null)" ] &&
13775 skip_env "no getfattr command"
13777 local file1=$DIR/$tdir/$tfile-1
13778 local file2=$DIR/$tdir/$tfile-2
13779 local file3=$DIR/$tdir/$tfile-3
13782 mkdir -p $DIR/$tdir
13783 touch $file1 || error "create $file1 failed"
13784 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
13785 error "create $file2 failed"
13786 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
13787 error "create $file3 failed"
13789 $LFS swap_layouts $file1 $file2 ||
13790 error "swap $file1 $file2 layouts failed"
13792 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
13793 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
13795 echo 123 > $file1 || error "Should be able to write into $file1"
13797 $LFS swap_layouts $file1 $file3 ||
13798 error "swap $file1 $file3 layouts failed"
13800 echo 123 > $file1 || error "Should be able to write into $file1"
13802 rm -rf $file1 $file2 $file3
13804 run_test 184e "Recreate layout after stripeless layout swaps"
13807 # Create a file with name longer than sizeof(struct stat) ==
13808 # 144 to see if we can get chars from the file name to appear
13809 # in the returned striping. Note that 'f' == 0x66.
13810 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
13812 mkdir -p $DIR/$tdir
13813 mcreate $DIR/$tdir/$file
13814 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
13815 error "IOC_MDC_GETFILEINFO returned garbage striping"
13818 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
13820 test_185() { # LU-2441
13821 # LU-3553 - no volatile file support in old servers
13822 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
13823 skip "Need MDS version at least 2.3.60"
13825 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13826 touch $DIR/$tdir/spoo
13827 local mtime1=$(stat -c "%Y" $DIR/$tdir)
13828 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
13829 error "cannot create/write a volatile file"
13830 [ "$FILESET" == "" ] &&
13831 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
13832 error "FID is still valid after close"
13834 multiop_bg_pause $DIR/$tdir vVw4096_c
13841 # assume that the next FID for this client is sequential, since stdout
13842 # is unfortunately eaten by multiop_bg_pause
13843 local n=$((${fidv[1]} + 1))
13844 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
13845 if [ "$FILESET" == "" ]; then
13846 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
13847 error "FID is missing before close"
13849 kill -USR1 $multi_pid
13850 # 1 second delay, so if mtime change we will see it
13852 local mtime2=$(stat -c "%Y" $DIR/$tdir)
13853 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
13855 run_test 185 "Volatile file support"
13858 remote_mds_nodsh && skip "remote MDS with nodsh"
13859 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
13860 skip "Need MDS version at least 2.3.0"
13862 local dir0=$DIR/$tdir/$testnum
13863 mkdir -p $dir0 || error "creating dir $dir0"
13865 local file=$dir0/file1
13866 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
13867 local dv1=$($LFS data_version $file)
13868 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
13869 local dv2=$($LFS data_version $file)
13870 [[ $dv1 != $dv2 ]] ||
13871 error "data version did not change on write $dv1 == $dv2"
13876 run_test 187a "Test data version change"
13879 remote_mds_nodsh && skip "remote MDS with nodsh"
13880 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
13881 skip "Need MDS version at least 2.3.0"
13883 local dir0=$DIR/$tdir/$testnum
13884 mkdir -p $dir0 || error "creating dir $dir0"
13886 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
13887 [[ ${DV[0]} != ${DV[1]} ]] ||
13888 error "data version did not change on write"\
13889 " ${DV[0]} == ${DV[1]}"
13894 run_test 187b "Test data version change on volatile file"
13897 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13898 remote_mgs_nodsh && skip "remote MGS with nodsh"
13899 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13901 local POOL=${POOL:-cea1}
13902 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
13903 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
13906 local last_ost=$(($OSTCOUNT - 1))
13908 local ost_list=$(seq $first_ost $ost_step $last_ost)
13909 local ost_range="$first_ost $last_ost $ost_step"
13910 local test_path=$POOL_ROOT/$POOL_DIR_NAME
13911 local file_dir=$POOL_ROOT/file_tst
13912 local subdir=$test_path/subdir
13915 if ! combined_mgs_mds ; then
13920 # former test_200a test_200b
13921 pool_add $POOL || { rc=$? ; break; }
13922 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
13923 # former test_200c test_200d
13924 mkdir -p $test_path
13925 pool_set_dir $POOL $test_path || { rc=$? ; break; }
13926 pool_check_dir $POOL $test_path || { rc=$? ; break; }
13928 pool_check_dir $POOL $subdir || { rc=$? ; break; }
13929 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
13930 || { rc=$? ; break; }
13931 # former test_200e test_200f
13932 local files=$((OSTCOUNT*3))
13933 pool_alloc_files $POOL $test_path $files "$ost_list" \
13934 || { rc=$? ; break; }
13935 pool_create_files $POOL $file_dir $files "$ost_list" \
13936 || { rc=$? ; break; }
13937 # former test_200g test_200h
13938 pool_lfs_df $POOL || { rc=$? ; break; }
13939 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
13941 # former test_201a test_201b test_201c
13942 pool_remove_first_target $POOL || { rc=$? ; break; }
13944 local f=$test_path/$tfile
13945 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
13946 pool_remove $POOL $f || { rc=$? ; break; }
13952 if ! combined_mgs_mds ; then
13957 run_test 200 "OST pools"
13959 # usage: default_attr <count | size | offset>
13961 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
13964 # usage: check_default_stripe_attr
13965 check_default_stripe_attr() {
13966 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
13969 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
13971 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
13975 error "unknown getstripe attr '$1'"
13978 [ $ACTUAL == $EXPECTED ] ||
13979 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
13983 test_mkdir $DIR/$tdir
13984 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
13986 check_default_stripe_attr --stripe-count
13987 check_default_stripe_attr --stripe-size
13988 check_default_stripe_attr --stripe-index
13990 run_test 204a "Print default stripe attributes"
13993 test_mkdir $DIR/$tdir
13994 $LFS setstripe --stripe-count 1 $DIR/$tdir
13996 check_default_stripe_attr --stripe-size
13997 check_default_stripe_attr --stripe-index
13999 run_test 204b "Print default stripe size and offset"
14002 test_mkdir $DIR/$tdir
14003 $LFS setstripe --stripe-size 65536 $DIR/$tdir
14005 check_default_stripe_attr --stripe-count
14006 check_default_stripe_attr --stripe-index
14008 run_test 204c "Print default stripe count and offset"
14011 test_mkdir $DIR/$tdir
14012 $LFS setstripe --stripe-index 0 $DIR/$tdir
14014 check_default_stripe_attr --stripe-count
14015 check_default_stripe_attr --stripe-size
14017 run_test 204d "Print default stripe count and size"
14020 test_mkdir $DIR/$tdir
14021 $LFS setstripe -d $DIR/$tdir
14023 check_default_stripe_attr --stripe-count --raw
14024 check_default_stripe_attr --stripe-size --raw
14025 check_default_stripe_attr --stripe-index --raw
14027 run_test 204e "Print raw stripe attributes"
14030 test_mkdir $DIR/$tdir
14031 $LFS setstripe --stripe-count 1 $DIR/$tdir
14033 check_default_stripe_attr --stripe-size --raw
14034 check_default_stripe_attr --stripe-index --raw
14036 run_test 204f "Print raw stripe size and offset"
14039 test_mkdir $DIR/$tdir
14040 $LFS setstripe --stripe-size 65536 $DIR/$tdir
14042 check_default_stripe_attr --stripe-count --raw
14043 check_default_stripe_attr --stripe-index --raw
14045 run_test 204g "Print raw stripe count and offset"
14048 test_mkdir $DIR/$tdir
14049 $LFS setstripe --stripe-index 0 $DIR/$tdir
14051 check_default_stripe_attr --stripe-count --raw
14052 check_default_stripe_attr --stripe-size --raw
14054 run_test 204h "Print raw stripe count and size"
14056 # Figure out which job scheduler is being used, if any,
14057 # or use a fake one
14058 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
14059 JOBENV=SLURM_JOB_ID
14060 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
14062 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
14064 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
14065 JOBENV=LOADL_STEP_ID
14066 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
14069 $LCTL list_param jobid_name > /dev/null 2>&1
14070 if [ $? -eq 0 ]; then
14076 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
14078 verify_jobstats() {
14083 # we don't really need to clear the stats for this test to work, since each
14084 # command has a unique jobid, but it makes debugging easier if needed.
14085 # for facet in $facets; do
14086 # local dev=$(convert_facet2label $facet)
14087 # # clear old jobstats
14088 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
14091 # use a new JobID for each test, or we might see an old one
14092 [ "$JOBENV" = "FAKE_JOBID" ] &&
14093 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
14095 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
14097 [ "$JOBENV" = "nodelocal" ] && {
14098 FAKE_JOBID=id.$testnum.%e.$RANDOM
14099 $LCTL set_param jobid_name=$FAKE_JOBID
14100 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
14103 log "Test: ${cmd[*]}"
14104 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
14106 if [ $JOBENV = "FAKE_JOBID" ]; then
14107 FAKE_JOBID=$JOBVAL ${cmd[*]}
14112 # all files are created on OST0000
14113 for facet in $facets; do
14114 local stats="*.$(convert_facet2label $facet).job_stats"
14116 # strip out libtool wrappers for in-tree executables
14117 if [ $(do_facet $facet lctl get_param $stats |
14118 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
14119 do_facet $facet lctl get_param $stats
14120 error "No jobstats for $JOBVAL found on $facet::$stats"
14126 local new_jobenv=$1
14128 set_persistent_param_and_check client "jobid_var" \
14129 "$FSNAME.sys.jobid_var" $new_jobenv
14132 test_205() { # Job stats
14133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14134 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
14135 skip "Need MDS version with at least 2.7.1"
14136 remote_mgs_nodsh && skip "remote MGS with nodsh"
14137 remote_mds_nodsh && skip "remote MDS with nodsh"
14138 remote_ost_nodsh && skip "remote OST with nodsh"
14139 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
14140 skip "Server doesn't support jobstats"
14141 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
14143 local old_jobenv=$($LCTL get_param -n jobid_var)
14144 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
14146 if [[ $PERM_CMD == *"set_param -P"* ]]; then
14147 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
14149 stack_trap "do_facet mgs $PERM_CMD \
14150 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
14154 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
14155 mdt.*.job_cleanup_interval | head -n 1)
14156 local new_interval=5
14157 do_facet $SINGLEMDS \
14158 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
14159 stack_trap "do_facet $SINGLEMDS \
14160 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
14161 local start=$SECONDS
14165 cmd="mkdir $DIR/$tdir"
14166 verify_jobstats "$cmd" "$SINGLEMDS"
14168 cmd="rmdir $DIR/$tdir"
14169 verify_jobstats "$cmd" "$SINGLEMDS"
14170 # mkdir on secondary MDT
14171 if [ $MDSCOUNT -gt 1 ]; then
14172 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
14173 verify_jobstats "$cmd" "mds2"
14176 cmd="mknod $DIR/$tfile c 1 3"
14177 verify_jobstats "$cmd" "$SINGLEMDS"
14179 cmd="rm -f $DIR/$tfile"
14180 verify_jobstats "$cmd" "$SINGLEMDS"
14181 # create all files on OST0000 so verify_jobstats can find OST stats
14183 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
14184 verify_jobstats "$cmd" "$SINGLEMDS"
14186 cmd="touch $DIR/$tfile"
14187 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14189 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
14190 verify_jobstats "$cmd" "ost1"
14192 cancel_lru_locks osc
14193 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
14194 verify_jobstats "$cmd" "ost1"
14196 cmd="$TRUNCATE $DIR/$tfile 0"
14197 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14199 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
14200 verify_jobstats "$cmd" "$SINGLEMDS"
14201 # jobstats expiry - sleep until old stats should be expired
14202 local left=$((new_interval + 5 - (SECONDS - start)))
14203 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
14204 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
14206 cmd="mkdir $DIR/$tdir.expire"
14207 verify_jobstats "$cmd" "$SINGLEMDS"
14208 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
14209 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
14211 # Ensure that jobid are present in changelog (if supported by MDS)
14212 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
14213 changelog_dump | tail -10
14214 jobids=$(changelog_dump | tail -9 | grep -c "j=")
14215 [ $jobids -eq 9 ] ||
14216 error "Wrong changelog jobid count $jobids != 9"
14220 jobstats_set $JOBENV
14222 changelog_dump | grep $tfile
14223 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
14224 [ $jobids -eq 0 ] ||
14225 error "Unexpected jobids when jobid_var=$JOBENV"
14228 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
14229 JOBENV="JOBCOMPLEX"
14230 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
14232 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
14234 run_test 205 "Verify job stats"
14236 # LU-1480, LU-1773 and LU-1657
14238 mkdir -p $DIR/$tdir
14239 $LFS setstripe -c -1 $DIR/$tdir
14240 #define OBD_FAIL_LOV_INIT 0x1403
14241 $LCTL set_param fail_loc=0xa0001403
14242 $LCTL set_param fail_val=1
14243 touch $DIR/$tdir/$tfile || true
14245 run_test 206 "fail lov_init_raid0() doesn't lbug"
14248 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
14249 local fsz=`stat -c %s $DIR/$tfile`
14250 cancel_lru_locks mdc
14252 # do not return layout in getattr intent
14253 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
14254 $LCTL set_param fail_loc=0x170
14255 local sz=`stat -c %s $DIR/$tfile`
14257 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
14261 run_test 207a "can refresh layout at glimpse"
14264 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
14265 local cksum=`md5sum $DIR/$tfile`
14266 local fsz=`stat -c %s $DIR/$tfile`
14267 cancel_lru_locks mdc
14268 cancel_lru_locks osc
14270 # do not return layout in getattr intent
14271 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
14272 $LCTL set_param fail_loc=0x171
14274 # it will refresh layout after the file is opened but before read issues
14275 echo checksum is "$cksum"
14276 echo "$cksum" |md5sum -c --quiet || error "file differs"
14280 run_test 207b "can refresh layout at open"
14283 # FIXME: in this test suite, only RD lease is used. This is okay
14284 # for now as only exclusive open is supported. After generic lease
14285 # is done, this test suite should be revised. - Jinshan
14287 remote_mds_nodsh && skip "remote MDS with nodsh"
14288 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
14289 skip "Need MDS version at least 2.4.52"
14291 echo "==== test 1: verify get lease work"
14292 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
14294 echo "==== test 2: verify lease can be broken by upcoming open"
14295 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14299 $MULTIOP $DIR/$tfile oO_RDONLY:c
14300 kill -USR1 $PID && wait $PID || error "break lease error"
14302 echo "==== test 3: verify lease can't be granted if an open already exists"
14303 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
14307 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
14308 kill -USR1 $PID && wait $PID || error "open file error"
14310 echo "==== test 4: lease can sustain over recovery"
14311 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
14317 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
14319 echo "==== test 5: lease broken can't be regained by replay"
14320 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14324 # open file to break lease and then recovery
14325 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
14328 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
14332 run_test 208 "Exclusive open"
14335 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
14336 skip_env "must have disp_stripe"
14339 sync; sleep 5; sync;
14341 echo 3 > /proc/sys/vm/drop_caches
14342 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14344 # open/close 500 times
14345 for i in $(seq 500); do
14349 echo 3 > /proc/sys/vm/drop_caches
14350 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14352 echo "before: $req_before, after: $req_after"
14353 [ $((req_after - req_before)) -ge 300 ] &&
14354 error "open/close requests are not freed"
14357 run_test 209 "read-only open/close requests should be freed promptly"
14361 size=$((size % 8192 + 1))
14362 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
14363 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
14364 rm -f $DIR/f212 $DIR/f212.xyz
14366 run_test 212 "Sendfile test ============================================"
14369 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
14370 cancel_lru_locks osc
14371 lctl set_param fail_loc=0x8000040f
14372 # generate a read lock
14373 cat $DIR/$tfile > /dev/null
14374 # write to the file, it will try to cancel the above read lock.
14375 cat /etc/hosts >> $DIR/$tfile
14377 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
14379 test_214() { # for bug 20133
14380 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
14381 for (( i=0; i < 340; i++ )) ; do
14382 touch $DIR/$tdir/d214c/a$i
14385 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
14386 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
14387 ls $DIR/d214c || error "ls $DIR/d214c failed"
14388 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
14389 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
14391 run_test 214 "hash-indexed directory test - bug 20133"
14393 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
14394 create_lnet_proc_files() {
14395 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
14398 # counterpart of create_lnet_proc_files
14399 remove_lnet_proc_files() {
14400 rm -f $TMP/lnet_$1.sys
14403 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14404 # 3rd arg as regexp for body
14405 check_lnet_proc_stats() {
14406 local l=$(cat "$TMP/lnet_$1" |wc -l)
14407 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
14409 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
14412 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14413 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
14414 # optional and can be regexp for 2nd line (lnet.routes case)
14415 check_lnet_proc_entry() {
14416 local blp=2 # blp stands for 'position of 1st line of body'
14417 [ -z "$5" ] || blp=3 # lnet.routes case
14419 local l=$(cat "$TMP/lnet_$1" |wc -l)
14420 # subtracting one from $blp because the body can be empty
14421 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
14423 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
14424 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
14426 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
14427 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
14429 # bail out if any unexpected line happened
14430 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
14431 [ "$?" != 0 ] || error "$2 misformatted"
14434 test_215() { # for bugs 18102, 21079, 21517
14435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14437 local N='(0|[1-9][0-9]*)' # non-negative numeric
14438 local P='[1-9][0-9]*' # positive numeric
14439 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
14440 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
14441 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
14442 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
14444 local L1 # regexp for 1st line
14445 local L2 # regexp for 2nd line (optional)
14446 local BR # regexp for the rest (body)
14448 # lnet.stats should look as 11 space-separated non-negative numerics
14449 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
14450 create_lnet_proc_files "stats"
14451 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
14452 remove_lnet_proc_files "stats"
14454 # lnet.routes should look like this:
14455 # Routing disabled/enabled
14456 # net hops priority state router
14457 # where net is a string like tcp0, hops > 0, priority >= 0,
14458 # state is up/down,
14459 # router is a string like 192.168.1.1@tcp2
14460 L1="^Routing (disabled|enabled)$"
14461 L2="^net +hops +priority +state +router$"
14462 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
14463 create_lnet_proc_files "routes"
14464 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
14465 remove_lnet_proc_files "routes"
14467 # lnet.routers should look like this:
14468 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
14469 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
14470 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
14471 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
14472 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
14473 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
14474 create_lnet_proc_files "routers"
14475 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
14476 remove_lnet_proc_files "routers"
14478 # lnet.peers should look like this:
14479 # nid refs state last max rtr min tx min queue
14480 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
14481 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
14482 # numeric (0 or >0 or <0), queue >= 0.
14483 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
14484 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
14485 create_lnet_proc_files "peers"
14486 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
14487 remove_lnet_proc_files "peers"
14489 # lnet.buffers should look like this:
14490 # pages count credits min
14491 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
14492 L1="^pages +count +credits +min$"
14493 BR="^ +$N +$N +$I +$I$"
14494 create_lnet_proc_files "buffers"
14495 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
14496 remove_lnet_proc_files "buffers"
14498 # lnet.nis should look like this:
14499 # nid status alive refs peer rtr max tx min
14500 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
14501 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
14502 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
14503 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
14504 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
14505 create_lnet_proc_files "nis"
14506 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
14507 remove_lnet_proc_files "nis"
14509 # can we successfully write to lnet.stats?
14510 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
14512 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
14514 test_216() { # bug 20317
14515 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14516 remote_ost_nodsh && skip "remote OST with nodsh"
14519 local facets=$(get_facets OST)
14520 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14522 save_lustre_params client "osc.*.contention_seconds" > $p
14523 save_lustre_params $facets \
14524 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
14525 save_lustre_params $facets \
14526 "ldlm.namespaces.filter-*.contended_locks" >> $p
14527 save_lustre_params $facets \
14528 "ldlm.namespaces.filter-*.contention_seconds" >> $p
14529 clear_stats osc.*.osc_stats
14531 # agressive lockless i/o settings
14532 do_nodes $(comma_list $(osts_nodes)) \
14533 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
14534 ldlm.namespaces.filter-*.contended_locks=0 \
14535 ldlm.namespaces.filter-*.contention_seconds=60"
14536 lctl set_param -n osc.*.contention_seconds=60
14538 $DIRECTIO write $DIR/$tfile 0 10 4096
14539 $CHECKSTAT -s 40960 $DIR/$tfile
14541 # disable lockless i/o
14542 do_nodes $(comma_list $(osts_nodes)) \
14543 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
14544 ldlm.namespaces.filter-*.contended_locks=32 \
14545 ldlm.namespaces.filter-*.contention_seconds=0"
14546 lctl set_param -n osc.*.contention_seconds=0
14547 clear_stats osc.*.osc_stats
14549 dd if=/dev/zero of=$DIR/$tfile count=0
14550 $CHECKSTAT -s 0 $DIR/$tfile
14552 restore_lustre_params <$p
14556 run_test 216 "check lockless direct write updates file size and kms correctly"
14558 test_217() { # bug 22430
14559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14564 for node in $(nodes_list); do
14565 nid=$(host_nids_address $node $NETTYPE)
14566 if [[ $nid = *-* ]] ; then
14567 echo "lctl ping $(h2nettype $nid)"
14568 lctl ping $(h2nettype $nid)
14570 echo "skipping $node (no hyphen detected)"
14574 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
14577 # do directio so as not to populate the page cache
14578 log "creating a 10 Mb file"
14579 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14580 log "starting reads"
14581 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14582 log "truncating the file"
14583 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14585 kill %+ || true # reads might have finished
14586 echo "wait until dd is finished"
14588 log "removing the temporary file"
14589 rm -rf $DIR/$tfile || error "tmp file removal failed"
14591 run_test 218 "parallel read and truncate should not deadlock"
14594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14596 # write one partial page
14597 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
14598 # set no grant so vvp_io_commit_write will do sync write
14599 $LCTL set_param fail_loc=0x411
14600 # write a full page at the end of file
14601 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
14603 $LCTL set_param fail_loc=0
14604 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
14605 $LCTL set_param fail_loc=0x411
14606 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
14609 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
14610 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
14612 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
14614 test_220() { #LU-325
14615 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14616 remote_ost_nodsh && skip "remote OST with nodsh"
14617 remote_mds_nodsh && skip "remote MDS with nodsh"
14618 remote_mgs_nodsh && skip "remote MGS with nodsh"
14622 # create on MDT0000 so the last_id and next_id are correct
14624 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
14628 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
14629 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
14630 osc.$mdtosc_proc1.prealloc_last_id)
14631 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
14632 osc.$mdtosc_proc1.prealloc_next_id)
14636 if ! combined_mgs_mds ; then
14640 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
14641 #define OBD_FAIL_OST_ENOINO 0x229
14642 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
14643 create_pool $FSNAME.$TESTNAME || return 1
14644 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
14646 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
14648 MDSOBJS=$((last_id - next_id))
14649 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
14651 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
14652 echo "OST still has $count kbytes free"
14654 echo "create $MDSOBJS files @next_id..."
14655 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
14657 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14658 osc.$mdtosc_proc1.prealloc_last_id)
14659 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14660 osc.$mdtosc_proc1.prealloc_next_id)
14662 echo "after creation, last_id=$last_id2, next_id=$next_id2"
14667 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
14668 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
14670 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
14671 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
14672 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14673 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
14674 echo "unlink $MDSOBJS files @$next_id..."
14675 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
14677 if ! combined_mgs_mds ; then
14681 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
14684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14686 dd if=`which date` of=$MOUNT/date oflag=sync
14687 chmod +x $MOUNT/date
14689 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
14690 $LCTL set_param fail_loc=0x80001401
14692 $MOUNT/date > /dev/null
14695 run_test 221 "make sure fault and truncate race to not cause OOM"
14698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14701 test_mkdir $DIR/$tdir
14702 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14703 createmany -o $DIR/$tdir/$tfile 10
14704 cancel_lru_locks mdc
14705 cancel_lru_locks osc
14706 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
14707 $LCTL set_param fail_loc=0x31a
14708 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
14709 $LCTL set_param fail_loc=0
14712 run_test 222a "AGL for ls should not trigger CLIO lock failure"
14715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14718 test_mkdir $DIR/$tdir
14719 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14720 createmany -o $DIR/$tdir/$tfile 10
14721 cancel_lru_locks mdc
14722 cancel_lru_locks osc
14723 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
14724 $LCTL set_param fail_loc=0x31a
14725 rm -r $DIR/$tdir || error "AGL for rmdir failed"
14726 $LCTL set_param fail_loc=0
14728 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
14731 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14734 test_mkdir $DIR/$tdir
14735 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14736 createmany -o $DIR/$tdir/$tfile 10
14737 cancel_lru_locks mdc
14738 cancel_lru_locks osc
14739 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
14740 $LCTL set_param fail_loc=0x31b
14741 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
14742 $LCTL set_param fail_loc=0
14745 run_test 223 "osc reenqueue if without AGL lock granted ======================="
14747 test_224a() { # LU-1039, MRP-303
14748 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14750 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
14751 $LCTL set_param fail_loc=0x508
14752 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
14753 $LCTL set_param fail_loc=0
14756 run_test 224a "Don't panic on bulk IO failure"
14758 test_224b() { # LU-1039, MRP-303
14759 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14761 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
14762 cancel_lru_locks osc
14763 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
14764 $LCTL set_param fail_loc=0x515
14765 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
14766 $LCTL set_param fail_loc=0
14769 run_test 224b "Don't panic on bulk IO failure"
14771 test_224c() { # LU-6441
14772 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14773 remote_mds_nodsh && skip "remote MDS with nodsh"
14775 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14776 save_writethrough $p
14777 set_cache writethrough on
14779 local pages_per_rpc=$($LCTL get_param \
14780 osc.*.max_pages_per_rpc)
14781 local at_max=$($LCTL get_param -n at_max)
14782 local timeout=$($LCTL get_param -n timeout)
14783 local test_at="at_max"
14784 local param_at="$FSNAME.sys.at_max"
14785 local test_timeout="timeout"
14786 local param_timeout="$FSNAME.sys.timeout"
14788 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
14790 set_persistent_param_and_check client "$test_at" "$param_at" 0
14791 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
14793 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
14794 do_facet ost1 "$LCTL set_param fail_loc=0x520"
14795 $LFS setstripe -c 1 -i 0 $DIR/$tfile
14796 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
14798 do_facet ost1 "$LCTL set_param fail_loc=0"
14800 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
14801 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
14804 $LCTL set_param -n $pages_per_rpc
14805 restore_lustre_params < $p
14808 run_test 224c "Don't hang if one of md lost during large bulk RPC"
14810 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
14812 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14813 if [ -z ${MDSSURVEY} ]; then
14814 skip_env "mds-survey not found"
14816 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
14817 skip "Need MDS version at least 2.2.51"
14819 local mds=$(facet_host $SINGLEMDS)
14820 local target=$(do_nodes $mds 'lctl dl' |
14821 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
14823 local cmd1="file_count=1000 thrhi=4"
14824 local cmd2="dir_count=2 layer=mdd stripe_count=0"
14825 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
14826 local cmd="$cmd1 $cmd2 $cmd3"
14828 rm -f ${TMP}/mds_survey*
14830 eval $cmd || error "mds-survey with zero-stripe failed"
14831 cat ${TMP}/mds_survey*
14832 rm -f ${TMP}/mds_survey*
14834 run_test 225a "Metadata survey sanity with zero-stripe"
14837 if [ -z ${MDSSURVEY} ]; then
14838 skip_env "mds-survey not found"
14840 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
14841 skip "Need MDS version at least 2.2.51"
14842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14843 remote_mds_nodsh && skip "remote MDS with nodsh"
14844 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
14845 skip_env "Need to mount OST to test"
14848 local mds=$(facet_host $SINGLEMDS)
14849 local target=$(do_nodes $mds 'lctl dl' |
14850 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
14852 local cmd1="file_count=1000 thrhi=4"
14853 local cmd2="dir_count=2 layer=mdd stripe_count=1"
14854 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
14855 local cmd="$cmd1 $cmd2 $cmd3"
14857 rm -f ${TMP}/mds_survey*
14859 eval $cmd || error "mds-survey with stripe_count failed"
14860 cat ${TMP}/mds_survey*
14861 rm -f ${TMP}/mds_survey*
14863 run_test 225b "Metadata survey sanity with stripe_count = 1"
14865 mcreate_path2fid () {
14871 local path=$DIR/$tdir/$name
14876 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
14877 error "cannot create $desc"
14879 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
14881 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
14883 fid_path=$($LFS fid2path $MOUNT $fid)
14885 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
14887 [ "$path" == "$fid_path" ] ||
14888 error "fid2path returned $fid_path, expected $path"
14890 echo "pass with $path and $fid"
14895 mkdir -p $DIR/$tdir
14897 mcreate_path2fid 0010666 0 0 fifo "FIFO"
14898 mcreate_path2fid 0020666 1 3 null "character special file (null)"
14899 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
14900 mcreate_path2fid 0040666 0 0 dir "directory"
14901 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
14902 mcreate_path2fid 0100666 0 0 file "regular file"
14903 mcreate_path2fid 0120666 0 0 link "symbolic link"
14904 mcreate_path2fid 0140666 0 0 sock "socket"
14906 run_test 226a "call path2fid and fid2path on files of all type"
14909 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14914 mkdir -p $DIR/$tdir
14915 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
14916 error "create remote directory failed"
14917 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
14918 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
14919 "character special file (null)"
14920 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
14921 "character special file (no device)"
14922 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
14923 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
14924 "block special file (loop)"
14925 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
14926 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
14927 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
14929 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
14931 # LU-1299 Executing or running ldd on a truncated executable does not
14932 # cause an out-of-memory condition.
14934 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14935 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
14937 dd if=$(which date) of=$MOUNT/date bs=1k count=1
14938 chmod +x $MOUNT/date
14940 $MOUNT/date > /dev/null
14941 ldd $MOUNT/date > /dev/null
14944 run_test 227 "running truncated executable does not cause OOM"
14946 # LU-1512 try to reuse idle OI blocks
14948 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14949 remote_mds_nodsh && skip "remote MDS with nodsh"
14950 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
14952 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14953 local myDIR=$DIR/$tdir
14956 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14957 $LCTL set_param fail_loc=0x80001002
14958 createmany -o $myDIR/t- 10000
14959 $LCTL set_param fail_loc=0
14960 # The guard is current the largest FID holder
14962 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14964 local IDX=$(($SEQ % 64))
14966 do_facet $SINGLEMDS sync
14967 # Make sure journal flushed.
14969 local blk1=$(do_facet $SINGLEMDS \
14970 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14971 grep Blockcount | awk '{print $4}')
14973 # Remove old files, some OI blocks will become idle.
14974 unlinkmany $myDIR/t- 10000
14975 # Create new files, idle OI blocks should be reused.
14976 createmany -o $myDIR/t- 2000
14977 do_facet $SINGLEMDS sync
14978 # Make sure journal flushed.
14980 local blk2=$(do_facet $SINGLEMDS \
14981 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14982 grep Blockcount | awk '{print $4}')
14984 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14986 run_test 228a "try to reuse idle OI blocks"
14989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14990 remote_mds_nodsh && skip "remote MDS with nodsh"
14991 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
14993 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14994 local myDIR=$DIR/$tdir
14997 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14998 $LCTL set_param fail_loc=0x80001002
14999 createmany -o $myDIR/t- 10000
15000 $LCTL set_param fail_loc=0
15001 # The guard is current the largest FID holder
15003 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15005 local IDX=$(($SEQ % 64))
15007 do_facet $SINGLEMDS sync
15008 # Make sure journal flushed.
15010 local blk1=$(do_facet $SINGLEMDS \
15011 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15012 grep Blockcount | awk '{print $4}')
15014 # Remove old files, some OI blocks will become idle.
15015 unlinkmany $myDIR/t- 10000
15018 stop $SINGLEMDS || error "Fail to stop MDT."
15020 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
15022 df $MOUNT || error "Fail to df."
15023 # Create new files, idle OI blocks should be reused.
15024 createmany -o $myDIR/t- 2000
15025 do_facet $SINGLEMDS sync
15026 # Make sure journal flushed.
15028 local blk2=$(do_facet $SINGLEMDS \
15029 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15030 grep Blockcount | awk '{print $4}')
15032 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15034 run_test 228b "idle OI blocks can be reused after MDT restart"
15038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15039 remote_mds_nodsh && skip "remote MDS with nodsh"
15040 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15042 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15043 local myDIR=$DIR/$tdir
15046 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15047 $LCTL set_param fail_loc=0x80001002
15048 # 20000 files can guarantee there are index nodes in the OI file
15049 createmany -o $myDIR/t- 20000
15050 $LCTL set_param fail_loc=0
15051 # The guard is current the largest FID holder
15053 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15055 local IDX=$(($SEQ % 64))
15057 do_facet $SINGLEMDS sync
15058 # Make sure journal flushed.
15060 local blk1=$(do_facet $SINGLEMDS \
15061 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15062 grep Blockcount | awk '{print $4}')
15064 # Remove old files, some OI blocks will become idle.
15065 unlinkmany $myDIR/t- 20000
15067 # The OI file should become empty now
15069 # Create new files, idle OI blocks should be reused.
15070 createmany -o $myDIR/t- 2000
15071 do_facet $SINGLEMDS sync
15072 # Make sure journal flushed.
15074 local blk2=$(do_facet $SINGLEMDS \
15075 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15076 grep Blockcount | awk '{print $4}')
15078 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15080 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
15082 test_229() { # LU-2482, LU-3448
15083 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15084 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
15085 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
15086 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
15090 # Create a file with a released layout and stripe count 2.
15091 $MULTIOP $DIR/$tfile H2c ||
15092 error "failed to create file with released layout"
15094 $LFS getstripe -v $DIR/$tfile
15096 local pattern=$($LFS getstripe -L $DIR/$tfile)
15097 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
15099 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
15101 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
15102 stat $DIR/$tfile || error "failed to stat released file"
15104 chown $RUNAS_ID $DIR/$tfile ||
15105 error "chown $RUNAS_ID $DIR/$tfile failed"
15107 chgrp $RUNAS_ID $DIR/$tfile ||
15108 error "chgrp $RUNAS_ID $DIR/$tfile failed"
15110 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
15111 rm $DIR/$tfile || error "failed to remove released file"
15113 run_test 229 "getstripe/stat/rm/attr changes work on released files"
15116 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15117 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15118 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15119 skip "Need MDS version at least 2.11.52"
15123 test_mkdir $DIR/$tdir
15124 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
15125 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
15126 [ $mdt_idx -ne 0 ] &&
15127 error "create local directory on wrong MDT $mdt_idx"
15129 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
15130 error "create remote directory failed"
15131 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
15132 [ $mdt_idx -ne $MDTIDX ] &&
15133 error "create remote directory on wrong MDT $mdt_idx"
15135 createmany -o $DIR/$tdir/test_230/t- 10 ||
15136 error "create files on remote directory failed"
15137 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
15138 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
15139 rm -r $DIR/$tdir || error "unlink remote directory failed"
15141 run_test 230a "Create remote directory and files under the remote directory"
15144 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15145 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15146 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15147 skip "Need MDS version at least 2.11.52"
15155 local migrate_dir=$DIR/$tdir/migrate_dir
15156 local other_dir=$DIR/$tdir/other_dir
15158 test_mkdir $DIR/$tdir
15159 test_mkdir -i0 -c1 $migrate_dir
15160 test_mkdir -i0 -c1 $other_dir
15161 for ((i=0; i<10; i++)); do
15162 mkdir -p $migrate_dir/dir_${i}
15163 createmany -o $migrate_dir/dir_${i}/f 10 ||
15164 error "create files under remote dir failed $i"
15167 cp /etc/passwd $migrate_dir/$tfile
15168 cp /etc/passwd $other_dir/$tfile
15169 chattr +SAD $migrate_dir
15170 chattr +SAD $migrate_dir/$tfile
15172 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15173 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15174 local old_dir_mode=$(stat -c%f $migrate_dir)
15175 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
15177 mkdir -p $migrate_dir/dir_default_stripe2
15178 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
15179 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
15181 mkdir -p $other_dir
15182 ln $migrate_dir/$tfile $other_dir/luna
15183 ln $migrate_dir/$tfile $migrate_dir/sofia
15184 ln $other_dir/$tfile $migrate_dir/david
15185 ln -s $migrate_dir/$tfile $other_dir/zachary
15186 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
15187 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
15189 $LFS migrate -m $MDTIDX $migrate_dir ||
15190 error "fails on migrating remote dir to MDT1"
15192 echo "migratate to MDT1, then checking.."
15193 for ((i = 0; i < 10; i++)); do
15194 for file in $(find $migrate_dir/dir_${i}); do
15195 mdt_index=$($LFS getstripe -m $file)
15196 [ $mdt_index == $MDTIDX ] ||
15197 error "$file is not on MDT${MDTIDX}"
15201 # the multiple link file should still in MDT0
15202 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
15203 [ $mdt_index == 0 ] ||
15204 error "$file is not on MDT${MDTIDX}"
15206 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15207 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15208 error " expect $old_dir_flag get $new_dir_flag"
15210 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15211 [ "$old_file_flag" = "$new_file_flag" ] ||
15212 error " expect $old_file_flag get $new_file_flag"
15214 local new_dir_mode=$(stat -c%f $migrate_dir)
15215 [ "$old_dir_mode" = "$new_dir_mode" ] ||
15216 error "expect mode $old_dir_mode get $new_dir_mode"
15218 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
15219 [ "$old_file_mode" = "$new_file_mode" ] ||
15220 error "expect mode $old_file_mode get $new_file_mode"
15222 diff /etc/passwd $migrate_dir/$tfile ||
15223 error "$tfile different after migration"
15225 diff /etc/passwd $other_dir/luna ||
15226 error "luna different after migration"
15228 diff /etc/passwd $migrate_dir/sofia ||
15229 error "sofia different after migration"
15231 diff /etc/passwd $migrate_dir/david ||
15232 error "david different after migration"
15234 diff /etc/passwd $other_dir/zachary ||
15235 error "zachary different after migration"
15237 diff /etc/passwd $migrate_dir/${tfile}_ln ||
15238 error "${tfile}_ln different after migration"
15240 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
15241 error "${tfile}_ln_other different after migration"
15243 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
15244 [ $stripe_count = 2 ] ||
15245 error "dir strpe_count $d != 2 after migration."
15247 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
15248 [ $stripe_count = 2 ] ||
15249 error "file strpe_count $d != 2 after migration."
15251 #migrate back to MDT0
15254 $LFS migrate -m $MDTIDX $migrate_dir ||
15255 error "fails on migrating remote dir to MDT0"
15257 echo "migrate back to MDT0, checking.."
15258 for file in $(find $migrate_dir); do
15259 mdt_index=$($LFS getstripe -m $file)
15260 [ $mdt_index == $MDTIDX ] ||
15261 error "$file is not on MDT${MDTIDX}"
15264 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15265 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15266 error " expect $old_dir_flag get $new_dir_flag"
15268 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15269 [ "$old_file_flag" = "$new_file_flag" ] ||
15270 error " expect $old_file_flag get $new_file_flag"
15272 local new_dir_mode=$(stat -c%f $migrate_dir)
15273 [ "$old_dir_mode" = "$new_dir_mode" ] ||
15274 error "expect mode $old_dir_mode get $new_dir_mode"
15276 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
15277 [ "$old_file_mode" = "$new_file_mode" ] ||
15278 error "expect mode $old_file_mode get $new_file_mode"
15280 diff /etc/passwd ${migrate_dir}/$tfile ||
15281 error "$tfile different after migration"
15283 diff /etc/passwd ${other_dir}/luna ||
15284 error "luna different after migration"
15286 diff /etc/passwd ${migrate_dir}/sofia ||
15287 error "sofia different after migration"
15289 diff /etc/passwd ${other_dir}/zachary ||
15290 error "zachary different after migration"
15292 diff /etc/passwd $migrate_dir/${tfile}_ln ||
15293 error "${tfile}_ln different after migration"
15295 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
15296 error "${tfile}_ln_other different after migration"
15298 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
15299 [ $stripe_count = 2 ] ||
15300 error "dir strpe_count $d != 2 after migration."
15302 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
15303 [ $stripe_count = 2 ] ||
15304 error "file strpe_count $d != 2 after migration."
15306 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15308 run_test 230b "migrate directory"
15311 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15312 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15313 remote_mds_nodsh && skip "remote MDS with nodsh"
15314 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15315 skip "Need MDS version at least 2.11.52"
15321 local migrate_dir=$DIR/$tdir/migrate_dir
15323 #If migrating directory fails in the middle, all entries of
15324 #the directory is still accessiable.
15325 test_mkdir $DIR/$tdir
15326 test_mkdir -i0 -c1 $migrate_dir
15327 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
15329 createmany -o $migrate_dir/f $total ||
15330 error "create files under ${migrate_dir} failed"
15332 # fail after migrating top dir, and this will fail only once, so the
15333 # first sub file migration will fail (currently f3), others succeed.
15334 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
15335 do_facet mds1 lctl set_param fail_loc=0x1801
15336 local t=$(ls $migrate_dir | wc -l)
15337 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
15338 error "migrate should fail"
15339 local u=$(ls $migrate_dir | wc -l)
15340 [ "$u" == "$t" ] || error "$u != $t during migration"
15342 # add new dir/file should succeed
15343 mkdir $migrate_dir/dir ||
15344 error "mkdir failed under migrating directory"
15345 touch $migrate_dir/file ||
15346 error "create file failed under migrating directory"
15348 # add file with existing name should fail
15349 for file in $migrate_dir/f*; do
15350 stat $file > /dev/null || error "stat $file failed"
15351 $OPENFILE -f O_CREAT:O_EXCL $file &&
15352 error "open(O_CREAT|O_EXCL) $file should fail"
15353 $MULTIOP $file m && error "create $file should fail"
15354 touch $DIR/$tdir/remote_dir/$tfile ||
15355 error "touch $tfile failed"
15356 ln $DIR/$tdir/remote_dir/$tfile $file &&
15357 error "link $file should fail"
15358 mdt_index=$($LFS getstripe -m $file)
15359 if [ $mdt_index == 0 ]; then
15360 # file failed to migrate is not allowed to rename to
15361 mv $DIR/$tdir/remote_dir/$tfile $file &&
15362 error "rename to $file should fail"
15364 mv $DIR/$tdir/remote_dir/$tfile $file ||
15365 error "rename to $file failed"
15367 echo hello >> $file || error "write $file failed"
15370 # resume migration with different options should fail
15371 $LFS migrate -m 0 $migrate_dir &&
15372 error "migrate -m 0 $migrate_dir should fail"
15374 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
15375 error "migrate -c 2 $migrate_dir should fail"
15377 # resume migration should succeed
15378 $LFS migrate -m $MDTIDX $migrate_dir ||
15379 error "migrate $migrate_dir failed"
15381 echo "Finish migration, then checking.."
15382 for file in $(find $migrate_dir); do
15383 mdt_index=$($LFS getstripe -m $file)
15384 [ $mdt_index == $MDTIDX ] ||
15385 error "$file is not on MDT${MDTIDX}"
15388 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15390 run_test 230c "check directory accessiblity if migration failed"
15393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15394 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15395 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15396 skip "Need MDS version at least 2.11.52"
15398 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
15400 local migrate_dir=$DIR/$tdir/migrate_dir
15410 old_index=$((RANDOM % MDSCOUNT))
15411 old_count=$((MDSCOUNT - old_index))
15412 new_index=$((RANDOM % MDSCOUNT))
15413 new_count=$((MDSCOUNT - new_index))
15414 new_hash="all_char"
15416 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
15417 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
15419 test_mkdir $DIR/$tdir
15420 test_mkdir -i $old_index -c $old_count $migrate_dir
15422 for ((i=0; i<100; i++)); do
15423 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
15424 createmany -o $migrate_dir/dir_${i}/f 100 ||
15425 error "create files under remote dir failed $i"
15428 echo -n "Migrate from MDT$old_index "
15429 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
15430 echo -n "to MDT$new_index"
15431 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
15434 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
15435 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
15436 error "migrate remote dir error"
15438 echo "Finish migration, then checking.."
15439 for file in $(find $migrate_dir); do
15440 mdt_index=$($LFS getstripe -m $file)
15441 if [ $mdt_index -lt $new_index ] ||
15442 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
15443 error "$file is on MDT$mdt_index"
15447 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15449 run_test 230d "check migrate big directory"
15452 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15453 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15454 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15455 skip "Need MDS version at least 2.11.52"
15462 mkdir -p $DIR/$tdir
15463 mkdir $DIR/$tdir/migrate_dir
15464 mkdir $DIR/$tdir/other_dir
15465 touch $DIR/$tdir/migrate_dir/a
15466 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
15467 ls $DIR/$tdir/other_dir
15469 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15470 error "migrate dir fails"
15472 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15473 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15475 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15476 [ $mdt_index == 0 ] || error "a is not on MDT0"
15478 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
15479 error "migrate dir fails"
15481 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
15482 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
15484 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15485 [ $mdt_index == 1 ] || error "a is not on MDT1"
15487 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
15488 [ $mdt_index == 1 ] || error "b is not on MDT1"
15490 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15491 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
15493 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
15495 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15497 run_test 230e "migrate mulitple local link files"
15500 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15501 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15502 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15503 skip "Need MDS version at least 2.11.52"
15508 mkdir -p $DIR/$tdir
15509 mkdir $DIR/$tdir/migrate_dir
15510 $LFS mkdir -i1 $DIR/$tdir/other_dir
15511 touch $DIR/$tdir/migrate_dir/a
15512 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
15513 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
15514 ls $DIR/$tdir/other_dir
15516 # a should be migrated to MDT1, since no other links on MDT0
15517 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15518 error "#1 migrate dir fails"
15519 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15520 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15521 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15522 [ $mdt_index == 1 ] || error "a is not on MDT1"
15524 # a should stay on MDT1, because it is a mulitple link file
15525 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15526 error "#2 migrate dir fails"
15527 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15528 [ $mdt_index == 1 ] || error "a is not on MDT1"
15530 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15531 error "#3 migrate dir fails"
15533 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15534 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
15535 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
15537 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
15538 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
15540 # a should be migrated to MDT0, since no other links on MDT1
15541 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15542 error "#4 migrate dir fails"
15543 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15544 [ $mdt_index == 0 ] || error "a is not on MDT0"
15546 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15548 run_test 230f "migrate mulitple remote link files"
15551 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15552 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15553 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15554 skip "Need MDS version at least 2.11.52"
15556 mkdir -p $DIR/$tdir/migrate_dir
15558 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
15559 error "migrating dir to non-exist MDT succeeds"
15562 run_test 230g "migrate dir to non-exist MDT"
15565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15566 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15567 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15568 skip "Need MDS version at least 2.11.52"
15572 mkdir -p $DIR/$tdir/migrate_dir
15574 $LFS migrate -m1 $DIR &&
15575 error "migrating mountpoint1 should fail"
15577 $LFS migrate -m1 $DIR/$tdir/.. &&
15578 error "migrating mountpoint2 should fail"
15581 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
15582 error "migrating $tdir/migrate_dir/.. should fail"
15586 run_test 230h "migrate .. and root"
15589 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15590 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15591 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15592 skip "Need MDS version at least 2.11.52"
15594 mkdir -p $DIR/$tdir/migrate_dir
15596 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
15597 error "migration fails with a tailing slash"
15599 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
15600 error "migration fails with two tailing slashes"
15602 run_test 230i "lfs migrate -m tolerates trailing slashes"
15605 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
15606 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15607 skip "Need MDS version at least 2.11.52"
15609 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
15610 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
15611 error "create $tfile failed"
15612 cat /etc/passwd > $DIR/$tdir/$tfile
15614 $LFS migrate -m 1 $DIR/$tdir
15616 cmp /etc/passwd $DIR/$tdir/$tfile ||
15617 error "DoM file mismatch after migration"
15619 run_test 230j "DoM file data not changed after dir migration"
15622 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
15623 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
15624 skip "Need MDS version at least 2.11.56"
15627 local files_on_starting_mdt=0
15629 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
15630 $LFS getdirstripe $DIR/$tdir
15631 for i in $(seq $total); do
15632 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
15633 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
15634 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15637 echo "$files_on_starting_mdt files on MDT0"
15639 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
15640 $LFS getdirstripe $DIR/$tdir
15642 files_on_starting_mdt=0
15643 for i in $(seq $total); do
15644 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
15645 error "file $tfile.$i mismatch after migration"
15646 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
15647 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15650 echo "$files_on_starting_mdt files on MDT1 after migration"
15651 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
15653 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
15654 $LFS getdirstripe $DIR/$tdir
15656 files_on_starting_mdt=0
15657 for i in $(seq $total); do
15658 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
15659 error "file $tfile.$i mismatch after 2nd migration"
15660 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
15661 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15664 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
15665 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
15669 run_test 230k "file data not changed after dir migration"
15672 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
15673 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
15674 skip "Need MDS version at least 2.11.56"
15676 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
15677 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
15678 error "create files under remote dir failed $i"
15679 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
15681 run_test 230l "readdir between MDTs won't crash"
15685 # For simplicity this test assumes that max_pages_per_rpc
15686 # is the same across all OSCs
15687 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
15688 local bulk_size=$((max_pages * PAGE_SIZE))
15689 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
15692 mkdir -p $DIR/$tdir
15693 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
15694 error "failed to set stripe with -S ${brw_size}M option"
15696 # clear the OSC stats
15697 $LCTL set_param osc.*.stats=0 &>/dev/null
15700 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
15701 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
15702 oflag=direct &>/dev/null || error "dd failed"
15704 sync; sleep 1; sync # just to be safe
15705 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
15706 if [ x$nrpcs != "x1" ]; then
15707 $LCTL get_param osc.*.stats
15708 error "found $nrpcs ost_write RPCs, not 1 as expected"
15712 # Drop the OSC cache, otherwise we will read from it
15713 cancel_lru_locks osc
15715 # clear the OSC stats
15716 $LCTL set_param osc.*.stats=0 &>/dev/null
15718 # Client reads $bulk_size.
15719 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
15720 iflag=direct &>/dev/null || error "dd failed"
15722 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
15723 if [ x$nrpcs != "x1" ]; then
15724 $LCTL get_param osc.*.stats
15725 error "found $nrpcs ost_read RPCs, not 1 as expected"
15728 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
15731 mkdir -p $DIR/$tdir
15733 for i in {0..1023}; do
15734 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
15735 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
15736 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
15740 run_test 231b "must not assert on fully utilized OST request buffer"
15743 mkdir -p $DIR/$tdir
15744 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
15746 #define OBD_FAIL_LDLM_OST_LVB 0x31c
15747 do_facet ost1 $LCTL set_param fail_loc=0x31c
15749 # ignore dd failure
15750 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
15752 do_facet ost1 $LCTL set_param fail_loc=0
15753 umount_client $MOUNT || error "umount failed"
15754 mount_client $MOUNT || error "mount failed"
15755 stop ost1 || error "cannot stop ost1"
15756 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
15758 run_test 232a "failed lock should not block umount"
15761 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
15762 skip "Need MDS version at least 2.10.58"
15764 mkdir -p $DIR/$tdir
15765 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
15766 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
15768 cancel_lru_locks osc
15770 #define OBD_FAIL_LDLM_OST_LVB 0x31c
15771 do_facet ost1 $LCTL set_param fail_loc=0x31c
15774 $LFS data_version $DIR/$tdir/$tfile || true
15776 do_facet ost1 $LCTL set_param fail_loc=0
15777 umount_client $MOUNT || error "umount failed"
15778 mount_client $MOUNT || error "mount failed"
15779 stop ost1 || error "cannot stop ost1"
15780 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
15782 run_test 232b "failed data version lock should not block umount"
15785 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
15786 skip "Need MDS version at least 2.3.64"
15787 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
15789 local fid=$($LFS path2fid $MOUNT)
15791 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15792 error "cannot access $MOUNT using its FID '$fid'"
15794 run_test 233a "checking that OBF of the FS root succeeds"
15797 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
15798 skip "Need MDS version at least 2.5.90"
15799 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
15801 local fid=$($LFS path2fid $MOUNT/.lustre)
15803 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15804 error "cannot access $MOUNT/.lustre using its FID '$fid'"
15806 fid=$($LFS path2fid $MOUNT/.lustre/fid)
15807 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15808 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
15810 run_test 233b "checking that OBF of the FS .lustre succeeds"
15813 local p="$TMP/sanityN-$TESTNAME.parameters"
15814 save_lustre_params client "llite.*.xattr_cache" > $p
15815 lctl set_param llite.*.xattr_cache 1 ||
15816 skip_env "xattr cache is not supported"
15818 mkdir -p $DIR/$tdir || error "mkdir failed"
15819 touch $DIR/$tdir/$tfile || error "touch failed"
15820 # OBD_FAIL_LLITE_XATTR_ENOMEM
15821 $LCTL set_param fail_loc=0x1405
15822 getfattr -n user.attr $DIR/$tdir/$tfile &&
15823 error "getfattr should have failed with ENOMEM"
15824 $LCTL set_param fail_loc=0x0
15827 restore_lustre_params < $p
15830 run_test 234 "xattr cache should not crash on ENOMEM"
15833 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
15834 skip "Need MDS version at least 2.4.52"
15836 flock_deadlock $DIR/$tfile
15841 124) error "process hangs on a deadlock"
15843 *) error "error executing flock_deadlock $DIR/$tfile"
15847 run_test 235 "LU-1715: flock deadlock detection does not work properly"
15851 check_swap_layouts_support
15853 local ref1=/etc/passwd
15854 local ref2=/etc/group
15855 local file1=$DIR/$tdir/f1
15856 local file2=$DIR/$tdir/f2
15858 test_mkdir -c1 $DIR/$tdir
15859 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
15860 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
15861 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
15862 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
15863 local fd=$(free_fd)
15864 local cmd="exec $fd<>$file2"
15867 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
15868 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
15871 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
15876 run_test 236 "Layout swap on open unlinked file"
15878 # LU-4659 linkea consistency
15880 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
15881 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
15882 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
15883 skip "Need MDS version at least 2.5.58 or 2.5.2+"
15886 ln $DIR/$tfile $DIR/$tfile.lnk
15887 touch $DIR/$tfile.new
15888 mv $DIR/$tfile.new $DIR/$tfile
15889 local fid1=$($LFS path2fid $DIR/$tfile)
15890 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
15891 local path1=$($LFS fid2path $FSNAME "$fid1")
15892 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
15893 local path2=$($LFS fid2path $FSNAME "$fid2")
15894 [ $tfile.lnk == $path2 ] ||
15895 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
15898 run_test 238 "Verify linkea consistency"
15900 test_239A() { # was test_239
15901 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
15902 skip "Need MDS version at least 2.5.60"
15904 local list=$(comma_list $(mdts_nodes))
15906 mkdir -p $DIR/$tdir
15907 createmany -o $DIR/$tdir/f- 5000
15908 unlinkmany $DIR/$tdir/f- 5000
15909 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
15910 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
15911 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
15912 osp.*MDT*.sync_in_flight" | calc_sum)
15913 [ "$changes" -eq 0 ] || error "$changes not synced"
15915 run_test 239A "osp_sync test"
15917 test_239a() { #LU-5297
15918 remote_mds_nodsh && skip "remote MDS with nodsh"
15921 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
15922 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
15923 chgrp $RUNAS_GID $DIR/$tfile
15924 wait_delete_completed
15926 run_test 239a "process invalid osp sync record correctly"
15928 test_239b() { #LU-5297
15929 remote_mds_nodsh && skip "remote MDS with nodsh"
15932 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
15933 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
15934 chgrp $RUNAS_GID $DIR/$tfile1
15935 wait_delete_completed
15936 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
15938 chgrp $RUNAS_GID $DIR/$tfile2
15939 wait_delete_completed
15941 run_test 239b "process osp sync record with ENOMEM error correctly"
15944 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15945 remote_mds_nodsh && skip "remote MDS with nodsh"
15947 mkdir -p $DIR/$tdir
15949 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
15950 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
15951 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
15952 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
15954 umount_client $MOUNT || error "umount failed"
15955 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
15956 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
15957 mount_client $MOUNT || error "failed to mount client"
15959 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
15960 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
15962 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
15968 for LOOP in $(seq $count); do
15969 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
15970 cancel_lru_locks $OSC || true
15978 for LOOP in $(seq $1); do
15979 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
15984 test_241a() { # was test_241
15985 local bsize=$PAGE_SIZE
15987 (( bsize < 40960 )) && bsize=40960
15988 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
15990 cancel_lru_locks $OSC
15991 test_241_bio 1000 $bsize &
15993 test_241_dio 1000 $bsize
15996 run_test 241a "bio vs dio"
15999 local bsize=$PAGE_SIZE
16001 (( bsize < 40960 )) && bsize=40960
16002 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
16004 test_241_dio 1000 $bsize &
16006 test_241_dio 1000 $bsize
16009 run_test 241b "dio vs dio"
16012 remote_mds_nodsh && skip "remote MDS with nodsh"
16014 mkdir -p $DIR/$tdir
16015 touch $DIR/$tdir/$tfile
16017 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
16018 do_facet mds1 lctl set_param fail_loc=0x105
16019 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
16021 do_facet mds1 lctl set_param fail_loc=0
16022 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
16024 run_test 242 "mdt_readpage failure should not cause directory unreadable"
16028 test_mkdir $DIR/$tdir
16029 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
16031 run_test 243 "various group lock tests"
16035 test_mkdir $DIR/$tdir
16036 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
16037 sendfile_grouplock $DIR/$tdir/$tfile || \
16038 error "sendfile+grouplock failed"
16041 run_test 244 "sendfile with group lock tests"
16044 local flagname="multi_mod_rpcs"
16045 local connect_data_name="max_mod_rpcs"
16048 # check if multiple modify RPCs flag is set
16049 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
16050 grep "connect_flags:")
16053 echo "$out" | grep -qw $flagname
16054 if [ $? -ne 0 ]; then
16055 echo "connect flag $flagname is not set"
16059 # check if multiple modify RPCs data is set
16060 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
16063 echo "$out" | grep -qw $connect_data_name ||
16064 error "import should have connect data $connect_data_name"
16066 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
16068 test_246() { # LU-7371
16069 remote_ost_nodsh && skip "remote OST with nodsh"
16070 [ $OST1_VERSION -lt $(version_code 2.7.62) ] &&
16071 skip "Need OST version >= 2.7.62"
16073 do_facet ost1 $LCTL set_param fail_val=4095
16074 #define OBD_FAIL_OST_READ_SIZE 0x234
16075 do_facet ost1 $LCTL set_param fail_loc=0x234
16076 $LFS setstripe $DIR/$tfile -i 0 -c 1
16077 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
16078 cancel_lru_locks $FSNAME-OST0000
16079 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
16081 run_test 246 "Read file of size 4095 should return right length"
16087 umount_client $submount
16092 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16094 skip_env "Fileset feature is not supported"
16096 local submount=${MOUNT}_$tdir
16099 mkdir -p $submount || error "mkdir $submount failed"
16100 FILESET="$FILESET/$tdir" mount_client $submount ||
16101 error "mount $submount failed"
16102 trap "cleanup_247 $submount" EXIT
16103 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
16104 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
16105 error "read $MOUNT/$tdir/$tfile failed"
16106 cleanup_247 $submount
16108 run_test 247a "mount subdir as fileset"
16111 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16112 skip_env "Fileset feature is not supported"
16114 local submount=${MOUNT}_$tdir
16116 rm -rf $MOUNT/$tdir
16117 mkdir -p $submount || error "mkdir $submount failed"
16119 FILESET="$FILESET/$tdir" mount_client $submount &&
16120 error "mount $submount should fail"
16123 run_test 247b "mount subdir that dose not exist"
16126 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16127 skip_env "Fileset feature is not supported"
16129 local submount=${MOUNT}_$tdir
16131 mkdir -p $MOUNT/$tdir/dir1
16132 mkdir -p $submount || error "mkdir $submount failed"
16133 trap "cleanup_247 $submount" EXIT
16134 FILESET="$FILESET/$tdir" mount_client $submount ||
16135 error "mount $submount failed"
16136 local fid=$($LFS path2fid $MOUNT/)
16137 $LFS fid2path $submount $fid && error "fid2path should fail"
16138 cleanup_247 $submount
16140 run_test 247c "running fid2path outside root"
16143 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16144 skip "Fileset feature is not supported"
16146 local submount=${MOUNT}_$tdir
16148 mkdir -p $MOUNT/$tdir/dir1
16149 mkdir -p $submount || error "mkdir $submount failed"
16150 FILESET="$FILESET/$tdir" mount_client $submount ||
16151 error "mount $submount failed"
16152 trap "cleanup_247 $submount" EXIT
16153 local fid=$($LFS path2fid $submount/dir1)
16154 $LFS fid2path $submount $fid || error "fid2path should succeed"
16155 cleanup_247 $submount
16157 run_test 247d "running fid2path inside root"
16161 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16163 skip "Fileset feature is not supported"
16165 local submount=${MOUNT}_$tdir
16168 mkdir -p $submount || error "mkdir $submount failed"
16169 FILESET="$FILESET/.." mount_client $submount &&
16170 error "mount $submount should fail"
16173 run_test 247e "mount .. as fileset"
16176 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
16177 [ -z "$fast_read_sav" ] && skip "no fast read support"
16179 # create a large file for fast read verification
16180 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
16182 # make sure the file is created correctly
16183 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
16184 { rm -f $DIR/$tfile; skip "file creation error"; }
16186 echo "Test 1: verify that fast read is 4 times faster on cache read"
16188 # small read with fast read enabled
16189 $LCTL set_param -n llite.*.fast_read=1
16190 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16191 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16192 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16193 # small read with fast read disabled
16194 $LCTL set_param -n llite.*.fast_read=0
16195 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16196 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16197 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16199 # verify that fast read is 4 times faster for cache read
16200 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
16201 error_not_in_vm "fast read was not 4 times faster: " \
16202 "$t_fast vs $t_slow"
16204 echo "Test 2: verify the performance between big and small read"
16205 $LCTL set_param -n llite.*.fast_read=1
16207 # 1k non-cache read
16208 cancel_lru_locks osc
16209 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16210 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16211 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16213 # 1M non-cache read
16214 cancel_lru_locks osc
16215 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16216 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16217 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16219 # verify that big IO is not 4 times faster than small IO
16220 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
16221 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
16223 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
16226 run_test 248 "fast read verification"
16228 test_249() { # LU-7890
16229 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
16230 skip "Need at least version 2.8.54"
16233 $LFS setstripe -c 1 $DIR/$tfile
16234 # Offset 2T == 4k * 512M
16235 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
16236 error "dd to 2T offset failed"
16238 run_test 249 "Write above 2T file size"
16241 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
16242 && skip "no 16TB file size limit on ZFS"
16244 $LFS setstripe -c 1 $DIR/$tfile
16245 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
16246 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
16247 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
16248 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
16249 conv=notrunc,fsync && error "append succeeded"
16252 run_test 250 "Write above 16T limit"
16255 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
16257 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
16258 #Skip once - writing the first stripe will succeed
16259 $LCTL set_param fail_loc=0xa0001407 fail_val=1
16260 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
16261 error "short write happened"
16263 $LCTL set_param fail_loc=0xa0001407 fail_val=1
16264 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
16265 error "short read happened"
16269 run_test 251 "Handling short read and write correctly"
16272 remote_mds_nodsh && skip "remote MDS with nodsh"
16273 remote_ost_nodsh && skip "remote OST with nodsh"
16274 if [ "$ost1_FSTYPE" != "ldiskfs" -o "$mds1_FSTYPE" != "ldiskfs" ]; then
16275 skip_env "ldiskfs only test"
16285 # check lr_reader on OST0000
16287 dev=$(facet_device $tgt)
16288 out=$(do_facet $tgt $LR_READER $dev)
16289 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16291 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
16292 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
16293 error "Invalid uuid returned by $LR_READER on target $tgt"
16294 echo -e "uuid returned by $LR_READER is '$uuid'\n"
16296 # check lr_reader -c on MDT0000
16298 dev=$(facet_device $tgt)
16299 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
16300 skip "$LR_READER does not support additional options"
16302 out=$(do_facet $tgt $LR_READER -c $dev)
16303 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16305 num=$(echo "$out" | grep -c "mdtlov")
16306 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
16307 error "Invalid number of mdtlov clients returned by $LR_READER"
16308 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
16310 # check lr_reader -cr on MDT0000
16311 out=$(do_facet $tgt $LR_READER -cr $dev)
16312 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16314 echo "$out" | grep -q "^reply_data:$" ||
16315 error "$LR_READER should have returned 'reply_data' section"
16316 num=$(echo "$out" | grep -c "client_generation")
16317 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
16319 run_test 252 "check lr_reader tool"
16321 test_253_fill_ost() {
16322 local size_mb #how many MB should we write to pass watermark
16323 local lwm=$3 #low watermark
16324 local free_10mb #10% of free space
16326 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
16327 size_mb=$((free_kb / 1024 - lwm))
16328 free_10mb=$((free_kb / 10240))
16329 #If 10% of free space cross low watermark use it
16330 if (( free_10mb > size_mb )); then
16333 #At least we need to store 1.1 of difference between
16334 #free space and low watermark
16335 size_mb=$((size_mb + size_mb / 10))
16337 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
16338 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
16339 oflag=append conv=notrunc
16344 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
16345 echo "OST still has $((free_kb / 1024)) mbytes free"
16349 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16350 remote_mds_nodsh && skip "remote MDS with nodsh"
16351 remote_mgs_nodsh && skip "remote MGS with nodsh"
16356 local ost_name=$($LFS osts |
16357 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
16359 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
16360 do_facet $SINGLEMDS $LCTL get_param -n \
16361 osp.$mdtosc_proc1.reserved_mb_high ||
16362 skip "remote MDS does not support reserved_mb_high"
16366 wait_delete_completed
16369 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
16370 osp.$mdtosc_proc1.reserved_mb_high)
16371 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
16372 osp.$mdtosc_proc1.reserved_mb_low)
16373 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
16375 if ! combined_mgs_mds ; then
16378 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
16379 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
16380 error "Adding $ost_name to pool failed"
16382 # Wait for client to see a OST at pool
16383 wait_update $HOSTNAME "$LCTL get_param -n
16384 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
16385 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
16386 error "Client can not see the pool"
16387 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
16388 error "Setstripe failed"
16390 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
16391 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
16392 echo "OST still has $((blocks/1024)) mbytes free"
16394 local new_lwm=$((blocks/1024-10))
16395 do_facet $SINGLEMDS $LCTL set_param \
16396 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
16397 do_facet $SINGLEMDS $LCTL set_param \
16398 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
16400 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
16402 #First enospc could execute orphan deletion so repeat.
16403 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
16405 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
16406 osp.$mdtosc_proc1.prealloc_status)
16407 echo "prealloc_status $oa_status"
16409 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
16410 error "File creation should fail"
16411 #object allocation was stopped, but we still able to append files
16412 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
16413 error "Append failed"
16414 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
16416 wait_delete_completed
16420 for i in $(seq 10 12); do
16421 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
16422 error "File creation failed after rm";
16425 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
16426 osp.$mdtosc_proc1.prealloc_status)
16427 echo "prealloc_status $oa_status"
16429 if (( oa_status != 0 )); then
16430 error "Object allocation still disable after rm"
16432 do_facet $SINGLEMDS $LCTL set_param \
16433 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
16434 do_facet $SINGLEMDS $LCTL set_param \
16435 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
16438 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
16439 error "Remove $ost_name from pool failed"
16440 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
16441 error "Pool destroy fialed"
16443 if ! combined_mgs_mds ; then
16447 run_test 253 "Check object allocation limit"
16450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16451 remote_mds_nodsh && skip "remote MDS with nodsh"
16452 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
16453 skip "MDS does not support changelog_size"
16456 local MDT0=$(facet_svc $SINGLEMDS)
16458 changelog_register || error "changelog_register failed"
16460 changelog_clear 0 || error "changelog_clear failed"
16462 local size1=$(do_facet $SINGLEMDS \
16463 $LCTL get_param -n mdd.$MDT0.changelog_size)
16464 echo "Changelog size $size1"
16467 $LFS mkdir -i 0 $DIR/$tdir
16469 mkdir -p $DIR/$tdir/pics/2008/zachy
16470 touch $DIR/$tdir/pics/2008/zachy/timestamp
16471 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
16472 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16473 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16474 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16475 rm $DIR/$tdir/pics/desktop.jpg
16477 local size2=$(do_facet $SINGLEMDS \
16478 $LCTL get_param -n mdd.$MDT0.changelog_size)
16479 echo "Changelog size after work $size2"
16481 (( $size2 > $size1 )) ||
16482 error "new Changelog size=$size2 less than old size=$size1"
16484 run_test 254 "Check changelog size"
16491 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
16492 awk -F: '{print $2}' | grep $type > /dev/null
16493 if [ $? -ne 0 ]; then
16503 lfs ladvise -a willread $file > /dev/null 2>&1
16504 if [ $? -eq 0 ]; then
16508 lfs ladvise -a willread $file 2>&1 |
16509 grep "Inappropriate ioctl for device" > /dev/null
16510 if [ $? -eq 0 ]; then
16517 bc <<<"scale=2; ($1 - $2) * 100 / $2"
16520 # run a random read IO workload
16521 # usage: random_read_iops <filename> <filesize> <iosize>
16522 random_read_iops() {
16525 local iosize=${3:-4096}
16527 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
16528 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
16531 drop_file_oss_cache() {
16535 $LFS ladvise -a dontneed $file 2>/dev/null ||
16536 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
16539 ladvise_willread_performance()
16542 local average_origin=0
16543 local average_cache=0
16544 local average_ladvise=0
16546 for ((i = 1; i <= $repeat; i++)); do
16547 echo "Iter $i/$repeat: reading without willread hint"
16548 cancel_lru_locks osc
16549 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16550 local speed_origin=$(random_read_iops $DIR/$tfile $size)
16551 echo "Iter $i/$repeat: uncached speed: $speed_origin"
16552 average_origin=$(bc <<<"$average_origin + $speed_origin")
16554 cancel_lru_locks osc
16555 local speed_cache=$(random_read_iops $DIR/$tfile $size)
16556 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
16557 average_cache=$(bc <<<"$average_cache + $speed_cache")
16559 cancel_lru_locks osc
16560 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16561 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
16562 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
16563 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
16564 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
16566 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
16567 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
16568 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
16570 speedup_cache=$(percent $average_cache $average_origin)
16571 speedup_ladvise=$(percent $average_ladvise $average_origin)
16573 echo "Average uncached read: $average_origin"
16574 echo "Average speedup with OSS cached read: " \
16575 "$average_cache = +$speedup_cache%"
16576 echo "Average speedup with ladvise willread: " \
16577 "$average_ladvise = +$speedup_ladvise%"
16579 local lowest_speedup=20
16580 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
16581 echo "Speedup with OSS cached read less than $lowest_speedup%," \
16582 "got $average_cache%. Skipping ladvise willread check."
16586 # the test won't work on ZFS until it supports 'ladvise dontneed', but
16587 # it is still good to run until then to exercise 'ladvise willread'
16588 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16589 [ "$ost1_FSTYPE" = "zfs" ] &&
16590 echo "osd-zfs does not support dontneed or drop_caches" &&
16593 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
16594 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
16595 error_not_in_vm "Speedup with willread is less than " \
16596 "$lowest_speedup%, got $average_ladvise%"
16600 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
16601 skip "lustre < 2.8.54 does not support ladvise "
16602 remote_ost_nodsh && skip "remote OST with nodsh"
16604 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
16606 ladvise_no_type willread $DIR/$tfile &&
16607 skip "willread ladvise is not supported"
16609 ladvise_no_ioctl $DIR/$tfile &&
16610 skip "ladvise ioctl is not supported"
16613 local size=$((size_mb * 1048576))
16614 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
16615 error "dd to $DIR/$tfile failed"
16617 lfs ladvise -a willread $DIR/$tfile ||
16618 error "Ladvise failed with no range argument"
16620 lfs ladvise -a willread -s 0 $DIR/$tfile ||
16621 error "Ladvise failed with no -l or -e argument"
16623 lfs ladvise -a willread -e 1 $DIR/$tfile ||
16624 error "Ladvise failed with only -e argument"
16626 lfs ladvise -a willread -l 1 $DIR/$tfile ||
16627 error "Ladvise failed with only -l argument"
16629 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
16630 error "End offset should not be smaller than start offset"
16632 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
16633 error "End offset should not be equal to start offset"
16635 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
16636 error "Ladvise failed with overflowing -s argument"
16638 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
16639 error "Ladvise failed with overflowing -e argument"
16641 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
16642 error "Ladvise failed with overflowing -l argument"
16644 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
16645 error "Ladvise succeeded with conflicting -l and -e arguments"
16647 echo "Synchronous ladvise should wait"
16649 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
16650 do_nodes $(comma_list $(osts_nodes)) \
16651 $LCTL set_param fail_val=$delay fail_loc=0x237
16653 local start_ts=$SECONDS
16654 lfs ladvise -a willread $DIR/$tfile ||
16655 error "Ladvise failed with no range argument"
16656 local end_ts=$SECONDS
16657 local inteval_ts=$((end_ts - start_ts))
16659 if [ $inteval_ts -lt $(($delay - 1)) ]; then
16660 error "Synchronous advice didn't wait reply"
16663 echo "Asynchronous ladvise shouldn't wait"
16664 local start_ts=$SECONDS
16665 lfs ladvise -a willread -b $DIR/$tfile ||
16666 error "Ladvise failed with no range argument"
16667 local end_ts=$SECONDS
16668 local inteval_ts=$((end_ts - start_ts))
16670 if [ $inteval_ts -gt $(($delay / 2)) ]; then
16671 error "Asynchronous advice blocked"
16674 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
16675 ladvise_willread_performance
16677 run_test 255a "check 'lfs ladvise -a willread'"
16683 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
16687 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
16688 skip "lustre < 2.8.54 does not support ladvise "
16689 remote_ost_nodsh && skip "remote OST with nodsh"
16691 lfs setstripe -c 1 -i 0 $DIR/$tfile
16693 ladvise_no_type dontneed $DIR/$tfile &&
16694 skip "dontneed ladvise is not supported"
16696 ladvise_no_ioctl $DIR/$tfile &&
16697 skip "ladvise ioctl is not supported"
16699 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16700 [ "$ost1_FSTYPE" = "zfs" ] &&
16701 skip "zfs-osd does not support 'ladvise dontneed'"
16704 local size=$((size_mb * 1048576))
16705 # In order to prevent disturbance of other processes, only check 3/4
16706 # of the memory usage
16707 local kibibytes=$((size_mb * 1024 * 3 / 4))
16709 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
16710 error "dd to $DIR/$tfile failed"
16712 #force write to complete before dropping OST cache & checking memory
16715 local total=$(facet_meminfo ost1 MemTotal)
16716 echo "Total memory: $total KiB"
16718 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
16719 local before_read=$(facet_meminfo ost1 Cached)
16720 echo "Cache used before read: $before_read KiB"
16722 lfs ladvise -a willread $DIR/$tfile ||
16723 error "Ladvise willread failed"
16724 local after_read=$(facet_meminfo ost1 Cached)
16725 echo "Cache used after read: $after_read KiB"
16727 lfs ladvise -a dontneed $DIR/$tfile ||
16728 error "Ladvise dontneed again failed"
16729 local no_read=$(facet_meminfo ost1 Cached)
16730 echo "Cache used after dontneed ladvise: $no_read KiB"
16732 if [ $total -lt $((before_read + kibibytes)) ]; then
16733 echo "Memory is too small, abort checking"
16737 if [ $((before_read + kibibytes)) -gt $after_read ]; then
16738 error "Ladvise willread should use more memory" \
16739 "than $kibibytes KiB"
16742 if [ $((no_read + kibibytes)) -gt $after_read ]; then
16743 error "Ladvise dontneed should release more memory" \
16744 "than $kibibytes KiB"
16747 run_test 255b "check 'lfs ladvise -a dontneed'"
16750 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
16751 skip "lustre < 2.10.53 does not support lockahead"
16759 test_mkdir -p $DIR/$tdir
16760 $LFS setstripe -i 0 $DIR/$tdir
16762 #test 10 returns only success/failure
16764 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16766 if [ $rc -eq 255 ]; then
16767 error "Ladvise test${i} failed, ${rc}"
16770 #test 11 counts lock enqueue requests, all others count new locks
16772 count=$(do_facet ost1 \
16773 $LCTL get_param -n ost.OSS.ost.stats)
16774 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
16776 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16778 if [ $rc -eq 255 ]; then
16779 error "Ladvise test${i} failed, ${rc}"
16782 new_count=$(do_facet ost1 \
16783 $LCTL get_param -n ost.OSS.ost.stats)
16784 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
16785 awk '{ print $2 }')
16787 difference="$((new_count - count))"
16788 if [ $difference -ne $rc ]; then
16789 error "Ladvise test${i}, bad enqueue count, returned " \
16790 "${rc}, actual ${difference}"
16793 for i in $(seq 12 21); do
16794 # If we do not do this, we run the risk of having too many
16795 # locks and starting lock cancellation while we are checking
16797 cancel_lru_locks osc
16799 count=$($LCTL get_param -n \
16800 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
16802 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16804 if [ $rc -eq 255 ]; then
16805 error "Ladvise test ${i} failed, ${rc}"
16808 new_count=$($LCTL get_param -n \
16809 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
16810 difference="$((new_count - count))"
16812 # Test 15 output is divided by 100 to map down to valid return
16813 if [ $i -eq 15 ]; then
16817 if [ $difference -ne $rc ]; then
16818 error "Ladvise test ${i}, bad lock count, returned " \
16819 "${rc}, actual ${difference}"
16823 #test 22 returns only success/failure
16825 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16827 if [ $rc -eq 255 ]; then
16828 error "Ladvise test${i} failed, ${rc}"
16831 run_test 255c "suite of ladvise lockahead tests"
16834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16835 remote_mds_nodsh && skip "remote MDS with nodsh"
16836 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
16837 changelog_users $SINGLEMDS | grep "^cl" &&
16838 skip "active changelog user"
16844 mdt_dev=$(mdsdevname 1)
16847 changelog_register || error "changelog_register failed"
16850 mkdir -p $DIR/$tdir
16852 changelog_clear 0 || error "changelog_clear failed"
16855 touch $DIR/$tdir/{1..10}
16858 stop $SINGLEMDS || error "Fail to stop MDT"
16862 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
16864 #after mount new plainllog is used
16865 touch $DIR/$tdir/{11..19}
16866 local tmpfile=$(mktemp -u $tfile.XXXXXX)
16867 cat_sl=$(do_facet $SINGLEMDS "sync; \
16868 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
16869 llog_reader $tmpfile | grep -c type=1064553b")
16870 do_facet $SINGLEMDS llog_reader $tmpfile
16872 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
16874 changelog_clear 0 || error "changelog_clear failed"
16876 cat_sl=$(do_facet $SINGLEMDS "sync; \
16877 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
16878 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
16880 if (( cat_sl == 2 )); then
16881 error "Empty plain llog was not deleted from changelog catalog"
16882 elif (( cat_sl != 1 )); then
16883 error "Active plain llog shouldn't be deleted from catalog"
16886 run_test 256 "Check llog delete for empty and not full state"
16889 remote_mds_nodsh && skip "remote MDS with nodsh"
16890 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
16891 skip "Need MDS version at least 2.8.55"
16893 test_mkdir $DIR/$tdir
16895 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
16896 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
16899 #define OBD_FAIL_MDS_XATTR_REP 0x161
16900 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
16901 local facet=mds$((mdtidx + 1))
16902 set_nodes_failloc $(facet_active_host $facet) 0x80000161
16903 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
16905 stop $facet || error "stop MDS failed"
16906 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
16907 error "start MDS fail"
16908 wait_recovery_complete $facet
16910 run_test 257 "xattr locks are not lost"
16912 # Verify we take the i_mutex when security requires it
16914 #define OBD_FAIL_IMUTEX_SEC 0x141c
16915 $LCTL set_param fail_loc=0x141c
16917 chmod u+s $DIR/$tfile
16918 chmod a+rwx $DIR/$tfile
16919 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
16921 if [ $RC -ne 0 ]; then
16922 error "error, failed to take i_mutex, rc=$?"
16928 # Verify we do NOT take the i_mutex in the normal case
16930 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
16931 $LCTL set_param fail_loc=0x141d
16934 chmod a+rw $DIR/$tfile
16935 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
16937 if [ $RC -ne 0 ]; then
16938 error "error, took i_mutex unnecessarily, rc=$?"
16943 run_test 258b "verify i_mutex security behavior"
16946 local file=$DIR/$tfile
16950 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
16952 stack_trap "rm -f $file" EXIT
16954 wait_delete_completed
16955 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16956 echo "before: $before"
16958 $LFS setstripe -i 0 -c 1 $file
16959 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
16961 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16962 echo "after write: $after"
16964 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
16965 do_facet ost1 $LCTL set_param fail_loc=0x2301
16967 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16968 echo "after truncate: $after"
16971 do_facet ost1 $LCTL set_param fail_loc=0
16972 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16974 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16975 echo "after restart: $after"
16976 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
16977 error "missing truncate?"
16981 run_test 259 "crash at delayed truncate"
16984 #define OBD_FAIL_MDC_CLOSE 0x806
16985 $LCTL set_param fail_loc=0x80000806
16989 run_test 260 "Check mdc_close fail"
16991 ### Data-on-MDT sanity tests ###
16993 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
16994 skip "Need MDS version at least 2.10.55 for DoM"
16997 local dom=$DIR/$tdir/dom_file
16998 local tmp=$DIR/$tdir/tmp_file
17000 mkdir -p $DIR/$tdir
17002 # basic checks for DoM component creation
17003 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
17004 error "Can set MDT layout to non-first entry"
17006 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
17007 error "Can define multiple entries as MDT layout"
17009 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
17011 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
17012 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
17013 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
17015 local mdtidx=$($LFS getstripe -m $dom)
17016 local mdtname=MDT$(printf %04x $mdtidx)
17017 local facet=mds$((mdtidx + 1))
17018 local space_check=1
17020 # Skip free space checks with ZFS
17021 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
17025 local size_tmp=$((65536 * 3))
17026 local mdtfree1=$(do_facet $facet \
17027 lctl get_param -n osd*.*$mdtname.kbytesfree)
17029 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17030 # check also direct IO along write
17031 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
17032 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17034 cmp $tmp $dom || error "file data is different"
17035 [ $(stat -c%s $dom) == $size_tmp ] ||
17036 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17037 if [ $space_check == 1 ]; then
17038 local mdtfree2=$(do_facet $facet \
17039 lctl get_param -n osd*.*$mdtname.kbytesfree)
17041 # increase in usage from by $size_tmp
17042 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17043 error "MDT free space wrong after write: " \
17044 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17048 local size_dom=10000
17050 $TRUNCATE $dom $size_dom
17051 [ $(stat -c%s $dom) == $size_dom ] ||
17052 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
17053 if [ $space_check == 1 ]; then
17054 mdtfree1=$(do_facet $facet \
17055 lctl get_param -n osd*.*$mdtname.kbytesfree)
17056 # decrease in usage from $size_tmp to new $size_dom
17057 [ $(($mdtfree1 - $mdtfree2)) -ge \
17058 $(((size_tmp - size_dom) / 1024)) ] ||
17059 error "MDT free space is wrong after truncate: " \
17060 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
17066 size_dom=$((size_dom + size_tmp))
17067 [ $(stat -c%s $dom) == $size_dom ] ||
17068 error "bad size after append: $(stat -c%s $dom) != $size_dom"
17069 if [ $space_check == 1 ]; then
17070 mdtfree2=$(do_facet $facet \
17071 lctl get_param -n osd*.*$mdtname.kbytesfree)
17072 # increase in usage by $size_tmp from previous
17073 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17074 error "MDT free space is wrong after append: " \
17075 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17080 if [ $space_check == 1 ]; then
17081 mdtfree1=$(do_facet $facet \
17082 lctl get_param -n osd*.*$mdtname.kbytesfree)
17083 # decrease in usage by $size_dom from previous
17084 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
17085 error "MDT free space is wrong after removal: " \
17086 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
17089 # combined striping
17090 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
17091 error "Can't create DoM + OST striping"
17093 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
17094 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17095 # check also direct IO along write
17096 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17098 cmp $tmp $dom || error "file data is different"
17099 [ $(stat -c%s $dom) == $size_tmp ] ||
17100 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17105 run_test 270a "DoM: basic functionality tests"
17108 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17109 skip "Need MDS version at least 2.10.55"
17111 local dom=$DIR/$tdir/dom_file
17112 local max_size=1048576
17114 mkdir -p $DIR/$tdir
17115 $LFS setstripe -E $max_size -L mdt $dom
17117 # truncate over the limit
17118 $TRUNCATE $dom $(($max_size + 1)) &&
17119 error "successful truncate over the maximum size"
17120 # write over the limit
17121 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
17122 error "successful write over the maximum size"
17123 # append over the limit
17124 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
17125 echo "12345" >> $dom && error "successful append over the maximum size"
17130 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
17133 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17134 skip "Need MDS version at least 2.10.55"
17136 mkdir -p $DIR/$tdir
17137 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17139 # check files inherit DoM EA
17140 touch $DIR/$tdir/first
17141 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
17142 error "bad pattern"
17143 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
17144 error "bad stripe count"
17145 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
17146 error "bad stripe size"
17148 # check directory inherits DoM EA and uses it as default
17149 mkdir $DIR/$tdir/subdir
17150 touch $DIR/$tdir/subdir/second
17151 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
17152 error "bad pattern in sub-directory"
17153 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
17154 error "bad stripe count in sub-directory"
17155 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
17156 error "bad stripe size in sub-directory"
17159 run_test 270c "DoM: DoM EA inheritance tests"
17162 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17163 skip "Need MDS version at least 2.10.55"
17165 mkdir -p $DIR/$tdir
17166 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17168 # inherit default DoM striping
17169 mkdir $DIR/$tdir/subdir
17170 touch $DIR/$tdir/subdir/f1
17172 # change default directory striping
17173 $LFS setstripe -c 1 $DIR/$tdir/subdir
17174 touch $DIR/$tdir/subdir/f2
17175 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
17176 error "wrong default striping in file 2"
17177 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
17178 error "bad pattern in file 2"
17181 run_test 270d "DoM: change striping from DoM to RAID0"
17184 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17185 skip "Need MDS version at least 2.10.55"
17187 mkdir -p $DIR/$tdir/dom
17188 mkdir -p $DIR/$tdir/norm
17191 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
17192 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
17194 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
17195 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
17197 # find DoM files by layout
17198 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
17199 [ $NUM -eq $DOMFILES ] ||
17200 error "lfs find -L: found $NUM, expected $DOMFILES"
17201 echo "Test 1: lfs find 20 DOM files by layout: OK"
17203 # there should be 1 dir with default DOM striping
17204 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
17206 error "lfs find -L: found $NUM, expected 1 dir"
17207 echo "Test 2: lfs find 1 DOM dir by layout: OK"
17209 # find DoM files by stripe size
17210 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
17211 [ $NUM -eq $DOMFILES ] ||
17212 error "lfs find -S: found $NUM, expected $DOMFILES"
17213 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
17215 # find files by stripe offset except DoM files
17216 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
17217 [ $NUM -eq $NORMFILES ] ||
17218 error "lfs find -i: found $NUM, expected $NORMFILES"
17219 echo "Test 5: lfs find no DOM files by stripe index: OK"
17222 run_test 270e "DoM: lfs find with DoM files test"
17225 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17226 skip "Need MDS version at least 2.10.55"
17228 local mdtname=${FSNAME}-MDT0000-mdtlov
17229 local dom=$DIR/$tdir/dom_file
17230 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
17231 lod.$mdtname.dom_stripesize)
17232 local dom_limit=131072
17234 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
17235 local dom_current=$(do_facet mds1 $LCTL get_param -n \
17236 lod.$mdtname.dom_stripesize)
17237 [ ${dom_limit} -eq ${dom_current} ] ||
17238 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
17240 $LFS mkdir -i 0 -c 1 $DIR/$tdir
17241 $LFS setstripe -d $DIR/$tdir
17242 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
17243 error "Can't set directory default striping"
17245 # exceed maximum stripe size
17246 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
17247 error "Can't create file with $((dom_limit * 2)) DoM stripe"
17248 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
17249 error "Able to create DoM component size more than LOD limit"
17251 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
17252 dom_current=$(do_facet mds1 $LCTL get_param -n \
17253 lod.$mdtname.dom_stripesize)
17254 [ 0 -eq ${dom_current} ] ||
17255 error "Can't set zero DoM stripe limit"
17258 # attempt to create DoM file on server with disabled DoM should
17259 # remove DoM entry from layout and be succeed
17260 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
17261 error "Can't create DoM file (DoM is disabled)"
17262 [ $($LFS getstripe -L $dom) == "mdt" ] &&
17263 error "File has DoM component while DoM is disabled"
17266 # attempt to create DoM file with only DoM stripe should return error
17267 $LFS setstripe -E $dom_limit -L mdt $dom &&
17268 error "Able to create DoM-only file while DoM is disabled"
17270 # too low values to be aligned with smallest stripe size 64K
17271 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
17272 dom_current=$(do_facet mds1 $LCTL get_param -n \
17273 lod.$mdtname.dom_stripesize)
17274 [ 30000 -eq ${dom_current} ] &&
17275 error "Can set too small DoM stripe limit"
17277 # 64K is a minimal stripe size in Lustre, expect limit of that size
17278 [ 65536 -eq ${dom_current} ] ||
17279 error "Limit is not set to 64K but ${dom_current}"
17281 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
17282 dom_current=$(do_facet mds1 $LCTL get_param -n \
17283 lod.$mdtname.dom_stripesize)
17285 [ 2147483648 -eq ${dom_current} ] &&
17286 error "Can set too large DoM stripe limit"
17288 do_facet mds1 $LCTL set_param -n \
17289 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
17290 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
17291 error "Can't create DoM component size after limit change"
17292 do_facet mds1 $LCTL set_param -n \
17293 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
17294 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
17295 error "Can't create DoM file after limit decrease"
17296 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
17297 error "Can create big DoM component after limit decrease"
17298 touch ${dom}_def ||
17299 error "Can't create file with old default layout"
17301 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
17304 run_test 270f "DoM: maximum DoM stripe size checks"
17307 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17308 skip "Need MDS version at least 2.10.55"
17310 local dom=$DIR/$tdir/dom
17312 mkdir -p $DIR/$tdir
17314 $LFS setstripe -E 1024K -L mdt $dom
17316 lctl set_param -n mdc.*.stats=clear
17317 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
17318 cat $dom > /dev/null
17319 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
17320 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
17324 run_test 271a "DoM: data is cached for read after write"
17327 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17328 skip "Need MDS version at least 2.10.55"
17330 local dom=$DIR/$tdir/dom
17332 mkdir -p $DIR/$tdir
17334 $LFS setstripe -E 1024K -L mdt -E EOF $dom
17336 lctl set_param -n mdc.*.stats=clear
17337 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
17338 cancel_lru_locks mdc
17339 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
17340 # second stat to check size is cached on client
17341 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
17342 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
17343 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
17346 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
17349 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17350 skip "Need MDS version at least 2.10.55"
17352 local dom=$DIR/$tdir/dom
17354 mkdir -p $DIR/$tdir
17356 $LFS setstripe -E 1024K -L mdt -E EOF $dom
17358 lctl set_param -n mdc.*.stats=clear
17359 lctl set_param -n osc.*.stats=clear
17360 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
17361 cancel_lru_locks mdc
17362 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
17363 # second stat to check size is cached on client
17364 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
17365 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
17366 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
17367 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
17368 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
17371 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
17377 local mdt=MDT$(printf %04x $mdtidx)
17379 if [ -z $param ]; then
17380 lctl get_param -n mdc.*$mdt*.stats
17382 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
17387 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17388 skip "Need MDS version at least 2.10.55"
17390 local dom=$DIR/$tdir/dom
17392 mkdir -p $DIR/$tdir
17394 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17396 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
17397 local facet=mds$((mdtidx + 1))
17399 cancel_lru_locks mdc
17400 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
17401 createmany -o $dom 1000
17402 lctl set_param -n mdc.*.stats=clear
17403 smalliomany -w $dom 1000 200
17404 get_mdc_stats $mdtidx
17405 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
17406 # Each file has 1 open, 1 IO enqueues, total 2000
17407 # but now we have also +1 getxattr for security.capability, total 3000
17408 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
17409 unlinkmany $dom 1000
17411 cancel_lru_locks mdc
17412 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
17413 createmany -o $dom 1000
17414 lctl set_param -n mdc.*.stats=clear
17415 smalliomany -w $dom 1000 200
17416 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
17417 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
17418 # for OPEN and IO lock.
17419 [ $((enq - enq_2)) -ge 1000 ] ||
17420 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
17421 unlinkmany $dom 1000
17424 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
17426 cleanup_271def_tests() {
17432 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
17433 skip "Need MDS version at least 2.10.57"
17435 local dom=$DIR/$tdir/dom
17436 local tmp=$TMP/$tfile
17437 trap "cleanup_271def_tests $tmp" EXIT
17439 mkdir -p $DIR/$tdir
17441 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17443 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
17445 cancel_lru_locks mdc
17446 dd if=/dev/urandom of=$tmp bs=1000 count=1
17447 dd if=$tmp of=$dom bs=1000 count=1
17448 cancel_lru_locks mdc
17450 cat /etc/hosts >> $tmp
17451 lctl set_param -n mdc.*.stats=clear
17453 # append data to the same file it should update local page
17454 echo "Append to the same page"
17455 cat /etc/hosts >> $dom
17456 local num=$(get_mdc_stats $mdtidx ost_read)
17457 local ra=$(get_mdc_stats $mdtidx req_active)
17458 local rw=$(get_mdc_stats $mdtidx req_waittime)
17460 [ -z $num ] || error "$num READ RPC occured"
17461 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17465 cmp $tmp $dom || error "file miscompare"
17467 cancel_lru_locks mdc
17468 lctl set_param -n mdc.*.stats=clear
17470 echo "Open and read file"
17471 cat $dom > /dev/null
17472 local num=$(get_mdc_stats $mdtidx ost_read)
17473 local ra=$(get_mdc_stats $mdtidx req_active)
17474 local rw=$(get_mdc_stats $mdtidx req_waittime)
17476 [ -z $num ] || error "$num READ RPC occured"
17477 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17481 cmp $tmp $dom || error "file miscompare"
17485 run_test 271d "DoM: read on open (1K file in reply buffer)"
17488 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
17489 skip "Need MDS version at least 2.10.57"
17491 local dom=$DIR/$tdir/dom
17492 local tmp=$TMP/${tfile}.data
17493 trap "cleanup_271def_tests $tmp" EXIT
17495 mkdir -p $DIR/$tdir
17497 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17499 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
17501 cancel_lru_locks mdc
17502 dd if=/dev/urandom of=$tmp bs=30K count=1
17503 dd if=$tmp of=$dom bs=30K count=1
17504 cancel_lru_locks mdc
17505 cat /etc/hosts >> $tmp
17506 lctl set_param -n mdc.*.stats=clear
17508 echo "Append to the same page"
17509 cat /etc/hosts >> $dom
17511 local num=$(get_mdc_stats $mdtidx ost_read)
17512 local ra=$(get_mdc_stats $mdtidx req_active)
17513 local rw=$(get_mdc_stats $mdtidx req_waittime)
17515 [ -z $num ] || error "$num READ RPC occured"
17516 # Reply buffer can be adjusted for larger buffer by resend
17517 echo "... DONE with $((ra - rw)) resends"
17520 cmp $tmp $dom || error "file miscompare"
17522 cancel_lru_locks mdc
17523 lctl set_param -n mdc.*.stats=clear
17525 echo "Open and read file"
17526 cat $dom > /dev/null
17527 local num=$(get_mdc_stats $mdtidx ost_read)
17528 local ra=$(get_mdc_stats $mdtidx req_active)
17529 local rw=$(get_mdc_stats $mdtidx req_waittime)
17531 [ -z $num ] || error "$num READ RPC occured"
17532 # Reply buffer can be adjusted for larger buffer by resend
17533 echo "... DONE with $((ra - rw)) resends"
17536 cmp $tmp $dom || error "file miscompare"
17540 run_test 271e "DoM: read on open (30K file with reply buffer adjusting)"
17543 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
17544 skip "Need MDS version at least 2.10.57"
17546 local dom=$DIR/$tdir/dom
17547 local tmp=$TMP/$tfile
17548 trap "cleanup_271def_tests $tmp" EXIT
17550 mkdir -p $DIR/$tdir
17552 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17554 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
17556 cancel_lru_locks mdc
17557 dd if=/dev/urandom of=$tmp bs=200000 count=1
17558 dd if=$tmp of=$dom bs=200000 count=1
17559 cancel_lru_locks mdc
17560 cat /etc/hosts >> $tmp
17561 lctl set_param -n mdc.*.stats=clear
17563 echo "Append to the same page"
17564 cat /etc/hosts >> $dom
17565 local num=$(get_mdc_stats $mdtidx ost_read)
17566 local ra=$(get_mdc_stats $mdtidx req_active)
17567 local rw=$(get_mdc_stats $mdtidx req_waittime)
17569 [ -z $num ] || error "$num READ RPC occured"
17570 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17574 cmp $tmp $dom || error "file miscompare"
17576 cancel_lru_locks mdc
17577 lctl set_param -n mdc.*.stats=clear
17579 echo "Open and read file"
17580 cat $dom > /dev/null
17581 local num=$(get_mdc_stats $mdtidx ost_read)
17582 local ra=$(get_mdc_stats $mdtidx req_active)
17583 local rw=$(get_mdc_stats $mdtidx req_waittime)
17585 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
17586 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17590 cmp $tmp $dom || error "file miscompare"
17594 run_test 271f "DoM: read on open (200K file and read tail)"
17597 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17598 skip "Need MDS version at least 2.11.50"
17600 local dom=$DIR/$tdir/dom
17601 mkdir -p $DIR/$tdir
17603 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
17604 dd if=/dev/urandom of=$dom bs=512K count=1 ||
17605 error "failed to write data into $dom"
17606 local old_md5=$(md5sum $dom)
17608 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
17609 error "failed to migrate to the same DoM component"
17611 local new_md5=$(md5sum $dom)
17613 [ "$old_md5" == "$new_md5" ] ||
17614 error "md5sum differ: $old_md5, $new_md5"
17616 [ $($LFS getstripe -c $dom) -eq 2 ] ||
17617 error "migrate stripe count bad: $(LFS getstripe -c $dom) != 2"
17619 run_test 272a "DoM migration: new layout with the same DOM component"
17622 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17623 skip "Need MDS version at least 2.11.50"
17625 local dom=$DIR/$tdir/dom
17626 mkdir -p $DIR/$tdir
17627 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
17629 local mdtidx=$($LFS getstripe -m $dom)
17630 local mdtname=MDT$(printf %04x $mdtidx)
17631 local facet=mds$((mdtidx + 1))
17633 local mdtfree1=$(do_facet $facet \
17634 lctl get_param -n osd*.*$mdtname.kbytesfree)
17635 dd if=/dev/urandom of=$dom bs=2M count=1 ||
17636 error "failed to write data into $dom"
17637 local old_md5=$(md5sum $dom)
17638 cancel_lru_locks mdc
17639 local mdtfree1=$(do_facet $facet \
17640 lctl get_param -n osd*.*$mdtname.kbytesfree)
17642 $LFS migrate -c2 $dom ||
17643 error "failed to migrate to the new composite layout"
17644 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
17645 error "MDT stripe was not removed"
17647 cancel_lru_locks mdc
17648 local new_md5=$(md5sum $dom)
17649 [ "$old_md5" != "$new_md5" ] &&
17650 error "$old_md5 != $new_md5"
17652 # Skip free space checks with ZFS
17653 if [ "$(facet_fstype $facet)" != "zfs" ]; then
17654 local mdtfree2=$(do_facet $facet \
17655 lctl get_param -n osd*.*$mdtname.kbytesfree)
17656 [ $mdtfree2 -gt $mdtfree1 ] ||
17657 error "MDT space is not freed after migration"
17661 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
17664 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17665 skip "Need MDS version at least 2.11.50"
17667 local dom=$DIR/$tdir/$tfile
17668 mkdir -p $DIR/$tdir
17669 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
17671 local mdtidx=$($LFS getstripe -m $dom)
17672 local mdtname=MDT$(printf %04x $mdtidx)
17673 local facet=mds$((mdtidx + 1))
17675 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
17676 error "failed to write data into $dom"
17677 local old_md5=$(md5sum $dom)
17678 cancel_lru_locks mdc
17679 local mdtfree1=$(do_facet $facet \
17680 lctl get_param -n osd*.*$mdtname.kbytesfree)
17682 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
17683 error "failed to migrate to the new composite layout"
17684 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
17685 error "MDT stripe was not removed"
17687 cancel_lru_locks mdc
17688 local new_md5=$(md5sum $dom)
17689 [ "$old_md5" != "$new_md5" ] &&
17690 error "$old_md5 != $new_md5"
17692 # Skip free space checks with ZFS
17693 if [ "$(facet_fstype $facet)" != "zfs" ]; then
17694 local mdtfree2=$(do_facet $facet \
17695 lctl get_param -n osd*.*$mdtname.kbytesfree)
17696 [ $mdtfree2 -gt $mdtfree1 ] ||
17697 error "MDS space is not freed after migration"
17701 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
17704 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17705 skip "Need MDS version at least 2.11.50"
17707 # Layout swap cannot be done if either file has DOM component,
17708 # this will never be supported, migration should be used instead
17710 local dom=$DIR/$tdir/$tfile
17711 mkdir -p $DIR/$tdir
17713 $LFS setstripe -c2 ${dom}_plain
17714 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
17715 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
17716 error "can swap layout with DoM component"
17717 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
17718 error "can swap layout with DoM component"
17720 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
17721 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
17722 error "can swap layout with DoM component"
17723 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
17724 error "can swap layout with DoM component"
17727 run_test 273a "DoM: layout swapping should fail with DOM"
17730 remote_ost_nodsh && skip "remote OST with nodsh"
17731 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
17732 skip "Need OST version >= 2.10.57"
17734 local file=$DIR/$tfile
17737 oss=$(comma_list $(osts_nodes))
17739 dd if=/dev/urandom of=$file bs=1M count=2 ||
17740 error "failed to create a file"
17741 cancel_lru_locks osc
17744 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
17745 error "failed to read a file"
17747 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
17748 $LCTL set_param fail_loc=0x8000031f
17750 cancel_lru_locks osc &
17753 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
17754 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
17755 #IO takes another lock, but matches the PENDING one
17756 #and places it to the IO RPC
17757 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
17758 error "failed to read a file with PENDING lock"
17760 run_test 275 "Read on a canceled duplicate lock"
17763 remote_ost_nodsh && skip "remote OST with nodsh"
17766 do_facet ost1 "(while true; do \
17767 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
17768 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
17771 for LOOP in $(seq 20); do
17773 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
17776 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
17777 rm $TMP/sanity_276_pid"
17779 run_test 276 "Race between mount and obd_statfs"
17781 cleanup_test_300() {
17785 test_striped_dir() {
17790 mkdir -p $DIR/$tdir
17792 SAVE_UMASK=$(umask)
17793 trap cleanup_test_300 RETURN EXIT
17795 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
17796 $DIR/$tdir/striped_dir ||
17797 error "set striped dir error"
17799 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
17800 [ "$mode" = "755" ] || error "expect 755 got $mode"
17802 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
17803 error "getdirstripe failed"
17804 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
17805 if [ "$stripe_count" != "2" ]; then
17806 error "1:stripe_count is $stripe_count, expect 2"
17808 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
17809 if [ "$stripe_count" != "2" ]; then
17810 error "2:stripe_count is $stripe_count, expect 2"
17813 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
17814 if [ "$stripe_index" != "$mdt_index" ]; then
17815 error "stripe_index is $stripe_index, expect $mdt_index"
17818 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
17819 error "nlink error after create striped dir"
17821 mkdir $DIR/$tdir/striped_dir/a
17822 mkdir $DIR/$tdir/striped_dir/b
17824 stat $DIR/$tdir/striped_dir/a ||
17825 error "create dir under striped dir failed"
17826 stat $DIR/$tdir/striped_dir/b ||
17827 error "create dir under striped dir failed"
17829 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
17830 error "nlink error after mkdir"
17832 rmdir $DIR/$tdir/striped_dir/a
17833 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
17834 error "nlink error after rmdir"
17836 rmdir $DIR/$tdir/striped_dir/b
17837 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
17838 error "nlink error after rmdir"
17840 chattr +i $DIR/$tdir/striped_dir
17841 createmany -o $DIR/$tdir/striped_dir/f 10 &&
17842 error "immutable flags not working under striped dir!"
17843 chattr -i $DIR/$tdir/striped_dir
17845 rmdir $DIR/$tdir/striped_dir ||
17846 error "rmdir striped dir error"
17854 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
17855 skip "skipped for lustre < 2.7.0"
17856 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17857 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17859 test_striped_dir 0 || error "failed on striped dir on MDT0"
17860 test_striped_dir 1 || error "failed on striped dir on MDT0"
17862 run_test 300a "basic striped dir sanity test"
17865 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
17866 skip "skipped for lustre < 2.7.0"
17867 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17868 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17875 test_mkdir $DIR/$tdir || error "mkdir fail"
17876 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17877 error "set striped dir error"
17878 for i in {0..9}; do
17879 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
17881 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
17882 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
17883 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
17885 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
17886 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
17887 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
17891 run_test 300b "check ctime/mtime for striped dir"
17894 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
17895 skip "skipped for lustre < 2.7.0"
17896 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17897 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17901 mkdir -p $DIR/$tdir
17902 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
17903 error "set striped dir error"
17905 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
17906 error "chown striped dir failed"
17908 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
17909 error "create 5k files failed"
17911 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
17913 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
17917 run_test 300c "chown && check ls under striped directory"
17920 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
17921 skip "skipped for lustre < 2.7.0"
17922 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17923 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17928 mkdir -p $DIR/$tdir
17929 $LFS setstripe -c 2 $DIR/$tdir
17931 #local striped directory
17932 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17933 error "set striped dir error"
17934 createmany -o $DIR/$tdir/striped_dir/f 10 ||
17935 error "create 10 files failed"
17937 #remote striped directory
17938 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
17939 error "set striped dir error"
17940 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
17941 error "create 10 files failed"
17943 for file in $(find $DIR/$tdir); do
17944 stripe_count=$($LFS getstripe -c $file)
17945 [ $stripe_count -eq 2 ] ||
17946 error "wrong stripe $stripe_count for $file"
17951 run_test 300d "check default stripe under striped directory"
17954 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
17955 skip "Need MDS version at least 2.7.55"
17956 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17957 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17962 mkdir -p $DIR/$tdir
17964 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17965 error "set striped dir error"
17967 touch $DIR/$tdir/striped_dir/a
17968 touch $DIR/$tdir/striped_dir/b
17969 touch $DIR/$tdir/striped_dir/c
17971 mkdir $DIR/$tdir/striped_dir/dir_a
17972 mkdir $DIR/$tdir/striped_dir/dir_b
17973 mkdir $DIR/$tdir/striped_dir/dir_c
17975 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
17976 error "set striped adir under striped dir error"
17978 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
17979 error "set striped bdir under striped dir error"
17981 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
17982 error "set striped cdir under striped dir error"
17984 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
17985 error "rename dir under striped dir fails"
17987 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
17988 error "rename dir under different stripes fails"
17990 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
17991 error "rename file under striped dir should succeed"
17993 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
17994 error "rename dir under striped dir should succeed"
17998 run_test 300e "check rename under striped directory"
18001 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18002 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18003 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18004 skip "Need MDS version at least 2.7.55"
18010 mkdir -p $DIR/$tdir
18012 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18013 error "set striped dir error"
18015 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
18016 error "set striped dir error"
18018 touch $DIR/$tdir/striped_dir/a
18019 mkdir $DIR/$tdir/striped_dir/dir_a
18020 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
18021 error "create striped dir under striped dir fails"
18023 touch $DIR/$tdir/striped_dir1/b
18024 mkdir $DIR/$tdir/striped_dir1/dir_b
18025 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
18026 error "create striped dir under striped dir fails"
18028 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
18029 error "rename dir under different striped dir should fail"
18031 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
18032 error "rename striped dir under diff striped dir should fail"
18034 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
18035 error "rename file under diff striped dirs fails"
18039 run_test 300f "check rename cross striped directory"
18041 test_300_check_default_striped_dir()
18044 local default_count=$2
18045 local default_index=$3
18048 local dir_stripe_index
18051 echo "checking $dirname $default_count $default_index"
18052 $LFS setdirstripe -D -c $default_count -i $default_index \
18053 -t all_char $DIR/$tdir/$dirname ||
18054 error "set default stripe on striped dir error"
18055 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
18056 [ $stripe_count -eq $default_count ] ||
18057 error "expect $default_count get $stripe_count for $dirname"
18059 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
18060 [ $stripe_index -eq $default_index ] ||
18061 error "expect $default_index get $stripe_index for $dirname"
18063 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
18064 error "create dirs failed"
18066 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
18067 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
18068 for dir in $(find $DIR/$tdir/$dirname/*); do
18069 stripe_count=$($LFS getdirstripe -c $dir)
18070 [ $stripe_count -eq $default_count ] ||
18071 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
18072 error "stripe count $default_count != $stripe_count for $dir"
18074 stripe_index=$($LFS getdirstripe -i $dir)
18075 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
18076 error "$stripe_index != $default_index for $dir"
18078 #check default stripe
18079 stripe_count=$($LFS getdirstripe -D -c $dir)
18080 [ $stripe_count -eq $default_count ] ||
18081 error "default count $default_count != $stripe_count for $dir"
18083 stripe_index=$($LFS getdirstripe -D -i $dir)
18084 [ $stripe_index -eq $default_index ] ||
18085 error "default index $default_index != $stripe_index for $dir"
18087 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
18091 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18092 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18093 skip "Need MDS version at least 2.7.55"
18100 mkdir $DIR/$tdir/normal_dir
18102 #Checking when client cache stripe index
18103 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
18104 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
18105 error "create striped_dir failed"
18107 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
18108 error "create dir0 fails"
18109 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
18110 [ $stripe_index -eq 0 ] ||
18111 error "dir0 expect index 0 got $stripe_index"
18113 mkdir $DIR/$tdir/striped_dir/dir1 ||
18114 error "create dir1 fails"
18115 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
18116 [ $stripe_index -eq 1 ] ||
18117 error "dir1 expect index 1 got $stripe_index"
18119 #check default stripe count/stripe index
18120 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
18121 test_300_check_default_striped_dir normal_dir 1 0
18122 test_300_check_default_striped_dir normal_dir 2 1
18123 test_300_check_default_striped_dir normal_dir 2 -1
18125 #delete default stripe information
18126 echo "delete default stripeEA"
18127 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
18128 error "set default stripe on striped dir error"
18130 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
18131 for dir in $(find $DIR/$tdir/normal_dir/*); do
18132 stripe_count=$($LFS getdirstripe -c $dir)
18133 [ $stripe_count -eq 0 ] ||
18134 error "expect 1 get $stripe_count for $dir"
18135 stripe_index=$($LFS getdirstripe -i $dir)
18136 [ $stripe_index -eq 0 ] ||
18137 error "expect 0 get $stripe_index for $dir"
18140 run_test 300g "check default striped directory for normal directory"
18143 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18144 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18145 skip "Need MDS version at least 2.7.55"
18151 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18152 error "set striped dir error"
18154 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
18155 test_300_check_default_striped_dir striped_dir 1 0
18156 test_300_check_default_striped_dir striped_dir 2 1
18157 test_300_check_default_striped_dir striped_dir 2 -1
18159 #delete default stripe information
18160 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
18161 error "set default stripe on striped dir error"
18163 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
18164 for dir in $(find $DIR/$tdir/striped_dir/*); do
18165 stripe_count=$($LFS getdirstripe -c $dir)
18166 [ $stripe_count -eq 0 ] ||
18167 error "expect 1 get $stripe_count for $dir"
18170 run_test 300h "check default striped directory for striped directory"
18173 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18174 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18175 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18176 skip "Need MDS version at least 2.7.55"
18183 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18184 error "set striped dir error"
18186 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18187 error "create files under striped dir failed"
18189 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
18190 error "set striped hashdir error"
18192 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
18193 error "create dir0 under hash dir failed"
18194 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
18195 error "create dir1 under hash dir failed"
18197 # unfortunately, we need to umount to clear dir layout cache for now
18198 # once we fully implement dir layout, we can drop this
18199 umount_client $MOUNT || error "umount failed"
18200 mount_client $MOUNT || error "mount failed"
18202 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
18203 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
18204 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
18206 #set the stripe to be unknown hash type
18207 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
18208 $LCTL set_param fail_loc=0x1901
18209 for ((i = 0; i < 10; i++)); do
18210 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
18211 error "stat f-$i failed"
18212 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
18215 touch $DIR/$tdir/striped_dir/f0 &&
18216 error "create under striped dir with unknown hash should fail"
18218 $LCTL set_param fail_loc=0
18220 umount_client $MOUNT || error "umount failed"
18221 mount_client $MOUNT || error "mount failed"
18225 run_test 300i "client handle unknown hash type striped directory"
18228 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18229 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18230 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18231 skip "Need MDS version at least 2.7.55"
18238 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
18239 $LCTL set_param fail_loc=0x1702
18240 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18241 error "set striped dir error"
18243 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18244 error "create files under striped dir failed"
18246 $LCTL set_param fail_loc=0
18248 rm -rf $DIR/$tdir || error "unlink striped dir fails"
18252 run_test 300j "test large update record"
18255 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18256 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18257 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18258 skip "Need MDS version at least 2.7.55"
18260 # this test needs a huge transaction
18262 kb=$(do_facet $SINGLEMDS lctl get_param -n osd*.lustre-MDT0000.kbytestotal)
18263 [ $kb -lt $((1024*1024)) ] && skip "too small mds: $kb"
18270 #define OBD_FAIL_LARGE_STRIPE 0x1703
18271 $LCTL set_param fail_loc=0x1703
18272 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
18273 error "set striped dir error"
18274 $LCTL set_param fail_loc=0
18276 $LFS getdirstripe $DIR/$tdir/striped_dir ||
18277 error "getstripeddir fails"
18278 rm -rf $DIR/$tdir/striped_dir ||
18279 error "unlink striped dir fails"
18283 run_test 300k "test large striped directory"
18286 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18287 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18288 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18289 skip "Need MDS version at least 2.7.55"
18293 test_mkdir -p $DIR/$tdir/striped_dir
18294 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
18295 error "chown $RUNAS_ID failed"
18296 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
18297 error "set default striped dir failed"
18299 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
18300 $LCTL set_param fail_loc=0x80000158
18301 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
18303 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
18304 [ $stripe_index -eq 1 ] ||
18305 error "expect 1 get $stripe_index for $dir"
18307 run_test 300l "non-root user to create dir under striped dir with stale layout"
18310 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18311 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
18312 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18313 skip "Need MDS version at least 2.7.55"
18315 mkdir -p $DIR/$tdir/striped_dir
18316 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
18317 error "set default stripes dir error"
18319 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
18321 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
18322 [ $stripe_count -eq 0 ] ||
18323 error "expect 0 get $stripe_count for a"
18325 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
18326 error "set default stripes dir error"
18328 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
18330 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
18331 [ $stripe_count -eq 0 ] ||
18332 error "expect 0 get $stripe_count for b"
18334 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
18335 error "set default stripes dir error"
18337 mkdir $DIR/$tdir/striped_dir/c &&
18338 error "default stripe_index is invalid, mkdir c should fails"
18340 rm -rf $DIR/$tdir || error "rmdir fails"
18342 run_test 300m "setstriped directory on single MDT FS"
18345 local list=$(comma_list $(mdts_nodes))
18348 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18352 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18353 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18354 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18355 skip "Need MDS version at least 2.7.55"
18356 remote_mds_nodsh && skip "remote MDS with nodsh"
18359 local list=$(comma_list $(mdts_nodes))
18361 trap cleanup_300n RETURN EXIT
18362 mkdir -p $DIR/$tdir
18363 chmod 777 $DIR/$tdir
18364 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
18365 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
18366 error "create striped dir succeeds with gid=0"
18368 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
18369 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
18370 error "create striped dir fails with gid=-1"
18372 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18373 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
18374 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
18375 error "set default striped dir succeeds with gid=0"
18378 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
18379 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
18380 error "set default striped dir fails with gid=-1"
18383 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18384 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
18385 error "create test_dir fails"
18386 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
18387 error "create test_dir1 fails"
18388 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
18389 error "create test_dir2 fails"
18392 run_test 300n "non-root user to create dir under striped dir with default EA"
18395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18396 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18397 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18398 skip "Need MDS version at least 2.7.55"
18403 mkdir -p $DIR/$tdir
18405 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
18406 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
18407 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
18408 skip "not enough free inodes $numfree1 $numfree2"
18411 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
18412 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
18413 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
18414 skip "not enough free space $numfree1 $numfree2"
18417 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
18418 error "setdirstripe fails"
18420 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
18421 error "create dirs fails"
18423 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
18424 ls $DIR/$tdir/striped_dir > /dev/null ||
18425 error "ls striped dir fails"
18426 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
18427 error "unlink big striped dir fails"
18429 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
18432 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18433 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18434 remote_mds_nodsh && skip "remote MDS with nodsh"
18436 mkdir -p $DIR/$tdir
18438 #define OBD_FAIL_OUT_ENOSPC 0x1704
18439 do_facet mds2 lctl set_param fail_loc=0x80001704
18440 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
18441 && error "create striped directory should fail"
18443 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
18445 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
18448 run_test 300p "create striped directory without space"
18451 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18452 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18454 local fd=$(free_fd)
18455 local cmd="exec $fd<$tdir"
18457 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
18460 trap "eval $cmd" EXIT
18461 cd $tdir || error "cd $tdir fails"
18462 rmdir ../$tdir || error "rmdir $tdir fails"
18463 mkdir local_dir && error "create dir succeeds"
18464 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
18468 run_test 300q "create remote directory under orphan directory"
18471 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
18472 skip "Need MDS version at least 2.7.55" && return
18473 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
18477 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
18478 error "set striped dir error"
18480 $LFS getdirstripe $DIR/$tdir/striped_dir ||
18481 error "getstripeddir fails"
18484 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
18485 awk '/lmv_stripe_count:/ { print $2 }')
18487 [ $MDSCOUNT -ne $stripe_count ] &&
18488 error "wrong stripe count $stripe_count expected $MDSCOUNT"
18490 rm -rf $DIR/$tdir/striped_dir ||
18491 error "unlink striped dir fails"
18493 run_test 300r "test -1 striped directory"
18495 prepare_remote_file() {
18496 mkdir $DIR/$tdir/src_dir ||
18497 error "create remote source failed"
18499 cp /etc/hosts $DIR/$tdir/src_dir/a ||
18500 error "cp to remote source failed"
18501 touch $DIR/$tdir/src_dir/a
18503 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
18504 error "create remote target dir failed"
18506 touch $DIR/$tdir/tgt_dir/b
18508 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
18509 error "rename dir cross MDT failed!"
18511 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
18512 error "src_child still exists after rename"
18514 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
18515 error "missing file(a) after rename"
18517 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
18518 error "diff after rename"
18522 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
18523 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18525 local remote_file=$DIR/$tdir/tgt_dir/b
18527 mkdir -p $DIR/$tdir
18529 prepare_remote_file || error "prepare remote file failed"
18532 $OPENUNLINK $remote_file $remote_file ||
18533 error "openunlink $remote_file failed"
18534 $CHECKSTAT -a $remote_file || error "$remote_file exists"
18536 run_test 310a "open unlink remote file"
18539 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
18540 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18542 local remote_file=$DIR/$tdir/tgt_dir/b
18544 mkdir -p $DIR/$tdir
18546 prepare_remote_file || error "prepare remote file failed"
18548 ln $remote_file $DIR/$tfile || error "link failed for remote file"
18549 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
18550 $CHECKSTAT -t file $remote_file || error "check file failed"
18552 run_test 310b "unlink remote file with multiple links while open"
18555 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18556 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
18558 local remote_file=$DIR/$tdir/tgt_dir/b
18560 mkdir -p $DIR/$tdir
18562 prepare_remote_file || error "prepare remote file failed"
18564 ln $remote_file $DIR/$tfile || error "link failed for remote file"
18565 multiop_bg_pause $remote_file O_uc ||
18566 error "mulitop failed for remote file"
18568 $MULTIOP $DIR/$tfile Ouc
18569 kill -USR1 $MULTIPID
18572 run_test 310c "open-unlink remote file with multiple links"
18576 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18577 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
18578 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
18579 skip "lustre < 2.8.54 does not contain LU-4825 fix"
18580 remote_mds_nodsh && skip "remote MDS with nodsh"
18582 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
18583 local mdts=$(comma_list $(mdts_nodes))
18585 mkdir -p $DIR/$tdir
18586 $LFS setstripe -i 0 -c 1 $DIR/$tdir
18587 createmany -o $DIR/$tdir/$tfile. 1000
18589 # statfs data is not real time, let's just calculate it
18590 old_iused=$((old_iused + 1000))
18592 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
18593 osp.*OST0000*MDT0000.create_count")
18594 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
18595 osp.*OST0000*MDT0000.max_create_count")
18596 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
18598 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
18599 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
18600 [ $index -ne 0 ] || error "$tfile stripe index is 0"
18602 unlinkmany $DIR/$tdir/$tfile. 1000
18604 do_nodes $mdts "$LCTL set_param -n \
18605 osp.*OST0000*.max_create_count=$max_count"
18606 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
18607 do_nodes $mdts "$LCTL set_param -n \
18608 osp.*OST0000*.create_count=$count"
18609 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
18610 grep "=0" && error "create_count is zero"
18613 for i in $(seq 120); do
18614 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
18615 # system may be too busy to destroy all objs in time, use
18616 # a somewhat small value to not fail autotest
18617 [ $((old_iused - new_iused)) -gt 400 ] && break
18621 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
18622 [ $((old_iused - new_iused)) -gt 400 ] ||
18623 error "objs not destroyed after unlink"
18625 run_test 311 "disable OSP precreate, and unlink should destroy objs"
18632 local vdevdir=$(dirname $(facet_vdevice $ost))
18633 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
18634 local zfs_zapid=$(do_facet $ost $cmd |
18635 grep -w "/O/0/d$((objid%32))" -C 5 |
18636 awk '/Object/{getline; print $1}')
18637 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
18638 awk "/$objid = /"'{printf $3}')
18643 zfs_object_blksz() {
18647 local vdevdir=$(dirname $(facet_vdevice $ost))
18648 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
18649 local blksz=$(do_facet $ost $cmd $objid |
18650 awk '/dblk/{getline; printf $4}')
18652 case "${blksz: -1}" in
18653 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
18654 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
18661 test_312() { # LU-4856
18662 remote_ost_nodsh && skip "remote OST with nodsh"
18663 [ "$ost1_FSTYPE" = "zfs" ] ||
18664 skip_env "the test only applies to zfs"
18666 local max_blksz=$(do_facet ost1 \
18667 $ZFS get -p recordsize $(facet_device ost1) |
18668 awk '!/VALUE/{print $3}')
18670 # to make life a little bit easier
18671 $LFS mkdir -c 1 -i 0 $DIR/$tdir
18672 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18674 local tf=$DIR/$tdir/$tfile
18676 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18678 # Get ZFS object id
18679 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18680 # block size change by sequential overwrite
18683 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
18684 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
18686 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
18687 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
18691 # block size change by sequential append write
18692 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
18693 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18694 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18697 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
18698 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
18699 oflag=sync conv=notrunc
18701 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18702 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
18703 error "blksz error, actual $blksz, " \
18704 "expected: 2 * $count * $PAGE_SIZE"
18710 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18711 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18713 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
18714 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18715 [ $blksz -eq $PAGE_SIZE ] ||
18716 error "blksz error: $blksz, expected: $PAGE_SIZE"
18718 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
18719 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18720 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
18722 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
18723 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18724 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
18726 run_test 312 "make sure ZFS adjusts its block size by write pattern"
18729 remote_ost_nodsh && skip "remote OST with nodsh"
18731 local file=$DIR/$tfile
18734 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
18736 # define OBD_FAIL_TGT_RCVD_EIO 0x720
18737 do_facet ost1 "$LCTL set_param fail_loc=0x720"
18738 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
18739 error "write should failed"
18740 do_facet ost1 "$LCTL set_param fail_loc=0"
18743 run_test 313 "io should fail after last_rcvd update fail"
18746 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
18748 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
18749 do_facet ost1 "$LCTL set_param fail_loc=0x720"
18751 wait_delete_completed
18752 do_facet ost1 "$LCTL set_param fail_loc=0"
18754 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
18756 test_315() { # LU-618
18757 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
18759 local file=$DIR/$tfile
18762 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
18763 error "multiop file write failed"
18764 $MULTIOP $file oO_RDONLY:r4063232_c &
18769 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
18772 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
18775 run_test 315 "read should be accounted"
18778 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
18779 large_xattr_enabled || skip_env "ea_inode feature disabled"
18781 rm -rf $DIR/$tdir/d
18782 mkdir -p $DIR/$tdir/d
18783 chown nobody $DIR/$tdir/d
18784 touch $DIR/$tdir/d/file
18786 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
18788 run_test 316 "lfs mv"
18791 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
18792 skip "Need MDS version at least 2.11.53"
18794 local grant_blk_size
18796 if [ "$(facet_fstype $facet)" == "zfs" ]; then
18797 skip "LU-10370: no implementation for ZFS" && return
18800 stack_trap "rm -f $DIR/$tfile" EXIT
18801 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
18802 awk '/grant_block_size:/ { print $2; exit; }')
18804 # Create File of size 5M. Truncate it to below size's and verify
18807 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
18808 error "Create file : $DIR/$tfile"
18810 for trunc_sz in 2097152 4097 4000 509 0; do
18811 $TRUNCATE $DIR/$tfile $trunc_sz ||
18812 error "truncate $tfile to $trunc_sz failed"
18813 local sz=$(stat --format=%s $DIR/$tfile)
18814 local blk=$(stat --format=%b $DIR/$tfile)
18815 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
18816 grant_blk_size) * 8))
18818 if [[ $blk -ne $trunc_blk ]]; then
18819 $(which stat) $DIR/$tfile
18820 error "Expected Block $trunc_blk got $blk for $tfile"
18823 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
18824 error "Expected Size $trunc_sz got $sz for $tfile"
18829 # Create file with a hole and write actual two blocks. Block count
18832 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
18833 conv=fsync || error "Create file : $DIR/$tfile"
18835 # Calculate the final truncate size.
18836 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
18839 # truncate to size $trunc_sz bytes. Strip the last block
18840 # The block count must drop to 8
18842 $TRUNCATE $DIR/$tfile $trunc_sz ||
18843 error "truncate $tfile to $trunc_sz failed"
18845 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
18846 sz=$(stat --format=%s $DIR/$tfile)
18847 blk=$(stat --format=%b $DIR/$tfile)
18849 if [[ $blk -ne $trunc_bsz ]]; then
18850 $(which stat) $DIR/$tfile
18851 error "Expected Block $trunc_bsz got $blk for $tfile"
18854 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
18855 error "Expected Size $trunc_sz got $sz for $tfile"
18857 run_test 317 "Verify blocks get correctly update after truncate"
18860 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
18862 local before=$(date +%s)
18864 local mdir=$DIR/$tdir
18865 local file=$mdir/xxx
18867 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
18870 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
18871 $LCTL set_param fail_val=5 fail_loc=0x8000032c
18872 $LFS mv -m1 $file &
18875 dd if=$file of=/dev/null
18877 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
18878 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
18880 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
18882 run_test 319 "lost lease lock on migrate error"
18885 local read_write=$1
18886 if [ "$read_write" = "write" ]; then
18887 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
18888 elif [ "$read_write" = "read" ]; then
18889 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
18891 error "argument error"
18894 # turn off debug for performance testing
18895 local saved_debug=$($LCTL get_param -n debug)
18896 $LCTL set_param debug=0
18898 $LFS setstripe -c 1 -i 0 $DIR/$tfile
18900 # get ost1 size - lustre-OST0000
18901 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
18902 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
18903 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
18905 if [ "$read_write" = "read" ]; then
18906 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
18909 local start_time=$(date +%s.%N)
18910 $dd_cmd bs=1M count=$blocks oflag=sync ||
18911 error "real dd $read_write error"
18912 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
18914 if [ "$read_write" = "write" ]; then
18918 # define OBD_FAIL_OST_FAKE_RW 0x238
18919 do_facet ost1 $LCTL set_param fail_loc=0x238
18921 local start_time=$(date +%s.%N)
18922 $dd_cmd bs=1M count=$blocks oflag=sync ||
18923 error "fake dd $read_write error"
18924 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
18926 if [ "$read_write" = "write" ]; then
18928 cancel_lru_locks osc
18929 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
18930 error "$tfile size not $blocks MB"
18932 do_facet ost1 $LCTL set_param fail_loc=0
18934 echo "fake $read_write $duration_fake vs. normal $read_write" \
18935 "$duration in seconds"
18936 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
18937 error_not_in_vm "fake write is slower"
18939 $LCTL set_param -n debug="$saved_debug"
18942 test_399a() { # LU-7655 for OST fake write
18943 remote_ost_nodsh && skip "remote OST with nodsh"
18947 run_test 399a "fake write should not be slower than normal write"
18949 test_399b() { # LU-8726 for OST fake read
18950 remote_ost_nodsh && skip "remote OST with nodsh"
18951 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
18952 skip_env "ldiskfs only test"
18957 run_test 399b "fake read should not be slower than normal read"
18959 test_400a() { # LU-1606, was conf-sanity test_74
18960 if ! which $CC > /dev/null 2>&1; then
18961 skip_env "$CC is not installed"
18964 local extra_flags=''
18965 local out=$TMP/$tfile
18966 local prefix=/usr/include/lustre
18969 if ! [[ -d $prefix ]]; then
18970 # Assume we're running in tree and fixup the include path.
18971 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
18972 extra_flags+=" -L$LUSTRE/utils/.lib"
18975 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
18976 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
18977 error "client api broken"
18981 run_test 400a "Lustre client api program can compile and link"
18983 test_400b() { # LU-1606, LU-5011
18985 local out=$TMP/$tfile
18986 local prefix=/usr/include/linux/lustre
18988 # We use a hard coded prefix so that this test will not fail
18989 # when run in tree. There are headers in lustre/include/lustre/
18990 # that are not packaged (like lustre_idl.h) and have more
18991 # complicated include dependencies (like config.h and lnet/types.h).
18992 # Since this test about correct packaging we just skip them when
18993 # they don't exist (see below) rather than try to fixup cppflags.
18995 if ! which $CC > /dev/null 2>&1; then
18996 skip_env "$CC is not installed"
18999 for header in $prefix/*.h; do
19000 if ! [[ -f "$header" ]]; then
19004 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
19005 continue # lustre_ioctl.h is internal header
19008 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
19009 error "cannot compile '$header'"
19013 run_test 400b "packaged headers can be compiled"
19015 test_401a() { #LU-7437
19016 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
19017 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
19019 #count the number of parameters by "list_param -R"
19020 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
19021 #count the number of parameters by listing proc files
19022 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
19023 echo "proc_dirs='$proc_dirs'"
19024 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
19025 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
19028 [ $params -eq $procs ] ||
19029 error "found $params parameters vs. $procs proc files"
19031 # test the list_param -D option only returns directories
19032 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
19033 #count the number of parameters by listing proc directories
19034 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
19037 [ $params -eq $procs ] ||
19038 error "found $params parameters vs. $procs proc files"
19040 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
19043 local save=$($LCTL get_param -n jobid_var)
19046 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
19047 error "no error returned when setting bad parameters"
19049 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
19050 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
19052 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
19053 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
19054 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
19056 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
19059 local jobid_var_old=$($LCTL get_param -n jobid_var)
19060 local jobid_var_new
19062 $LCTL set_param jobid_var= &&
19063 error "no error returned for 'set_param a='"
19065 jobid_var_new=$($LCTL get_param -n jobid_var)
19066 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
19067 error "jobid_var was changed by setting without value"
19069 $LCTL set_param jobid_var &&
19070 error "no error returned for 'set_param a'"
19072 jobid_var_new=$($LCTL get_param -n jobid_var)
19073 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
19074 error "jobid_var was changed by setting without value"
19076 run_test 401c "Verify 'lctl set_param' without value fails in either format."
19079 local jobid_var_old=$($LCTL get_param -n jobid_var)
19080 local jobid_var_new
19081 local new_value="foo=bar"
19083 $LCTL set_param jobid_var=$new_value ||
19084 error "'set_param a=b' did not accept a value containing '='"
19086 jobid_var_new=$($LCTL get_param -n jobid_var)
19087 [[ "$jobid_var_new" == "$new_value" ]] ||
19088 error "'set_param a=b' failed on a value containing '='"
19090 # Reset the jobid_var to test the other format
19091 $LCTL set_param jobid_var=$jobid_var_old
19092 jobid_var_new=$($LCTL get_param -n jobid_var)
19093 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
19094 error "failed to reset jobid_var"
19096 $LCTL set_param jobid_var $new_value ||
19097 error "'set_param a b' did not accept a value containing '='"
19099 jobid_var_new=$($LCTL get_param -n jobid_var)
19100 [[ "$jobid_var_new" == "$new_value" ]] ||
19101 error "'set_param a b' failed on a value containing '='"
19103 $LCTL set_param jobid_var $jobid_var_old
19104 jobid_var_new=$($LCTL get_param -n jobid_var)
19105 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
19106 error "failed to reset jobid_var"
19108 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
19111 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
19112 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
19113 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
19114 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
19115 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
19116 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
19117 remote_mds_nodsh && skip "remote MDS with nodsh"
19119 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
19120 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
19121 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
19122 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
19123 echo "Touch failed - OK"
19125 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
19128 local file1=$DIR/$tfile.1
19129 local file2=$DIR/$tfile.2
19130 local tfile=$TMP/$tfile
19132 rm -f $file1 $file2 $tfile
19137 # 30 sec OBD_TIMEOUT in ll_getattr()
19138 # right before populating st_nlink
19139 $LCTL set_param fail_loc=0x80001409
19140 stat -c %h $file1 > $tfile &
19142 # create an alias, drop all locks and reclaim the dentry
19144 cancel_lru_locks mdc
19145 cancel_lru_locks osc
19146 sysctl -w vm.drop_caches=2
19150 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
19152 rm -f $tfile $file1 $file2
19154 run_test 403 "i_nlink should not drop to zero due to aliasing"
19156 test_404() { # LU-6601
19157 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
19158 skip "Need server version newer than 2.8.52"
19159 remote_mds_nodsh && skip "remote MDS with nodsh"
19161 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
19162 awk '/osp .*-osc-MDT/ { print $4}')
19165 for osp in $mosps; do
19166 echo "Deactivate: " $osp
19167 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
19168 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19169 awk -vp=$osp '$4 == p { print $2 }')
19170 [ $stat = IN ] || {
19171 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19172 error "deactivate error"
19174 echo "Activate: " $osp
19175 do_facet $SINGLEMDS $LCTL --device %$osp activate
19176 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19177 awk -vp=$osp '$4 == p { print $2 }')
19178 [ $stat = UP ] || {
19179 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19180 error "activate error"
19184 run_test 404 "validate manual {de}activated works properly for OSPs"
19187 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
19188 [ $MDS1_VERSION -lt $(version_code 2.6.92) -o \
19189 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
19190 skip "Layout swap lock is not supported"
19191 check_swap_layouts_support
19193 test_mkdir $DIR/$tdir
19194 swap_lock_test -d $DIR/$tdir ||
19195 error "One layout swap locked test failed"
19197 run_test 405 "Various layout swap lock tests"
19200 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19201 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
19202 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
19203 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19204 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
19205 skip "Need MDS version at least 2.8.50"
19207 local def_stripe_size=$($LFS getstripe -S $MOUNT)
19208 local test_pool=$TESTNAME
19210 if ! combined_mgs_mds ; then
19213 pool_add $test_pool || error "pool_add failed"
19214 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
19215 error "pool_add_targets failed"
19217 save_layout_restore_at_exit $MOUNT
19219 # parent set default stripe count only, child will stripe from both
19220 # parent and fs default
19221 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
19222 error "setstripe $MOUNT failed"
19223 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
19224 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
19225 for i in $(seq 10); do
19226 local f=$DIR/$tdir/$tfile.$i
19227 touch $f || error "touch failed"
19228 local count=$($LFS getstripe -c $f)
19229 [ $count -eq $OSTCOUNT ] ||
19230 error "$f stripe count $count != $OSTCOUNT"
19231 local offset=$($LFS getstripe -i $f)
19232 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
19233 local size=$($LFS getstripe -S $f)
19234 [ $size -eq $((def_stripe_size * 2)) ] ||
19235 error "$f stripe size $size != $((def_stripe_size * 2))"
19236 local pool=$($LFS getstripe -p $f)
19237 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
19240 # change fs default striping, delete parent default striping, now child
19241 # will stripe from new fs default striping only
19242 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
19243 error "change $MOUNT default stripe failed"
19244 $LFS setstripe -c 0 $DIR/$tdir ||
19245 error "delete $tdir default stripe failed"
19246 for i in $(seq 11 20); do
19247 local f=$DIR/$tdir/$tfile.$i
19248 touch $f || error "touch $f failed"
19249 local count=$($LFS getstripe -c $f)
19250 [ $count -eq 1 ] || error "$f stripe count $count != 1"
19251 local offset=$($LFS getstripe -i $f)
19252 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
19253 local size=$($LFS getstripe -S $f)
19254 [ $size -eq $def_stripe_size ] ||
19255 error "$f stripe size $size != $def_stripe_size"
19256 local pool=$($LFS getstripe -p $f)
19257 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
19260 unlinkmany $DIR/$tdir/$tfile. 1 20
19262 local f=$DIR/$tdir/$tfile
19263 pool_remove_all_targets $test_pool $f
19264 pool_remove $test_pool $f
19266 if ! combined_mgs_mds ; then
19270 run_test 406 "DNE support fs default striping"
19273 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19274 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
19275 skip "Need MDS version at least 2.8.55"
19276 remote_mds_nodsh && skip "remote MDS with nodsh"
19278 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
19279 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
19280 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
19281 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
19282 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
19284 #define OBD_FAIL_DT_TXN_STOP 0x2019
19285 for idx in $(seq $MDSCOUNT); do
19286 do_facet mds$idx "lctl set_param fail_loc=0x2019"
19288 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
19289 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
19290 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
19293 run_test 407 "transaction fail should cause operation fail"
19296 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
19298 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
19299 lctl set_param fail_loc=0x8000040a
19300 # let ll_prepare_partial_page() fail
19301 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
19305 # create at least 100 unused inodes so that
19306 # shrink_icache_memory(0) should not return 0
19307 touch $DIR/$tfile-{0..100}
19308 rm -f $DIR/$tfile-{0..100}
19311 echo 2 > /proc/sys/vm/drop_caches
19313 run_test 408 "drop_caches should not hang due to page leaks"
19317 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19319 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
19320 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
19321 touch $DIR/$tdir/guard || error "(2) Fail to create"
19323 local PREFIX=$(str_repeat 'A' 128)
19324 echo "Create 1K hard links start at $(date)"
19325 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
19326 error "(3) Fail to hard link"
19328 echo "Links count should be right although linkEA overflow"
19329 stat $DIR/$tdir/guard || error "(4) Fail to stat"
19330 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
19331 [ $linkcount -eq 1001 ] ||
19332 error "(5) Unexpected hard links count: $linkcount"
19334 echo "List all links start at $(date)"
19335 ls -l $DIR/$tdir/foo > /dev/null ||
19336 error "(6) Fail to list $DIR/$tdir/foo"
19338 echo "Unlink hard links start at $(date)"
19339 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
19340 error "(7) Fail to unlink"
19341 echo "Unlink hard links finished at $(date)"
19343 run_test 409 "Large amount of cross-MDTs hard links on the same file"
19347 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
19348 skip "Need client version at least 2.9.59"
19350 # Create a file, and stat it from the kernel
19351 local testfile=$DIR/$tfile
19354 local run_id=$RANDOM
19355 local my_ino=$(stat --format "%i" $testfile)
19357 # Try to insert the module. This will always fail as the
19358 # module is designed to not be inserted.
19359 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
19362 # Anything but success is a test failure
19364 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
19365 error "no inode match"
19367 run_test 410 "Test inode number returned from kernel thread"
19369 cleanup_test411_cgroup() {
19375 local cg_basedir=/sys/fs/cgroup/memory
19377 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
19378 skip "no setup for cgroup"
19380 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
19381 error "test file creation failed"
19382 cancel_lru_locks osc
19384 # Create a very small memory cgroup to force a slab allocation error
19385 local cgdir=$cg_basedir/osc_slab_alloc
19386 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
19387 trap "cleanup_test411_cgroup $cgdir" EXIT
19388 echo 2M > $cgdir/memory.kmem.limit_in_bytes
19389 echo 1M > $cgdir/memory.limit_in_bytes
19391 # Should not LBUG, just be killed by oom-killer
19392 # dd will return 0 even allocation failure in some environment.
19393 # So don't check return value
19394 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
19395 cleanup_test411_cgroup $cgdir
19399 run_test 411 "Slab allocation error with cgroup does not LBUG"
19402 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19403 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
19404 skip "Need server version at least 2.10.55"
19407 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
19408 error "mkdir failed"
19409 $LFS getdirstripe $DIR/$tdir
19410 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
19411 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
19412 error "expect $((MDSCOUT - 1)) get $stripe_index"
19413 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
19414 [ $stripe_count -eq 2 ] ||
19415 error "expect 2 get $stripe_count"
19417 run_test 412 "mkdir on specific MDTs"
19420 [ $MDSCOUNT -lt 2 ] &&
19421 skip "We need at least 2 MDTs for this test"
19423 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
19424 skip "Need server version at least 2.10.55"
19427 mkdir $DIR/$tdir || error "mkdir failed"
19429 # find MDT that is the most full
19430 local max=$($LFS df | grep MDT |
19439 END { split(b, c, ":")
19444 for i in $(seq $((MDSCOUNT - 1))); do
19445 $LFS mkdir -c $i $DIR/$tdir/d$i ||
19446 error "mkdir d$i failed"
19447 $LFS getdirstripe $DIR/$tdir/d$i
19448 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
19449 [ $stripe_index -ne $max ] ||
19450 error "don't expect $max"
19453 run_test 413 "mkdir on less full MDTs"
19456 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
19457 $LCTL set_param fail_loc=0x80000521
19458 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
19461 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
19464 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19465 [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
19466 skip "Need server version at least 2.11.52"
19476 # this test may be slow on ZFS
19477 [ "$mds1_FSTYPE" == "zfs" ] && total=100
19479 # though this test is designed for striped directory, let's test normal
19480 # directory too since lock is always saved as CoS lock.
19481 test_mkdir $DIR/$tdir || error "mkdir $tdir"
19482 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
19491 start_time=$(date +%s)
19492 for i in $(seq $total); do
19493 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
19496 end_time=$(date +%s)
19497 duration=$((end_time - start_time))
19499 kill -9 $setattr_pid
19501 echo "rename $total files took $duration sec"
19502 [ $duration -lt 100 ] || error "rename took $duration sec"
19504 run_test 415 "lock revoke is not missing"
19507 [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
19508 skip "Need server version at least 2.11.55"
19510 # define OBD_FAIL_OSD_TXN_START 0x19a
19511 do_facet mds1 lctl set_param fail_loc=0x19a
19513 lfs mkdir -c $MDSCOUNT $DIR/$tdir
19517 run_test 416 "transaction start failure won't cause system hung"
19521 do_nodes $(comma_list $(mdts_nodes)) \
19522 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
19523 do_nodes $(comma_list $(mdts_nodes)) \
19524 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
19525 do_nodes $(comma_list $(mdts_nodes)) \
19526 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
19530 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19531 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
19532 skip "Need MDS version at least 2.11.56"
19534 trap cleanup_417 RETURN EXIT
19536 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
19537 do_nodes $(comma_list $(mdts_nodes)) \
19538 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
19539 $LFS migrate -m 0 $DIR/$tdir.1 &&
19540 error "migrate dir $tdir.1 should fail"
19542 do_nodes $(comma_list $(mdts_nodes)) \
19543 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
19544 $LFS mkdir -i 1 $DIR/$tdir.2 &&
19545 error "create remote dir $tdir.2 should fail"
19547 do_nodes $(comma_list $(mdts_nodes)) \
19548 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
19549 $LFS mkdir -c 2 $DIR/$tdir.3 &&
19550 error "create striped dir $tdir.3 should fail"
19553 run_test 417 "disable remote dir, striped dir and dir migration"
19555 # Checks that the outputs of df [-i] and lfs df [-i] match
19557 # usage: check_lfs_df <blocks | inodes> <mountpoint>
19567 [ "$1" == "blocks" ] && inodes= || inodes="-i"
19569 for count in {1..100}; do
19573 # read the lines of interest
19574 df_out=($(df -P $inodes $dir | tail -n +2)) ||
19575 error "df $inodes $dir | tail -n +2 failed"
19576 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
19577 error "lfs df $inodes $dir | grep summary: failed"
19579 # skip first substrings of each output as they are different
19580 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
19581 # compare the two outputs
19583 for i in {1..5}; do
19584 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
19592 lfs df $inodes $dir
19593 error "df and lfs df $1 output mismatch: " \
19594 "df ${inodes}: ${df_out[*]}, " \
19595 "lfs df ${inodes}: ${lfs_df_out[*]}"
19600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19602 local dir=$DIR/$tdir
19603 local numfiles=$((RANDOM % 4096 + 2))
19604 local numblocks=$((RANDOM % 256 + 1))
19606 wait_delete_completed
19609 # check block output
19610 check_lfs_df blocks $dir
19611 # check inode output
19612 check_lfs_df inodes $dir
19614 # create a single file and retest
19615 echo "Creating a single file and testing"
19616 createmany -o $dir/$tfile- 1 &>/dev/null ||
19617 error "creating 1 file in $dir failed"
19618 check_lfs_df blocks $dir
19619 check_lfs_df inodes $dir
19621 # create a random number of files
19622 echo "Creating $((numfiles - 1)) files and testing"
19623 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
19624 error "creating $((numfiles - 1)) files in $dir failed"
19626 # write a random number of blocks to the first test file
19627 echo "Writing $numblocks 4K blocks and testing"
19628 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
19629 count=$numblocks &>/dev/null ||
19630 error "dd to $dir/${tfile}-0 failed"
19633 check_lfs_df blocks $dir
19634 check_lfs_df inodes $dir
19636 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
19637 error "unlinking $numfiles files in $dir failed"
19639 run_test 418 "df and lfs df outputs match"
19642 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
19643 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
19644 skip "Need server version at least 2.9.55"
19646 start_full_debug_logging
19650 stop_full_debug_logging
19654 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
19655 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
19656 awk '/The barrier for/ { print $7 }')
19659 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
19664 barrier_expired() {
19667 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
19668 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
19669 awk '/will be expired/ { print $7 }')
19671 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
19680 echo "Start barrier_freeze at: $(date)"
19681 #define OBD_FAIL_BARRIER_DELAY 0x2202
19682 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
19683 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
19686 local b_status=$(barrier_stat)
19687 echo "Got barrier status at: $(date)"
19688 [ "$b_status" = "'freezing_p1'" ] ||
19689 error "(1) unexpected barrier status $b_status"
19691 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
19693 b_status=$(barrier_stat)
19694 [ "$b_status" = "'frozen'" ] ||
19695 error "(2) unexpected barrier status $b_status"
19697 local expired=$(barrier_expired)
19698 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
19699 sleep $((expired + 3))
19701 b_status=$(barrier_stat)
19702 [ "$b_status" = "'expired'" ] ||
19703 error "(3) unexpected barrier status $b_status"
19705 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
19706 error "(4) fail to freeze barrier"
19708 b_status=$(barrier_stat)
19709 [ "$b_status" = "'frozen'" ] ||
19710 error "(5) unexpected barrier status $b_status"
19712 echo "Start barrier_thaw at: $(date)"
19713 #define OBD_FAIL_BARRIER_DELAY 0x2202
19714 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
19715 do_facet mgs $LCTL barrier_thaw $FSNAME &
19718 b_status=$(barrier_stat)
19719 echo "Got barrier status at: $(date)"
19720 [ "$b_status" = "'thawing'" ] ||
19721 error "(6) unexpected barrier status $b_status"
19723 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
19725 b_status=$(barrier_stat)
19726 [ "$b_status" = "'thawed'" ] ||
19727 error "(7) unexpected barrier status $b_status"
19729 #define OBD_FAIL_BARRIER_FAILURE 0x2203
19730 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
19731 do_facet mgs $LCTL barrier_freeze $FSNAME
19733 b_status=$(barrier_stat)
19734 [ "$b_status" = "'failed'" ] ||
19735 error "(8) unexpected barrier status $b_status"
19737 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
19738 do_facet mgs $LCTL barrier_thaw $FSNAME
19742 run_test 801a "write barrier user interfaces and stat machine"
19747 mkdir $DIR/$tdir || error "(1) fail to mkdir"
19748 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
19749 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
19750 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
19751 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
19753 cancel_lru_locks mdc
19755 # 180 seconds should be long enough
19756 do_facet mgs $LCTL barrier_freeze $FSNAME 180
19758 local b_status=$(barrier_stat)
19759 [ "$b_status" = "'frozen'" ] ||
19760 error "(6) unexpected barrier status $b_status"
19762 mkdir $DIR/$tdir/d0/d10 &
19765 touch $DIR/$tdir/d1/f13 &
19768 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
19771 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
19774 rm -f $DIR/$tdir/d4/f12 &
19777 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
19779 # To guarantee taht the 'stat' is not blocked
19780 b_status=$(barrier_stat)
19781 [ "$b_status" = "'frozen'" ] ||
19782 error "(8) unexpected barrier status $b_status"
19784 # let above commands to run at background
19787 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
19788 ps -p $touch_pid || error "(10) touch should be blocked"
19789 ps -p $ln_pid || error "(11) link should be blocked"
19790 ps -p $mv_pid || error "(12) rename should be blocked"
19791 ps -p $rm_pid || error "(13) unlink should be blocked"
19793 b_status=$(barrier_stat)
19794 [ "$b_status" = "'frozen'" ] ||
19795 error "(14) unexpected barrier status $b_status"
19797 do_facet mgs $LCTL barrier_thaw $FSNAME
19798 b_status=$(barrier_stat)
19799 [ "$b_status" = "'thawed'" ] ||
19800 error "(15) unexpected barrier status $b_status"
19802 wait $mkdir_pid || error "(16) mkdir should succeed"
19803 wait $touch_pid || error "(17) touch should succeed"
19804 wait $ln_pid || error "(18) link should succeed"
19805 wait $mv_pid || error "(19) rename should succeed"
19806 wait $rm_pid || error "(20) unlink should succeed"
19810 run_test 801b "modification will be blocked by write barrier"
19813 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
19817 stop mds2 || error "(1) Fail to stop mds2"
19819 do_facet mgs $LCTL barrier_freeze $FSNAME 30
19821 local b_status=$(barrier_stat)
19822 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
19823 do_facet mgs $LCTL barrier_thaw $FSNAME
19824 error "(2) unexpected barrier status $b_status"
19827 do_facet mgs $LCTL barrier_rescan $FSNAME ||
19828 error "(3) Fail to rescan barrier bitmap"
19830 do_facet mgs $LCTL barrier_freeze $FSNAME 10
19832 b_status=$(barrier_stat)
19833 [ "$b_status" = "'frozen'" ] ||
19834 error "(4) unexpected barrier status $b_status"
19836 do_facet mgs $LCTL barrier_thaw $FSNAME
19837 b_status=$(barrier_stat)
19838 [ "$b_status" = "'thawed'" ] ||
19839 error "(5) unexpected barrier status $b_status"
19841 local devname=$(mdsdevname 2)
19843 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
19845 do_facet mgs $LCTL barrier_rescan $FSNAME ||
19846 error "(7) Fail to rescan barrier bitmap"
19850 run_test 801c "rescan barrier bitmap"
19852 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
19853 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
19854 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
19860 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
19861 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
19862 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
19868 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
19869 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
19870 skip "Need server version at least 2.9.55"
19872 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
19874 mkdir $DIR/$tdir || error "(1) fail to mkdir"
19876 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
19877 error "(2) Fail to copy"
19879 trap cleanup_802a EXIT
19881 # sync by force before remount as readonly
19882 sync; sync_all_data; sleep 3; sync_all_data
19886 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
19887 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
19888 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
19890 echo "Mount the server as read only"
19891 setupall server_only || error "(3) Fail to start servers"
19893 echo "Mount client without ro should fail"
19894 mount_client $MOUNT &&
19895 error "(4) Mount client without 'ro' should fail"
19897 echo "Mount client with ro should succeed"
19898 mount_client $MOUNT ro ||
19899 error "(5) Mount client with 'ro' should succeed"
19901 echo "Modify should be refused"
19902 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
19904 echo "Read should be allowed"
19905 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
19906 error "(7) Read should succeed under ro mode"
19910 run_test 802a "simulate readonly device"
19913 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19914 remote_mds_nodsh && skip "remote MDS with nodsh"
19916 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
19917 skip "readonly option not available"
19919 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
19921 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
19922 error "(2) Fail to copy"
19924 # write back all cached data before setting MDT to readonly
19928 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
19929 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
19931 echo "Modify should be refused"
19932 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
19934 echo "Read should be allowed"
19935 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
19936 error "(7) Read should succeed under ro mode"
19939 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
19941 run_test 802b "be able to set MDTs to readonly"
19944 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
19945 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
19946 skip "MDS needs to be newer than 2.10.54"
19948 mkdir -p $DIR/$tdir
19949 # Create some objects on all MDTs to trigger related logs objects
19950 for idx in $(seq $MDSCOUNT); do
19951 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
19952 $DIR/$tdir/dir${idx} ||
19953 error "Fail to create $DIR/$tdir/dir${idx}"
19957 wait_delete_completed # ensure old test cleanups are finished
19958 echo "before create:"
19960 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
19962 for i in {1..10}; do
19963 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
19964 error "Fail to create $DIR/$tdir/foo$i"
19968 echo "after create:"
19970 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
19972 # allow for an llog to be cleaned up during the test
19973 [ $after_used -ge $((before_used + 10 - 1)) ] ||
19974 error "before ($before_used) + 10 > after ($after_used)"
19976 for i in {1..10}; do
19977 rm -rf $DIR/$tdir/foo$i ||
19978 error "Fail to remove $DIR/$tdir/foo$i"
19981 sleep 3 # avoid MDT return cached statfs
19982 wait_delete_completed
19983 echo "after unlink:"
19985 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
19987 # allow for an llog to be created during the test
19988 [ $after_used -le $((before_used + 1)) ] ||
19989 error "after ($after_used) > before ($before_used) + 1"
19991 run_test 803 "verify agent object for remote object"
19994 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
19995 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
19996 skip "MDS needs to be newer than 2.10.54"
19997 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19999 mkdir -p $DIR/$tdir
20000 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
20001 error "Fail to create $DIR/$tdir/dir0"
20003 local fid=$($LFS path2fid $DIR/$tdir/dir0)
20004 local dev=$(mdsdevname 2)
20006 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20007 grep ${fid} || error "NOT found agent entry for dir0"
20009 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
20010 error "Fail to create $DIR/$tdir/dir1"
20012 touch $DIR/$tdir/dir1/foo0 ||
20013 error "Fail to create $DIR/$tdir/dir1/foo0"
20014 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
20017 for idx in $(seq $MDSCOUNT); do
20018 dev=$(mdsdevname $idx)
20019 do_facet mds${idx} \
20020 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20021 grep ${fid} && rc=$idx
20024 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
20025 error "Fail to rename foo0 to foo1"
20026 if [ $rc -eq 0 ]; then
20027 for idx in $(seq $MDSCOUNT); do
20028 dev=$(mdsdevname $idx)
20029 do_facet mds${idx} \
20030 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20031 grep ${fid} && rc=$idx
20035 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
20036 error "Fail to rename foo1 to foo2"
20037 if [ $rc -eq 0 ]; then
20038 for idx in $(seq $MDSCOUNT); do
20039 dev=$(mdsdevname $idx)
20040 do_facet mds${idx} \
20041 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20042 grep ${fid} && rc=$idx
20046 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
20048 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
20049 error "Fail to link to $DIR/$tdir/dir1/foo2"
20050 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
20051 error "Fail to rename foo2 to foo0"
20052 unlink $DIR/$tdir/dir1/foo0 ||
20053 error "Fail to unlink $DIR/$tdir/dir1/foo0"
20054 rm -rf $DIR/$tdir/dir0 ||
20055 error "Fail to rm $DIR/$tdir/dir0"
20057 for idx in $(seq $MDSCOUNT); do
20058 dev=$(mdsdevname $idx)
20062 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
20064 start mds${idx} $dev $MDS_MOUNT_OPTS ||
20065 error "mount mds$idx failed"
20066 df $MOUNT > /dev/null 2>&1
20068 # e2fsck should not return error
20070 error "e2fsck detected error on MDT${idx}: rc=$rc"
20073 run_test 804 "verify agent entry for remote entry"
20076 do_facet $SINGLEMDS zfs set quota=$old $fsset
20077 unlinkmany $DIR/$tdir/f- 1000000
20082 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
20083 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
20084 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
20085 skip "netfree not implemented before 0.7"
20086 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
20087 skip "Need MDS version at least 2.10.57"
20094 local pref="osd-zfs.lustre-MDT0000."
20096 # limit available space on MDS dataset to meet nospace issue
20097 # quickly. then ZFS 0.7.2 can use reserved space if asked
20098 # properly (using netfree flag in osd_declare_destroy()
20099 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
20100 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
20102 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
20103 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
20104 let "usedkb=usedkb-freekb"
20105 let "freekb=freekb/2"
20106 if let "freekb > 5000"; then
20109 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
20110 trap cleanup_805 EXIT
20112 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
20113 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
20114 rm -rf $DIR/$tdir || error "not able to remove"
20115 do_facet $SINGLEMDS zfs set quota=$old $fsset
20118 run_test 805 "ZFS can remove from full fs"
20124 local size=$($LFS getsom -s $file)
20125 local expect=$(stat -c %s $file)
20127 [[ $size == $expect ]] ||
20128 error "$file expected size: $expect, got: $size"
20130 local blocks=$($LFS getsom -b $file)
20131 expect=$(stat -c %b $file)
20132 [[ $blocks == $expect ]] ||
20133 error "$file expected blocks: $expect, got: $blocks"
20138 local size=$($LFS getsom -s $1)
20141 [[ $size == $expect ]] ||
20142 error "$file expected size: $expect, got: $size"
20146 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20147 skip "Need MDS version at least 2.11.52"
20151 touch $DIR/$tfile || error "touch $tfile failed"
20153 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
20154 save_lustre_params client "llite.*.xattr_cache" > $save
20155 lctl set_param llite.*.xattr_cache=0
20156 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
20158 # single-threaded write
20159 echo "Test SOM for single-threaded write"
20160 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
20161 error "write $tfile failed"
20162 check_lsom_size $DIR/$tfile $bs
20165 local size=$(($num * $bs))
20169 echo "Test SOM for single client multi-threaded($num) write"
20170 $TRUNCATE $DIR/$tfile 0
20171 for ((i = 0; i < $num; i++)); do
20172 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20174 offset=$((offset + $bs))
20176 for (( i=0; i < $num; i++ )); do
20179 check_lsom_size $DIR/$tfile $size
20181 $TRUNCATE $DIR/$tfile 0
20182 for ((i = 0; i < $num; i++)); do
20183 offset=$((offset - $bs))
20184 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20187 for (( i=0; i < $num; i++ )); do
20190 check_lsom_size $DIR/$tfile $size
20192 # multi-client wirtes
20193 num=$(get_node_count ${CLIENTS//,/ })
20194 size=$(($num * $bs))
20198 echo "Test SOM for multi-client ($num) writes"
20199 $TRUNCATE $DIR/$tfile 0
20200 for client in ${CLIENTS//,/ }; do
20201 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20204 offset=$((offset + $bs))
20206 for (( i=0; i < $num; i++ )); do
20209 check_lsom_size $DIR/$tfile $offset
20212 $TRUNCATE $DIR/$tfile 0
20213 for client in ${CLIENTS//,/ }; do
20214 offset=$((offset - $bs))
20215 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20219 for (( i=0; i < $num; i++ )); do
20222 check_lsom_size $DIR/$tfile $size
20225 echo "Test SOM for truncate"
20226 $TRUNCATE $DIR/$tfile 1048576
20227 check_lsom_size $DIR/$tfile 1048576
20228 $TRUNCATE $DIR/$tfile 1234
20229 check_lsom_size $DIR/$tfile 1234
20231 # verify SOM blocks count
20232 echo "Verify SOM block count"
20233 $TRUNCATE $DIR/$tfile 0
20234 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
20235 error "failed to write file $tfile"
20236 check_lsom_data $DIR/$tfile
20238 run_test 806 "Verify Lazy Size on MDS"
20241 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
20242 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20243 skip "Need MDS version at least 2.11.52"
20245 # Registration step
20246 changelog_register || error "changelog_register failed"
20247 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
20248 changelog_users $SINGLEMDS | grep -q $cl_user ||
20249 error "User $cl_user not found in changelog_users"
20251 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
20252 save_lustre_params client "llite.*.xattr_cache" > $save
20253 lctl set_param llite.*.xattr_cache=0
20254 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
20256 rm -rf $DIR/$tdir || error "rm $tdir failed"
20257 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
20258 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
20259 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
20260 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
20261 error "truncate $tdir/trunc failed"
20264 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
20265 error "write $tfile failed"
20267 # multi-client wirtes
20268 local num=$(get_node_count ${CLIENTS//,/ })
20272 echo "Test SOM for multi-client ($num) writes"
20273 touch $DIR/$tfile || error "touch $tfile failed"
20274 $TRUNCATE $DIR/$tfile 0
20275 for client in ${CLIENTS//,/ }; do
20276 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20279 offset=$((offset + $bs))
20281 for (( i=0; i < $num; i++ )); do
20286 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
20287 check_lsom_data $DIR/$tdir/trunc
20288 check_lsom_data $DIR/$tdir/single_dd
20289 check_lsom_data $DIR/$tfile
20292 # Deregistration step
20293 changelog_deregister || error "changelog_deregister failed"
20295 run_test 807 "verify LSOM syncing tool"
20297 check_som_nologged()
20299 local lines=$($LFS changelog $FSNAME-MDT0000 |
20300 grep 'x=trusted.som' | wc -l)
20301 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
20305 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
20306 skip "Need MDS version at least 2.11.55"
20308 # Registration step
20309 changelog_register || error "changelog_register failed"
20311 touch $DIR/$tfile || error "touch $tfile failed"
20314 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
20315 error "write $tfile failed"
20318 $TRUNCATE $DIR/$tfile 1234
20321 $TRUNCATE $DIR/$tfile 1048576
20324 # Deregistration step
20325 changelog_deregister || error "changelog_deregister failed"
20327 run_test 808 "Check trusted.som xattr not logged in Changelogs"
20332 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
20336 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20337 skip "Need MDS version at least 2.11.56"
20339 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
20340 error "failed to create DoM-only file $DIR/$tfile"
20341 touch $DIR/$tfile || error "touch $tfile failed"
20342 check_som_nodata $DIR/$tfile
20344 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
20345 error "write $tfile failed"
20346 check_som_nodata $DIR/$tfile
20348 $TRUNCATE $DIR/$tfile 1234
20349 check_som_nodata $DIR/$tfile
20351 $TRUNCATE $DIR/$tfile 4097
20352 check_som_nodata $DIR/$file
20354 run_test 809 "Verify no SOM xattr store for DoM-only files"
20360 # t10 seem to dislike partial pages
20361 lctl set_param osc.*.checksum_type=adler
20362 lctl set_param fail_loc=0x411
20363 dd if=/dev/urandom of=$DIR/$tfile bs=10240 count=2
20364 ORIG=$(md5sum $DIR/$tfile)
20365 lctl set_param ldlm.namespaces.*osc*.lru_size=clear
20366 CSUM=$(md5sum $DIR/$tfile)
20367 set_checksum_type adler
20368 if [ "$ORIG" != "$CSUM" ]; then
20369 error "$ORIG != $CSUM"
20372 run_test 810 "partial page writes on ZFS (LU-11663)"
20375 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
20376 skip "Need MDS version at least 2.11.56"
20378 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
20379 do_facet mds1 $LCTL set_param fail_loc=0x165
20380 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
20383 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
20386 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) -eq 0 ]] ||
20387 error "MDD orphan cleanup thread not quit"
20389 run_test 811 "orphan name stub can be cleaned up in startup"
20392 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
20393 skip "OST < 2.12.51 doesn't support this fail_loc"
20395 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20396 # ensure ost1 is connected
20397 stat $DIR/$tfile >/dev/null || error "can't stat"
20398 wait_osc_import_state client ost1 FULL
20399 # no locks, no reqs to let the connection idle
20400 cancel_lru_locks osc
20402 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
20403 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
20404 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
20405 wait_osc_import_state client ost1 CONNECTING
20406 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
20408 stat $DIR/$tfile >/dev/null || error "can't stat file"
20410 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
20413 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
20414 [ -z "$file_heat_sav" ] && skip "no file heat support"
20425 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
20426 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
20428 $LCTL set_param -n llite.*.file_heat=1
20429 echo "Turn on file heat"
20430 echo "Period second: $period_second, Decay percentage: $decay_pct"
20432 echo "QQQQ" > $DIR/$tfile
20433 echo "QQQQ" > $DIR/$tfile
20434 echo "QQQQ" > $DIR/$tfile
20435 cat $DIR/$tfile > /dev/null
20436 cat $DIR/$tfile > /dev/null
20437 cat $DIR/$tfile > /dev/null
20438 cat $DIR/$tfile > /dev/null
20440 local out=$($LFS heat_get $DIR/$tfile)
20442 $LFS heat_get $DIR/$tfile
20443 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20444 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20445 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20446 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20448 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
20449 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
20450 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
20451 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
20453 sleep $((period_second + 3))
20454 echo "Sleep $((period_second + 3)) seconds..."
20455 # The recursion formula to calculate the heat of the file f is as
20457 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
20458 # Where Hi is the heat value in the period between time points i*I and
20459 # (i+1)*I; Ci is the access count in the period; the symbol P refers
20460 # to the weight of Ci.
20461 out=$($LFS heat_get $DIR/$tfile)
20462 $LFS heat_get $DIR/$tfile
20463 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20464 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20465 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20466 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20468 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
20469 error "read sample ($readsample) is wrong"
20470 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
20471 error "write sample ($writesample) is wrong"
20472 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
20473 error "read bytes ($readbyte) is wrong"
20474 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
20475 error "write bytes ($writebyte) is wrong"
20477 echo "QQQQ" > $DIR/$tfile
20478 echo "QQQQ" > $DIR/$tfile
20479 echo "QQQQ" > $DIR/$tfile
20480 cat $DIR/$tfile > /dev/null
20481 cat $DIR/$tfile > /dev/null
20482 cat $DIR/$tfile > /dev/null
20483 cat $DIR/$tfile > /dev/null
20485 sleep $((period_second + 3))
20486 echo "Sleep $((period_second + 3)) seconds..."
20488 out=$($LFS heat_get $DIR/$tfile)
20489 $LFS heat_get $DIR/$tfile
20490 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20491 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20492 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20493 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20495 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
20496 4 * $decay_pct) / 100") -eq 1 ] ||
20497 error "read sample ($readsample1) is wrong"
20498 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
20499 3 * $decay_pct) / 100") -eq 1 ] ||
20500 error "write sample ($writesample1) is wrong"
20501 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
20502 20 * $decay_pct) / 100") -eq 1 ] ||
20503 error "read bytes ($readbyte1) is wrong"
20504 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
20505 15 * $decay_pct) / 100") -eq 1 ] ||
20506 error "write bytes ($writebyte1) is wrong"
20508 echo "Turn off file heat for the file $DIR/$tfile"
20509 $LFS heat_set -o $DIR/$tfile
20511 echo "QQQQ" > $DIR/$tfile
20512 echo "QQQQ" > $DIR/$tfile
20513 echo "QQQQ" > $DIR/$tfile
20514 cat $DIR/$tfile > /dev/null
20515 cat $DIR/$tfile > /dev/null
20516 cat $DIR/$tfile > /dev/null
20517 cat $DIR/$tfile > /dev/null
20519 out=$($LFS heat_get $DIR/$tfile)
20520 $LFS heat_get $DIR/$tfile
20521 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20522 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20523 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20524 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20526 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
20527 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
20528 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
20529 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
20531 echo "Trun on file heat for the file $DIR/$tfile"
20532 $LFS heat_set -O $DIR/$tfile
20534 echo "QQQQ" > $DIR/$tfile
20535 echo "QQQQ" > $DIR/$tfile
20536 echo "QQQQ" > $DIR/$tfile
20537 cat $DIR/$tfile > /dev/null
20538 cat $DIR/$tfile > /dev/null
20539 cat $DIR/$tfile > /dev/null
20540 cat $DIR/$tfile > /dev/null
20542 out=$($LFS heat_get $DIR/$tfile)
20543 $LFS heat_get $DIR/$tfile
20544 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20545 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20546 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20547 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20549 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
20550 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
20551 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
20552 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
20554 $LFS heat_set -c $DIR/$tfile
20555 $LCTL set_param -n llite.*.file_heat=0
20556 echo "Turn off file heat support for the Lustre filesystem"
20558 echo "QQQQ" > $DIR/$tfile
20559 echo "QQQQ" > $DIR/$tfile
20560 echo "QQQQ" > $DIR/$tfile
20561 cat $DIR/$tfile > /dev/null
20562 cat $DIR/$tfile > /dev/null
20563 cat $DIR/$tfile > /dev/null
20564 cat $DIR/$tfile > /dev/null
20566 out=$($LFS heat_get $DIR/$tfile)
20567 $LFS heat_get $DIR/$tfile
20568 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20569 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20570 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20571 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20573 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
20574 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
20575 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
20576 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
20578 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
20581 run_test 813 "File heat verfication"
20584 # tests that do cleanup/setup should be run at the end
20588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20591 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
20592 $LCTL set_param fail_loc=0x903
20594 cancel_lru_locks MGC
20596 FAIL_ON_ERROR=true cleanup
20597 FAIL_ON_ERROR=true setup
20599 run_test 900 "umount should not race with any mgc requeue thread"
20602 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
20603 check_and_cleanup_lustre
20604 if [ "$I_MOUNTED" != "yes" ]; then
20605 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true