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" ] || [ -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 ] || [ $num_uniq -ne $nrfiles ] ||
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"
1288 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1289 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1290 skip "Need MDS version at least 2.12.51"
1294 for index in 0 1; do
1295 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1296 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1299 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1301 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1302 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1304 local mdts=$(comma_list $(mdts_nodes))
1306 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1307 stack_trap "do_nodes $mdts $LCTL \
1308 set_param mdt.*.enable_remote_rename=1" EXIT
1310 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1312 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1313 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1315 run_test 24z "cross-MDT rename is done as cp"
1317 test_24A() { # LU-3182
1321 test_mkdir $DIR/$tdir
1322 trap simple_cleanup_common EXIT
1323 createmany -m $DIR/$tdir/$tfile $NFILES
1324 local t=$(ls $DIR/$tdir | wc -l)
1325 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1326 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1327 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1328 [ $v -ne $((NFILES + 2)) ] ; then
1329 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1332 simple_cleanup_common || error "Can not delete directories"
1334 run_test 24A "readdir() returns correct number of entries."
1336 test_24B() { # LU-4805
1337 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1341 test_mkdir $DIR/$tdir
1342 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1343 error "create striped dir failed"
1345 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1346 [ $count -eq 2 ] || error "Expected 2, got $count"
1348 touch $DIR/$tdir/striped_dir/a
1350 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1351 [ $count -eq 3 ] || error "Expected 3, got $count"
1353 touch $DIR/$tdir/striped_dir/.f
1355 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1356 [ $count -eq 4 ] || error "Expected 4, got $count"
1358 rm -rf $DIR/$tdir || error "Can not delete directories"
1360 run_test 24B "readdir for striped dir return correct number of entries"
1363 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1369 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1370 error "create striped dir failed"
1372 cd $DIR/$tdir/d0/striped_dir
1374 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1375 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1376 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1378 [ "$d0_ino" = "$parent_ino" ] ||
1379 error ".. wrong, expect $d0_ino, get $parent_ino"
1381 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1382 error "mv striped dir failed"
1384 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1386 [ "$d1_ino" = "$parent_ino" ] ||
1387 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1389 run_test 24C "check .. in striped dir"
1392 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1396 mkdir $DIR/$tdir/src_dir
1397 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1398 error "create remote source failed"
1400 touch $DIR/$tdir/src_dir/src_child/a
1402 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1403 error "create remote target dir failed"
1405 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1406 error "create remote target child failed"
1408 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1409 error "rename dir cross MDT failed!"
1413 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1414 error "src_child still exists after rename"
1416 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1417 error "missing file(a) after rename"
1419 rm -rf $DIR/$tdir || error "Can not delete directories"
1421 run_test 24E "cross MDT rename/link"
1424 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1427 [ "$SLOW" = "no" ] && repeats=100
1431 echo "$repeats repeats"
1432 for ((i = 0; i < repeats; i++)); do
1433 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1434 touch $DIR/$tdir/test/a || error "touch fails"
1435 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1436 rm -rf $DIR/$tdir/test || error "rmdir fails"
1441 run_test 24F "hash order vs readdir (LU-11330)"
1444 echo '== symlink sanity ============================================='
1448 touch $DIR/s25/foo ||
1449 error "File creation in symlinked directory failed"
1451 run_test 25a "create file in symlinked directory ==============="
1454 [ ! -d $DIR/d25 ] && test_25a
1455 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1457 run_test 25b "lookup file in symlinked directory ==============="
1461 test_mkdir $DIR/d26/d26-2
1462 ln -s d26/d26-2 $DIR/s26
1463 touch $DIR/s26/foo || error "File creation failed"
1465 run_test 26a "multiple component symlink ======================="
1468 test_mkdir -p $DIR/$tdir/d26-2
1469 ln -s $tdir/d26-2/foo $DIR/s26-2
1470 touch $DIR/s26-2 || error "File creation failed"
1472 run_test 26b "multiple component symlink at end of lookup ======"
1475 test_mkdir $DIR/d26.2
1476 touch $DIR/d26.2/foo
1477 ln -s d26.2 $DIR/s26.2-1
1478 ln -s s26.2-1 $DIR/s26.2-2
1479 ln -s s26.2-2 $DIR/s26.2-3
1480 chmod 0666 $DIR/s26.2-3/foo
1482 run_test 26c "chain of symlinks"
1484 # recursive symlinks (bug 439)
1486 ln -s d26-3/foo $DIR/d26-3
1488 run_test 26d "create multiple component recursive symlink"
1491 [ ! -h $DIR/d26-3 ] && test_26d
1494 run_test 26e "unlink multiple component recursive symlink"
1496 # recursive symlinks (bug 7022)
1498 test_mkdir $DIR/$tdir
1499 test_mkdir $DIR/$tdir/$tfile
1500 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1501 test_mkdir -p lndir/bar1
1502 test_mkdir $DIR/$tdir/$tfile/$tfile
1503 cd $tfile || error "cd $tfile failed"
1504 ln -s .. dotdot || error "ln dotdot failed"
1505 ln -s dotdot/lndir lndir || error "ln lndir failed"
1506 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1507 output=`ls $tfile/$tfile/lndir/bar1`
1508 [ "$output" = bar1 ] && error "unexpected output"
1509 rm -r $tfile || error "rm $tfile failed"
1510 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1512 run_test 26f "rm -r of a directory which has recursive symlink"
1515 test_mkdir $DIR/$tdir
1516 $LFS getstripe $DIR/$tdir
1517 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1518 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1519 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1521 run_test 27a "one stripe file"
1524 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1526 test_mkdir $DIR/$tdir
1527 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1528 $LFS getstripe -c $DIR/$tdir/$tfile
1529 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1530 error "two-stripe file doesn't have two stripes"
1532 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1534 run_test 27b "create and write to two stripe file"
1537 test_mkdir $DIR/$tdir
1538 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1539 error "setstripe failed"
1540 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1541 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1543 run_test 27d "create file with default settings"
1546 # LU-5839 adds check for existed layout before setting it
1547 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1548 skip "Need MDS version at least 2.7.56"
1550 test_mkdir $DIR/$tdir
1551 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1552 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1553 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1555 run_test 27e "setstripe existing file (should return error)"
1558 test_mkdir $DIR/$tdir
1559 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1560 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1561 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1562 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1563 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1564 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1566 run_test 27f "setstripe with bad stripe size (should return error)"
1569 test_mkdir $DIR/$tdir
1570 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1571 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1572 error "$DIR/$tdir/$tfile has object"
1574 run_test 27g "$LFS getstripe with no objects"
1577 test_mkdir $DIR/$tdir
1578 touch $DIR/$tdir/$tfile || error "touch failed"
1579 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1580 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1582 (( rc == 2 )) || error "getstripe did not return ENOENT"
1584 run_test 27ga "$LFS getstripe with missing file (should return error)"
1587 test_mkdir $DIR/$tdir
1588 touch $DIR/$tdir/$tfile || error "touch failed"
1589 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1590 error "missing objects"
1592 run_test 27i "$LFS getstripe with some objects"
1595 test_mkdir $DIR/$tdir
1596 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1597 error "setstripe failed" || true
1599 run_test 27j "setstripe with bad stripe offset (should return error)"
1601 test_27k() { # bug 2844
1602 test_mkdir $DIR/$tdir
1603 local file=$DIR/$tdir/$tfile
1604 local ll_max_blksize=$((4 * 1024 * 1024))
1605 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1606 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1607 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1608 dd if=/dev/zero of=$file bs=4k count=1
1609 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1610 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1612 run_test 27k "limit i_blksize for broken user apps"
1615 mcreate $DIR/$tfile || error "creating file"
1616 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1617 error "setstripe should have failed" || true
1619 run_test 27l "check setstripe permissions (should return error)"
1622 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1624 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1625 skip_env "multiple clients -- skipping"
1627 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1629 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1630 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1632 trap simple_cleanup_common EXIT
1633 test_mkdir $DIR/$tdir
1634 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1635 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1636 error "dd should fill OST0"
1638 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1640 [ $i -gt 256 ] && break
1643 touch $DIR/$tdir/$tfile.$i
1644 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1645 awk '{print $1}'| grep -w "0") ] &&
1646 error "OST0 was full but new created file still use it"
1648 touch $DIR/$tdir/$tfile.$i
1649 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1650 awk '{print $1}'| grep -w "0") ] &&
1651 error "OST0 was full but new created file still use it"
1652 simple_cleanup_common
1654 run_test 27m "create file while OST0 was full"
1657 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1658 awk '{ print $1 * 2; exit; }')
1662 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1663 # if the OST isn't full anymore.
1665 local OSTIDX=${1:-""}
1667 local list=$(comma_list $(osts_nodes))
1668 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1670 do_nodes $list lctl set_param fail_loc=0
1671 sync # initiate all OST_DESTROYs from MDS to OST
1675 exhaust_precreations() {
1678 local FAILIDX=${3:-$OSTIDX}
1679 local ofacet=ost$((OSTIDX + 1))
1681 test_mkdir -p -c1 $DIR/$tdir
1682 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1683 local mfacet=mds$((mdtidx + 1))
1684 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1686 local OST=$(ostname_from_index $OSTIDX)
1689 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1690 local last_id=$(do_facet $mfacet lctl get_param -n \
1691 osc.$mdtosc_proc1.prealloc_last_id)
1692 local next_id=$(do_facet $mfacet lctl get_param -n \
1693 osc.$mdtosc_proc1.prealloc_next_id)
1695 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1696 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1698 test_mkdir -p $DIR/$tdir/${OST}
1699 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1700 #define OBD_FAIL_OST_ENOSPC 0x215
1701 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1702 echo "Creating to objid $last_id on ost $OST..."
1703 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1704 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1705 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1709 exhaust_all_precreations() {
1711 for (( i=0; i < OSTCOUNT; i++ )) ; do
1712 exhaust_precreations $i $1 -1
1717 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1718 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1719 remote_mds_nodsh && skip "remote MDS with nodsh"
1720 remote_ost_nodsh && skip "remote OST with nodsh"
1723 rm -f $DIR/$tdir/$tfile
1724 exhaust_precreations 0 0x80000215
1725 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1726 touch $DIR/$tdir/$tfile || error "touch failed"
1727 $LFS getstripe $DIR/$tdir/$tfile
1730 run_test 27n "create file with some full OSTs"
1733 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1735 remote_mds_nodsh && skip "remote MDS with nodsh"
1736 remote_ost_nodsh && skip "remote OST with nodsh"
1739 rm -f $DIR/$tdir/$tfile
1740 exhaust_all_precreations 0x215
1742 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1747 run_test 27o "create file with all full OSTs (should error)"
1750 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1751 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1752 remote_mds_nodsh && skip "remote MDS with nodsh"
1753 remote_ost_nodsh && skip "remote OST with nodsh"
1756 rm -f $DIR/$tdir/$tfile
1757 test_mkdir $DIR/$tdir
1759 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1760 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1761 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1763 exhaust_precreations 0 0x80000215
1764 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1765 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1766 $LFS getstripe $DIR/$tdir/$tfile
1770 run_test 27p "append to a truncated file with some full OSTs"
1773 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1774 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1775 remote_mds_nodsh && skip "remote MDS with nodsh"
1776 remote_ost_nodsh && skip "remote OST with nodsh"
1779 rm -f $DIR/$tdir/$tfile
1781 test_mkdir $DIR/$tdir
1782 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1783 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1784 error "truncate $DIR/$tdir/$tfile failed"
1785 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1787 exhaust_all_precreations 0x215
1789 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1790 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1794 run_test 27q "append to truncated file with all OSTs full (should error)"
1797 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1798 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1799 remote_mds_nodsh && skip "remote MDS with nodsh"
1800 remote_ost_nodsh && skip "remote OST with nodsh"
1803 rm -f $DIR/$tdir/$tfile
1804 exhaust_precreations 0 0x80000215
1806 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1810 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1812 test_27s() { # bug 10725
1813 test_mkdir $DIR/$tdir
1814 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1815 local stripe_count=0
1816 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1817 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1818 error "stripe width >= 2^32 succeeded" || true
1821 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1823 test_27t() { # bug 10864
1828 $WLFS getstripe $tfile
1831 run_test 27t "check that utils parse path correctly"
1833 test_27u() { # bug 4900
1834 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1835 remote_mds_nodsh && skip "remote MDS with nodsh"
1838 local list=$(comma_list $(mdts_nodes))
1840 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1841 do_nodes $list $LCTL set_param fail_loc=0x139
1842 test_mkdir -p $DIR/$tdir
1843 trap simple_cleanup_common EXIT
1844 createmany -o $DIR/$tdir/t- 1000
1845 do_nodes $list $LCTL set_param fail_loc=0
1847 TLOG=$TMP/$tfile.getstripe
1848 $LFS getstripe $DIR/$tdir > $TLOG
1849 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1850 unlinkmany $DIR/$tdir/t- 1000
1852 [[ $OBJS -gt 0 ]] &&
1853 error "$OBJS objects created on OST-0. See $TLOG" ||
1856 run_test 27u "skip object creation on OSC w/o objects"
1858 test_27v() { # bug 4900
1859 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1860 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1861 remote_mds_nodsh && skip "remote MDS with nodsh"
1862 remote_ost_nodsh && skip "remote OST with nodsh"
1864 exhaust_all_precreations 0x215
1867 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1869 touch $DIR/$tdir/$tfile
1870 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1872 for (( i=1; i < OSTCOUNT; i++ )); do
1873 do_facet ost$i lctl set_param fail_loc=0x705
1875 local START=`date +%s`
1876 createmany -o $DIR/$tdir/$tfile 32
1878 local FINISH=`date +%s`
1879 local TIMEOUT=`lctl get_param -n timeout`
1880 local PROCESS=$((FINISH - START))
1881 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1882 error "$FINISH - $START >= $TIMEOUT / 2"
1883 sleep $((TIMEOUT / 2 - PROCESS))
1886 run_test 27v "skip object creation on slow OST"
1888 test_27w() { # bug 10997
1889 test_mkdir $DIR/$tdir
1890 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1891 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1892 error "stripe size $size != 65536" || true
1893 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1894 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1896 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1899 [[ $OSTCOUNT -lt 2 ]] &&
1900 skip_env "skipping multiple stripe count/offset test"
1902 test_mkdir $DIR/$tdir
1903 for i in $(seq 1 $OSTCOUNT); do
1905 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1906 error "setstripe -c $i -i $offset failed"
1907 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1908 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1909 [ $count -ne $i ] && error "stripe count $count != $i" || true
1910 [ $index -ne $offset ] &&
1911 error "stripe offset $index != $offset" || true
1914 run_test 27wa "check $LFS setstripe -c -i options"
1917 remote_ost_nodsh && skip "remote OST with nodsh"
1918 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1921 OFFSET=$(($OSTCOUNT - 1))
1923 local OST=$(ostname_from_index $OSTIDX)
1925 test_mkdir $DIR/$tdir
1926 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1927 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1929 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1930 for i in $(seq 0 $OFFSET); do
1931 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1932 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1933 error "OST0 was degraded but new created file still use it"
1935 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1937 run_test 27x "create files while OST0 is degraded"
1940 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1941 remote_mds_nodsh && skip "remote MDS with nodsh"
1942 remote_ost_nodsh && skip "remote OST with nodsh"
1943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1945 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1946 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1947 osc.$mdtosc.prealloc_last_id)
1948 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1949 osc.$mdtosc.prealloc_next_id)
1950 local fcount=$((last_id - next_id))
1951 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1952 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1954 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1955 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1956 local OST_DEACTIVE_IDX=-1
1961 for OSC in $MDS_OSCS; do
1962 OST=$(osc_to_ost $OSC)
1963 OSTIDX=$(index_from_ostuuid $OST)
1964 if [ $OST_DEACTIVE_IDX == -1 ]; then
1965 OST_DEACTIVE_IDX=$OSTIDX
1967 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1968 echo $OSC "is Deactivated:"
1969 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1973 OSTIDX=$(index_from_ostuuid $OST)
1974 test_mkdir $DIR/$tdir
1975 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1977 for OSC in $MDS_OSCS; do
1978 OST=$(osc_to_ost $OSC)
1979 OSTIDX=$(index_from_ostuuid $OST)
1980 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1981 echo $OST "is degraded:"
1982 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1983 obdfilter.$OST.degraded=1
1988 createmany -o $DIR/$tdir/$tfile $fcount
1990 for OSC in $MDS_OSCS; do
1991 OST=$(osc_to_ost $OSC)
1992 OSTIDX=$(index_from_ostuuid $OST)
1993 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1994 echo $OST "is recovered from degraded:"
1995 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1996 obdfilter.$OST.degraded=0
1998 do_facet $SINGLEMDS lctl --device %$OSC activate
2002 # all osp devices get activated, hence -1 stripe count restored
2003 local stripe_count=0
2005 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2006 # devices get activated.
2008 $LFS setstripe -c -1 $DIR/$tfile
2009 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2011 [ $stripe_count -ne $OSTCOUNT ] &&
2012 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2015 run_test 27y "create files while OST0 is degraded and the rest inactive"
2021 lmm_count=$($LFS getstripe -c $1)
2022 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2023 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2025 local old_ifs="$IFS"
2027 fid=($($LFS path2fid $1))
2030 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2031 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2033 # compare lmm_seq and lu_fid->f_seq
2034 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2035 # compare lmm_object_id and lu_fid->oid
2036 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2038 # check the trusted.fid attribute of the OST objects of the file
2039 local have_obdidx=false
2041 $LFS getstripe $1 | while read obdidx oid hex seq; do
2042 # skip lines up to and including "obdidx"
2043 [ -z "$obdidx" ] && break
2044 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2045 $have_obdidx || continue
2047 local ost=$((obdidx + 1))
2048 local dev=$(ostdevname $ost)
2051 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2053 seq=$(echo $seq | sed -e "s/^0x//g")
2054 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2055 oid_hex=$(echo $oid)
2057 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2059 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2063 # Don't unmount/remount the OSTs if we don't need to do that.
2064 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2065 # update too, until that use mount/ll_decode_filter_fid/mount.
2066 # Re-enable when debugfs will understand new filter_fid.
2068 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2069 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2070 $dev 2>/dev/null" | grep "parent=")
2072 if [ -z "$ff" ]; then
2074 mount_fstype ost$ost
2075 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2076 $(facet_mntpt ost$ost)/$obj_file)
2077 unmount_fstype ost$ost
2078 start ost$ost $dev $OST_MOUNT_OPTS
2082 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2084 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2086 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2087 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2089 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2090 # stripe_size=1048576 component_id=1 component_start=0 \
2091 # component_end=33554432
2092 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2093 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2094 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2096 if grep -q 'stripe=' <<<$ff; then
2097 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2099 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2100 # into f_ver in this case. See comment on ff_parent.
2101 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2104 # compare lmm_seq and filter_fid->ff_parent.f_seq
2105 [ $ff_pseq = $lmm_seq ] ||
2106 error "FF parent SEQ $ff_pseq != $lmm_seq"
2107 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2108 [ $ff_poid = $lmm_oid ] ||
2109 error "FF parent OID $ff_poid != $lmm_oid"
2110 (($ff_pstripe == $stripe_nr)) ||
2111 error "FF stripe $ff_pstripe != $stripe_nr"
2113 stripe_nr=$((stripe_nr + 1))
2114 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2116 if grep -q 'stripe_count=' <<<$ff; then
2117 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2118 -e 's/ .*//' <<<$ff)
2119 [ $lmm_count = $ff_scnt ] ||
2120 error "FF stripe count $lmm_count != $ff_scnt"
2126 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2127 remote_ost_nodsh && skip "remote OST with nodsh"
2129 test_mkdir $DIR/$tdir
2130 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2131 { error "setstripe -c -1 failed"; return 1; }
2132 # We need to send a write to every object to get parent FID info set.
2133 # This _should_ also work for setattr, but does not currently.
2134 # touch $DIR/$tdir/$tfile-1 ||
2135 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2136 { error "dd $tfile-1 failed"; return 2; }
2137 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2138 { error "setstripe -c -1 failed"; return 3; }
2139 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2140 { error "dd $tfile-2 failed"; return 4; }
2142 # make sure write RPCs have been sent to OSTs
2145 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2146 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2148 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2150 test_27A() { # b=19102
2151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2153 save_layout_restore_at_exit $MOUNT
2154 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2155 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2156 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2157 local default_size=$($LFS getstripe -S $MOUNT)
2158 local default_offset=$($LFS getstripe -i $MOUNT)
2159 local dsize=$(do_facet $SINGLEMDS \
2160 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2161 [ $default_size -eq $dsize ] ||
2162 error "stripe size $default_size != $dsize"
2163 [ $default_offset -eq -1 ] ||
2164 error "stripe offset $default_offset != -1"
2166 run_test 27A "check filesystem-wide default LOV EA values"
2168 test_27B() { # LU-2523
2169 test_mkdir $DIR/$tdir
2170 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2172 # open f1 with O_LOV_DELAY_CREATE
2174 # call setstripe ioctl on open file descriptor for f1
2176 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2180 # open f1 with O_LOV_DELAY_CREATE
2182 # call setstripe ioctl on open file descriptor for f1
2184 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2186 # Allow multiop to fail in imitation of NFS's busted semantics.
2189 run_test 27B "call setstripe on open unlinked file/rename victim"
2191 test_27C() { #LU-2871
2192 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2200 test_mkdir $DIR/$tdir
2202 for i in $(seq 0 $((OSTCOUNT - 1))); do
2203 # set stripe across all OSTs starting from OST$i
2204 $LFS setstripe -i $i -c -1 $tfile$i
2205 # get striping information
2206 ost_idx=($($LFS getstripe $tfile$i |
2207 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2211 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2212 error "${#ost_idx[@]} != $OSTCOUNT"
2214 for index in $(seq 0 $((OSTCOUNT - 1))); do
2216 for j in $(echo ${ost_idx[@]}); do
2217 if [ $index -eq $j ]; then
2223 error "Can not find $index in ${ost_idx[@]}"
2227 run_test 27C "check full striping across all OSTs"
2230 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2231 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2232 remote_mds_nodsh && skip "remote MDS with nodsh"
2234 local POOL=${POOL:-testpool}
2236 local last_ost=$(($OSTCOUNT - 1))
2238 local ost_list=$(seq $first_ost $ost_step $last_ost)
2239 local ost_range="$first_ost $last_ost $ost_step"
2241 if ! combined_mgs_mds ; then
2245 test_mkdir $DIR/$tdir
2246 pool_add $POOL || error "pool_add failed"
2247 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2250 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2252 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2253 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2254 skip27D+=" -s 30,31"
2255 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2256 error "llapi_layout_test failed"
2258 destroy_test_pools || error "destroy test pools failed"
2260 if ! combined_mgs_mds ; then
2264 run_test 27D "validate llapi_layout API"
2266 # Verify that default_easize is increased from its initial value after
2267 # accessing a widely striped file.
2269 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2270 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2271 skip "client does not have LU-3338 fix"
2273 # 72 bytes is the minimum space required to store striping
2274 # information for a file striped across one OST:
2275 # (sizeof(struct lov_user_md_v3) +
2276 # sizeof(struct lov_user_ost_data_v1))
2278 $LCTL set_param -n llite.*.default_easize $min_easize ||
2279 error "lctl set_param failed"
2280 local easize=$($LCTL get_param -n llite.*.default_easize)
2282 [ $easize -eq $min_easize ] ||
2283 error "failed to set default_easize"
2285 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2286 error "setstripe failed"
2290 easize=$($LCTL get_param -n llite.*.default_easize)
2292 [ $easize -gt $min_easize ] ||
2293 error "default_easize not updated"
2295 run_test 27E "check that default extended attribute size properly increases"
2297 test_27F() { # LU-5346/LU-7975
2298 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2299 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2300 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2301 skip "Need MDS version at least 2.8.51"
2302 remote_ost_nodsh && skip "remote OST with nodsh"
2304 test_mkdir $DIR/$tdir
2306 $LFS setstripe -c 2 $DIR/$tdir
2308 # stop all OSTs to reproduce situation for LU-7975 ticket
2309 for num in $(seq $OSTCOUNT); do
2313 # open/create f0 with O_LOV_DELAY_CREATE
2314 # truncate f0 to a non-0 size
2316 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2318 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2319 # open/write it again to force delayed layout creation
2320 cat /etc/hosts > $DIR/$tdir/f0 &
2324 for num in $(seq $OSTCOUNT); do
2325 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2326 error "ost$num failed to start"
2329 wait $catpid || error "cat failed"
2331 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2332 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2333 error "wrong stripecount"
2336 run_test 27F "Client resend delayed layout creation with non-zero size"
2338 test_27G() { #LU-10629
2339 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2340 skip "Need MDS version at least 2.11.51"
2341 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2342 remote_mds_nodsh && skip "remote MDS with nodsh"
2343 local POOL=${POOL:-testpool}
2344 local ostrange="0 0 1"
2346 test_mkdir $DIR/$tdir
2347 pool_add $POOL || error "pool_add failed"
2348 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2349 $LFS setstripe -p $POOL $DIR/$tdir
2351 local pool=$($LFS getstripe -p $DIR/$tdir)
2353 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2355 $LFS setstripe -d $DIR/$tdir
2357 pool=$($LFS getstripe -p $DIR/$tdir)
2361 [ -z "$pool" ] || error "'$pool' is not empty"
2363 run_test 27G "Clear OST pool from stripe"
2366 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2367 skip "Need MDS version newer than 2.11.54"
2368 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2369 test_mkdir $DIR/$tdir
2370 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2371 touch $DIR/$tdir/$tfile
2372 $LFS getstripe -c $DIR/$tdir/$tfile
2373 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2374 error "two-stripe file doesn't have two stripes"
2376 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2377 $LFS getstripe -y $DIR/$tdir/$tfile
2378 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2379 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2380 error "expected l_ost_idx: [02]$ not matched"
2382 # make sure ost list has been cleared
2383 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2384 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2385 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2387 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2389 run_test 27H "Set specific OSTs stripe"
2392 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2393 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2394 local pool=$TESTNAME
2395 local ostrange="1 1 1"
2397 save_layout_restore_at_exit $MOUNT
2398 $LFS setstripe -c 2 -i 0 $MOUNT
2399 pool_add $pool || error "pool_add failed"
2400 pool_add_targets $pool $ostrange || "pool_add_targets failed"
2401 test_mkdir $DIR/$tdir
2402 $LFS setstripe -p $pool $DIR/$tdir
2403 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2404 $LFS getstripe $DIR/$tdir/$tfile
2406 run_test 27I "check that root dir striping does not break parent dir one"
2409 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
2410 skip "Need MDS version newer than 2.12.51"
2412 test_mkdir $DIR/$tdir
2413 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2414 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2416 # create foreign file (raw way)
2417 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2418 -t 1 -F 0xda08 || error "create_foreign_file failed"
2420 # verify foreign file (raw way)
2421 parse_foreign_file -f $DIR/$tdir/$tfile |
2422 grep "lov_foreign_magic: 0x0BD70BD0" ||
2423 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2424 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2425 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2426 parse_foreign_file -f $DIR/$tdir/$tfile |
2427 grep "lov_foreign_size: 73" ||
2428 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2429 parse_foreign_file -f $DIR/$tdir/$tfile |
2430 grep "lov_foreign_type: 1" ||
2431 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2432 parse_foreign_file -f $DIR/$tdir/$tfile |
2433 grep "lov_foreign_flags: 0x0000DA08" ||
2434 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2435 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2436 grep "lov_foreign_value: 0x" |
2437 sed -e 's/lov_foreign_value: 0x//')
2438 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2439 [[ $lov = ${lov2// /} ]] ||
2440 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2442 # create foreign file (lfs + API)
2443 $LFS setstripe --foreign=daos --flags 0xda08 \
2444 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2445 error "$DIR/$tdir/${tfile}2: create failed"
2447 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2448 grep "lfm_magic:.*0x0BD70BD0" ||
2449 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2450 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2451 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2452 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2453 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
2454 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2455 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2456 grep "lfm_flags:.*0x0000DA08" ||
2457 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2458 $LFS getstripe $DIR/$tdir/${tfile}2 |
2459 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2460 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2462 # modify striping should fail
2463 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2464 error "$DIR/$tdir/$tfile: setstripe should fail"
2465 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2466 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2469 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2470 cat $DIR/$tdir/${tfile}2 &&
2471 error "$DIR/$tdir/${tfile}2: read should fail"
2472 cat /etc/passwd > $DIR/$tdir/$tfile &&
2473 error "$DIR/$tdir/$tfile: write should fail"
2474 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2475 error "$DIR/$tdir/${tfile}2: write should fail"
2478 chmod 222 $DIR/$tdir/$tfile ||
2479 error "$DIR/$tdir/$tfile: chmod failed"
2480 chmod 222 $DIR/$tdir/${tfile}2 ||
2481 error "$DIR/$tdir/${tfile}2: chmod failed"
2484 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2485 error "$DIR/$tdir/$tfile: chown failed"
2486 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2487 error "$DIR/$tdir/${tfile}2: chown failed"
2489 # rename should work
2490 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2491 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2492 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2493 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2495 #remove foreign file
2496 rm $DIR/$tdir/${tfile}.new ||
2497 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2498 rm $DIR/$tdir/${tfile}2.new ||
2499 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2501 run_test 27J "basic ops on file with foreign LOV"
2504 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
2505 skip "Need MDS version newer than 2.12.49"
2507 test_mkdir $DIR/$tdir
2508 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2509 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2511 # create foreign dir (raw way)
2512 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2513 error "create_foreign_dir FAILED"
2515 # verify foreign dir (raw way)
2516 parse_foreign_dir -d $DIR/$tdir/$tdir |
2517 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2518 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2519 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2520 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2521 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2522 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2523 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
2524 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2525 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2526 grep "lmv_foreign_value: 0x" |
2527 sed 's/lmv_foreign_value: 0x//')
2528 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2530 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2532 # create foreign dir (lfs + API)
2533 $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2534 $DIR/$tdir/${tdir}2 ||
2535 error "$DIR/$tdir/${tdir}2: create failed"
2537 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2538 grep "lfm_magic:.*0x0CD50CD0" ||
2539 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2540 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2541 # - sizeof(lfm_type) - sizeof(lfm_flags)
2542 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2543 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2544 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
2545 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2546 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2547 grep "lfm_flags:.*0x0000DA05" ||
2548 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2549 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2550 grep "lfm_value.*${uuid1}@${uuid2}" ||
2551 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2553 # file create in dir should fail
2554 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2555 touch $DIR/$tdir/${tdir}2/$tfile &&
2556 "$DIR/${tdir}2: file create should fail"
2559 chmod 777 $DIR/$tdir/$tdir ||
2560 error "$DIR/$tdir: chmod failed"
2561 chmod 777 $DIR/$tdir/${tdir}2 ||
2562 error "$DIR/${tdir}2: chmod failed"
2565 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2566 error "$DIR/$tdir: chown failed"
2567 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2568 error "$DIR/${tdir}2: chown failed"
2570 # rename should work
2571 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2572 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2573 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2574 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2577 rmdir $DIR/$tdir/${tdir}.new ||
2578 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2579 rmdir $DIR/$tdir/${tdir}2.new ||
2580 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2582 run_test 27K "basic ops on dir with foreign LMV"
2584 # createtest also checks that device nodes are created and
2585 # then visible correctly (#2091)
2586 test_28() { # bug 2091
2588 $CREATETEST $DIR/d28/ct || error "createtest failed"
2590 run_test 28 "create/mknod/mkdir with bad file types ============"
2593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2595 sync; sleep 1; sync # flush out any dirty pages from previous tests
2602 declare -i LOCKCOUNTORIG=0
2603 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2604 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2606 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2608 declare -i LOCKUNUSEDCOUNTORIG=0
2609 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2610 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2617 declare -i LOCKCOUNTCURRENT=0
2618 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2619 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2622 declare -i LOCKUNUSEDCOUNTCURRENT=0
2623 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2624 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2627 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2628 $LCTL set_param -n ldlm.dump_namespaces ""
2629 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2630 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2631 log "dumped log to $TMP/test_29.dk (bug 5793)"
2634 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2635 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2636 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2637 log "dumped log to $TMP/test_29.dk (bug 5793)"
2641 run_test 29 "IT_GETATTR regression ============================"
2643 test_30a() { # was test_30
2644 cp $(which ls) $DIR || cp /bin/ls $DIR
2645 $DIR/ls / || error "Can't execute binary from lustre"
2648 run_test 30a "execute binary from Lustre (execve) =============="
2651 cp `which ls` $DIR || cp /bin/ls $DIR
2653 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2656 run_test 30b "execute binary from Lustre as non-root ==========="
2658 test_30c() { # b=22376
2659 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2661 cp `which ls` $DIR || cp /bin/ls $DIR
2663 cancel_lru_locks mdc
2664 cancel_lru_locks osc
2665 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2668 run_test 30c "execute binary from Lustre without read perms ===="
2671 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2672 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2674 run_test 31a "open-unlink file =================================="
2677 touch $DIR/f31 || error "touch $DIR/f31 failed"
2678 ln $DIR/f31 $DIR/f31b || error "ln failed"
2679 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2680 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2682 run_test 31b "unlink file with multiple links while open ======="
2685 touch $DIR/f31 || error "touch $DIR/f31 failed"
2686 ln $DIR/f31 $DIR/f31c || error "ln failed"
2687 multiop_bg_pause $DIR/f31 O_uc ||
2688 error "multiop_bg_pause for $DIR/f31 failed"
2690 $MULTIOP $DIR/f31c Ouc
2691 kill -USR1 $MULTIPID
2694 run_test 31c "open-unlink file with multiple links ============="
2697 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2698 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2700 run_test 31d "remove of open directory ========================="
2702 test_31e() { # bug 2904
2703 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2705 run_test 31e "remove of open non-empty directory ==============="
2707 test_31f() { # bug 4554
2708 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2711 test_mkdir $DIR/d31f
2712 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
2713 cp /etc/hosts $DIR/d31f
2715 $LFS getstripe $DIR/d31f/hosts
2716 multiop_bg_pause $DIR/d31f D_c || return 1
2719 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2720 test_mkdir $DIR/d31f
2721 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
2722 cp /etc/hosts $DIR/d31f
2724 $LFS getstripe $DIR/d31f/hosts
2725 multiop_bg_pause $DIR/d31f D_c || return 1
2728 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2729 wait $MULTIPID || error "first opendir $MULTIPID failed"
2733 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2734 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2737 run_test 31f "remove of open directory with open-unlink file ==="
2740 echo "-- cross directory link --"
2741 test_mkdir -c1 $DIR/${tdir}ga
2742 test_mkdir -c1 $DIR/${tdir}gb
2743 touch $DIR/${tdir}ga/f
2744 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2745 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2746 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2747 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2748 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2750 run_test 31g "cross directory link==============="
2753 echo "-- cross directory link --"
2754 test_mkdir -c1 $DIR/${tdir}
2755 test_mkdir -c1 $DIR/${tdir}/dir
2756 touch $DIR/${tdir}/f
2757 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2758 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2759 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2760 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2761 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2763 run_test 31h "cross directory link under child==============="
2766 echo "-- cross directory link --"
2767 test_mkdir -c1 $DIR/$tdir
2768 test_mkdir -c1 $DIR/$tdir/dir
2769 touch $DIR/$tdir/dir/f
2770 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2771 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2772 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2773 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2774 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2776 run_test 31i "cross directory link under parent==============="
2779 test_mkdir -c1 -p $DIR/$tdir
2780 test_mkdir -c1 -p $DIR/$tdir/dir1
2781 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2782 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2783 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2784 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2787 run_test 31j "link for directory==============="
2790 test_mkdir -c1 -p $DIR/$tdir
2792 touch $DIR/$tdir/exist
2793 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2794 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2795 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2796 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2797 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2798 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2799 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2802 run_test 31k "link to file: the same, non-existing, dir==============="
2808 touch $DIR/d31m2/exist
2809 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2810 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2811 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2812 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2813 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2814 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2817 run_test 31m "link to file: the same, non-existing, dir==============="
2820 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2821 nlink=$(stat --format=%h $DIR/$tfile)
2822 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2824 local cmd="exec $fd<$DIR/$tfile"
2827 trap "eval $cmd" EXIT
2828 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2829 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2830 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2831 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2832 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2835 run_test 31n "check link count of unlinked file"
2838 local TEMPNAME=$(mktemp $1_XXXXXX)
2839 mlink $TEMPNAME $1 2> /dev/null &&
2840 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2844 test_31o() { # LU-2901
2845 test_mkdir $DIR/$tdir
2846 for LOOP in $(seq 100); do
2847 rm -f $DIR/$tdir/$tfile*
2848 for THREAD in $(seq 8); do
2849 link_one $DIR/$tdir/$tfile.$LOOP &
2852 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2853 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2854 error "$LINKS duplicate links to $tfile.$LOOP" &&
2858 run_test 31o "duplicate hard links with same filename"
2861 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2863 test_mkdir $DIR/$tdir
2864 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2865 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2867 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2868 error "open unlink test1 failed"
2869 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2870 error "open unlink test2 failed"
2872 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2873 error "test1 still exists"
2874 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2875 error "test2 still exists"
2877 run_test 31p "remove of open striped directory"
2879 cleanup_test32_mount() {
2882 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2883 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2884 losetup -d $loopdev || true
2890 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2892 echo "== more mountpoints and symlinks ================="
2893 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2894 trap cleanup_test32_mount EXIT
2895 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2896 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2897 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2898 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2899 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2900 cleanup_test32_mount
2902 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2905 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2907 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2908 trap cleanup_test32_mount EXIT
2909 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2910 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2911 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2912 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2913 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2914 cleanup_test32_mount
2916 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2921 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2922 trap cleanup_test32_mount EXIT
2923 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2924 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2925 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2926 test_mkdir -p $DIR/$tdir/d2/test_dir
2927 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2928 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2929 cleanup_test32_mount
2931 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2934 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2936 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2937 trap cleanup_test32_mount EXIT
2938 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2939 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2940 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2941 test_mkdir -p $DIR/$tdir/d2/test_dir
2942 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2943 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2944 cleanup_test32_mount
2946 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2950 test_mkdir -p $DIR/$tdir/tmp
2951 local tmp_dir=$DIR/$tdir/tmp
2952 ln -s $DIR/$tdir $tmp_dir/symlink11
2953 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2954 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2955 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2957 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2961 test_mkdir -p $DIR/$tdir/tmp
2962 local tmp_dir=$DIR/$tdir/tmp
2963 ln -s $DIR/$tdir $tmp_dir/symlink11
2964 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2965 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2966 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2968 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2971 local tmp_dir=$DIR/$tdir/tmp
2972 test_mkdir -p $tmp_dir
2973 test_mkdir $DIR/${tdir}2
2974 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2975 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2976 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2977 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2978 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2979 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2981 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2984 rm -fr $DIR/$tdir $DIR/${tdir}2
2985 tmp_dir=$DIR/$tdir/tmp
2986 test_mkdir -p $tmp_dir
2987 test_mkdir $DIR/${tdir}2
2988 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2989 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2990 ls $tmp_dir/symlink12 || error "listing symlink12"
2991 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2993 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2996 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2998 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2999 trap cleanup_test32_mount EXIT
3000 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3001 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3002 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3003 touch $DIR/$tdir/test_file
3004 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3005 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3006 cleanup_test32_mount
3008 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3011 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3013 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3014 trap cleanup_test32_mount EXIT
3015 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3016 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3017 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3018 touch $DIR/$tdir/test_file
3019 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3020 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3021 cleanup_test32_mount
3023 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3026 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3029 trap cleanup_test32_mount EXIT
3030 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3031 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3032 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3033 test_mkdir -p $DIR/$tdir/d2
3034 touch $DIR/$tdir/d2/test_file || error "touch failed"
3035 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3036 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3037 cleanup_test32_mount
3039 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3042 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3045 trap cleanup_test32_mount EXIT
3046 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3047 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3048 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3049 test_mkdir -p $DIR/$tdir/d2
3050 touch $DIR/$tdir/d2/test_file || error "touch failed"
3051 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3052 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3053 cleanup_test32_mount
3055 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3059 test_mkdir -p $DIR/d32m/tmp
3060 TMP_DIR=$DIR/d32m/tmp
3061 ln -s $DIR $TMP_DIR/symlink11
3062 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3063 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3064 error "symlink11 not a link"
3065 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3066 error "symlink01 not a link"
3068 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3072 test_mkdir -p $DIR/d32n/tmp
3073 TMP_DIR=$DIR/d32n/tmp
3074 ln -s $DIR $TMP_DIR/symlink11
3075 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3076 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3077 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3079 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3083 test_mkdir -p $DIR/d32o/tmp
3084 TMP_DIR=$DIR/d32o/tmp
3085 ln -s $DIR/$tfile $TMP_DIR/symlink12
3086 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3087 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3088 error "symlink12 not a link"
3089 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3090 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3091 error "$DIR/d32o/tmp/symlink12 not file type"
3092 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3093 error "$DIR/d32o/symlink02 not file type"
3095 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3105 test_mkdir -p $DIR/d32p/tmp
3107 TMP_DIR=$DIR/d32p/tmp
3109 ln -s $DIR/$tfile $TMP_DIR/symlink12
3111 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3113 cat $DIR/d32p/tmp/symlink12 ||
3114 error "Can't open $DIR/d32p/tmp/symlink12"
3116 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3119 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3122 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3124 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3125 trap cleanup_test32_mount EXIT
3126 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3127 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3128 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3129 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3130 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3131 cleanup_test32_mount
3133 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3136 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3138 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3139 trap cleanup_test32_mount EXIT
3140 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3141 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3142 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3143 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3144 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3145 cleanup_test32_mount
3147 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3152 chmod 444 $DIR/$tfile
3153 chown $RUNAS_ID $DIR/$tfile
3155 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3158 run_test 33aa "write file with mode 444 (should return error)"
3162 test_mkdir $DIR/$tdir
3163 chown $RUNAS_ID $DIR/$tdir
3164 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3165 error "$RUNAS create $tdir/$tfile failed"
3166 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3167 error "open RDWR" || true
3169 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3173 test_mkdir $DIR/$tdir
3174 chown $RUNAS_ID $DIR/$tdir
3175 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3177 run_test 33b "test open file with malformed flags (No panic)"
3180 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3181 remote_ost_nodsh && skip "remote OST with nodsh"
3190 test_mkdir $DIR/$tdir
3191 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3194 for ostnum in $(seq $OSTCOUNT); do
3195 # test-framework's OST numbering is one-based, while Lustre's
3197 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3198 # Parsing llobdstat's output sucks; we could grep the /proc
3199 # path, but that's likely to not be as portable as using the
3200 # llobdstat utility. So we parse lctl output instead.
3201 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3202 obdfilter/$ostname/stats |
3203 awk '/^write_bytes/ {print $7}' )
3204 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3205 if (( ${write_bytes:-0} > 0 ))
3212 $all_zeros || return 0
3215 echo foo > $DIR/$tdir/bar
3219 # Total up write_bytes after writing. We'd better find non-zeros.
3220 for ostnum in $(seq $OSTCOUNT); do
3221 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3222 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3223 obdfilter/$ostname/stats |
3224 awk '/^write_bytes/ {print $7}' )
3225 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3226 if (( ${write_bytes:-0} > 0 ))
3235 for ostnum in $(seq $OSTCOUNT); do
3236 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3237 echo "Check that write_bytes is present in obdfilter/*/stats:"
3238 do_facet ost$ostnum lctl get_param -n \
3239 obdfilter/$ostname/stats
3241 error "OST not keeping write_bytes stats (b22312)"
3244 run_test 33c "test llobdstat and write_bytes"
3247 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3248 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3251 local remote_dir=$DIR/$tdir/remote_dir
3253 test_mkdir $DIR/$tdir
3254 $LFS mkdir -i $MDTIDX $remote_dir ||
3255 error "create remote directory failed"
3257 touch $remote_dir/$tfile
3258 chmod 444 $remote_dir/$tfile
3259 chown $RUNAS_ID $remote_dir/$tfile
3261 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3263 chown $RUNAS_ID $remote_dir
3264 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3265 error "create" || true
3266 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3267 error "open RDWR" || true
3268 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3270 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3273 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3277 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3278 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3279 mkdir $DIR/$tdir/local_dir
3281 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3282 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3283 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3285 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3286 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3288 rmdir $DIR/$tdir/* || error "rmdir failed"
3291 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3292 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3293 mkdir $DIR/$tdir/local_dir
3295 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3296 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3297 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3299 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3300 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3302 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3305 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3306 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3307 mkdir $DIR/$tdir/local_dir
3309 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3310 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3311 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3313 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3314 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3316 run_test 33e "mkdir and striped directory should have same mode"
3320 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3324 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3325 remote_mds_nodsh && skip "remote MDS with nodsh"
3328 chmod go+rwx $DIR/$tdir
3329 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3330 trap cleanup_33f EXIT
3332 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3333 error "cannot create striped directory"
3335 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3336 error "cannot create files in striped directory"
3338 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3339 error "cannot remove files in striped directory"
3341 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3342 error "cannot remove striped directory"
3346 run_test 33f "nonroot user can create, access, and remove a striped directory"
3349 mkdir -p $DIR/$tdir/dir2
3351 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3353 [[ $err =~ "exists" ]] || error "Not exists error"
3355 run_test 33g "nonroot user create already existing root created file"
3357 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3360 $MCREATE $DIR/f34 || error "mcreate failed"
3361 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3362 error "getstripe failed"
3363 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3364 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3365 error "getstripe failed"
3366 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3367 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3369 run_test 34a "truncate file that has not been opened ==========="
3372 [ ! -f $DIR/f34 ] && test_34a
3373 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3374 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3375 $OPENFILE -f O_RDONLY $DIR/f34
3376 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3377 error "getstripe failed"
3378 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3379 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3381 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3384 [ ! -f $DIR/f34 ] && test_34a
3385 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3386 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3387 $OPENFILE -f O_RDWR $DIR/f34
3388 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3389 error "$LFS getstripe failed"
3390 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3391 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3393 run_test 34c "O_RDWR opening file-with-size works =============="
3396 [ ! -f $DIR/f34 ] && test_34a
3397 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3399 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3400 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3403 run_test 34d "write to sparse file ============================="
3407 $MCREATE $DIR/f34e || error "mcreate failed"
3408 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3409 $CHECKSTAT -s 1000 $DIR/f34e ||
3410 error "Size of $DIR/f34e not equal to 1000 bytes"
3411 $OPENFILE -f O_RDWR $DIR/f34e
3412 $CHECKSTAT -s 1000 $DIR/f34e ||
3413 error "Size of $DIR/f34e not equal to 1000 bytes"
3415 run_test 34e "create objects, some with size and some without =="
3417 test_34f() { # bug 6242, 6243
3418 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3422 $MCREATE $DIR/f34f || error "mcreate failed"
3423 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3424 dd if=$DIR/f34f of=$TMP/f34f
3425 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3426 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3427 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3428 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3429 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3431 run_test 34f "read from a file with no objects until EOF ======="
3434 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3436 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3438 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3439 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3440 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3441 cancel_lru_locks osc
3442 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3443 error "wrong size after lock cancel"
3445 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3446 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3447 error "expanding truncate failed"
3448 cancel_lru_locks osc
3449 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3450 error "wrong expanded size after lock cancel"
3452 run_test 34g "truncate long file ==============================="
3455 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3460 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3461 sync # Flush the cache so that multiop below does not block on cache
3462 # flush when getting the group lock
3463 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3466 # Since just timed wait is not good enough, let's do a sync write
3467 # that way we are sure enough time for a roundtrip + processing
3468 # passed + 2 seconds of extra margin.
3469 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3473 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3474 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3478 local nsz=`stat -c %s $DIR/$tfile`
3479 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3481 run_test 34h "ftruncate file under grouplock should not block"
3484 cp /bin/sh $DIR/f35a
3486 chown $RUNAS_ID $DIR/f35a
3487 $RUNAS $DIR/f35a && error || true
3490 run_test 35a "exec file with mode 444 (should return and not leak)"
3494 utime $DIR/f36 || error "utime failed for MDS"
3496 run_test 36a "MDS utime check (mknod, utime)"
3500 utime $DIR/f36 || error "utime failed for OST"
3502 run_test 36b "OST utime check (open, utime)"
3507 chown $RUNAS_ID $DIR/d36
3508 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3510 run_test 36c "non-root MDS utime check (mknod, utime)"
3513 [ ! -d $DIR/d36 ] && test_36c
3514 echo "" > $DIR/d36/f36
3515 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3517 run_test 36d "non-root OST utime check (open, utime)"
3520 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3522 test_mkdir $DIR/$tdir
3523 touch $DIR/$tdir/$tfile
3524 $RUNAS utime $DIR/$tdir/$tfile &&
3525 error "utime worked, expected failure" || true
3527 run_test 36e "utime on non-owned file (should return error)"
3531 local LANG_SAVE=$LANG
3532 local LC_LANG_SAVE=$LC_LANG
3533 export LANG=C LC_LANG=C # for date language
3535 DATESTR="Dec 20 2000"
3536 test_mkdir $DIR/$tdir
3537 lctl set_param fail_loc=$fl
3539 cp /etc/hosts $DIR/$tdir/$tfile
3540 sync & # write RPC generated with "current" inode timestamp, but delayed
3542 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3543 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3544 cancel_lru_locks $OSC
3545 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3547 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3548 echo "BEFORE: $LS_BEFORE" && \
3549 echo "AFTER : $LS_AFTER" && \
3550 echo "WANT : $DATESTR" && \
3551 error "$DIR/$tdir/$tfile timestamps changed" || true
3553 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3559 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3560 subr_36fh "0x80000214"
3562 run_test 36f "utime on file racing with OST BRW write =========="
3565 remote_ost_nodsh && skip "remote OST with nodsh"
3566 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3567 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
3568 skip "Need MDS version at least 2.12.51"
3573 local tgt="obdfilter"
3575 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
3577 test_mkdir $DIR/$tdir
3578 fmd_max_age=$(do_facet $facet \
3579 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
3582 echo "FMD max age: ${fmd_max_age}s"
3583 touch $DIR/$tdir/$tfile
3584 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3585 gawk '{cnt=cnt+$1} END{print cnt}')
3586 echo "FMD before: $fmd"
3588 error "FMD wasn't create by touch"
3589 sleep $((fmd_max_age + 12))
3590 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3591 gawk '{cnt=cnt+$1} END{print cnt}')
3592 echo "FMD after: $fmd"
3594 error "FMD wasn't expired by ping"
3596 run_test 36g "FMD cache expiry ====================="
3599 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3601 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3602 subr_36fh "0x80000227"
3604 run_test 36h "utime on file racing with OST BRW write =========="
3607 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3609 test_mkdir $DIR/$tdir
3610 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3612 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3613 local new_mtime=$((mtime + 200))
3615 #change Modify time of striped dir
3616 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3617 error "change mtime failed"
3619 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3621 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3623 run_test 36i "change mtime on striped directory"
3625 # test_37 - duplicate with tests 32q 32r
3628 local file=$DIR/$tfile
3630 openfile -f O_DIRECTORY $file
3633 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3634 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3636 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3638 test_39a() { # was test_39
3640 touch $DIR/${tfile}2
3641 # ls -l $DIR/$tfile $DIR/${tfile}2
3642 # ls -lu $DIR/$tfile $DIR/${tfile}2
3643 # ls -lc $DIR/$tfile $DIR/${tfile}2
3645 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3646 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3648 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3650 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3652 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3653 error "O_TRUNC didn't change timestamps"
3656 run_test 39a "mtime changed on create"
3659 test_mkdir -c1 $DIR/$tdir
3660 cp -p /etc/passwd $DIR/$tdir/fopen
3661 cp -p /etc/passwd $DIR/$tdir/flink
3662 cp -p /etc/passwd $DIR/$tdir/funlink
3663 cp -p /etc/passwd $DIR/$tdir/frename
3664 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3667 echo "aaaaaa" >> $DIR/$tdir/fopen
3668 echo "aaaaaa" >> $DIR/$tdir/flink
3669 echo "aaaaaa" >> $DIR/$tdir/funlink
3670 echo "aaaaaa" >> $DIR/$tdir/frename
3672 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3673 local link_new=`stat -c %Y $DIR/$tdir/flink`
3674 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3675 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3677 cat $DIR/$tdir/fopen > /dev/null
3678 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3679 rm -f $DIR/$tdir/funlink2
3680 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3682 for (( i=0; i < 2; i++ )) ; do
3683 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3684 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3685 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3686 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3688 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3689 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3690 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3691 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3693 cancel_lru_locks $OSC
3694 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3697 run_test 39b "mtime change on open, link, unlink, rename ======"
3699 # this should be set to past
3700 TEST_39_MTIME=`date -d "1 year ago" +%s`
3706 local mtime0=`stat -c %Y $DIR1/$tfile`
3708 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3709 local mtime1=`stat -c %Y $DIR1/$tfile`
3710 [ "$mtime1" = $TEST_39_MTIME ] || \
3711 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3714 echo hello >> $DIR1/$tfile
3716 local mtime2=`stat -c %Y $DIR1/$tfile`
3717 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3718 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3720 mv $DIR1/$tfile $DIR1/$tfile-1
3722 for (( i=0; i < 2; i++ )) ; do
3723 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3724 [ "$mtime2" = "$mtime3" ] || \
3725 error "mtime ($mtime2) changed (to $mtime3) on rename"
3727 cancel_lru_locks $OSC
3728 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3731 run_test 39c "mtime change on rename ==========================="
3735 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3738 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3740 for (( i=0; i < 2; i++ )) ; do
3741 local mtime=`stat -c %Y $DIR1/$tfile`
3742 [ $mtime = $TEST_39_MTIME ] || \
3743 error "mtime($mtime) is not set to $TEST_39_MTIME"
3745 cancel_lru_locks $OSC
3746 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3749 run_test 39d "create, utime, stat =============================="
3753 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3756 local mtime1=`stat -c %Y $DIR1/$tfile`
3758 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3760 for (( i=0; i < 2; i++ )) ; do
3761 local mtime2=`stat -c %Y $DIR1/$tfile`
3762 [ $mtime2 = $TEST_39_MTIME ] || \
3763 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3765 cancel_lru_locks $OSC
3766 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3769 run_test 39e "create, stat, utime, stat ========================"
3773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3776 mtime1=`stat -c %Y $DIR1/$tfile`
3779 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3781 for (( i=0; i < 2; i++ )) ; do
3782 local mtime2=`stat -c %Y $DIR1/$tfile`
3783 [ $mtime2 = $TEST_39_MTIME ] || \
3784 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3786 cancel_lru_locks $OSC
3787 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3790 run_test 39f "create, stat, sleep, utime, stat ================="
3794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3796 echo hello >> $DIR1/$tfile
3797 local mtime1=`stat -c %Y $DIR1/$tfile`
3800 chmod o+r $DIR1/$tfile
3802 for (( i=0; i < 2; i++ )) ; do
3803 local mtime2=`stat -c %Y $DIR1/$tfile`
3804 [ "$mtime1" = "$mtime2" ] || \
3805 error "lost mtime: $mtime2, should be $mtime1"
3807 cancel_lru_locks $OSC
3808 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3811 run_test 39g "write, chmod, stat ==============================="
3815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3821 echo hello >> $DIR1/$tfile
3822 local mtime1=`stat -c %Y $DIR1/$tfile`
3824 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3826 if [ "$d1" != "$d2" ]; then
3827 echo "write and touch not within one second"
3829 for (( i=0; i < 2; i++ )) ; do
3830 local mtime2=`stat -c %Y $DIR1/$tfile`
3831 [ "$mtime2" = $TEST_39_MTIME ] || \
3832 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3834 cancel_lru_locks $OSC
3835 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3839 run_test 39h "write, utime within one second, stat ============="
3842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3847 echo hello >> $DIR1/$tfile
3848 local mtime1=`stat -c %Y $DIR1/$tfile`
3850 mv $DIR1/$tfile $DIR1/$tfile-1
3852 for (( i=0; i < 2; i++ )) ; do
3853 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3855 [ "$mtime1" = "$mtime2" ] || \
3856 error "lost mtime: $mtime2, should be $mtime1"
3858 cancel_lru_locks $OSC
3859 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3862 run_test 39i "write, rename, stat =============================="
3865 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3867 start_full_debug_logging
3871 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3872 lctl set_param fail_loc=0x80000412
3873 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3874 error "multiop failed"
3876 local mtime1=`stat -c %Y $DIR1/$tfile`
3878 mv $DIR1/$tfile $DIR1/$tfile-1
3880 kill -USR1 $multipid
3881 wait $multipid || error "multiop close failed"
3883 for (( i=0; i < 2; i++ )) ; do
3884 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3885 [ "$mtime1" = "$mtime2" ] ||
3886 error "mtime is lost on close: $mtime2, " \
3889 cancel_lru_locks $OSC
3890 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3892 lctl set_param fail_loc=0
3893 stop_full_debug_logging
3895 run_test 39j "write, rename, close, stat ======================="
3898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3903 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3905 local mtime1=`stat -c %Y $DIR1/$tfile`
3907 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3909 kill -USR1 $multipid
3910 wait $multipid || error "multiop close failed"
3912 for (( i=0; i < 2; i++ )) ; do
3913 local mtime2=`stat -c %Y $DIR1/$tfile`
3915 [ "$mtime2" = $TEST_39_MTIME ] || \
3916 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3918 cancel_lru_locks osc
3919 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3922 run_test 39k "write, utime, close, stat ========================"
3924 # this should be set to future
3925 TEST_39_ATIME=`date -d "1 year" +%s`
3928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3929 remote_mds_nodsh && skip "remote MDS with nodsh"
3931 local atime_diff=$(do_facet $SINGLEMDS \
3932 lctl get_param -n mdd.*MDT0000*.atime_diff)
3936 # test setting directory atime to future
3937 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3938 local atime=$(stat -c %X $DIR/$tdir)
3939 [ "$atime" = $TEST_39_ATIME ] ||
3940 error "atime is not set to future: $atime, $TEST_39_ATIME"
3942 # test setting directory atime from future to now
3943 local now=$(date +%s)
3944 touch -a -d @$now $DIR/$tdir
3946 atime=$(stat -c %X $DIR/$tdir)
3947 [ "$atime" -eq "$now" ] ||
3948 error "atime is not updated from future: $atime, $now"
3950 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3953 # test setting directory atime when now > dir atime + atime_diff
3954 local d1=$(date +%s)
3956 local d2=$(date +%s)
3957 cancel_lru_locks mdc
3958 atime=$(stat -c %X $DIR/$tdir)
3959 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3960 error "atime is not updated : $atime, should be $d2"
3962 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3965 # test not setting directory atime when now < dir atime + atime_diff
3967 cancel_lru_locks mdc
3968 atime=$(stat -c %X $DIR/$tdir)
3969 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3970 error "atime is updated to $atime, should remain $d1<atime<$d2"
3972 do_facet $SINGLEMDS \
3973 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3975 run_test 39l "directory atime update ==========================="
3978 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3982 local far_past_mtime=$(date -d "May 29 1953" +%s)
3983 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3985 touch -m -d @$far_past_mtime $DIR1/$tfile
3986 touch -a -d @$far_past_atime $DIR1/$tfile
3988 for (( i=0; i < 2; i++ )) ; do
3989 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3990 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3991 error "atime or mtime set incorrectly"
3993 cancel_lru_locks $OSC
3994 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3997 run_test 39m "test atime and mtime before 1970"
3999 test_39n() { # LU-3832
4000 remote_mds_nodsh && skip "remote MDS with nodsh"
4002 local atime_diff=$(do_facet $SINGLEMDS \
4003 lctl get_param -n mdd.*MDT0000*.atime_diff)
4008 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4011 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4012 atime0=$(stat -c %X $DIR/$tfile)
4015 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4016 atime1=$(stat -c %X $DIR/$tfile)
4019 cancel_lru_locks mdc
4020 cancel_lru_locks osc
4021 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4022 atime2=$(stat -c %X $DIR/$tfile)
4024 do_facet $SINGLEMDS \
4025 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4027 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4028 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4030 run_test 39n "check that O_NOATIME is honored"
4033 TESTDIR=$DIR/$tdir/$tfile
4034 [ -e $TESTDIR ] && rm -rf $TESTDIR
4041 links2=$(stat -c %h .)
4042 [ $(($links1 + 2)) != $links2 ] &&
4043 error "wrong links count $(($links1 + 2)) != $links2"
4045 links3=$(stat -c %h .)
4046 [ $(($links1 + 1)) != $links3 ] &&
4047 error "wrong links count $links1 != $links3"
4050 run_test 39o "directory cached attributes updated after create"
4053 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4056 TESTDIR=$DIR/$tdir/$tdir
4057 [ -e $TESTDIR ] && rm -rf $TESTDIR
4058 test_mkdir -p $TESTDIR
4062 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4063 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4065 links2=$(stat -c %h .)
4066 [ $(($links1 + 2)) != $links2 ] &&
4067 error "wrong links count $(($links1 + 2)) != $links2"
4069 links3=$(stat -c %h .)
4070 [ $(($links1 + 1)) != $links3 ] &&
4071 error "wrong links count $links1 != $links3"
4074 run_test 39p "remote directory cached attributes updated after create ========"
4077 test_39q() { # LU-8041
4078 local testdir=$DIR/$tdir
4080 multiop_bg_pause $testdir D_c || error "multiop failed"
4082 cancel_lru_locks mdc
4083 kill -USR1 $multipid
4084 local atime=$(stat -c %X $testdir)
4085 [ "$atime" -ne 0 ] || error "atime is zero"
4087 run_test 39q "close won't zero out atime"
4090 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4091 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4092 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4093 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4094 error "$tfile is not 4096 bytes in size"
4096 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4100 small_write $DIR/f41 18
4102 run_test 41 "test small file write + fstat ====================="
4104 count_ost_writes() {
4105 lctl get_param -n ${OSC}.*.stats |
4106 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4107 END { printf("%0.0f", writes) }'
4114 BG_DIRTY_RATIO_SAVE=10
4115 MAX_BG_DIRTY_RATIO=25
4119 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4120 # dirty_ratio, dirty_background_ratio
4121 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4122 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4123 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4124 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4126 # if file not here, we are a 2.4 kernel
4127 kill -CONT `pidof kupdated`
4132 # setup the trap first, so someone cannot exit the test at the
4133 # exact wrong time and mess up a machine
4134 trap start_writeback EXIT
4135 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4136 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4137 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4138 sysctl -w vm.dirty_writeback_centisecs=0
4139 sysctl -w vm.dirty_writeback_centisecs=0
4140 # save and increase /proc/sys/vm/dirty_ratio
4141 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4142 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4143 # save and increase /proc/sys/vm/dirty_background_ratio
4144 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4145 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4147 # if file not here, we are a 2.4 kernel
4148 kill -STOP `pidof kupdated`
4152 # ensure that all stripes have some grant before we test client-side cache
4154 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4155 dd if=/dev/zero of=$i bs=4k count=1
4160 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4161 # file truncation, and file removal.
4163 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4166 cancel_lru_locks $OSC
4168 sync; sleep 1; sync # just to be safe
4169 BEFOREWRITES=`count_ost_writes`
4170 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4171 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4172 AFTERWRITES=`count_ost_writes`
4173 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4174 error "$BEFOREWRITES < $AFTERWRITES"
4177 run_test 42a "ensure that we don't flush on close"
4180 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4183 cancel_lru_locks $OSC
4186 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4187 BEFOREWRITES=$(count_ost_writes)
4188 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4189 AFTERWRITES=$(count_ost_writes)
4190 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4191 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4193 BEFOREWRITES=$(count_ost_writes)
4194 sync || error "sync: $?"
4195 AFTERWRITES=$(count_ost_writes)
4196 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4197 error "$BEFOREWRITES < $AFTERWRITES on sync"
4199 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4203 run_test 42b "test destroy of file with cached dirty data ======"
4205 # if these tests just want to test the effect of truncation,
4206 # they have to be very careful. consider:
4207 # - the first open gets a {0,EOF}PR lock
4208 # - the first write conflicts and gets a {0, count-1}PW
4209 # - the rest of the writes are under {count,EOF}PW
4210 # - the open for truncate tries to match a {0,EOF}PR
4211 # for the filesize and cancels the PWs.
4212 # any number of fixes (don't get {0,EOF} on open, match
4213 # composite locks, do smarter file size management) fix
4214 # this, but for now we want these tests to verify that
4215 # the cancellation with truncate intent works, so we
4216 # start the file with a full-file pw lock to match against
4217 # until the truncate.
4222 cancel_lru_locks $OSC
4224 # prime the file with 0,EOF PW to match
4228 # now the real test..
4229 dd if=/dev/zero of=$file bs=1024 count=100
4230 BEFOREWRITES=`count_ost_writes`
4231 $TRUNCATE $file $offset
4232 cancel_lru_locks $OSC
4233 AFTERWRITES=`count_ost_writes`
4238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4241 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4242 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4245 run_test 42c "test partial truncate of file with cached dirty data"
4248 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4251 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4252 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4255 run_test 42d "test complete truncate of file with cached dirty data"
4257 test_42e() { # bug22074
4258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4260 local TDIR=$DIR/${tdir}e
4261 local pages=16 # hardcoded 16 pages, don't change it.
4262 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4263 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4267 test_mkdir $DIR/${tdir}e
4268 $LFS setstripe -c 1 $TDIR
4269 createmany -o $TDIR/f $files
4271 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4273 # we assume that with $OSTCOUNT files, at least one of them will
4274 # be allocated on OST0.
4275 warmup_files=$((OSTCOUNT * max_dirty_mb))
4276 createmany -o $TDIR/w $warmup_files
4278 # write a large amount of data into one file and sync, to get good
4279 # avail_grant number from OST.
4280 for ((i=0; i<$warmup_files; i++)); do
4281 idx=$($LFS getstripe -i $TDIR/w$i)
4282 [ $idx -ne 0 ] && continue
4283 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4286 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4288 $LCTL get_param $proc_osc0/cur_dirty_bytes
4289 $LCTL get_param $proc_osc0/cur_grant_bytes
4291 # create as much dirty pages as we can while not to trigger the actual
4292 # RPCs directly. but depends on the env, VFS may trigger flush during this
4293 # period, hopefully we are good.
4294 for ((i=0; i<$warmup_files; i++)); do
4295 idx=$($LFS getstripe -i $TDIR/w$i)
4296 [ $idx -ne 0 ] && continue
4297 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4299 $LCTL get_param $proc_osc0/cur_dirty_bytes
4300 $LCTL get_param $proc_osc0/cur_grant_bytes
4302 # perform the real test
4303 $LCTL set_param $proc_osc0/rpc_stats 0
4304 for ((;i<$files; i++)); do
4305 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
4306 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4309 $LCTL get_param $proc_osc0/rpc_stats
4312 local have_ppr=false
4313 $LCTL get_param $proc_osc0/rpc_stats |
4314 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4315 # skip lines until we are at the RPC histogram data
4316 [ "$PPR" == "pages" ] && have_ppr=true && continue
4317 $have_ppr || continue
4319 # we only want the percent stat for < 16 pages
4320 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4322 percent=$((percent + WPCT))
4323 if [[ $percent -gt 15 ]]; then
4324 error "less than 16-pages write RPCs" \
4331 run_test 42e "verify sub-RPC writes are not done synchronously"
4333 test_43A() { # was test_43
4334 test_mkdir $DIR/$tdir
4335 cp -p /bin/ls $DIR/$tdir/$tfile
4336 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4338 # give multiop a chance to open
4341 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4344 run_test 43A "execution of file opened for write should return -ETXTBSY"
4347 test_mkdir $DIR/$tdir
4348 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4349 $DIR/$tdir/sleep 60 &
4351 # Make sure exec of $tdir/sleep wins race with truncate
4353 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4356 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4359 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4361 test_mkdir $DIR/$tdir
4362 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4363 $DIR/$tdir/sleep 60 &
4365 # Make sure exec of $tdir/sleep wins race with truncate
4367 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4370 run_test 43b "truncate of file being executed should return -ETXTBSY"
4373 local testdir="$DIR/$tdir"
4376 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4377 ( cd $testdir && md5sum -c )
4379 run_test 43c "md5sum of copy into lustre"
4381 test_44A() { # was test_44
4382 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4384 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4385 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4387 run_test 44A "zero length read from a sparse stripe"
4390 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4392 [ -z "$nstripe" ] && skip "can't get stripe info"
4393 [[ $nstripe -gt $OSTCOUNT ]] &&
4394 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4396 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4398 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4399 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4403 OFFSETS="0 $((stride/2)) $((stride-1))"
4404 for offset in $OFFSETS; do
4405 for i in $(seq 0 $((nstripe-1))); do
4406 local GLOBALOFFSETS=""
4408 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4409 local myfn=$DIR/d44a-$size
4410 echo "--------writing $myfn at $size"
4411 ll_sparseness_write $myfn $size ||
4412 error "ll_sparseness_write"
4413 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4414 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4415 error "ll_sparseness_verify $GLOBALOFFSETS"
4417 for j in $(seq 0 $((nstripe-1))); do
4419 size=$((((j + $nstripe )*$stride + $offset)))
4420 ll_sparseness_write $myfn $size ||
4421 error "ll_sparseness_write"
4422 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4424 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4425 error "ll_sparseness_verify $GLOBALOFFSETS"
4430 run_test 44a "test sparse pwrite ==============================="
4434 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4440 before=`dirty_osc_total`
4441 echo executing "\"$*\""
4443 after=`dirty_osc_total`
4444 echo before $before, after $after
4447 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4450 # Obtain grants from OST if it supports it
4451 echo blah > ${f}_grant
4454 do_dirty_record "echo blah > $f"
4455 [[ $before -eq $after ]] && error "write wasn't cached"
4456 do_dirty_record "> $f"
4457 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4458 do_dirty_record "echo blah > $f"
4459 [[ $before -eq $after ]] && error "write wasn't cached"
4460 do_dirty_record "sync"
4461 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4462 do_dirty_record "echo blah > $f"
4463 [[ $before -eq $after ]] && error "write wasn't cached"
4464 do_dirty_record "cancel_lru_locks osc"
4465 [[ $before -gt $after ]] ||
4466 error "lock cancellation didn't lower dirty count"
4469 run_test 45 "osc io page accounting ============================"
4471 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4472 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4473 # objects offset and an assert hit when an rpc was built with 1023's mapped
4474 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4476 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4481 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4483 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4484 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4488 run_test 46 "dirtying a previously written page ================"
4490 # test_47 is removed "Device nodes check" is moved to test_28
4492 test_48a() { # bug 2399
4493 [ "$mds1_FSTYPE" = "zfs" ] &&
4494 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4495 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4497 test_mkdir $DIR/$tdir
4499 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4500 test_mkdir $DIR/$tdir
4501 touch foo || error "'touch foo' failed after recreating cwd"
4503 touch .foo || error "'touch .foo' failed after recreating cwd"
4505 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4506 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4507 cd . || error "'cd .' failed after recreating cwd"
4508 mkdir . && error "'mkdir .' worked after recreating cwd"
4509 rmdir . && error "'rmdir .' worked after recreating cwd"
4510 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4511 cd .. || error "'cd ..' failed after recreating cwd"
4513 run_test 48a "Access renamed working dir (should return errors)="
4515 test_48b() { # bug 2399
4517 test_mkdir $DIR/$tdir
4519 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4520 touch foo && error "'touch foo' worked after removing cwd"
4521 mkdir foo && error "'mkdir foo' worked after removing cwd"
4522 touch .foo && error "'touch .foo' worked after removing cwd"
4523 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4524 ls . > /dev/null && error "'ls .' worked after removing cwd"
4525 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4526 mkdir . && error "'mkdir .' worked after removing cwd"
4527 rmdir . && error "'rmdir .' worked after removing cwd"
4528 ln -s . foo && error "'ln -s .' worked after removing cwd"
4529 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4531 run_test 48b "Access removed working dir (should return errors)="
4533 test_48c() { # bug 2350
4534 #lctl set_param debug=-1
4537 test_mkdir -p $DIR/$tdir/dir
4539 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4540 $TRACE touch foo && error "touch foo worked after removing cwd"
4541 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4542 touch .foo && error "touch .foo worked after removing cwd"
4543 mkdir .foo && error "mkdir .foo worked after removing cwd"
4544 $TRACE ls . && error "'ls .' worked after removing cwd"
4545 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4546 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4547 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4548 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4549 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4551 run_test 48c "Access removed working subdir (should return errors)"
4553 test_48d() { # bug 2350
4554 #lctl set_param debug=-1
4557 test_mkdir -p $DIR/$tdir/dir
4559 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4560 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4561 $TRACE touch foo && error "'touch foo' worked after removing parent"
4562 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4563 touch .foo && error "'touch .foo' worked after removing parent"
4564 mkdir .foo && error "mkdir .foo worked after removing parent"
4565 $TRACE ls . && error "'ls .' worked after removing parent"
4566 $TRACE ls .. && error "'ls ..' worked after removing parent"
4567 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4568 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4569 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4572 run_test 48d "Access removed parent subdir (should return errors)"
4574 test_48e() { # bug 4134
4575 #lctl set_param debug=-1
4578 test_mkdir -p $DIR/$tdir/dir
4580 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4581 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4582 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4583 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4584 # On a buggy kernel addition of "touch foo" after cd .. will
4585 # produce kernel oops in lookup_hash_it
4586 touch ../foo && error "'cd ..' worked after recreate parent"
4588 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4590 run_test 48e "Access to recreated parent subdir (should return errors)"
4592 test_49() { # LU-1030
4593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4594 remote_ost_nodsh && skip "remote OST with nodsh"
4596 # get ost1 size - lustre-OST0000
4597 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4599 # write 800M at maximum
4600 [[ $ost1_size -lt 2 ]] && ost1_size=2
4601 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4603 $LFS setstripe -c 1 -i 0 $DIR/$tfile
4604 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4607 # change max_pages_per_rpc while writing the file
4608 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4609 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4610 # loop until dd process exits
4611 while ps ax -opid | grep -wq $dd_pid; do
4612 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4613 sleep $((RANDOM % 5 + 1))
4615 # restore original max_pages_per_rpc
4616 $LCTL set_param $osc1_mppc=$orig_mppc
4617 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4619 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4623 test_mkdir $DIR/$tdir
4625 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4627 run_test 50 "special situations: /proc symlinks ==============="
4629 test_51a() { # was test_51
4630 # bug 1516 - create an empty entry right after ".." then split dir
4631 test_mkdir -c1 $DIR/$tdir
4632 touch $DIR/$tdir/foo
4633 $MCREATE $DIR/$tdir/bar
4635 createmany -m $DIR/$tdir/longfile 201
4637 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4638 $MCREATE $DIR/$tdir/longfile$FNUM
4643 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4645 run_test 51a "special situations: split htree with empty entry =="
4647 cleanup_print_lfs_df () {
4654 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4656 local dir=$DIR/$tdir
4657 local nrdirs=$((65536 + 100))
4659 # cleanup the directory
4666 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
4667 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4668 [[ $numfree -lt $nrdirs ]] &&
4669 skip "not enough free inodes ($numfree) on MDT$mdtidx"
4671 # need to check free space for the directories as well
4672 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4673 numfree=$(( blkfree / $(fs_inode_ksize) ))
4674 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
4676 trap cleanup_print_lfs_df EXIT
4679 createmany -d $dir/d $nrdirs || {
4680 unlinkmany $dir/d $nrdirs
4681 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4685 nrdirs=$(ls -U $dir | wc -l)
4687 # unlink all but 100 subdirectories, then check it still works
4689 local delete=$((nrdirs - left))
4694 # for ldiskfs the nlink count should be 1, but this is OSD specific
4695 # and so this is listed for informational purposes only
4696 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4697 unlinkmany -d $dir/d $delete ||
4698 error "unlink of first $delete subdirs failed"
4700 echo "nlink between: $(stat -c %h $dir)"
4701 local found=$(ls -U $dir | wc -l)
4702 [ $found -ne $left ] &&
4703 error "can't find subdirs: found only $found, expected $left"
4705 unlinkmany -d $dir/d $delete $left ||
4706 error "unlink of second $left subdirs failed"
4707 # regardless of whether the backing filesystem tracks nlink accurately
4708 # or not, the nlink count shouldn't be more than "." and ".." here
4709 local after=$(stat -c %h $dir)
4710 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4711 echo "nlink after: $after"
4713 cleanup_print_lfs_df
4715 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4718 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4719 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
4721 test_mkdir $DIR/$tdir
4722 createmany -o $DIR/$tdir/t- 1000
4723 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4724 for N in $(seq 0 $((OSTCOUNT - 1))); do
4725 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4726 END { printf("%0.0f", objs) }' $TMP/$tfile)
4727 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4728 '($1 == '$N') { objs += 1 } \
4729 END { printf("%0.0f", objs) }')
4730 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4732 unlinkmany $DIR/$tdir/t- 1000
4735 for N in $(seq 1 $((OSTCOUNT - 1))); do
4736 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4737 error "OST $N has less objects vs OST $NLAST" \
4738 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4739 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4740 error "OST $N has less objects vs OST $NLAST" \
4741 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4743 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4744 error "OST $N has less #0 objects vs OST $NLAST" \
4745 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4746 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4747 error "OST $N has less #0 objects vs OST $NLAST" \
4748 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4753 run_test 51d "check object distribution"
4756 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4757 skip_env "ldiskfs only test"
4760 test_mkdir -c1 $DIR/$tdir
4761 test_mkdir -c1 $DIR/$tdir/d0
4763 touch $DIR/$tdir/d0/foo
4764 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4765 error "file exceed 65000 nlink limit!"
4766 unlinkmany $DIR/$tdir/d0/f- 65001
4769 run_test 51e "check file nlink limit"
4772 test_mkdir $DIR/$tdir
4775 local ulimit_old=$(ulimit -n)
4776 local spare=20 # number of spare fd's for scripts/libraries, etc.
4777 local mdt=$($LFS getstripe -m $DIR/$tdir)
4778 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4780 echo "MDT$mdt numfree=$numfree, max=$max"
4781 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4782 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4783 while ! ulimit -n $((numfree + spare)); do
4784 numfree=$((numfree * 3 / 4))
4786 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4788 echo "left ulimit at $ulimit_old"
4791 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4792 unlinkmany $DIR/$tdir/f $numfree
4793 error "create+open $numfree files in $DIR/$tdir failed"
4795 ulimit -n $ulimit_old
4797 # if createmany exits at 120s there will be fewer than $numfree files
4798 unlinkmany $DIR/$tdir/f $numfree || true
4800 run_test 51f "check many open files limit"
4803 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4804 test_mkdir $DIR/$tdir
4805 touch $DIR/$tdir/foo
4806 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4807 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4808 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4809 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4810 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4812 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4813 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4814 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4816 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4817 cp -r $DIR/$tdir $TMP/
4818 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4820 run_test 52a "append-only flag test (should return errors)"
4823 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4824 test_mkdir $DIR/$tdir
4825 touch $DIR/$tdir/foo
4826 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4827 cat test > $DIR/$tdir/foo && error "cat test worked"
4828 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4829 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4830 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4832 echo foo >> $DIR/$tdir/foo && error "echo worked"
4833 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4834 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4835 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4836 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4838 chattr -i $DIR/$tdir/foo || error "chattr failed"
4840 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4842 run_test 52b "immutable flag test (should return errors) ======="
4845 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4846 remote_mds_nodsh && skip "remote MDS with nodsh"
4847 remote_ost_nodsh && skip "remote OST with nodsh"
4860 local support_last_seq=true
4862 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
4863 support_last_seq=false
4866 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4868 for value in $(do_facet $SINGLEMDS \
4869 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4870 param=$(echo ${value[0]} | cut -d "=" -f1)
4871 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4873 if $support_last_seq; then
4874 param_seq=$(echo $param |
4875 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4876 mds_last_seq=$(do_facet $SINGLEMDS \
4877 $LCTL get_param -n $param_seq)
4879 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4881 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4882 node=$(facet_active_host ost$((ostnum+1)))
4883 param="obdfilter.$ostname.last_id"
4884 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4885 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4886 ost_last_id=$ost_last
4888 if $support_last_seq; then
4889 ost_last_id=$(echo $ost_last |
4890 awk -F':' '{print $2}' |
4892 ost_last_seq=$(echo $ost_last |
4893 awk -F':' '{print $1}')
4894 [[ $ost_last_seq = $mds_last_seq ]] || continue
4897 if [[ $ost_last_id != $mds_last ]]; then
4898 error "$ost_last_id != $mds_last"
4905 $found || error "can not match last_seq/last_id for $mdtosc"
4908 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4911 perl -MSocket -e ';' || skip "no Socket perl module installed"
4913 $SOCKETSERVER $DIR/socket ||
4914 error "$SOCKETSERVER $DIR/socket failed: $?"
4915 $SOCKETCLIENT $DIR/socket ||
4916 error "$SOCKETCLIENT $DIR/socket failed: $?"
4917 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4919 run_test 54a "unix domain socket test =========================="
4925 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
4927 run_test 54b "char device works in lustre ======================"
4930 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4931 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4932 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4934 for i in $(seq 3 7); do
4935 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4944 loopdev="$DIR/loop54c"
4947 $UMOUNT $DIR/$tdir || rc=$?
4948 losetup -d $loopdev || true
4949 losetup -d $LOOPDEV || true
4950 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4955 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4957 loopdev="$DIR/loop54c"
4960 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
4961 trap cleanup_54c EXIT
4962 mknod $loopdev b 7 $LOOPNUM
4963 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4964 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
4965 losetup $loopdev $DIR/$tfile ||
4966 error "can't set up $loopdev for $DIR/$tfile"
4967 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4968 test_mkdir $DIR/$tdir
4969 mount -t ext2 $loopdev $DIR/$tdir ||
4970 error "error mounting $loopdev on $DIR/$tdir"
4971 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
4974 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
4978 run_test 54c "block device works in lustre ====================="
4984 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4986 run_test 54d "fifo device works in lustre ======================"
4991 cp -aL /dev/console $f
4992 echo $string > $f || error "echo $string to $f failed"
4994 run_test 54e "console/tty device works in lustre ======================"
4998 local dir=$DIR/$tdir
5001 test_mkdir -p $dir/dir
5002 for i in $(seq $numfiles); do
5004 touch $dir/dir/file$i
5007 local numcomp=$($LFS getstripe --component-count $dir)
5009 [[ $numcomp == 0 ]] && numcomp=1
5011 # test lfs getstripe with --recursive
5012 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5014 [[ $filenum -eq $((numfiles * 2)) ]] ||
5015 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5016 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5017 [[ $filenum -eq $numfiles ]] ||
5018 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5019 echo "$LFS getstripe showed obdidx or l_ost_idx"
5021 # test lfs getstripe with file instead of dir
5022 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5023 [[ $filenum -eq 1 ]] ||
5024 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5025 echo "$LFS getstripe file1 passed"
5027 #test lfs getstripe with --verbose
5028 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5029 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5030 error "$LFS getstripe --verbose $dir: "\
5031 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5032 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5033 error "$LFS getstripe $dir: showed lmm_magic"
5035 #test lfs getstripe with -v prints lmm_fid
5036 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5037 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5038 error "$LFS getstripe -v $dir: "\
5039 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5040 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5041 error "$LFS getstripe $dir: showed lmm_fid by default"
5042 echo "$LFS getstripe --verbose passed"
5044 #check for FID information
5045 local fid1=$($LFS getstripe --fid $dir/file1)
5046 local fid2=$($LFS getstripe --verbose $dir/file1 |
5047 awk '/lmm_fid: / { print $2; exit; }')
5048 local fid3=$($LFS path2fid $dir/file1)
5050 [ "$fid1" != "$fid2" ] &&
5051 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5052 [ "$fid1" != "$fid3" ] &&
5053 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5054 echo "$LFS getstripe --fid passed"
5056 #test lfs getstripe with --obd
5057 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5058 error "$LFS getstripe --obd wrong_uuid: should return error"
5060 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5063 local obduuid=$(ostuuid_from_index $ostidx)
5064 local found=$($LFS getstripe -r --obd $obduuid $dir |
5065 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5067 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5068 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5070 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5073 [[ $found -eq $filenum ]] ||
5074 error "$LFS getstripe --obd: found $found expect $filenum"
5075 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5076 sed '/^[ ]*'${ostidx}'[ ]/d' |
5077 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5078 error "$LFS getstripe --obd: should not show file on other obd"
5079 echo "$LFS getstripe --obd passed"
5081 run_test 56a "check $LFS getstripe"
5084 local dir=$DIR/$tdir
5088 for i in $(seq $numdirs); do
5089 test_mkdir $dir/dir$i
5092 # test lfs getdirstripe default mode is non-recursion, which is
5093 # different from lfs getstripe
5094 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5096 [[ $dircnt -eq 1 ]] ||
5097 error "$LFS getdirstripe: found $dircnt, not 1"
5098 dircnt=$($LFS getdirstripe --recursive $dir |
5099 grep -c lmv_stripe_count)
5100 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5101 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5103 run_test 56b "check $LFS getdirstripe"
5106 remote_ost_nodsh && skip "remote OST with nodsh"
5109 local ost_name=$(ostname_from_index $ost_idx)
5110 local old_status=$(ost_dev_status $ost_idx)
5112 [[ -z "$old_status" ]] ||
5113 skip_env "OST $ost_name is in $old_status status"
5115 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5118 local new_status=$(ost_dev_status $ost_idx)
5120 [[ "$new_status" = "D" ]] ||
5121 error "OST $ost_name is in status of '$new_status', not 'D'"
5123 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5126 new_status=$(ost_dev_status $ost_idx)
5127 [[ -z "$new_status" ]] ||
5128 error "OST $ost_name is in status of '$new_status', not ''"
5130 run_test 56c "check 'lfs df' showing device status"
5135 local local_tdir="$1"
5136 local local_numfiles="$2"
5137 local local_numdirs="$3"
5138 local dir_params="$4"
5139 local dir_stripe_params="$5"
5141 if [ ! -d "$local_tdir" ] ; then
5142 test_mkdir -p $dir_stripe_params $local_tdir
5143 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5144 for i in $(seq $local_numfiles) ; do
5145 touch $local_tdir/file$i
5147 for i in $(seq $local_numdirs) ; do
5148 test_mkdir $dir_stripe_params $local_tdir/dir$i
5149 for j in $(seq $local_numfiles) ; do
5150 touch $local_tdir/dir$i/file$j
5156 setup_56_special() {
5158 local local_numfiles=$2
5159 local local_numdirs=$3
5161 setup_56 $local_tdir $local_numfiles $local_numdirs
5163 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5164 for i in $(seq $local_numfiles) ; do
5165 mknod $local_tdir/loop${i}b b 7 $i
5166 mknod $local_tdir/null${i}c c 1 3
5167 ln -s $local_tdir/file1 $local_tdir/link${i}
5169 for i in $(seq $local_numdirs) ; do
5170 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5171 mknod $local_tdir/dir$i/null${i}c c 1 3
5172 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5178 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5179 local expected=$(($NUMDIRS + 2))
5181 setup_56 $dir $NUMFILES $NUMDIRS
5183 # test lfs find with -name
5184 for i in $(seq $NUMFILES) ; do
5185 local nums=$($LFS find -name "*$i" $dir | wc -l)
5187 [ $nums -eq $expected ] ||
5188 error "lfs find -name '*$i' $dir wrong: "\
5189 "found $nums, expected $expected"
5192 run_test 56g "check lfs find -name"
5195 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5196 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5198 setup_56 $dir $NUMFILES $NUMDIRS
5200 # test lfs find with ! -name
5201 for i in $(seq $NUMFILES) ; do
5202 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5204 [ $nums -eq $expected ] ||
5205 error "lfs find ! -name '*$i' $dir wrong: "\
5206 "found $nums, expected $expected"
5209 run_test 56h "check lfs find ! -name"
5212 local dir=$DIR/$tdir
5216 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5219 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5221 run_test 56i "check 'lfs find -ost UUID' skips directories"
5224 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5226 setup_56_special $dir $NUMFILES $NUMDIRS
5228 local expected=$((NUMDIRS + 1))
5229 local cmd="$LFS find -type d $dir"
5230 local nums=$($cmd | wc -l)
5232 [ $nums -eq $expected ] ||
5233 error "'$cmd' wrong: found $nums, expected $expected"
5235 run_test 56j "check lfs find -type d"
5238 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5240 setup_56_special $dir $NUMFILES $NUMDIRS
5242 local expected=$(((NUMDIRS + 1) * NUMFILES))
5243 local cmd="$LFS find -type f $dir"
5244 local nums=$($cmd | wc -l)
5246 [ $nums -eq $expected ] ||
5247 error "'$cmd' wrong: found $nums, expected $expected"
5249 run_test 56k "check lfs find -type f"
5252 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5254 setup_56_special $dir $NUMFILES $NUMDIRS
5256 local expected=$((NUMDIRS + NUMFILES))
5257 local cmd="$LFS find -type b $dir"
5258 local nums=$($cmd | wc -l)
5260 [ $nums -eq $expected ] ||
5261 error "'$cmd' wrong: found $nums, expected $expected"
5263 run_test 56l "check lfs find -type b"
5266 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5268 setup_56_special $dir $NUMFILES $NUMDIRS
5270 local expected=$((NUMDIRS + NUMFILES))
5271 local cmd="$LFS find -type c $dir"
5272 local nums=$($cmd | wc -l)
5273 [ $nums -eq $expected ] ||
5274 error "'$cmd' wrong: found $nums, expected $expected"
5276 run_test 56m "check lfs find -type c"
5279 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5280 setup_56_special $dir $NUMFILES $NUMDIRS
5282 local expected=$((NUMDIRS + NUMFILES))
5283 local cmd="$LFS find -type l $dir"
5284 local nums=$($cmd | wc -l)
5286 [ $nums -eq $expected ] ||
5287 error "'$cmd' wrong: found $nums, expected $expected"
5289 run_test 56n "check lfs find -type l"
5292 local dir=$DIR/$tdir
5294 setup_56 $dir $NUMFILES $NUMDIRS
5295 utime $dir/file1 > /dev/null || error "utime (1)"
5296 utime $dir/file2 > /dev/null || error "utime (2)"
5297 utime $dir/dir1 > /dev/null || error "utime (3)"
5298 utime $dir/dir2 > /dev/null || error "utime (4)"
5299 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5300 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5303 local nums=$($LFS find -mtime +0 $dir | wc -l)
5305 [ $nums -eq $expected ] ||
5306 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5309 cmd="$LFS find -mtime 0 $dir"
5310 nums=$($cmd | wc -l)
5311 [ $nums -eq $expected ] ||
5312 error "'$cmd' wrong: found $nums, expected $expected"
5314 run_test 56o "check lfs find -mtime for old files"
5317 local dir=$DIR/$tdir
5321 # just to make sure there is something that won't be found
5323 touch $dir/$tfile.now
5325 for age in year week day hour min; do
5326 count=$((count + 1))
5328 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
5329 touch --date="$count $age ago" -a $dir/$tfile-a.$age
5330 touch --date="$count $age ago" -m $dir/$tfile-m.$age
5332 local cmd="$LFS find $dir -mtime $count${age:0:1}"
5333 local nums=$($cmd | wc -l)
5334 [ $nums -eq $expected ] ||
5335 error "'$cmd' wrong: found $nums, expected $expected"
5337 cmd="$LFS find $dir -atime $count${age:0:1}"
5338 nums=$($cmd | wc -l)
5339 [ $nums -eq $expected ] ||
5340 error "'$cmd' wrong: found $nums, expected $expected"
5344 cmd="$LFS find $dir -ctime +1s -type f"
5345 nums=$($cmd | wc -l)
5346 (( $nums == $count * 2 + 1)) ||
5347 error "'$cmd' wrong: found $nums, expected $((expected*2+1))"
5349 run_test 56ob "check lfs find -atime -mtime -ctime with units"
5352 [ $RUNAS_ID -eq $UID ] &&
5353 skip_env "RUNAS_ID = UID = $UID -- skipping"
5355 local dir=$DIR/$tdir
5357 setup_56 $dir $NUMFILES $NUMDIRS
5358 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5360 local expected=$NUMFILES
5361 local cmd="$LFS find -uid $RUNAS_ID $dir"
5362 local nums=$($cmd | wc -l)
5364 [ $nums -eq $expected ] ||
5365 error "'$cmd' wrong: found $nums, expected $expected"
5367 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5368 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5369 nums=$($cmd | wc -l)
5370 [ $nums -eq $expected ] ||
5371 error "'$cmd' wrong: found $nums, expected $expected"
5373 run_test 56p "check lfs find -uid and ! -uid"
5376 [ $RUNAS_ID -eq $UID ] &&
5377 skip_env "RUNAS_ID = UID = $UID -- skipping"
5379 local dir=$DIR/$tdir
5381 setup_56 $dir $NUMFILES $NUMDIRS
5382 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5384 local expected=$NUMFILES
5385 local cmd="$LFS find -gid $RUNAS_GID $dir"
5386 local nums=$($cmd | wc -l)
5388 [ $nums -eq $expected ] ||
5389 error "'$cmd' wrong: found $nums, expected $expected"
5391 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5392 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5393 nums=$($cmd | wc -l)
5394 [ $nums -eq $expected ] ||
5395 error "'$cmd' wrong: found $nums, expected $expected"
5397 run_test 56q "check lfs find -gid and ! -gid"
5400 local dir=$DIR/$tdir
5402 setup_56 $dir $NUMFILES $NUMDIRS
5405 local cmd="$LFS find -size 0 -type f $dir"
5406 local nums=$($cmd | wc -l)
5408 [ $nums -eq $expected ] ||
5409 error "'$cmd' wrong: found $nums, expected $expected"
5411 cmd="$LFS find ! -size 0 -type f $dir"
5412 nums=$($cmd | wc -l)
5413 [ $nums -eq $expected ] ||
5414 error "'$cmd' wrong: found $nums, expected $expected"
5415 echo "test" > $dir/$tfile
5416 echo "test2" > $dir/$tfile.2 && sync
5418 cmd="$LFS find -size 5 -type f $dir"
5419 nums=$($cmd | wc -l)
5420 [ $nums -eq $expected ] ||
5421 error "'$cmd' wrong: found $nums, expected $expected"
5423 cmd="$LFS find -size +5 -type f $dir"
5424 nums=$($cmd | wc -l)
5425 [ $nums -eq $expected ] ||
5426 error "'$cmd' wrong: found $nums, expected $expected"
5428 cmd="$LFS find -size +0 -type f $dir"
5429 nums=$($cmd | wc -l)
5430 [ $nums -eq $expected ] ||
5431 error "'$cmd' wrong: found $nums, expected $expected"
5433 cmd="$LFS find ! -size -5 -type f $dir"
5434 nums=$($cmd | wc -l)
5435 [ $nums -eq $expected ] ||
5436 error "'$cmd' wrong: found $nums, expected $expected"
5438 cmd="$LFS find -size -5 -type f $dir"
5439 nums=$($cmd | wc -l)
5440 [ $nums -eq $expected ] ||
5441 error "'$cmd' wrong: found $nums, expected $expected"
5443 run_test 56r "check lfs find -size works"
5445 test_56s() { # LU-611 #LU-9369
5446 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
5448 local dir=$DIR/$tdir
5449 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5451 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5452 for i in $(seq $NUMDIRS); do
5453 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5456 local expected=$NUMDIRS
5457 local cmd="$LFS find -c $OSTCOUNT $dir"
5458 local nums=$($cmd | wc -l)
5460 [ $nums -eq $expected ] || {
5461 $LFS getstripe -R $dir
5462 error "'$cmd' wrong: found $nums, expected $expected"
5465 expected=$((NUMDIRS + onestripe))
5466 cmd="$LFS find -stripe-count +0 -type f $dir"
5467 nums=$($cmd | wc -l)
5468 [ $nums -eq $expected ] || {
5469 $LFS getstripe -R $dir
5470 error "'$cmd' wrong: found $nums, expected $expected"
5474 cmd="$LFS find -stripe-count 1 -type f $dir"
5475 nums=$($cmd | wc -l)
5476 [ $nums -eq $expected ] || {
5477 $LFS getstripe -R $dir
5478 error "'$cmd' wrong: found $nums, expected $expected"
5481 cmd="$LFS find -stripe-count -2 -type f $dir"
5482 nums=$($cmd | wc -l)
5483 [ $nums -eq $expected ] || {
5484 $LFS getstripe -R $dir
5485 error "'$cmd' wrong: found $nums, expected $expected"
5489 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5490 nums=$($cmd | wc -l)
5491 [ $nums -eq $expected ] || {
5492 $LFS getstripe -R $dir
5493 error "'$cmd' wrong: found $nums, expected $expected"
5496 run_test 56s "check lfs find -stripe-count works"
5498 test_56t() { # LU-611 #LU-9369
5499 local dir=$DIR/$tdir
5501 setup_56 $dir 0 $NUMDIRS
5502 for i in $(seq $NUMDIRS); do
5503 $LFS setstripe -S 8M $dir/dir$i/$tfile
5506 local expected=$NUMDIRS
5507 local cmd="$LFS find -S 8M $dir"
5508 local nums=$($cmd | wc -l)
5510 [ $nums -eq $expected ] || {
5511 $LFS getstripe -R $dir
5512 error "'$cmd' wrong: found $nums, expected $expected"
5516 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5518 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5520 expected=$(((NUMDIRS + 1) * NUMFILES))
5521 cmd="$LFS find -stripe-size 512k -type f $dir"
5522 nums=$($cmd | wc -l)
5523 [ $nums -eq $expected ] ||
5524 error "'$cmd' wrong: found $nums, expected $expected"
5526 cmd="$LFS find -stripe-size +320k -type f $dir"
5527 nums=$($cmd | wc -l)
5528 [ $nums -eq $expected ] ||
5529 error "'$cmd' wrong: found $nums, expected $expected"
5531 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5532 cmd="$LFS find -stripe-size +200k -type f $dir"
5533 nums=$($cmd | wc -l)
5534 [ $nums -eq $expected ] ||
5535 error "'$cmd' wrong: found $nums, expected $expected"
5537 cmd="$LFS find -stripe-size -640k -type f $dir"
5538 nums=$($cmd | wc -l)
5539 [ $nums -eq $expected ] ||
5540 error "'$cmd' wrong: found $nums, expected $expected"
5543 cmd="$LFS find -stripe-size 256k -type f $dir"
5544 nums=$($cmd | wc -l)
5545 [ $nums -eq $expected ] ||
5546 error "'$cmd' wrong: found $nums, expected $expected"
5548 cmd="$LFS find -stripe-size -320k -type f $dir"
5549 nums=$($cmd | wc -l)
5550 [ $nums -eq $expected ] ||
5551 error "'$cmd' wrong: found $nums, expected $expected"
5554 cmd="$LFS find -stripe-size 1024k -type f $dir"
5555 nums=$($cmd | wc -l)
5556 [ $nums -eq $expected ] ||
5557 error "'$cmd' wrong: found $nums, expected $expected"
5559 run_test 56t "check lfs find -stripe-size works"
5561 test_56u() { # LU-611
5562 local dir=$DIR/$tdir
5564 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5566 if [[ $OSTCOUNT -gt 1 ]]; then
5567 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5573 local expected=$(((NUMDIRS + 1) * NUMFILES))
5574 local cmd="$LFS find -stripe-index 0 -type f $dir"
5575 local nums=$($cmd | wc -l)
5577 [ $nums -eq $expected ] ||
5578 error "'$cmd' wrong: found $nums, expected $expected"
5581 cmd="$LFS find -stripe-index 1 -type f $dir"
5582 nums=$($cmd | wc -l)
5583 [ $nums -eq $expected ] ||
5584 error "'$cmd' wrong: found $nums, expected $expected"
5586 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5587 nums=$($cmd | wc -l)
5588 [ $nums -eq $expected ] ||
5589 error "'$cmd' wrong: found $nums, expected $expected"
5592 # This should produce an error and not return any files
5593 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5594 nums=$($cmd 2>/dev/null | wc -l)
5595 [ $nums -eq $expected ] ||
5596 error "'$cmd' wrong: found $nums, expected $expected"
5598 if [[ $OSTCOUNT -gt 1 ]]; then
5599 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5600 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5601 nums=$($cmd | wc -l)
5602 [ $nums -eq $expected ] ||
5603 error "'$cmd' wrong: found $nums, expected $expected"
5606 run_test 56u "check lfs find -stripe-index works"
5610 local dir=$DIR/$tdir
5612 setup_56 $dir $NUMFILES $NUMDIRS
5614 UUID=$(mdtuuid_from_index $mdt_idx $dir)
5615 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
5617 for file in $($LFS find -m $UUID $dir); do
5618 file_midx=$($LFS getstripe -m $file)
5619 [ $file_midx -eq $mdt_idx ] ||
5620 error "lfs find -m $UUID != getstripe -m $file_midx"
5623 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
5626 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5629 local dir=$DIR/$tdir
5631 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5633 local stripe_size=$($LFS getstripe -S -d $dir) ||
5634 error "$LFS getstripe -S -d $dir failed"
5635 stripe_size=${stripe_size%% *}
5637 local file_size=$((stripe_size * OSTCOUNT))
5638 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5639 local required_space=$((file_num * file_size))
5640 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5642 [[ $free_space -le $((required_space / 1024)) ]] &&
5643 skip_env "need $required_space, have $free_space kbytes"
5646 local dd_count=$((file_size / dd_bs))
5648 # write data into the files
5653 for i in $(seq $NUMFILES); do
5655 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5656 error "write data into $file failed"
5658 for i in $(seq $NUMDIRS); do
5659 for j in $(seq $NUMFILES); do
5660 file=$dir/dir$i/file$j
5661 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5662 error "write data into $file failed"
5666 # $LFS_MIGRATE will fail if hard link migration is unsupported
5667 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5668 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5669 error "creating links to $dir/dir1/file1 failed"
5674 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5677 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5680 eval $cmd || error "$cmd failed"
5682 check_stripe_count $dir/file1 $expected
5684 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
5686 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5687 # OST 1 if it is on OST 0. This file is small enough to
5688 # be on only one stripe.
5689 file=$dir/migr_1_ost
5690 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5691 error "write data into $file failed"
5692 local obdidx=$($LFS getstripe -i $file)
5693 local oldmd5=$(md5sum $file)
5696 [[ $obdidx -eq 0 ]] && newobdidx=1
5697 cmd="$LFS migrate -i $newobdidx $file"
5699 eval $cmd || error "$cmd failed"
5701 local realobdix=$($LFS getstripe -i $file)
5702 local newmd5=$(md5sum $file)
5704 [[ $newobdidx -ne $realobdix ]] &&
5705 error "new OST is different (was=$obdidx, "\
5706 "wanted=$newobdidx, got=$realobdix)"
5707 [[ "$oldmd5" != "$newmd5" ]] &&
5708 error "md5sum differ: $oldmd5, $newmd5"
5712 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5714 eval $cmd || error "$cmd failed"
5716 for j in $(seq $NUMFILES); do
5717 check_stripe_count $dir/dir1/file$j $expected
5720 # lfs_migrate works with lfs find
5721 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5722 $LFS_MIGRATE -y -c $expected"
5724 eval $cmd || error "$cmd failed"
5726 for i in $(seq 2 $NUMFILES); do
5727 check_stripe_count $dir/file$i $expected
5729 for i in $(seq 2 $NUMDIRS); do
5730 for j in $(seq $NUMFILES); do
5731 check_stripe_count $dir/dir$i/file$j $expected
5735 run_test 56w "check lfs_migrate -c stripe_count works"
5738 local file1=$DIR/$tdir/file1
5739 local create_pool=false
5740 local initial_pool=$($LFS getstripe -p $DIR)
5744 echo -n "Creating test dir..."
5745 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5748 echo -n "Creating test file..."
5749 touch $file1 || error "cannot create file"
5752 echo -n "Detecting existing pools..."
5753 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
5755 if [ ${#pool_list[@]} -gt 0 ]; then
5756 echo "${pool_list[@]}"
5757 for thispool in "${pool_list[@]}"; do
5758 if [[ -z "$initial_pool" ||
5759 "$initial_pool" != "$thispool" ]]; then
5761 echo "Using existing pool '$pool'"
5766 echo "none detected."
5768 if [ -z "$pool" ]; then
5769 pool=${POOL:-testpool}
5770 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5771 echo -n "Creating pool '$pool'..."
5773 pool_add $pool &> /dev/null ||
5774 error "pool_add failed"
5777 echo -n "Adding target to pool..."
5778 pool_add_targets $pool 0 0 1 &> /dev/null ||
5779 error "pool_add_targets failed"
5783 echo -n "Setting pool using -p option..."
5784 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5785 error "migrate failed rc = $?"
5788 echo -n "Verifying test file is in pool after migrating..."
5789 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5790 error "file was not migrated to pool $pool"
5793 echo -n "Removing test file from pool '$pool'..."
5794 $LFS migrate $file1 &> /dev/null ||
5795 error "cannot remove from pool"
5796 [ "$($LFS getstripe -p $file1)" ] &&
5797 error "pool still set"
5800 echo -n "Setting pool using --pool option..."
5801 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5802 error "migrate failed rc = $?"
5807 if $create_pool; then
5808 destroy_test_pools 2> /dev/null ||
5809 error "destroy test pools failed"
5812 run_test 56wb "check lfs_migrate pool support"
5815 local file1="$DIR/$tdir/file1"
5817 echo -n "Creating test dir..."
5818 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5819 local def_stripe_size=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
5820 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5821 error "cannot set stripe"
5824 echo -n "Setting initial stripe for test file..."
5825 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5826 error "cannot set stripe"
5827 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5828 error "stripe size not set"
5831 # File currently set to -S 512K -c 1
5833 # Ensure -c and -S options are rejected when -R is set
5834 echo -n "Verifying incompatible options are detected..."
5835 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5836 error "incompatible -c and -R options not detected"
5837 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5838 error "incompatible -S and -R options not detected"
5841 # Ensure unrecognized options are passed through to 'lfs migrate'
5842 echo -n "Verifying -S option is passed through to lfs migrate..."
5843 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5844 error "migration failed"
5845 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5846 error "file was not restriped"
5849 # File currently set to -S 1M -c 1
5851 # Ensure long options are supported
5852 echo -n "Verifying long options supported..."
5853 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5854 error "long option without argument not supported"
5855 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5856 error "long option with argument not supported"
5857 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5858 error "file not restriped with --stripe-size option"
5861 # File currently set to -S 512K -c 1
5863 if [ "$OSTCOUNT" -gt 1 ]; then
5864 echo -n "Verifying explicit stripe count can be set..."
5865 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5866 error "migrate failed"
5867 [ $($LFS getstripe -c "$file1") -eq 2 ] ||
5868 error "file not restriped to explicit count"
5872 # File currently set to -S 512K -c 1 or -S 512K -c 2
5874 # Ensure parent striping is used if -R is set, and no stripe
5875 # count or size is specified
5876 echo -n "Setting stripe for parent directory..."
5877 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5878 error "cannot set stripe"
5881 echo -n "Verifying restripe option uses parent stripe settings..."
5882 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5883 error "migrate failed"
5884 [ $($LFS getstripe -S "$file1") -eq $def_stripe_size ] ||
5885 error "file not restriped to parent settings"
5886 [ $($LFS getstripe -c "$file1") -eq 1 ] ||
5887 error "file not restriped to parent settings"
5890 # File currently set to -S 1M -c 1
5892 # Ensure striping is preserved if -R is not set, and no stripe
5893 # count or size is specified
5894 echo -n "Verifying striping size preserved when not specified..."
5895 local orig_stripe_size=$($LFS getstripe -S "$file1" 2>/dev/null)
5896 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5897 error "cannot set stripe on parent directory"
5898 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5899 error "migrate failed"
5900 [ $($LFS getstripe -S "$file1") -eq $orig_stripe_size ] ||
5901 error "file was restriped"
5904 # Ensure file name properly detected when final option has no argument
5905 echo -n "Verifying file name properly detected..."
5906 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5907 error "file name interpreted as option argument"
5913 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5916 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5918 local file1=$DIR/$tdir/file1
5920 echo -n "Creating test dir..."
5921 test_mkdir $DIR/$tdir || error "cannot create dir"
5924 echo -n "Creating test file..."
5928 # Ensure 'lfs migrate' will fail by using a non-existent option,
5929 # and make sure rsync is not called to recover
5930 echo -n "Make sure --no-rsync option works..."
5931 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
5932 grep -q 'refusing to fall back to rsync' ||
5933 error "rsync was called with --no-rsync set"
5936 # Ensure rsync is called without trying 'lfs migrate' first
5937 echo -n "Make sure --rsync option works..."
5938 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
5939 grep -q 'falling back to rsync' &&
5940 error "lfs migrate was called with --rsync set"
5943 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
5944 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
5945 grep -q 'at the same time' ||
5946 error "--rsync and --no-rsync accepted concurrently"
5952 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
5955 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5956 check_swap_layouts_support
5958 local dir=$DIR/$tdir
5959 local ref1=/etc/passwd
5960 local file1=$dir/file1
5962 test_mkdir $dir || error "creating dir $dir"
5963 $LFS setstripe -c 2 $file1
5965 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5966 stripe=$($LFS getstripe -c $file1)
5967 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5968 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5973 run_test 56x "lfs migration support"
5976 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5977 check_swap_layouts_support
5979 local dir=$DIR/$tdir/$testnum
5983 local ref1=/etc/passwd
5984 local file1=$dir/file1
5986 $LFS setstripe -c 2 $file1
5988 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5990 local stripe=$($LFS getstripe -c $file1)
5992 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5993 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5998 run_test 56xa "lfs migration --block support"
6000 check_migrate_links() {
6002 local file1="$dir/file1"
6005 local total_count=$(($begin + $count - 1))
6006 local symlink_count=10
6009 if [ ! -f "$file1" ]; then
6010 echo -n "creating initial file..."
6011 $LFS setstripe -c 1 -S "512k" "$file1" ||
6012 error "cannot setstripe initial file"
6015 echo -n "creating symlinks..."
6016 for s in $(seq 1 $symlink_count); do
6017 ln -s "$file1" "$dir/slink$s" ||
6018 error "cannot create symlinks"
6022 echo -n "creating nonlinked files..."
6023 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6024 error "cannot create nonlinked files"
6029 if [ ! -f "$dir/file$total_count" ]; then
6030 echo -n "creating hard links $begin:$total_count..."
6031 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6032 /dev/null || error "cannot create hard links"
6036 echo -n "checking number of hard links listed in xattrs..."
6037 local fid=$($LFS getstripe -F "$file1")
6038 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6041 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6042 skip "hard link list has unexpected size, skipping test"
6044 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6045 error "link names should exceed xattrs size"
6048 echo -n "migrating files..."
6049 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
6051 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6054 # make sure all links have been properly migrated
6055 echo -n "verifying files..."
6056 fid=$($LFS getstripe -F "$file1") ||
6057 error "cannot get fid for file $file1"
6058 for i in $(seq 2 $total_count); do
6059 local fid2=$($LFS getstripe -F $dir/file$i)
6061 [ "$fid2" == "$fid" ] ||
6062 error "migrated hard link has mismatched FID"
6065 # make sure hard links were properly detected, and migration was
6066 # performed only once for the entire link set; nonlinked files should
6068 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
6069 local expected=$(($uniq_count + 1))
6071 [ "$actual" -eq "$expected" ] ||
6072 error "hard links individually migrated ($actual != $expected)"
6074 # make sure the correct number of hard links are present
6075 local hardlinks=$(stat -c '%h' "$file1")
6077 [ $hardlinks -eq $total_count ] ||
6078 error "num hard links $hardlinks != $total_count"
6085 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6086 skip "Need MDS version at least 2.10.55"
6088 local dir="$DIR/$tdir"
6090 test_mkdir "$dir" || error "cannot create dir $dir"
6092 echo "testing lfs migrate mode when all links fit within xattrs"
6093 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6095 echo "testing rsync mode when all links fit within xattrs"
6096 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6098 echo "testing lfs migrate mode when all links do not fit within xattrs"
6099 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6101 echo "testing rsync mode when all links do not fit within xattrs"
6102 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6108 run_test 56xb "lfs migration hard link support"
6111 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6113 local dir="$DIR/$tdir"
6115 test_mkdir "$dir" || error "cannot create dir $dir"
6117 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6118 echo -n "Setting initial stripe for 20MB test file..."
6119 $LFS setstripe -c 2 -i 0 "$dir/20mb" || error "cannot setstripe"
6121 echo -n "Sizing 20MB test file..."
6122 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6124 echo -n "Verifying small file autostripe count is 1..."
6125 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" &> /dev/null ||
6126 error "cannot migrate 20MB file"
6127 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
6128 error "cannot get stripe for $dir/20mb"
6129 [ $stripe_count -eq 1 ] ||
6130 error "unexpected stripe count $stripe_count for 20MB file"
6134 # Test 2: File is small enough to fit within the available space on
6135 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
6136 # have at least an additional 1KB for each desired stripe for test 3
6137 echo -n "Setting stripe for 1GB test file..."
6138 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe"
6140 echo -n "Sizing 1GB test file..."
6141 # File size is 1GB + 3KB
6142 truncate "$dir/1gb" 1073744896 &> /dev/null ||
6143 error "cannot create 1GB test file"
6145 echo -n "Migrating 1GB file..."
6146 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" &> /dev/null ||
6147 error "cannot migrate file"
6149 echo -n "Verifying autostripe count is sqrt(n) + 1..."
6150 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
6151 error "cannot get stripe for $dir/1gb"
6152 [ $stripe_count -eq 2 ] ||
6153 error "unexpected stripe count $stripe_count (expected 2)"
6156 # Test 3: File is too large to fit within the available space on
6157 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
6158 if [ $OSTCOUNT -ge 3 ]; then
6159 # The required available space is calculated as
6160 # file size (1GB + 3KB) / OST count (3).
6161 local kb_per_ost=349526
6163 echo -n "Migrating 1GB file..."
6164 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" &>> \
6165 /dev/null || error "cannot migrate file"
6168 stripe_count=$($LFS getstripe -c "$dir/1gb")
6169 echo -n "Verifying autostripe count with limited space..."
6170 [ "$stripe_count" -a $stripe_count -eq 3 ] ||
6171 error "unexpected stripe count $stripe_count (wanted 3)"
6178 run_test 56xc "lfs migration autostripe"
6181 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
6182 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
6185 local dir=$DIR/$tdir
6189 test_mkdir -p $dir || error "creating dir $dir"
6190 touch $f1 || error "creating std file $f1"
6191 $MULTIOP $f2 H2c || error "creating released file $f2"
6193 # a directory can be raid0, so ask only for files
6194 res=$($LFS find $dir -L raid0 -type f | wc -l)
6195 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
6197 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
6198 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
6200 # only files can be released, so no need to force file search
6201 res=$($LFS find $dir -L released)
6202 [[ $res == $f2 ]] || error "search released: found $res != $f2"
6204 res=$($LFS find $dir -type f \! -L released)
6205 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
6207 run_test 56y "lfs find -L raid0|released"
6209 test_56z() { # LU-4824
6210 # This checks to make sure 'lfs find' continues after errors
6211 # There are two classes of errors that should be caught:
6212 # - If multiple paths are provided, all should be searched even if one
6214 # - If errors are encountered during the search, it should not terminate
6216 local dir=$DIR/$tdir
6220 for i in d{0..9}; do
6223 touch $dir/d{0..9}/$tfile
6224 $LFS find $DIR/non_existent_dir $dir &&
6225 error "$LFS find did not return an error"
6226 # Make a directory unsearchable. This should NOT be the last entry in
6227 # directory order. Arbitrarily pick the 6th entry
6228 chmod 700 $($LFS find $dir -type d | sed '6!d')
6230 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
6232 # The user should be able to see 10 directories and 9 files
6233 [ $count == 19 ] || error "$LFS find did not continue after error"
6235 run_test 56z "lfs find should continue after an error"
6237 test_56aa() { # LU-5937
6238 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
6240 local dir=$DIR/$tdir
6243 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
6245 createmany -o $dir/striped_dir/${tfile}- 1024
6246 local dirs=$($LFS find --size +8k $dir/)
6248 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
6250 run_test 56aa "lfs find --size under striped dir"
6252 test_56ab() { # LU-10705
6253 test_mkdir $DIR/$tdir
6254 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
6255 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
6256 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
6257 # Flush writes to ensure valid blocks. Need to be more thorough for
6258 # ZFS, since blocks are not allocated/returned to client immediately.
6260 wait_zfs_commit ost1 2
6261 cancel_lru_locks osc
6264 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
6266 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
6268 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
6269 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
6271 rm -f $DIR/$tdir/$tfile.[123]
6273 run_test 56ab "lfs find --blocks"
6276 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
6277 skip "Need MDS version at least 2.10.50"
6279 # Create composite files with one component
6280 local dir=$DIR/$tdir
6282 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
6283 # Create composite files with three components
6284 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
6285 # Create non-composite files
6286 createmany -o $dir/${tfile}- 10
6288 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
6290 [[ $nfiles == 10 ]] ||
6291 error "lfs find -E 1M found $nfiles != 10 files"
6293 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
6294 [[ $nfiles == 25 ]] ||
6295 error "lfs find ! -E 1M found $nfiles != 25 files"
6297 # All files have a component that starts at 0
6298 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
6299 [[ $nfiles == 35 ]] ||
6300 error "lfs find --component-start 0 - $nfiles != 35 files"
6302 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
6303 [[ $nfiles == 15 ]] ||
6304 error "lfs find --component-start 2M - $nfiles != 15 files"
6306 # All files created here have a componenet that does not starts at 2M
6307 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
6308 [[ $nfiles == 35 ]] ||
6309 error "lfs find ! --component-start 2M - $nfiles != 35 files"
6311 # Find files with a specified number of components
6312 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
6313 [[ $nfiles == 15 ]] ||
6314 error "lfs find --component-count 3 - $nfiles != 15 files"
6316 # Remember non-composite files have a component count of zero
6317 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
6318 [[ $nfiles == 10 ]] ||
6319 error "lfs find --component-count 0 - $nfiles != 10 files"
6321 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
6322 [[ $nfiles == 20 ]] ||
6323 error "lfs find ! --component-count 3 - $nfiles != 20 files"
6325 # All files have a flag called "init"
6326 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
6327 [[ $nfiles == 35 ]] ||
6328 error "lfs find --component-flags init - $nfiles != 35 files"
6330 # Multi-component files will have a component not initialized
6331 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
6332 [[ $nfiles == 15 ]] ||
6333 error "lfs find !--component-flags init - $nfiles != 15 files"
6338 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
6341 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
6342 skip "Need MDS version at least 2.10.57"
6352 # create mirrored directories and mirrored files
6353 mkdir $td || error "mkdir $td failed"
6354 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
6355 createmany -o $tf- 10 || error "create $tf- failed"
6357 for i in $(seq 2); do
6359 mkdir $dir || error "mkdir $dir failed"
6360 $LFS mirror create -N$((3 + i)) $dir ||
6361 error "create mirrored dir $dir failed"
6362 createmany -o $dir/$tfile- 10 ||
6363 error "create $dir/$tfile- failed"
6366 # change the states of some mirrored files
6368 for i in $(seq 2); do
6370 for j in $(seq 4 9); do
6371 echo foo > $dir/$tfile-$j
6375 # find mirrored files with specific mirror count
6376 cmd="$LFS find --mirror-count 3 --type f $td"
6377 nfiles=$($cmd | wc -l)
6378 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
6380 cmd="$LFS find ! --mirror-count 3 --type f $td"
6381 nfiles=$($cmd | wc -l)
6382 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
6384 cmd="$LFS find --mirror-count +2 --type f $td"
6385 nfiles=$($cmd | wc -l)
6386 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6388 cmd="$LFS find --mirror-count -6 --type f $td"
6389 nfiles=$($cmd | wc -l)
6390 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6392 # find mirrored files with specific file state
6393 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
6394 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
6396 cmd="$LFS find --mirror-state=ro --type f $td"
6397 nfiles=$($cmd | wc -l)
6398 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
6400 cmd="$LFS find ! --mirror-state=ro --type f $td"
6401 nfiles=$($cmd | wc -l)
6402 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6404 cmd="$LFS find --mirror-state=wp --type f $td"
6405 nfiles=$($cmd | wc -l)
6406 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6408 cmd="$LFS find ! --mirror-state=sp --type f $td"
6409 nfiles=$($cmd | wc -l)
6410 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6412 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6415 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6416 # note test will not do anything if MDS is not local
6417 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6418 skip_env "ldiskfs only test"
6420 remote_mds_nodsh && skip "remote MDS with nodsh"
6422 local MNTDEV="osd*.*MDT*.mntdev"
6423 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6424 [ -z "$DEV" ] && error "can't access $MNTDEV"
6425 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
6426 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
6427 error "can't access $DEV"
6428 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
6429 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
6433 run_test 57a "verify MDS filesystem created with large inodes =="
6436 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6437 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6438 skip_env "ldiskfs only test"
6440 remote_mds_nodsh && skip "remote MDS with nodsh"
6442 local dir=$DIR/$tdir
6445 local fileN=$dir/f$filecount
6447 rm -rf $dir || error "removing $dir"
6449 local mdtidx=$($LFS getstripe -m $dir)
6450 local mdtname=MDT$(printf %04x $mdtidx)
6451 local facet=mds$((mdtidx + 1))
6453 echo "mcreating $filecount files"
6454 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
6456 # verify that files do not have EAs yet
6457 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
6458 error "$file1 has an EA"
6459 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
6460 error "$fileN has an EA"
6464 df $dir #make sure we get new statfs data
6465 local mdsfree=$(do_facet $facet \
6466 lctl get_param -n osd*.*$mdtname.kbytesfree)
6467 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6470 echo "opening files to create objects/EAs"
6471 for file in $(seq -f $dir/f%g 1 $filecount); do
6472 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
6473 error "opening $file"
6476 # verify that files have EAs now
6477 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
6478 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
6480 sleep 1 #make sure we get new statfs data
6482 local mdsfree2=$(do_facet $facet \
6483 lctl get_param -n osd*.*$mdtname.kbytesfree)
6484 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6486 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
6487 if [ "$mdsfree" != "$mdsfree2" ]; then
6488 error "MDC before $mdcfree != after $mdcfree2"
6490 echo "MDC before $mdcfree != after $mdcfree2"
6491 echo "unable to confirm if MDS has large inodes"
6496 run_test 57b "default LOV EAs are stored inside large inodes ==="
6499 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6500 [ -z "$(which wiretest 2>/dev/null)" ] &&
6501 skip_env "could not find wiretest"
6505 run_test 58 "verify cross-platform wire constants =============="
6508 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6510 echo "touch 130 files"
6511 createmany -o $DIR/f59- 130
6513 unlinkmany $DIR/f59- 130
6515 # wait for commitment of removal
6516 wait_delete_completed
6518 run_test 59 "verify cancellation of llog records async ========="
6520 TEST60_HEAD="test_60 run $RANDOM"
6522 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6523 remote_mgs_nodsh && skip "remote MGS with nodsh"
6524 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6525 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6526 skip_env "missing subtest run-llog.sh"
6528 log "$TEST60_HEAD - from kernel mode"
6529 do_facet mgs "$LCTL dk > /dev/null"
6530 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
6531 do_facet mgs $LCTL dk > $TMP/$tfile
6533 # LU-6388: test llog_reader
6534 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6535 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6536 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6537 skip_env "missing llog_reader"
6538 local fstype=$(facet_fstype mgs)
6539 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6540 skip_env "Only for ldiskfs or zfs type mgs"
6542 local mntpt=$(facet_mntpt mgs)
6543 local mgsdev=$(mgsdevname 1)
6555 #get fid and record list
6556 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6558 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6560 #remount mgs as ldiskfs or zfs type
6561 stop mgs || error "stop mgs failed"
6562 mount_fstype mgs || error "remount mgs failed"
6563 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6566 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6567 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6572 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6574 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6576 echo "obj_file is $obj_file"
6577 do_facet mgs $llog_reader $obj_file
6579 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6580 awk '{ print $3 }' | sed -e "s/^type=//g")
6581 if [ $rec_type != $rec ]; then
6582 echo "FAILED test_60a wrong record type $rec_type," \
6588 #check obj path if record type is LLOG_LOGID_MAGIC
6589 if [ "$rec" == "1064553b" ]; then
6590 path=$(do_facet mgs $llog_reader $obj_file |
6591 grep "path=" | awk '{ print $NF }' |
6592 sed -e "s/^path=//g")
6593 if [ $obj_file != $mntpt/$path ]; then
6594 echo "FAILED test_60a wrong obj path" \
6595 "$montpt/$path, should be $obj_file"
6602 #restart mgs before "error", otherwise it will block the next test
6603 stop mgs || error "stop mgs failed"
6604 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6605 $pass || error "test failed, see FAILED test_60a messages for specifics"
6607 run_test 60a "llog_test run from kernel module and test llog_reader"
6609 test_60b() { # bug 6411
6610 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6613 LLOG_COUNT=$(do_facet mgs dmesg |
6614 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6615 /llog_[a-z]*.c:[0-9]/ {
6627 [[ $LLOG_COUNT -gt 120 ]] &&
6628 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6630 run_test 60b "limit repeated messages from CERROR/CWARN"
6633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6635 echo "create 5000 files"
6636 createmany -o $DIR/f60c- 5000
6637 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6638 lctl set_param fail_loc=0x80000137
6639 unlinkmany $DIR/f60c- 5000
6640 lctl set_param fail_loc=0
6642 run_test 60c "unlink file when mds full"
6645 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6647 SAVEPRINTK=$(lctl get_param -n printk)
6648 # verify "lctl mark" is even working"
6649 MESSAGE="test message ID $RANDOM $$"
6650 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6651 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6653 lctl set_param printk=0 || error "set lnet.printk failed"
6654 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6655 MESSAGE="new test message ID $RANDOM $$"
6656 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6657 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6658 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6660 lctl set_param -n printk="$SAVEPRINTK"
6662 run_test 60d "test printk console message masking"
6665 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6666 remote_mds_nodsh && skip "remote MDS with nodsh"
6669 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6670 do_facet mds1 lctl set_param fail_loc=0x15b
6673 run_test 60e "no space while new llog is being created"
6678 test_mkdir -c $MDSCOUNT $DIR/$tdir
6679 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir
6684 mkdir $DIR/$tdir/subdir$index 2>/dev/null
6685 rmdir $DIR/$tdir/subdir$index 2>/dev/null
6686 index=$((index + 1))
6692 for i in $(seq 100); do
6693 # define OBD_FAIL_OSD_TXN_START 0x19a
6694 do_facet mds1 lctl set_param fail_loc=0x8000019a
6700 mkdir $DIR/$tdir/new || error "mkdir failed"
6701 rmdir $DIR/$tdir/new || error "rmdir failed"
6703 run_test 60g "transaction abort won't cause MDT hung"
6706 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6709 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
6710 cancel_lru_locks osc
6711 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6714 run_test 61a "mmap() writes don't make sync hang ================"
6717 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
6719 run_test 61b "mmap() of unstriped file is successful"
6721 # bug 2330 - insufficient obd_match error checking causes LBUG
6723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6727 cancel_lru_locks osc
6728 lctl set_param fail_loc=0x405
6729 cat $f && error "cat succeeded, expect -EIO"
6730 lctl set_param fail_loc=0
6732 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6733 # match every page all of the time.
6734 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6736 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6737 # Though this test is irrelevant anymore, it helped to reveal some
6738 # other grant bugs (LU-4482), let's keep it.
6739 test_63a() { # was test_63
6740 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6742 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
6744 for i in `seq 10` ; do
6745 dd if=/dev/zero of=$DIR/f63 bs=8k &
6751 rm -f $DIR/f63 || true
6753 run_test 63a "Verify oig_wait interruption does not crash ======="
6755 # bug 2248 - async write errors didn't return to application on sync
6756 # bug 3677 - async write errors left page locked
6758 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6761 lctl set_param debug=-1
6763 # ensure we have a grant to do async writes
6764 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6767 sync # sync lest earlier test intercept the fail_loc
6769 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6770 lctl set_param fail_loc=0x80000406
6771 $MULTIOP $DIR/$tfile Owy && \
6772 error "sync didn't return ENOMEM"
6773 sync; sleep 2; sync # do a real sync this time to flush page
6774 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6775 error "locked page left in cache after async error" || true
6778 run_test 63b "async write errors should be returned to fsync ==="
6781 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6784 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6786 run_test 64a "verify filter grant calculations (in kernel) ====="
6789 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6791 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6793 run_test 64b "check out-of-space detection on client"
6796 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6798 run_test 64c "verify grant shrink"
6800 # this does exactly what osc_request.c:osc_announce_cached() does in
6801 # order to calculate max amount of grants to ask from server
6805 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
6806 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
6808 ((rpc_in_flight ++));
6809 nrpages=$((nrpages * rpc_in_flight))
6811 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
6813 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
6815 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6816 local undirty=$((nrpages * PAGE_SIZE))
6818 local max_extent_pages
6819 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
6820 grep grant_max_extent_size | awk '{print $2}')
6821 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
6822 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6823 local grant_extent_tax
6824 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6825 grep grant_extent_tax | awk '{print $2}')
6827 undirty=$((undirty + nrextents * grant_extent_tax))
6832 # this is size of unit for grant allocation. It should be equal to
6833 # what tgt_grant.c:tgt_grant_chunk() calculates
6837 local grant_extent_tax
6839 max_brw_size=$($LCTL get_param osc.${tgt}.import |
6840 grep max_brw_size | awk '{print $2}')
6842 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6843 grep grant_extent_tax | awk '{print $2}')
6845 echo $(((max_brw_size + grant_extent_tax) * 2))
6849 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
6850 skip "OST < 2.10.55 doesn't limit grants enough"
6852 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
6853 local file=$DIR/$tfile
6855 [[ $($LCTL get_param osc.${tgt}.import |
6856 grep "connect_flags:.*grant_param") ]] ||
6857 skip "no grant_param connect flag"
6859 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
6861 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
6863 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
6864 stack_trap "rm -f $file" EXIT
6866 $LFS setstripe $file -i 0 -c 1
6867 dd if=/dev/zero of=$file bs=1M count=1000 &
6872 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
6873 if [[ $cur_grant -gt $max_cur_granted ]]
6876 error "cur_grant $cur_grant > $max_cur_granted"
6879 [[ $? -ne 0 ]] && break;
6884 wait_delete_completed
6885 $LCTL set_param debug="$olddebug" 2> /dev/null || true
6887 run_test 64d "check grant limit exceed"
6889 # bug 1414 - set/get directories' stripe info
6891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6893 test_mkdir $DIR/$tdir
6895 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
6897 run_test 65a "directory with no stripe info"
6900 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6902 test_mkdir $DIR/$tdir
6903 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
6905 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6908 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
6910 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
6913 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6914 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
6916 test_mkdir $DIR/$tdir
6917 local stripesize=$($LFS getstripe -S $DIR/$tdir)
6919 $LFS setstripe -S $((stripesize * 4)) -i 1 \
6920 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
6922 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
6924 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
6927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6929 test_mkdir $DIR/$tdir
6930 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
6931 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
6933 if [[ $STRIPECOUNT -le 0 ]]; then
6935 elif [[ $STRIPECOUNT -gt 2000 ]]; then
6936 #LOV_MAX_STRIPE_COUNT is 2000
6937 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
6939 sc=$(($STRIPECOUNT - 1))
6941 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
6942 touch $DIR/$tdir/f4 $DIR/$tdir/f5
6943 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
6944 error "lverify failed"
6946 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
6949 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6951 test_mkdir $DIR/$tdir
6953 $LFS setstripe $DIR/$tdir || error "setstripe"
6954 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6955 error "no stripe info failed"
6957 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
6959 run_test 65e "directory setstripe defaults"
6962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6964 test_mkdir $DIR/${tdir}f
6965 $RUNAS $LFS setstripe $DIR/${tdir}f &&
6966 error "setstripe succeeded" || true
6968 run_test 65f "dir setstripe permission (should return error) ==="
6971 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6973 test_mkdir $DIR/$tdir
6974 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
6976 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6977 error "setstripe -S failed"
6978 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
6979 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6980 error "delete default stripe failed"
6982 run_test 65g "directory setstripe -d"
6985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6987 test_mkdir $DIR/$tdir
6988 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
6990 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6991 error "setstripe -S failed"
6992 test_mkdir $DIR/$tdir/dd1
6993 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
6994 error "stripe info inherit failed"
6996 run_test 65h "directory stripe info inherit ===================="
6999 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7001 save_layout_restore_at_exit $MOUNT
7003 # bug6367: set non-default striping on root directory
7004 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
7006 # bug12836: getstripe on -1 default directory striping
7007 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
7009 # bug12836: getstripe -v on -1 default directory striping
7010 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
7012 # bug12836: new find on -1 default directory striping
7013 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
7015 run_test 65i "various tests to set root directory striping"
7017 test_65j() { # bug6367
7018 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7022 # if we aren't already remounting for each test, do so for this test
7023 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
7024 cleanup || error "failed to unmount"
7028 save_layout_restore_at_exit $MOUNT
7030 $LFS setstripe -d $MOUNT || error "setstripe failed"
7032 run_test 65j "set default striping on root directory (bug 6367)="
7036 wait_delete_completed
7037 do_facet $SINGLEMDS "lctl set_param -n \
7038 osp.$ost*MDT0000.max_create_count=$max_count"
7039 do_facet $SINGLEMDS "lctl set_param -n \
7040 osp.$ost*MDT0000.create_count=$count"
7041 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7042 echo $INACTIVE_OSC "is Activate"
7044 wait_osc_import_state mds ost$ostnum FULL
7047 test_65k() { # bug11679
7048 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7049 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7050 remote_mds_nodsh && skip "remote MDS with nodsh"
7052 local disable_precreate=true
7053 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
7054 disable_precreate=false
7056 echo "Check OST status: "
7057 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
7058 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
7060 for OSC in $MDS_OSCS; do
7061 echo $OSC "is active"
7062 do_facet $SINGLEMDS lctl --device %$OSC activate
7065 for INACTIVE_OSC in $MDS_OSCS; do
7066 local ost=$(osc_to_ost $INACTIVE_OSC)
7067 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
7068 lov.*md*.target_obd |
7069 awk -F: /$ost/'{ print $1 }' | head -n 1)
7072 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
7073 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
7075 echo "Deactivate: " $INACTIVE_OSC
7076 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
7078 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
7079 osp.$ost*MDT0000.create_count")
7080 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
7081 osp.$ost*MDT0000.max_create_count")
7082 $disable_precreate &&
7083 do_facet $SINGLEMDS "lctl set_param -n \
7084 osp.$ost*MDT0000.max_create_count=0"
7086 for idx in $(seq 0 $((OSTCOUNT - 1))); do
7087 [ -f $DIR/$tdir/$idx ] && continue
7088 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
7089 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
7091 error "setstripe $idx should succeed"; }
7092 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
7094 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
7097 do_facet $SINGLEMDS "lctl set_param -n \
7098 osp.$ost*MDT0000.max_create_count=$max_count"
7099 do_facet $SINGLEMDS "lctl set_param -n \
7100 osp.$ost*MDT0000.create_count=$count"
7101 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7102 echo $INACTIVE_OSC "is Activate"
7104 wait_osc_import_state mds ost$ostnum FULL
7107 run_test 65k "validate manual striping works properly with deactivated OSCs"
7109 test_65l() { # bug 12836
7110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7112 test_mkdir -p $DIR/$tdir/test_dir
7113 $LFS setstripe -c -1 $DIR/$tdir/test_dir
7114 $LFS find -mtime -1 $DIR/$tdir >/dev/null
7116 run_test 65l "lfs find on -1 stripe dir ========================"
7119 local layout=$(save_layout $MOUNT)
7120 $RUNAS $LFS setstripe -c 2 $MOUNT && {
7121 restore_layout $MOUNT $layout
7122 error "setstripe should fail by non-root users"
7126 run_test 65m "normal user can't set filesystem default stripe"
7129 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
7130 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.12.50) ]] ||
7131 skip "Need MDS version at least 2.12.50"
7132 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7134 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7135 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
7136 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
7138 local root_layout=$(save_layout $MOUNT)
7139 stack_trap "restore_layout $MOUNT $root_layout" EXIT
7141 # new subdirectory under root directory should not inherit
7142 # the default layout from root
7143 local dir1=$MOUNT/$tdir-1
7144 mkdir $dir1 || error "mkdir $dir1 failed"
7145 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
7146 error "$dir1 shouldn't have LOV EA"
7148 # delete the default layout on root directory
7149 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
7151 local dir2=$MOUNT/$tdir-2
7152 mkdir $dir2 || error "mkdir $dir2 failed"
7153 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
7154 error "$dir2 shouldn't have LOV EA"
7156 # set a new striping pattern on root directory
7157 local def_stripe_size=$($LFS getstripe -S $MOUNT)
7158 local new_def_stripe_size=$((def_stripe_size * 2))
7159 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
7160 error "set stripe size on $MOUNT failed"
7162 # new file created in $dir2 should inherit the new stripe size from
7163 # the filesystem default
7164 local file2=$dir2/$tfile-2
7165 touch $file2 || error "touch $file2 failed"
7167 local file2_stripe_size=$($LFS getstripe -S $file2)
7168 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
7169 error "$file2 didn't inherit stripe size $new_def_stripe_size"
7171 local dir3=$MOUNT/$tdir-3
7172 mkdir $dir3 || error "mkdir $dir3 failed"
7173 ! getfattr -n trusted.lov $dir3 &> /dev/null ||
7174 error "$dir3 shouldn't have LOV EA"
7176 # set OST pool on root directory
7177 local pool=$TESTNAME
7178 pool_add $pool || error "add $pool failed"
7179 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
7180 error "add targets to $pool failed"
7182 $LFS setstripe -p $pool $MOUNT ||
7183 error "set OST pool on $MOUNT failed"
7185 # new file created in $dir3 should inherit the pool from
7186 # the filesystem default
7187 local file3=$dir3/$tfile-3
7188 touch $file3 || error "touch $file3 failed"
7190 local file3_pool=$($LFS getstripe -p $file3)
7191 [[ "$file3_pool" = "$pool" ]] ||
7192 error "$file3 didn't inherit OST pool $pool"
7194 local dir4=$MOUNT/$tdir-4
7195 mkdir $dir4 || error "mkdir $dir4 failed"
7196 ! getfattr -n trusted.lov $dir4 &> /dev/null ||
7197 error "$dir4 shouldn't have LOV EA"
7199 # new file created in $dir4 should inherit the pool from
7200 # the filesystem default
7201 local file4=$dir4/$tfile-4
7202 touch $file4 || error "touch $file4 failed"
7204 local file4_pool=$($LFS getstripe -p $file4)
7205 [[ "$file4_pool" = "$pool" ]] ||
7206 error "$file4 didn't inherit OST pool $pool"
7208 # new subdirectory under non-root directory should inherit
7209 # the default layout from its parent directory
7210 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
7211 error "set directory layout on $dir4 failed"
7213 local dir5=$dir4/$tdir-5
7214 mkdir $dir5 || error "mkdir $dir5 failed"
7216 local dir4_layout=$(get_layout_param $dir4)
7217 local dir5_layout=$(get_layout_param $dir5)
7218 [[ "$dir4_layout" = "$dir5_layout" ]] ||
7219 error "$dir5 should inherit the default layout from $dir4"
7221 run_test 65n "don't inherit default layout from root for new subdirectories"
7223 # bug 2543 - update blocks count on client
7225 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7228 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
7229 sync; sync_all_data; sync; sync_all_data
7230 cancel_lru_locks osc
7231 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
7232 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
7234 run_test 66 "update inode blocks count on client ==============="
7237 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
7241 swapon -s | awk '($1 == "'$1'") { print $4 }'
7244 # bug5265, obdfilter oa2dentry return -ENOENT
7245 # #define OBD_FAIL_SRV_ENOENT 0x217
7247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7248 remote_ost_nodsh && skip "remote OST with nodsh"
7251 $LFS setstripe -c 1 -i 0 $f
7253 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
7255 do_facet ost1 lctl set_param fail_loc=0x217
7256 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
7257 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
7259 do_facet ost1 lctl set_param fail_loc=0
7260 $DIRECTIO write $f 0 2 || error "write error"
7262 cancel_lru_locks osc
7263 $DIRECTIO read $f 0 1 || error "read error"
7265 do_facet ost1 lctl set_param fail_loc=0x217
7266 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
7268 do_facet ost1 lctl set_param fail_loc=0
7271 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
7274 test_mkdir $DIR/$tdir
7275 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
7276 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
7278 run_test 71 "Running dbench on lustre (don't segment fault) ===="
7280 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
7281 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7282 [ "$RUNAS_ID" = "$UID" ] &&
7283 skip_env "RUNAS_ID = UID = $UID -- skipping"
7284 # Check that testing environment is properly set up. Skip if not
7285 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
7286 skip_env "User $RUNAS_ID does not exist - skipping"
7289 chmod 777 $DIR/$tfile
7290 chmod ug+s $DIR/$tfile
7291 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
7292 error "$RUNAS dd $DIR/$tfile failed"
7293 # See if we are still setuid/sgid
7294 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
7295 error "S/gid is not dropped on write"
7296 # Now test that MDS is updated too
7297 cancel_lru_locks mdc
7298 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
7299 error "S/gid is not dropped on MDS"
7302 run_test 72a "Test that remove suid works properly (bug5695) ===="
7304 test_72b() { # bug 24226 -- keep mode setting when size is not changing
7307 [ "$RUNAS_ID" = "$UID" ] &&
7308 skip_env "RUNAS_ID = UID = $UID -- skipping"
7309 [ "$RUNAS_ID" -eq 0 ] &&
7310 skip_env "RUNAS_ID = 0 -- skipping"
7311 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7312 # Check that testing environment is properly set up. Skip if not
7313 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
7314 skip_env "User $RUNAS_ID does not exist - skipping"
7316 touch $DIR/${tfile}-f{g,u}
7317 test_mkdir $DIR/${tfile}-dg
7318 test_mkdir $DIR/${tfile}-du
7319 chmod 770 $DIR/${tfile}-{f,d}{g,u}
7320 chmod g+s $DIR/${tfile}-{f,d}g
7321 chmod u+s $DIR/${tfile}-{f,d}u
7322 for perm in 777 2777 4777; do
7323 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
7324 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
7325 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
7326 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
7330 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
7332 # bug 3462 - multiple simultaneous MDC requests
7334 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7336 test_mkdir $DIR/d73-1
7337 test_mkdir $DIR/d73-2
7338 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
7341 lctl set_param fail_loc=0x80000129
7342 $MULTIOP $DIR/d73-1/f73-2 Oc &
7344 lctl set_param fail_loc=0
7346 $MULTIOP $DIR/d73-2/f73-3 Oc &
7350 wait $pid1 || return 1
7354 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
7355 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
7356 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
7360 run_test 73 "multiple MDC requests (should not deadlock)"
7362 test_74a() { # bug 6149, 6184
7363 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7366 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7368 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7369 # will spin in a tight reconnection loop
7370 $LCTL set_param fail_loc=0x8000030e
7371 # get any lock that won't be difficult - lookup works.
7373 $LCTL set_param fail_loc=0
7377 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
7379 test_74b() { # bug 13310
7380 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7382 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7384 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7385 # will spin in a tight reconnection loop
7386 $LCTL set_param fail_loc=0x8000030e
7387 # get a "difficult" lock
7389 $LCTL set_param fail_loc=0
7393 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
7396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7398 #define OBD_FAIL_LDLM_NEW_LOCK
7399 $LCTL set_param fail_loc=0x319
7400 touch $DIR/$tfile && error "touch successful"
7401 $LCTL set_param fail_loc=0
7404 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
7407 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
7410 test_76() { # Now for bug 20433, added originally in bug 1443
7411 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7413 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
7415 cancel_lru_locks osc
7416 BEFORE_INODES=$(num_inodes)
7417 echo "before inodes: $BEFORE_INODES"
7419 [ "$SLOW" = "no" ] && COUNT=100
7420 for i in $(seq $COUNT); do
7424 cancel_lru_locks osc
7425 AFTER_INODES=$(num_inodes)
7426 echo "after inodes: $AFTER_INODES"
7428 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
7430 AFTER_INODES=$(num_inodes)
7432 echo "wait $wait seconds inodes: $AFTER_INODES"
7433 if [ $wait -gt 30 ]; then
7434 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
7438 run_test 76 "confirm clients recycle inodes properly ===="
7444 # Note: in sptlrpc modes which enable its own bulk checksum, the
7445 # original crc32_le bulk checksum will be automatically disabled,
7446 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
7447 # will be checked by sptlrpc code against sptlrpc bulk checksum.
7448 # In this case set_checksums() will not be no-op, because sptlrpc
7449 # bulk checksum will be enabled all through the test.
7451 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
7452 lctl set_param -n osc.*.checksums $1
7456 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7457 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
7458 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7459 tr -d [] | head -n1)}
7462 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
7463 log "set checksum type to $1"
7466 F77_TMP=$TMP/f77-temp
7469 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
7470 error "error writing to $F77_TMP"
7473 test_77a() { # bug 10889
7474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7475 $GSS && skip_env "could not run with gss"
7477 [ ! -f $F77_TMP ] && setup_f77
7479 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
7483 run_test 77a "normal checksum read/write operation"
7485 test_77b() { # bug 10889
7486 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7487 $GSS && skip_env "could not run with gss"
7489 [ ! -f $F77_TMP ] && setup_f77
7490 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7491 $LCTL set_param fail_loc=0x80000409
7494 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7495 error "dd error: $?"
7496 $LCTL set_param fail_loc=0
7498 for algo in $CKSUM_TYPES; do
7499 cancel_lru_locks osc
7500 set_checksum_type $algo
7501 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7502 $LCTL set_param fail_loc=0x80000408
7503 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7504 $LCTL set_param fail_loc=0
7507 set_checksum_type $ORIG_CSUM_TYPE
7510 run_test 77b "checksum error on client write, read"
7515 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7517 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7518 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7519 $check_ost && [ -n "$ost_file_prefix" ] &&
7520 do_facet ost1 rm -f ${ost_file_prefix}\*
7524 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7525 $GSS && skip_env "could not run with gss"
7526 remote_ost_nodsh && skip "remote OST with nodsh"
7529 local osc_file_prefix
7531 local check_ost=false
7532 local ost_file_prefix
7538 # ensure corruption will occur on first OSS/OST
7539 $LFS setstripe -i 0 $DIR/$tfile
7541 [ ! -f $F77_TMP ] && setup_f77
7542 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7543 error "dd write error: $?"
7544 fid=$($LFS path2fid $DIR/$tfile)
7546 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
7549 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7550 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7552 echo "OSS do not support bulk pages dump upon error"
7555 osc_file_prefix=$($LCTL get_param -n debug_path)
7556 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7558 trap cleanup_77c EXIT
7561 # enable bulk pages dump upon error on Client
7562 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7563 # enable bulk pages dump upon error on OSS
7565 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7567 # flush Client cache to allow next read to reach OSS
7568 cancel_lru_locks osc
7570 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7571 $LCTL set_param fail_loc=0x80000408
7572 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7573 $LCTL set_param fail_loc=0
7577 # check cksum dump on Client
7578 osc_file=$(ls ${osc_file_prefix}*)
7579 [ -n "$osc_file" ] || error "no checksum dump file on Client"
7580 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
7581 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
7582 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
7583 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
7585 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
7586 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7587 error "dump content does not match on Client"
7589 $check_ost || skip "No need to check cksum dump on OSS"
7591 # check cksum dump on OSS
7592 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
7593 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
7594 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
7595 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
7596 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7597 error "dump content does not match on OSS"
7601 run_test 77c "checksum error on client read with debug"
7603 test_77d() { # bug 10889
7604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7605 $GSS && skip_env "could not run with gss"
7607 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7608 $LCTL set_param fail_loc=0x80000409
7610 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7611 error "direct write: rc=$?"
7612 $LCTL set_param fail_loc=0
7615 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7616 $LCTL set_param fail_loc=0x80000408
7618 cancel_lru_locks osc
7619 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7620 error "direct read: rc=$?"
7621 $LCTL set_param fail_loc=0
7624 run_test 77d "checksum error on OST direct write, read"
7626 test_77f() { # bug 10889
7627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7628 $GSS && skip_env "could not run with gss"
7631 for algo in $CKSUM_TYPES; do
7632 cancel_lru_locks osc
7633 set_checksum_type $algo
7634 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7635 $LCTL set_param fail_loc=0x409
7636 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
7637 error "direct write succeeded"
7638 $LCTL set_param fail_loc=0
7640 set_checksum_type $ORIG_CSUM_TYPE
7643 run_test 77f "repeat checksum error on write (expect error)"
7645 test_77g() { # bug 10889
7646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7647 $GSS && skip_env "could not run with gss"
7648 remote_ost_nodsh && skip "remote OST with nodsh"
7650 [ ! -f $F77_TMP ] && setup_f77
7652 local file=$DIR/$tfile
7653 stack_trap "rm -f $file" EXIT
7655 $LFS setstripe -c 1 -i 0 $file
7656 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
7657 do_facet ost1 lctl set_param fail_loc=0x8000021a
7659 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
7660 error "write error: rc=$?"
7661 do_facet ost1 lctl set_param fail_loc=0
7664 cancel_lru_locks osc
7665 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
7666 do_facet ost1 lctl set_param fail_loc=0x8000021b
7668 cmp $F77_TMP $file || error "file compare failed"
7669 do_facet ost1 lctl set_param fail_loc=0
7672 run_test 77g "checksum error on OST write, read"
7674 test_77k() { # LU-10906
7675 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7676 $GSS && skip_env "could not run with gss"
7678 local cksum_param="osc.$FSNAME*.checksums"
7679 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
7683 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
7684 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
7685 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
7689 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
7690 error "failed to set checksum=$i on MGS"
7691 wait_update $HOSTNAME "$get_checksum" $i
7693 echo "remount client, checksum should be $i"
7694 remount_client $MOUNT || "failed to remount client"
7695 checksum=$(eval $get_checksum)
7696 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7698 # remove persistent param to avoid races with checksum mountopt below
7699 do_facet mgs $LCTL set_param -P -d $cksum_param ||
7700 error "failed to delete checksum on MGS"
7702 for opt in "checksum" "nochecksum"; do
7703 #remount with mount option
7704 echo "remount client with option $opt, checksum should be $i"
7705 umount_client $MOUNT || "failed to umount client"
7706 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
7707 "failed to mount client with option '$opt'"
7708 checksum=$(eval $get_checksum)
7709 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7713 remount_client $MOUNT || "failed to remount client"
7715 run_test 77k "enable/disable checksum correctly"
7717 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
7726 test_78() { # bug 10901
7727 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7728 remote_ost || skip_env "local OST"
7731 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
7732 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
7733 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
7734 echo "MemTotal: $MEMTOTAL"
7736 # reserve 256MB of memory for the kernel and other running processes,
7737 # and then take 1/2 of the remaining memory for the read/write buffers.
7738 if [ $MEMTOTAL -gt 512 ] ;then
7739 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
7741 # for those poor memory-starved high-end clusters...
7742 MEMTOTAL=$((MEMTOTAL / 2))
7744 echo "Mem to use for directio: $MEMTOTAL"
7746 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
7747 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
7748 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
7749 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
7751 echo "Smallest OST: $SMALLESTOST"
7752 [[ $SMALLESTOST -lt 10240 ]] &&
7753 skip "too small OSTSIZE, useless to run large O_DIRECT test"
7755 trap cleanup_test_78 EXIT
7757 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
7758 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
7760 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
7761 echo "File size: $F78SIZE"
7762 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
7763 for i in $(seq 1 $NSEQ); do
7764 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
7765 echo directIO rdwr round $i of $NSEQ
7766 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
7771 run_test 78 "handle large O_DIRECT writes correctly ============"
7773 test_79() { # bug 12743
7774 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7776 wait_delete_completed
7778 BKTOTAL=$(calc_osc_kbytes kbytestotal)
7779 BKFREE=$(calc_osc_kbytes kbytesfree)
7780 BKAVAIL=$(calc_osc_kbytes kbytesavail)
7782 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
7783 DFTOTAL=`echo $STRING | cut -d, -f1`
7784 DFUSED=`echo $STRING | cut -d, -f2`
7785 DFAVAIL=`echo $STRING | cut -d, -f3`
7786 DFFREE=$(($DFTOTAL - $DFUSED))
7788 ALLOWANCE=$((64 * $OSTCOUNT))
7790 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
7791 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
7792 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
7794 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
7795 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
7796 error "df free($DFFREE) mismatch OST free($BKFREE)"
7798 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
7799 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
7800 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
7803 run_test 79 "df report consistency check ======================="
7805 test_80() { # bug 10718
7806 remote_ost_nodsh && skip "remote OST with nodsh"
7807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7809 # relax strong synchronous semantics for slow backends like ZFS
7810 local soc="obdfilter.*.sync_on_lock_cancel"
7811 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
7813 if [ "$soc_old" != "never" ] &&
7814 [ "$ost1_FSTYPE" != "ldiskfs" ]; then
7815 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
7816 facet_active_host $host; done | sort -u)
7817 do_nodes $hosts lctl set_param $soc=never
7820 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
7822 local BEFORE=`date +%s`
7823 cancel_lru_locks osc
7824 local AFTER=`date +%s`
7825 local DIFF=$((AFTER-BEFORE))
7826 if [ $DIFF -gt 1 ] ; then
7827 error "elapsed for 1M@1T = $DIFF"
7830 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
7834 run_test 80 "Page eviction is equally fast at high offsets too ===="
7836 test_81a() { # LU-456
7837 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7838 remote_ost_nodsh && skip "remote OST with nodsh"
7840 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7841 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
7842 do_facet ost1 lctl set_param fail_loc=0x80000228
7844 # write should trigger a retry and success
7845 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7846 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7848 if [ $RC -ne 0 ] ; then
7849 error "write should success, but failed for $RC"
7852 run_test 81a "OST should retry write when get -ENOSPC ==============="
7854 test_81b() { # LU-456
7855 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7856 remote_ost_nodsh && skip "remote OST with nodsh"
7858 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7859 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
7860 do_facet ost1 lctl set_param fail_loc=0x228
7862 # write should retry several times and return -ENOSPC finally
7863 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7864 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7867 if [ $RC -ne $ENOSPC ] ; then
7868 error "dd should fail for -ENOSPC, but succeed."
7871 run_test 81b "OST should return -ENOSPC when retry still fails ======="
7873 test_82() { # LU-1031
7874 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
7878 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
7880 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
7882 kill -USR1 $MULTIPID2
7884 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
7885 error "First grouplock does not block second one"
7887 echo "Second grouplock blocks first one"
7889 kill -USR1 $MULTIPID1
7893 run_test 82 "Basic grouplock test"
7896 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
7898 test_mkdir $DIR/$tdir.cvsroot
7899 chown $RUNAS_ID $DIR/$tdir.cvsroot
7902 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
7905 # some versions of cvs import exit(1) when asked to import links or
7906 # files they can't read. ignore those files.
7907 local toignore=$(find . -type l -printf '-I %f\n' -o \
7908 ! -perm /4 -printf '-I %f\n')
7909 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
7910 $tdir.reposname vtag rtag
7913 test_mkdir $DIR/$tdir.reposname
7914 chown $RUNAS_ID $DIR/$tdir.reposname
7915 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
7917 cd $DIR/$tdir.reposname
7919 $RUNAS cvs add -m 'addmsg' foo99
7921 $RUNAS cvs commit -m 'nomsg' foo99
7922 rm -fr $DIR/$tdir.cvsroot
7924 run_test 99 "cvs strange file/directory operations"
7927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7928 [[ "$NETTYPE" =~ tcp ]] ||
7929 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
7930 remote_ost_nodsh && skip "remote OST with nodsh"
7931 remote_mds_nodsh && skip "remote MDS with nodsh"
7933 skip "useless for local single node setup"
7935 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
7936 [ "$PROT" != "tcp" ] && continue
7937 RPORT=$(echo $REMOTE | cut -d: -f2)
7938 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
7941 LPORT=`echo $LOCAL | cut -d: -f2`
7942 if [ $LPORT -ge 1024 ]; then
7943 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
7945 error_exit "local: $LPORT > 1024, remote: $RPORT"
7948 [ "$rc" = 0 ] || error_exit "privileged port not found" )
7950 run_test 100 "check local port using privileged port ==========="
7952 function get_named_value()
7961 echo $line | sed "s/^$tag[ ]*//"
7968 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
7969 awk '/^max_cached_mb/ { print $2 }')
7972 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
7977 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7978 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
7983 local cache_limit=32
7985 $LCTL set_param -n osc.*-osc*.rpc_stats 0
7986 trap cleanup_101a EXIT
7987 $LCTL set_param -n llite.*.read_ahead_stats 0
7988 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
7991 # randomly read 10000 of 64K chunks from file 3x 32MB in size
7993 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
7994 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
7997 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
7998 get_named_value 'read but discarded' | cut -d" " -f1); do
7999 discard=$(($discard + $s))
8003 if [[ $(($discard * 10)) -gt $nreads ]]; then
8004 $LCTL get_param osc.*-osc*.rpc_stats
8005 $LCTL get_param llite.*.read_ahead_stats
8006 error "too many ($discard) discarded pages"
8008 rm -f $DIR/$tfile || true
8010 run_test 101a "check read-ahead for random reads"
8013 test_mkdir $DIR/$tdir
8015 local FILE_LENGTH=$2
8018 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
8020 local list=$(comma_list $(osts_nodes))
8021 set_osd_param $list '' read_cache_enable 0
8022 set_osd_param $list '' writethrough_cache_enable 0
8024 trap cleanup_test101bc EXIT
8025 # prepare the read-ahead file
8026 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
8028 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
8029 count=$FILE_SIZE_MB 2> /dev/null
8033 cleanup_test101bc() {
8038 local list=$(comma_list $(osts_nodes))
8039 set_osd_param $list '' read_cache_enable 1
8040 set_osd_param $list '' writethrough_cache_enable 1
8044 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
8049 local STRIPE_SIZE=$2
8050 local FILE_LENGTH=$3
8051 local RA_INC=1048576
8052 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
8053 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
8054 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
8055 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
8056 get_named_value 'read but discarded' |
8057 cut -d" " -f1 | calc_total)
8058 if [[ $DISCARD -gt $discard_limit ]]; then
8059 $LCTL get_param llite.*.read_ahead_stats
8060 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
8062 echo "Read-ahead success for size ${READ_SIZE}"
8067 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8068 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8070 local STRIPE_SIZE=1048576
8071 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
8073 if [ $SLOW == "yes" ]; then
8074 local FILE_LENGTH=$((STRIDE_SIZE * 64))
8076 local FILE_LENGTH=$((STRIDE_SIZE * 8))
8079 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
8081 # prepare the read-ahead file
8082 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8083 cancel_lru_locks osc
8084 for BIDX in 2 4 8 16 32 64 128 256
8086 local BSIZE=$((BIDX*4096))
8087 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
8088 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
8089 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
8090 $LCTL set_param -n llite.*.read_ahead_stats 0
8091 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
8092 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
8093 cancel_lru_locks osc
8094 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
8099 run_test 101b "check stride-io mode read-ahead ================="
8102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8104 local STRIPE_SIZE=1048576
8105 local FILE_LENGTH=$((STRIPE_SIZE*100))
8110 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8112 cancel_lru_locks osc
8113 $LCTL set_param osc.*.rpc_stats 0
8114 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
8115 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
8116 local stats=$($LCTL get_param -n $osc_rpc_stats)
8117 local lines=$(echo "$stats" | awk 'END {print NR;}')
8120 if [ $lines -le 20 ]; then
8123 for size in 1 2 4 8; do
8124 local rpc=$(echo "$stats" |
8125 awk '($1 == "'$size':") {print $2; exit; }')
8126 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
8127 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
8129 echo "$osc_rpc_stats check passed!"
8134 run_test 101c "check stripe_size aligned read-ahead ================="
8137 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
8138 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
8142 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8144 local file=$DIR/$tfile
8145 local sz_MB=${FILESIZE_101d:-500}
8146 local ra_MB=${READAHEAD_MB:-40}
8148 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
8149 [ $free_MB -lt $sz_MB ] &&
8150 skip "Need free space ${sz_MB}M, have ${free_MB}M"
8152 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
8153 $LFS setstripe -c -1 $file || error "setstripe failed"
8155 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
8156 echo Cancel LRU locks on lustre client to flush the client cache
8157 cancel_lru_locks osc
8159 echo Disable read-ahead
8160 local old_READAHEAD=$(set_read_ahead 0)
8162 echo Reading the test file $file with read-ahead disabled
8163 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8165 echo Cancel LRU locks on lustre client to flush the client cache
8166 cancel_lru_locks osc
8167 echo Enable read-ahead with ${ra_MB}MB
8168 set_read_ahead $ra_MB
8170 echo Reading the test file $file with read-ahead enabled
8171 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8173 echo "read-ahead disabled time read $raOFF"
8174 echo "read-ahead enabled time read $raON"
8176 set_read_ahead $old_READAHEAD
8178 wait_delete_completed
8180 [ $raOFF -le 1 ] || [ $raON -lt $raOFF ] ||
8181 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
8183 run_test 101d "file read with and without read-ahead enabled"
8186 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8188 local file=$DIR/$tfile
8189 local size_KB=500 #KB
8193 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
8194 local need_KB=$((count * size_KB))
8195 [[ $free_KB -le $need_KB ]] &&
8196 skip_env "Need free space $need_KB, have $free_KB"
8198 echo "Creating $count ${size_KB}K test files"
8199 for ((i = 0; i < $count; i++)); do
8200 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
8203 echo "Cancel LRU locks on lustre client to flush the client cache"
8204 cancel_lru_locks $OSC
8206 echo "Reset readahead stats"
8207 $LCTL set_param -n llite.*.read_ahead_stats 0
8209 for ((i = 0; i < $count; i++)); do
8210 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
8213 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8214 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8216 for ((i = 0; i < $count; i++)); do
8217 rm -rf $file.$i 2>/dev/null
8220 #10000 means 20% reads are missing in readahead
8221 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
8223 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
8226 which iozone || skip_env "no iozone installed"
8228 local old_debug=$($LCTL get_param debug)
8229 old_debug=${old_debug#*=}
8230 $LCTL set_param debug="reada mmap"
8232 # create a test file
8233 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
8235 echo Cancel LRU locks on lustre client to flush the client cache
8236 cancel_lru_locks osc
8238 echo Reset readahead stats
8239 $LCTL set_param -n llite.*.read_ahead_stats 0
8241 echo mmap read the file with small block size
8242 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
8245 echo checking missing pages
8246 $LCTL get_param llite.*.read_ahead_stats
8247 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8248 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8250 $LCTL set_param debug="$old_debug"
8251 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
8254 run_test 101f "check mmap read performance"
8256 test_101g_brw_size_test() {
8258 local pages=$((mb * 1048576 / PAGE_SIZE))
8259 local file=$DIR/$tfile
8261 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
8262 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
8263 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
8264 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
8268 stack_trap "rm -f $file" EXIT
8269 $LCTL set_param -n osc.*.rpc_stats=0
8271 # 10 RPCs should be enough for the test
8273 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
8274 { error "dd write ${mb} MB blocks failed"; return 3; }
8275 cancel_lru_locks osc
8276 dd of=/dev/null if=$file bs=${mb}M count=$count ||
8277 { error "dd write ${mb} MB blocks failed"; return 4; }
8279 # calculate number of full-sized read and write RPCs
8280 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
8281 sed -n '/pages per rpc/,/^$/p' |
8282 awk '/'$pages':/ { reads += $2; writes += $6 }; \
8283 END { print reads,writes }'))
8284 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
8286 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
8293 remote_ost_nodsh && skip "remote OST with nodsh"
8296 local osts=$(get_facets OST)
8297 local list=$(comma_list $(osts_nodes))
8298 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8299 local brw_size="obdfilter.*.brw_size"
8301 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8303 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
8305 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
8306 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
8307 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
8308 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
8309 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
8310 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
8312 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
8315 if [[ $orig_mb -lt 16 ]]; then
8316 save_lustre_params $osts "$brw_size" > $p
8317 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
8318 error "set 16MB RPC size failed"
8320 echo "remount client to enable new RPC size"
8321 remount_client $MOUNT || error "remount_client failed"
8324 test_101g_brw_size_test 16 || error "16MB RPC test failed"
8325 # should be able to set brw_size=12, but no rpc_stats for that
8326 test_101g_brw_size_test 8 || error "8MB RPC test failed"
8329 test_101g_brw_size_test 4 || error "4MB RPC test failed"
8331 if [[ $orig_mb -lt 16 ]]; then
8332 restore_lustre_params < $p
8333 remount_client $MOUNT || error "remount_client restore failed"
8336 rm -f $p $DIR/$tfile
8338 run_test 101g "Big bulk(4/16 MiB) readahead"
8341 test_mkdir $DIR/$tdir
8342 chown $RUNAS_ID $DIR/$tdir
8345 STRIPE_COUNT=$OSTCOUNT
8346 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
8348 trap cleanup_test102 EXIT
8350 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
8352 for num in 1 2 3 4; do
8353 for count in $(seq 1 $STRIPE_COUNT); do
8354 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
8355 local size=`expr $STRIPE_SIZE \* $num`
8356 local file=file"$num-$idx-$count"
8357 $1 $LFS setstripe -S $size -i $idx -c $count $file
8363 $1 tar cf $TMP/f102.tar $tdir --xattrs
8369 rm -rf $DIR/d0.sanity/d102
8373 [ "$UID" != 0 ] && skip "must run as root"
8374 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
8375 skip_env "must have user_xattr"
8377 [ -z "$(which setfattr 2>/dev/null)" ] &&
8378 skip_env "could not find setfattr"
8380 local testfile=$DIR/$tfile
8383 echo "set/get xattr..."
8384 setfattr -n trusted.name1 -v value1 $testfile ||
8385 error "setfattr -n trusted.name1=value1 $testfile failed"
8386 getfattr -n trusted.name1 $testfile 2> /dev/null |
8387 grep "trusted.name1=.value1" ||
8388 error "$testfile missing trusted.name1=value1"
8390 setfattr -n user.author1 -v author1 $testfile ||
8391 error "setfattr -n user.author1=author1 $testfile failed"
8392 getfattr -n user.author1 $testfile 2> /dev/null |
8393 grep "user.author1=.author1" ||
8394 error "$testfile missing trusted.author1=author1"
8397 setfattr -n trusted.name2 -v value2 $testfile ||
8398 error "$testfile unable to set trusted.name2"
8399 setfattr -n trusted.name3 -v value3 $testfile ||
8400 error "$testfile unable to set trusted.name3"
8401 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
8402 grep "trusted.name" | wc -l) -eq 3 ] ||
8403 error "$testfile missing 3 trusted.name xattrs"
8405 setfattr -n user.author2 -v author2 $testfile ||
8406 error "$testfile unable to set user.author2"
8407 setfattr -n user.author3 -v author3 $testfile ||
8408 error "$testfile unable to set user.author3"
8409 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
8410 grep "user.author" | wc -l) -eq 3 ] ||
8411 error "$testfile missing 3 user.author xattrs"
8413 echo "remove xattr..."
8414 setfattr -x trusted.name1 $testfile ||
8415 error "$testfile error deleting trusted.name1"
8416 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
8417 error "$testfile did not delete trusted.name1 xattr"
8419 setfattr -x user.author1 $testfile ||
8420 error "$testfile error deleting user.author1"
8421 echo "set lustre special xattr ..."
8422 $LFS setstripe -c1 $testfile
8423 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
8424 awk -F "=" '/trusted.lov/ { print $2 }' )
8425 setfattr -n "trusted.lov" -v $lovea $testfile ||
8426 error "$testfile doesn't ignore setting trusted.lov again"
8427 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
8428 error "$testfile allow setting invalid trusted.lov"
8431 run_test 102a "user xattr test =================================="
8434 [ -z "$(which setfattr 2>/dev/null)" ] &&
8435 skip_env "could not find setfattr"
8436 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8438 # b10930: get/set/list trusted.lov xattr
8439 echo "get/set/list trusted.lov xattr ..."
8440 local testfile=$DIR/$tfile
8441 $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8442 error "setstripe failed"
8443 local STRIPECOUNT=$($LFS getstripe -c $testfile) ||
8444 error "getstripe failed"
8445 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
8446 error "can't get trusted.lov from $testfile"
8448 local testfile2=${testfile}2
8449 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
8450 grep "trusted.lov" | sed -e 's/[^=]\+=//')
8453 setfattr -n trusted.lov -v $value $testfile2
8454 local stripe_size=$($LFS getstripe -S $testfile2)
8455 local stripe_count=$($LFS getstripe -c $testfile2)
8456 [[ $stripe_size -eq 65536 ]] ||
8457 error "stripe size $stripe_size != 65536"
8458 [[ $stripe_count -eq $STRIPECOUNT ]] ||
8459 error "stripe count $stripe_count != $STRIPECOUNT"
8462 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
8465 [ -z "$(which setfattr 2>/dev/null)" ] &&
8466 skip_env "could not find setfattr"
8467 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8469 # b10930: get/set/list lustre.lov xattr
8470 echo "get/set/list lustre.lov xattr ..."
8471 test_mkdir $DIR/$tdir
8472 chown $RUNAS_ID $DIR/$tdir
8473 local testfile=$DIR/$tdir/$tfile
8474 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8475 error "setstripe failed"
8476 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
8477 error "getstripe failed"
8478 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
8479 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
8481 local testfile2=${testfile}2
8482 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
8483 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8485 $RUNAS $MCREATE $testfile2
8486 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8487 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
8488 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
8489 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8490 [ $stripe_count -eq $STRIPECOUNT ] ||
8491 error "stripe count $stripe_count != $STRIPECOUNT"
8493 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8495 compare_stripe_info1() {
8496 local stripe_index_all_zero=true
8498 for num in 1 2 3 4; do
8499 for count in $(seq 1 $STRIPE_COUNT); do
8500 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8501 local size=$((STRIPE_SIZE * num))
8502 local file=file"$num-$offset-$count"
8503 stripe_size=$($LFS getstripe -S $PWD/$file)
8504 [[ $stripe_size -ne $size ]] &&
8505 error "$file: size $stripe_size != $size"
8506 stripe_count=$($LFS getstripe -c $PWD/$file)
8507 # allow fewer stripes to be created, ORI-601
8508 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8509 error "$file: count $stripe_count != $count"
8510 stripe_index=$($LFS getstripe -i $PWD/$file)
8511 [[ $stripe_index -ne 0 ]] &&
8512 stripe_index_all_zero=false
8516 $stripe_index_all_zero &&
8517 error "all files are being extracted starting from OST index 0"
8521 have_xattrs_include() {
8522 tar --help | grep -q xattrs-include &&
8523 echo --xattrs-include="lustre.*"
8527 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8528 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8530 XINC=$(have_xattrs_include)
8532 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8534 compare_stripe_info1
8536 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8539 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8540 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8542 XINC=$(have_xattrs_include)
8544 test_mkdir $DIR/$tdir.restore
8546 tar cf - --xattrs $tdir | tar xf - \
8547 -C $DIR/$tdir.restore --xattrs $XINC
8548 cd $DIR/$tdir.restore/$tdir
8549 compare_stripe_info1
8551 run_test 102f "tar copy files, not keep osts"
8554 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8555 skip "must have user_xattr"
8556 [ -z "$(which setfattr 2>/dev/null)" ] &&
8557 skip_env "could not find setfattr"
8558 [ -z "$(which getfattr 2>/dev/null)" ] &&
8559 skip_env "could not find getfattr"
8561 local xsize=${1:-1024} # in bytes
8562 local file=$DIR/$tfile
8563 local value="$(generate_string $xsize)"
8564 local xbig=trusted.big
8568 log "save $xbig on $file"
8571 setfattr -n $xbig -v $value $file ||
8572 error "saving $xbig on $file failed"
8574 setfattr -n $xbig -v $value $file &&
8575 error "saving $xbig on $file succeeded"
8579 local orig=$(get_xattr_value $xbig $file)
8580 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
8582 local xsml=trusted.sml
8583 log "save $xsml on $file"
8584 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
8586 local new=$(get_xattr_value $xbig $file)
8587 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
8589 log "grow $xsml on $file"
8590 setfattr -n $xsml -v "$value" $file ||
8591 error "growing $xsml on $file failed"
8593 new=$(get_xattr_value $xbig $file)
8594 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
8595 log "$xbig still valid after growing $xsml"
8600 test_102h() { # bug 15777
8603 run_test 102h "grow xattr from inside inode to external block"
8606 large_xattr_enabled || skip_env "ea_inode feature disabled"
8608 echo "setting xattr of max xattr size: $(max_xattr_size)"
8609 grow_xattr $(max_xattr_size)
8611 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
8612 echo "This should fail:"
8613 grow_xattr $(($(max_xattr_size) + 10)) 1
8615 run_test 102ha "grow xattr from inside inode to external inode"
8617 test_102i() { # bug 17038
8618 [ -z "$(which getfattr 2>/dev/null)" ] &&
8619 skip "could not find getfattr"
8622 ln -s $DIR/$tfile $DIR/${tfile}link
8623 getfattr -n trusted.lov $DIR/$tfile ||
8624 error "lgetxattr on $DIR/$tfile failed"
8625 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
8626 grep -i "no such attr" ||
8627 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
8628 rm -f $DIR/$tfile $DIR/${tfile}link
8630 run_test 102i "lgetxattr test on symbolic link ============"
8633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8634 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8636 XINC=$(have_xattrs_include)
8637 setup_test102 "$RUNAS"
8638 chown $RUNAS_ID $DIR/$tdir
8639 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8641 compare_stripe_info1 "$RUNAS"
8643 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
8646 [ -z "$(which setfattr 2>/dev/null)" ] &&
8647 skip "could not find setfattr"
8650 # b22187 just check that does not crash for regular file.
8651 setfattr -n trusted.lov $DIR/$tfile
8652 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
8653 local test_kdir=$DIR/$tdir
8654 test_mkdir $test_kdir
8655 local default_size=$($LFS getstripe -S $test_kdir)
8656 local default_count=$($LFS getstripe -c $test_kdir)
8657 local default_offset=$($LFS getstripe -i $test_kdir)
8658 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
8659 error 'dir setstripe failed'
8660 setfattr -n trusted.lov $test_kdir
8661 local stripe_size=$($LFS getstripe -S $test_kdir)
8662 local stripe_count=$($LFS getstripe -c $test_kdir)
8663 local stripe_offset=$($LFS getstripe -i $test_kdir)
8664 [ $stripe_size -eq $default_size ] ||
8665 error "stripe size $stripe_size != $default_size"
8666 [ $stripe_count -eq $default_count ] ||
8667 error "stripe count $stripe_count != $default_count"
8668 [ $stripe_offset -eq $default_offset ] ||
8669 error "stripe offset $stripe_offset != $default_offset"
8670 rm -rf $DIR/$tfile $test_kdir
8672 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
8675 [ -z "$(which getfattr 2>/dev/null)" ] &&
8676 skip "could not find getfattr"
8678 # LU-532 trusted. xattr is invisible to non-root
8679 local testfile=$DIR/$tfile
8683 echo "listxattr as user..."
8684 chown $RUNAS_ID $testfile
8685 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
8686 grep -q "trusted" &&
8687 error "$testfile trusted xattrs are user visible"
8691 run_test 102l "listxattr size test =================================="
8693 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
8694 local path=$DIR/$tfile
8697 listxattr_size_check $path || error "listattr_size_check $path failed"
8699 run_test 102m "Ensure listxattr fails on small bufffer ========"
8703 getxattr() { # getxattr path name
8704 # Return the base64 encoding of the value of xattr name on path.
8708 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
8710 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8712 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8714 getfattr --absolute-names --encoding=base64 --name=$name $path |
8715 awk -F= -v name=$name '$1 == name {
8716 print substr($0, index($0, "=") + 1);
8720 test_102n() { # LU-4101 mdt: protect internal xattrs
8721 [ -z "$(which setfattr 2>/dev/null)" ] &&
8722 skip "could not find setfattr"
8723 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
8725 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
8728 local file0=$DIR/$tfile.0
8729 local file1=$DIR/$tfile.1
8730 local xattr0=$TMP/$tfile.0
8731 local xattr1=$TMP/$tfile.1
8732 local namelist="lov lma lmv link fid version som hsm"
8736 rm -rf $file0 $file1 $xattr0 $xattr1
8739 # Get 'before' xattrs of $file1.
8740 getfattr --absolute-names --dump --match=- $file1 > $xattr0
8742 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
8743 namelist+=" lfsck_namespace"
8744 for name in $namelist; do
8745 # Try to copy xattr from $file0 to $file1.
8746 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8748 setfattr --name=trusted.$name --value="$value" $file1 ||
8749 error "setxattr 'trusted.$name' failed"
8751 # Try to set a garbage xattr.
8752 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8754 if [[ x$name == "xlov" ]]; then
8755 setfattr --name=trusted.lov --value="$value" $file1 &&
8756 error "setxattr invalid 'trusted.lov' success"
8758 setfattr --name=trusted.$name --value="$value" $file1 ||
8759 error "setxattr invalid 'trusted.$name' failed"
8762 # Try to remove the xattr from $file1. We don't care if this
8763 # appears to succeed or fail, we just don't want there to be
8764 # any changes or crashes.
8765 setfattr --remove=$trusted.$name $file1 2> /dev/null
8768 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
8771 # Try to copy xattr from $file0 to $file1.
8772 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8774 setfattr --name=trusted.$name --value="$value" $file1 ||
8775 error "setxattr 'trusted.$name' failed"
8777 # Try to set a garbage xattr.
8778 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8780 setfattr --name=trusted.$name --value="$value" $file1 ||
8781 error "setxattr 'trusted.$name' failed"
8783 # Try to remove the xattr from $file1. We don't care if this
8784 # appears to succeed or fail, we just don't want there to be
8785 # any changes or crashes.
8786 setfattr --remove=$trusted.$name $file1 2> /dev/null
8789 # Get 'after' xattrs of file1.
8790 getfattr --absolute-names --dump --match=- $file1 > $xattr1
8792 if ! diff $xattr0 $xattr1; then
8793 error "before and after xattrs of '$file1' differ"
8796 rm -rf $file0 $file1 $xattr0 $xattr1
8800 run_test 102n "silently ignore setxattr on internal trusted xattrs"
8802 test_102p() { # LU-4703 setxattr did not check ownership
8803 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
8804 skip "MDS needs to be at least 2.5.56"
8806 local testfile=$DIR/$tfile
8810 echo "setfacl as user..."
8811 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
8812 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
8814 echo "setfattr as user..."
8815 setfacl -m "u:$RUNAS_ID:---" $testfile
8816 $RUNAS setfattr -x system.posix_acl_access $testfile
8817 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
8819 run_test 102p "check setxattr(2) correctly fails without permission"
8822 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
8823 skip "MDS needs to be at least 2.6.92"
8825 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
8827 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
8830 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
8831 skip "MDS needs to be at least 2.6.93"
8833 touch $DIR/$tfile || error "touch"
8834 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
8835 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
8836 rm $DIR/$tfile || error "rm"
8839 mkdir -p $DIR/$tdir || error "mkdir"
8840 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8841 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8842 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8843 error "$testfile error deleting user.author1"
8844 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8845 grep "user.$(basename $tdir)" &&
8846 error "$tdir did not delete user.$(basename $tdir)"
8847 rmdir $DIR/$tdir || error "rmdir"
8850 test_mkdir $DIR/$tdir
8851 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8852 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8853 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8854 error "$testfile error deleting user.author1"
8855 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8856 grep "user.$(basename $tdir)" &&
8857 error "$tdir did not delete user.$(basename $tdir)"
8858 rmdir $DIR/$tdir || error "rm striped dir"
8860 run_test 102r "set EAs with empty values"
8863 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
8864 skip "MDS needs to be at least 2.11.52"
8866 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
8868 save_lustre_params client "llite.*.xattr_cache" > $save
8870 for cache in 0 1; do
8871 lctl set_param llite.*.xattr_cache=$cache
8874 touch $DIR/$tfile || error "touch"
8875 for prefix in lustre security system trusted user; do
8876 # Note getxattr() may fail with 'Operation not
8877 # supported' or 'No such attribute' depending
8878 # on prefix and cache.
8879 getfattr -n $prefix.n102s $DIR/$tfile &&
8880 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
8884 restore_lustre_params < $save
8886 run_test 102s "getting nonexistent xattrs should fail"
8889 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
8890 skip "MDS needs to be at least 2.11.52"
8892 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
8894 save_lustre_params client "llite.*.xattr_cache" > $save
8896 for cache in 0 1; do
8897 lctl set_param llite.*.xattr_cache=$cache
8899 for buf_size in 0 256; do
8901 touch $DIR/$tfile || error "touch"
8902 setfattr -n user.multiop $DIR/$tfile
8903 $MULTIOP $DIR/$tfile oa$buf_size ||
8904 error "cannot get zero length xattr value (buf_size = $buf_size)"
8908 restore_lustre_params < $save
8910 run_test 102t "zero length xattr values handled correctly"
8914 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
8919 [ "$UID" != 0 ] && skip "must run as root"
8920 $GSS && skip_env "could not run under gss"
8921 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
8922 skip_env "must have acl enabled"
8923 [ -z "$(which setfacl 2>/dev/null)" ] &&
8924 skip_env "could not find setfacl"
8925 remote_mds_nodsh && skip "remote MDS with nodsh"
8927 gpasswd -a daemon bin # LU-5641
8928 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
8930 declare -a identity_old
8932 for num in $(seq $MDSCOUNT); do
8933 switch_identity $num true || identity_old[$num]=$?
8941 echo "performing cp ..."
8942 run_acl_subtest cp || error "run_acl_subtest cp failed"
8943 echo "performing getfacl-noacl..."
8944 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
8945 echo "performing misc..."
8946 run_acl_subtest misc || error "misc test failed"
8947 echo "performing permissions..."
8948 run_acl_subtest permissions || error "permissions failed"
8949 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
8950 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
8951 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
8952 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
8954 echo "performing permissions xattr..."
8955 run_acl_subtest permissions_xattr ||
8956 error "permissions_xattr failed"
8958 echo "performing setfacl..."
8959 run_acl_subtest setfacl || error "setfacl test failed"
8961 # inheritance test got from HP
8962 echo "performing inheritance..."
8963 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
8964 chmod +x make-tree || error "chmod +x failed"
8965 run_acl_subtest inheritance || error "inheritance test failed"
8968 echo "LU-974 ignore umask when acl is enabled..."
8969 run_acl_subtest 974 || error "LU-974 umask test failed"
8970 if [ $MDSCOUNT -ge 2 ]; then
8971 run_acl_subtest 974_remote ||
8972 error "LU-974 umask test failed under remote dir"
8975 echo "LU-2561 newly created file is same size as directory..."
8976 if [ "$mds1_FSTYPE" != "zfs" ]; then
8977 run_acl_subtest 2561 || error "LU-2561 test failed"
8979 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
8982 run_acl_subtest 4924 || error "LU-4924 test failed"
8987 for num in $(seq $MDSCOUNT); do
8988 if [ "${identity_old[$num]}" = 1 ]; then
8989 switch_identity $num false || identity_old[$num]=$?
8993 run_test 103a "acl test"
8999 for U in {0..511}; do
9001 local O=$(printf "%04o" $U)
9003 umask $(printf "%04o" $((511 ^ $O)))
9004 $LFS setstripe -c 1 $DIR/$tfile.s$O
9005 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
9007 (( $S == ($O & 0666) )) ||
9008 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
9010 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
9011 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
9012 (( $S == ($O & 0666) )) ||
9013 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
9015 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
9016 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
9017 (( $S == ($O & 0666) )) ||
9018 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
9019 rm -f $DIR/$tfile.[smp]$0
9023 # limit the concurrently running threads to 64. LU-11878
9024 local idx=$((U % 64))
9025 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
9030 run_test 103b "umask lfs setstripe"
9034 cp -rp $DIR/$tdir $DIR/$tdir.bak
9036 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
9037 error "$DIR/$tdir shouldn't contain default ACL"
9038 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
9039 error "$DIR/$tdir.bak shouldn't contain default ACL"
9042 run_test 103c "'cp -rp' won't set empty acl"
9045 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9048 lfs df || error "lfs df failed"
9049 lfs df -ih || error "lfs df -ih failed"
9050 lfs df -h $DIR || error "lfs df -h $DIR failed"
9051 lfs df -i $DIR || error "lfs df -i $DIR failed"
9052 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
9053 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
9055 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
9056 lctl --device %$OSC deactivate
9057 lfs df || error "lfs df with deactivated OSC failed"
9058 lctl --device %$OSC activate
9059 # wait the osc back to normal
9060 wait_osc_import_ready client ost
9062 lfs df || error "lfs df with reactivated OSC failed"
9065 run_test 104a "lfs df [-ih] [path] test ========================="
9068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9069 [ $RUNAS_ID -eq $UID ] &&
9070 skip_env "RUNAS_ID = UID = $UID -- skipping"
9072 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
9073 grep "Permission denied" | wc -l)))
9074 if [ $denied_cnt -ne 0 ]; then
9075 error "lfs check servers test failed"
9078 run_test 104b "$RUNAS lfs check servers test ===================="
9081 # doesn't work on 2.4 kernels
9083 if $(flock_is_enabled); then
9084 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
9086 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
9090 run_test 105a "flock when mounted without -o flock test ========"
9094 if $(flock_is_enabled); then
9095 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
9097 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
9101 run_test 105b "fcntl when mounted without -o flock test ========"
9105 if $(flock_is_enabled); then
9106 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
9108 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
9112 run_test 105c "lockf when mounted without -o flock test"
9114 test_105d() { # bug 15924
9115 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9117 test_mkdir $DIR/$tdir
9118 flock_is_enabled || skip_env "mount w/o flock enabled"
9119 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
9120 $LCTL set_param fail_loc=0x80000315
9121 flocks_test 2 $DIR/$tdir
9123 run_test 105d "flock race (should not freeze) ========"
9125 test_105e() { # bug 22660 && 22040
9126 flock_is_enabled || skip_env "mount w/o flock enabled"
9129 flocks_test 3 $DIR/$tfile
9131 run_test 105e "Two conflicting flocks from same process"
9133 test_106() { #bug 10921
9134 test_mkdir $DIR/$tdir
9135 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
9136 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
9138 run_test 106 "attempt exec of dir followed by chown of that dir"
9141 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9149 local save_pattern=$(sysctl -n kernel.core_pattern)
9150 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
9151 sysctl -w kernel.core_pattern=$file
9152 sysctl -w kernel.core_uses_pid=0
9160 kill -s 11 $SLEEPPID
9162 if [ -e $file ]; then
9163 size=`stat -c%s $file`
9164 [ $size -eq 0 ] && error "Fail to create core file $file"
9166 error "Fail to create core file $file"
9169 sysctl -w kernel.core_pattern=$save_pattern
9170 sysctl -w kernel.core_uses_pid=$save_uses_pid
9173 run_test 107 "Coredump on SIG"
9176 test_mkdir $DIR/$tdir
9177 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
9178 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
9179 error "mkdir with 256 char should fail, but did not"
9180 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
9181 error "create with 255 char failed"
9182 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
9183 error "create with 256 char should fail, but did not"
9188 run_test 110 "filename length checking"
9191 # Purpose: To verify dynamic thread (OSS) creation.
9194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9195 remote_ost_nodsh && skip "remote OST with nodsh"
9197 # Lustre does not stop service threads once they are started.
9198 # Reset number of running threads to default.
9203 local save_params="$TMP/sanity-$TESTNAME.parameters"
9205 # Get ll_ost_io count before I/O
9206 OSTIO_pre=$(do_facet ost1 \
9207 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
9208 # Exit if lustre is not running (ll_ost_io not running).
9209 [ -z "$OSTIO_pre" ] && error "no OSS threads"
9211 echo "Starting with $OSTIO_pre threads"
9212 local thread_max=$((OSTIO_pre * 2))
9213 local rpc_in_flight=$((thread_max * 2))
9214 # Number of I/O Process proposed to be started.
9216 local facets=$(get_facets OST)
9218 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
9219 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
9221 # Set in_flight to $rpc_in_flight
9222 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
9223 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
9224 nfiles=${rpc_in_flight}
9225 # Set ost thread_max to $thread_max
9226 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
9228 # 5 Minutes should be sufficient for max number of OSS
9229 # threads(thread_max) to be created.
9233 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
9234 test_mkdir $DIR/$tdir
9235 for i in $(seq $nfiles); do
9236 local file=$DIR/$tdir/${tfile}-$i
9237 $LFS setstripe -c -1 -i 0 $file
9238 ($WTL $file $timeout)&
9241 # I/O Started - Wait for thread_started to reach thread_max or report
9242 # error if thread_started is more than thread_max.
9243 echo "Waiting for thread_started to reach thread_max"
9244 local thread_started=0
9245 local end_time=$((SECONDS + timeout))
9247 while [ $SECONDS -le $end_time ] ; do
9249 # Get ost i/o thread_started count.
9250 thread_started=$(do_facet ost1 \
9252 ost.OSS.ost_io.threads_started | cut -d= -f2")
9253 # Break out if thread_started is equal/greater than thread_max
9254 if [[ $thread_started -ge $thread_max ]]; then
9255 echo ll_ost_io thread_started $thread_started, \
9256 equal/greater than thread_max $thread_max
9262 # Cleanup - We have the numbers, Kill i/o jobs if running.
9263 jobcount=($(jobs -p))
9264 for i in $(seq 0 $((${#jobcount[@]}-1)))
9266 kill -9 ${jobcount[$i]}
9267 if [ $? -ne 0 ] ; then
9269 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
9273 # Cleanup files left by WTL binary.
9274 for i in $(seq $nfiles); do
9275 local file=$DIR/$tdir/${tfile}-$i
9277 if [ $? -ne 0 ] ; then
9278 echo "Warning: Failed to delete file $file"
9282 restore_lustre_params <$save_params
9283 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
9285 # Error out if no new thread has started or Thread started is greater
9287 if [[ $thread_started -le $OSTIO_pre ||
9288 $thread_started -gt $thread_max ]]; then
9289 error "ll_ost_io: thread_started $thread_started" \
9290 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
9291 "No new thread started or thread started greater " \
9295 run_test 115 "verify dynamic thread creation===================="
9298 wait_delete_completed
9299 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
9300 echo "OST kbytes available: ${AVAIL[@]}"
9305 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
9306 #echo OST $i: ${AVAIL[i]}kb
9307 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
9311 if [[ ${AVAIL[i]} -lt $MINV ]]; then
9316 echo "Min free space: OST $MINI: $MINV"
9317 echo "Max free space: OST $MAXI: $MAXV"
9320 test_116a() { # was previously test_116()
9321 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9322 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9323 remote_mds_nodsh && skip "remote MDS with nodsh"
9325 echo -n "Free space priority "
9326 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
9331 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
9332 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
9333 trap simple_cleanup_common EXIT
9335 # Check if we need to generate uneven OSTs
9336 test_mkdir -p $DIR/$tdir/OST${MINI}
9337 local FILL=$((MINV / 4))
9338 local DIFF=$((MAXV - MINV))
9339 local DIFF2=$((DIFF * 100 / MINV))
9341 local threshold=$(do_facet $SINGLEMDS \
9342 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
9343 threshold=${threshold%%%}
9344 echo -n "Check for uneven OSTs: "
9345 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
9347 if [[ $DIFF2 -gt $threshold ]]; then
9349 echo "Don't need to fill OST$MINI"
9351 # generate uneven OSTs. Write 2% over the QOS threshold value
9353 DIFF=$((threshold - DIFF2 + 2))
9354 DIFF2=$((MINV * DIFF / 100))
9355 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
9356 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
9357 error "setstripe failed"
9358 DIFF=$((DIFF2 / 2048))
9360 while [ $i -lt $DIFF ]; do
9362 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
9363 bs=2M count=1 2>/dev/null
9372 DIFF=$((MAXV - MINV))
9373 DIFF2=$((DIFF * 100 / MINV))
9374 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
9375 if [ $DIFF2 -gt $threshold ]; then
9378 echo "failed - QOS mode won't be used"
9379 simple_cleanup_common
9380 skip "QOS imbalance criteria not met"
9388 # now fill using QOS
9389 $LFS setstripe -c 1 $DIR/$tdir
9390 FILL=$((FILL / 200))
9391 if [ $FILL -gt 600 ]; then
9394 echo "writing $FILL files to QOS-assigned OSTs"
9396 while [ $i -lt $FILL ]; do
9398 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
9402 echo "wrote $i 200k files"
9406 echo "Note: free space may not be updated, so measurements might be off"
9408 DIFF2=$((MAXV - MINV))
9409 echo "free space delta: orig $DIFF final $DIFF2"
9410 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
9411 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
9412 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
9413 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
9414 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
9415 if [[ $DIFF -gt 0 ]]; then
9416 FILL=$((DIFF2 * 100 / DIFF - 100))
9417 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
9420 # Figure out which files were written where
9421 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9422 awk '/'$MINI1': / {print $2; exit}')
9424 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9425 echo "$MINC files created on smaller OST $MINI1"
9426 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9427 awk '/'$MAXI1': / {print $2; exit}')
9429 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9430 echo "$MAXC files created on larger OST $MAXI1"
9431 if [[ $MINC -gt 0 ]]; then
9432 FILL=$((MAXC * 100 / MINC - 100))
9433 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
9435 [[ $MAXC -gt $MINC ]] ||
9436 error_ignore LU-9 "stripe QOS didn't balance free space"
9437 simple_cleanup_common
9439 run_test 116a "stripe QOS: free space balance ==================="
9441 test_116b() { # LU-2093
9442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9443 remote_mds_nodsh && skip "remote MDS with nodsh"
9445 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
9446 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
9447 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
9448 [ -z "$old_rr" ] && skip "no QOS"
9449 do_facet $SINGLEMDS lctl set_param \
9450 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
9452 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
9453 createmany -o $DIR/$tdir/f- 20 || error "can't create"
9454 do_facet $SINGLEMDS lctl set_param fail_loc=0
9456 do_facet $SINGLEMDS lctl set_param \
9457 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
9459 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
9461 test_117() # bug 10891
9463 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9465 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
9466 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
9467 lctl set_param fail_loc=0x21e
9468 > $DIR/$tfile || error "truncate failed"
9469 lctl set_param fail_loc=0
9470 echo "Truncate succeeded."
9473 run_test 117 "verify osd extend =========="
9475 NO_SLOW_RESENDCOUNT=4
9476 export OLD_RESENDCOUNT=""
9477 set_resend_count () {
9478 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
9479 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
9480 lctl set_param -n $PROC_RESENDCOUNT $1
9481 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
9484 # for reduce test_118* time (b=14842)
9485 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9487 # Reset async IO behavior after error case
9489 FILE=$DIR/reset_async
9491 # Ensure all OSCs are cleared
9492 $LFS setstripe -c -1 $FILE
9493 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
9498 test_118a() #bug 11710
9500 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9504 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9505 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9506 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9508 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9509 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9514 run_test 118a "verify O_SYNC works =========="
9518 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9519 remote_ost_nodsh && skip "remote OST with nodsh"
9523 #define OBD_FAIL_SRV_ENOENT 0x217
9524 set_nodes_failloc "$(osts_nodes)" 0x217
9525 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9527 set_nodes_failloc "$(osts_nodes)" 0
9528 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9529 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9532 if [[ $RC -eq 0 ]]; then
9533 error "Must return error due to dropped pages, rc=$RC"
9537 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9538 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9542 echo "Dirty pages not leaked on ENOENT"
9544 # Due to the above error the OSC will issue all RPCs syncronously
9545 # until a subsequent RPC completes successfully without error.
9546 $MULTIOP $DIR/$tfile Ow4096yc
9551 run_test 118b "Reclaim dirty pages on fatal error =========="
9555 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9557 # for 118c, restore the original resend count, LU-1940
9558 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
9559 set_resend_count $OLD_RESENDCOUNT
9560 remote_ost_nodsh && skip "remote OST with nodsh"
9564 #define OBD_FAIL_OST_EROFS 0x216
9565 set_nodes_failloc "$(osts_nodes)" 0x216
9567 # multiop should block due to fsync until pages are written
9568 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9572 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9573 error "Multiop failed to block on fsync, pid=$MULTIPID"
9576 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9578 if [[ $WRITEBACK -eq 0 ]]; then
9579 error "No page in writeback, writeback=$WRITEBACK"
9582 set_nodes_failloc "$(osts_nodes)" 0
9585 if [[ $RC -ne 0 ]]; then
9586 error "Multiop fsync failed, rc=$RC"
9589 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9590 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9592 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9593 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9597 echo "Dirty pages flushed via fsync on EROFS"
9600 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
9602 # continue to use small resend count to reduce test_118* time (b=14842)
9603 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9607 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9608 remote_ost_nodsh && skip "remote OST with nodsh"
9612 #define OBD_FAIL_OST_BRW_PAUSE_BULK
9613 set_nodes_failloc "$(osts_nodes)" 0x214
9614 # multiop should block due to fsync until pages are written
9615 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9619 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9620 error "Multiop failed to block on fsync, pid=$MULTIPID"
9623 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9625 if [[ $WRITEBACK -eq 0 ]]; then
9626 error "No page in writeback, writeback=$WRITEBACK"
9629 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
9630 set_nodes_failloc "$(osts_nodes)" 0
9632 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9633 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9635 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9636 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9640 echo "Dirty pages gaurenteed flushed via fsync"
9643 run_test 118d "Fsync validation inject a delay of the bulk =========="
9646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9650 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
9651 lctl set_param fail_loc=0x8000040a
9653 # Should simulate EINVAL error which is fatal
9654 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9656 if [[ $RC -eq 0 ]]; then
9657 error "Must return error due to dropped pages, rc=$RC"
9660 lctl set_param fail_loc=0x0
9662 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9663 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9664 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9666 if [[ $LOCKED -ne 0 ]]; then
9667 error "Locked pages remain in cache, locked=$LOCKED"
9670 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9671 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9675 echo "No pages locked after fsync"
9680 run_test 118f "Simulate unrecoverable OSC side error =========="
9683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9687 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9688 lctl set_param fail_loc=0x406
9690 # simulate local -ENOMEM
9691 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9694 lctl set_param fail_loc=0
9695 if [[ $RC -eq 0 ]]; then
9696 error "Must return error due to dropped pages, rc=$RC"
9699 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9700 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9701 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9703 if [[ $LOCKED -ne 0 ]]; then
9704 error "Locked pages remain in cache, locked=$LOCKED"
9707 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9708 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9712 echo "No pages locked after fsync"
9717 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
9720 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9721 remote_ost_nodsh && skip "remote OST with nodsh"
9725 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9726 set_nodes_failloc "$(osts_nodes)" 0x20e
9727 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9728 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9731 set_nodes_failloc "$(osts_nodes)" 0
9732 if [[ $RC -eq 0 ]]; then
9733 error "Must return error due to dropped pages, rc=$RC"
9736 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9737 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9738 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9740 if [[ $LOCKED -ne 0 ]]; then
9741 error "Locked pages remain in cache, locked=$LOCKED"
9744 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9745 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9749 echo "No pages locked after fsync"
9753 run_test 118h "Verify timeout in handling recoverables errors =========="
9755 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9758 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9759 remote_ost_nodsh && skip "remote OST with nodsh"
9763 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9764 set_nodes_failloc "$(osts_nodes)" 0x20e
9766 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9767 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9770 set_nodes_failloc "$(osts_nodes)" 0
9774 if [[ $RC -ne 0 ]]; then
9775 error "got error, but should be not, rc=$RC"
9778 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9779 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9780 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9781 if [[ $LOCKED -ne 0 ]]; then
9782 error "Locked pages remain in cache, locked=$LOCKED"
9785 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9786 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9790 echo "No pages locked after fsync"
9794 run_test 118i "Fix error before timeout in recoverable error =========="
9796 [ "$SLOW" = "no" ] && set_resend_count 4
9799 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9800 remote_ost_nodsh && skip "remote OST with nodsh"
9804 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
9805 set_nodes_failloc "$(osts_nodes)" 0x220
9807 # return -EIO from OST
9808 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9810 set_nodes_failloc "$(osts_nodes)" 0x0
9811 if [[ $RC -eq 0 ]]; then
9812 error "Must return error due to dropped pages, rc=$RC"
9815 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9816 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9817 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9818 if [[ $LOCKED -ne 0 ]]; then
9819 error "Locked pages remain in cache, locked=$LOCKED"
9822 # in recoverable error on OST we want resend and stay until it finished
9823 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9824 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9828 echo "No pages locked after fsync"
9832 run_test 118j "Simulate unrecoverable OST side error =========="
9836 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9837 remote_ost_nodsh && skip "remote OSTs with nodsh"
9839 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9840 set_nodes_failloc "$(osts_nodes)" 0x20e
9841 test_mkdir $DIR/$tdir
9843 for ((i=0;i<10;i++)); do
9844 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
9845 error "dd to $DIR/$tdir/$tfile-$i failed" )&
9852 set_nodes_failloc "$(osts_nodes)" 0
9855 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
9857 test_118l() # LU-646
9859 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9861 test_mkdir $DIR/$tdir
9862 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
9865 run_test 118l "fsync dir"
9867 test_118m() # LU-3066
9869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9871 test_mkdir $DIR/$tdir
9872 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
9875 run_test 118m "fdatasync dir ========="
9877 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9884 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9885 remote_ost_nodsh && skip "remote OSTs with nodsh"
9887 # Sleep to avoid a cached response.
9888 #define OBD_STATFS_CACHE_SECONDS 1
9891 # Inject a 10 second delay in the OST_STATFS handler.
9892 #define OBD_FAIL_OST_STATFS_DELAY 0x242
9893 set_nodes_failloc "$(osts_nodes)" 0x242
9896 stat --file-system $MOUNT > /dev/null
9899 set_nodes_failloc "$(osts_nodes)" 0
9901 if ((end - begin > 20)); then
9902 error "statfs took $((end - begin)) seconds, expected 10"
9905 run_test 118n "statfs() sends OST_STATFS requests in parallel"
9907 test_119a() # bug 11737
9909 BSIZE=$((512 * 1024))
9910 directio write $DIR/$tfile 0 1 $BSIZE
9911 # We ask to read two blocks, which is more than a file size.
9912 # directio will indicate an error when requested and actual
9913 # sizes aren't equeal (a normal situation in this case) and
9914 # print actual read amount.
9915 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
9916 if [ "$NOB" != "$BSIZE" ]; then
9917 error "read $NOB bytes instead of $BSIZE"
9921 run_test 119a "Short directIO read must return actual read amount"
9923 test_119b() # bug 11737
9925 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9927 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
9928 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
9930 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
9931 error "direct read failed"
9934 run_test 119b "Sparse directIO read must return actual read amount"
9936 test_119c() # bug 13099
9939 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
9940 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
9943 run_test 119c "Testing for direct read hitting hole"
9945 test_119d() # bug 15950
9947 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9949 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
9950 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
9952 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
9953 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
9954 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
9955 lctl set_param fail_loc=0x40d
9956 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
9959 cat $DIR/$tfile > /dev/null &
9960 lctl set_param fail_loc=0
9963 log "the DIO writes have completed, now wait for the reads (should not block very long)"
9965 [ -n "`ps h -p $pid_reads -o comm`" ] && \
9966 error "the read rpcs have not completed in 2s"
9968 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
9970 run_test 119d "The DIO path should try to send a new rpc once one is completed"
9973 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9974 remote_mds_nodsh && skip "remote MDS with nodsh"
9975 test_mkdir -i0 -c1 $DIR/$tdir
9976 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9977 skip_env "no early lock cancel on server"
9979 lru_resize_disable mdc
9980 lru_resize_disable osc
9981 cancel_lru_locks mdc
9982 # asynchronous object destroy at MDT could cause bl ast to client
9983 cancel_lru_locks osc
9985 stat $DIR/$tdir > /dev/null
9986 can1=$(do_facet mds1 \
9987 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9988 awk '/ldlm_cancel/ {print $2}')
9989 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9990 awk '/ldlm_bl_callback/ {print $2}')
9991 test_mkdir -i0 -c1 $DIR/$tdir/d1
9992 can2=$(do_facet mds1 \
9993 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9994 awk '/ldlm_cancel/ {print $2}')
9995 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9996 awk '/ldlm_bl_callback/ {print $2}')
9997 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9998 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9999 lru_resize_enable mdc
10000 lru_resize_enable osc
10002 run_test 120a "Early Lock Cancel: mkdir test"
10005 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10006 remote_mds_nodsh && skip "remote MDS with nodsh"
10007 test_mkdir $DIR/$tdir
10008 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10009 skip_env "no early lock cancel on server"
10011 lru_resize_disable mdc
10012 lru_resize_disable osc
10013 cancel_lru_locks mdc
10014 stat $DIR/$tdir > /dev/null
10015 can1=$(do_facet $SINGLEMDS \
10016 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10017 awk '/ldlm_cancel/ {print $2}')
10018 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10019 awk '/ldlm_bl_callback/ {print $2}')
10020 touch $DIR/$tdir/f1
10021 can2=$(do_facet $SINGLEMDS \
10022 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10023 awk '/ldlm_cancel/ {print $2}')
10024 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10025 awk '/ldlm_bl_callback/ {print $2}')
10026 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10027 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10028 lru_resize_enable mdc
10029 lru_resize_enable osc
10031 run_test 120b "Early Lock Cancel: create test"
10034 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10035 remote_mds_nodsh && skip "remote MDS with nodsh"
10036 test_mkdir -i0 -c1 $DIR/$tdir
10037 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10038 skip "no early lock cancel on server"
10040 lru_resize_disable mdc
10041 lru_resize_disable osc
10042 test_mkdir -i0 -c1 $DIR/$tdir/d1
10043 test_mkdir -i0 -c1 $DIR/$tdir/d2
10044 touch $DIR/$tdir/d1/f1
10045 cancel_lru_locks mdc
10046 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
10047 can1=$(do_facet mds1 \
10048 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10049 awk '/ldlm_cancel/ {print $2}')
10050 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10051 awk '/ldlm_bl_callback/ {print $2}')
10052 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10053 can2=$(do_facet mds1 \
10054 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10055 awk '/ldlm_cancel/ {print $2}')
10056 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10057 awk '/ldlm_bl_callback/ {print $2}')
10058 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10059 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10060 lru_resize_enable mdc
10061 lru_resize_enable osc
10063 run_test 120c "Early Lock Cancel: link test"
10066 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10067 remote_mds_nodsh && skip "remote MDS with nodsh"
10068 test_mkdir -i0 -c1 $DIR/$tdir
10069 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10070 skip_env "no early lock cancel on server"
10072 lru_resize_disable mdc
10073 lru_resize_disable osc
10075 cancel_lru_locks mdc
10076 stat $DIR/$tdir > /dev/null
10077 can1=$(do_facet mds1 \
10078 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10079 awk '/ldlm_cancel/ {print $2}')
10080 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10081 awk '/ldlm_bl_callback/ {print $2}')
10082 chmod a+x $DIR/$tdir
10083 can2=$(do_facet mds1 \
10084 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10085 awk '/ldlm_cancel/ {print $2}')
10086 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10087 awk '/ldlm_bl_callback/ {print $2}')
10088 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10089 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10090 lru_resize_enable mdc
10091 lru_resize_enable osc
10093 run_test 120d "Early Lock Cancel: setattr test"
10096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10097 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10098 skip_env "no early lock cancel on server"
10099 remote_mds_nodsh && skip "remote MDS with nodsh"
10101 local dlmtrace_set=false
10103 test_mkdir -i0 -c1 $DIR/$tdir
10104 lru_resize_disable mdc
10105 lru_resize_disable osc
10106 ! $LCTL get_param debug | grep -q dlmtrace &&
10107 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
10108 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
10109 cancel_lru_locks mdc
10110 cancel_lru_locks osc
10111 dd if=$DIR/$tdir/f1 of=/dev/null
10112 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
10113 # XXX client can not do early lock cancel of OST lock
10114 # during unlink (LU-4206), so cancel osc lock now.
10116 cancel_lru_locks osc
10117 can1=$(do_facet mds1 \
10118 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10119 awk '/ldlm_cancel/ {print $2}')
10120 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10121 awk '/ldlm_bl_callback/ {print $2}')
10122 unlink $DIR/$tdir/f1
10124 can2=$(do_facet mds1 \
10125 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10126 awk '/ldlm_cancel/ {print $2}')
10127 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10128 awk '/ldlm_bl_callback/ {print $2}')
10129 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
10130 $LCTL dk $TMP/cancel.debug.txt
10131 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
10132 $LCTL dk $TMP/blocking.debug.txt
10133 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
10134 lru_resize_enable mdc
10135 lru_resize_enable osc
10137 run_test 120e "Early Lock Cancel: unlink test"
10140 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10141 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10142 skip_env "no early lock cancel on server"
10143 remote_mds_nodsh && skip "remote MDS with nodsh"
10145 test_mkdir -i0 -c1 $DIR/$tdir
10146 lru_resize_disable mdc
10147 lru_resize_disable osc
10148 test_mkdir -i0 -c1 $DIR/$tdir/d1
10149 test_mkdir -i0 -c1 $DIR/$tdir/d2
10150 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
10151 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
10152 cancel_lru_locks mdc
10153 cancel_lru_locks osc
10154 dd if=$DIR/$tdir/d1/f1 of=/dev/null
10155 dd if=$DIR/$tdir/d2/f2 of=/dev/null
10156 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
10157 # XXX client can not do early lock cancel of OST lock
10158 # during rename (LU-4206), so cancel osc lock now.
10160 cancel_lru_locks osc
10161 can1=$(do_facet mds1 \
10162 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10163 awk '/ldlm_cancel/ {print $2}')
10164 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10165 awk '/ldlm_bl_callback/ {print $2}')
10166 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10168 can2=$(do_facet mds1 \
10169 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10170 awk '/ldlm_cancel/ {print $2}')
10171 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10172 awk '/ldlm_bl_callback/ {print $2}')
10173 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10174 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10175 lru_resize_enable mdc
10176 lru_resize_enable osc
10178 run_test 120f "Early Lock Cancel: rename test"
10181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10182 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10183 skip_env "no early lock cancel on server"
10184 remote_mds_nodsh && skip "remote MDS with nodsh"
10186 lru_resize_disable mdc
10187 lru_resize_disable osc
10189 echo create $count files
10190 test_mkdir $DIR/$tdir
10191 cancel_lru_locks mdc
10192 cancel_lru_locks osc
10195 can0=$(do_facet $SINGLEMDS \
10196 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10197 awk '/ldlm_cancel/ {print $2}')
10198 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10199 awk '/ldlm_bl_callback/ {print $2}')
10200 createmany -o $DIR/$tdir/f $count
10202 can1=$(do_facet $SINGLEMDS \
10203 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10204 awk '/ldlm_cancel/ {print $2}')
10205 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10206 awk '/ldlm_bl_callback/ {print $2}')
10208 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
10209 echo rm $count files
10212 can2=$(do_facet $SINGLEMDS \
10213 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10214 awk '/ldlm_cancel/ {print $2}')
10215 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10216 awk '/ldlm_bl_callback/ {print $2}')
10218 echo total: $count removes in $((t2-t1))
10219 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
10221 # wait for commitment of removal
10222 lru_resize_enable mdc
10223 lru_resize_enable osc
10225 run_test 120g "Early Lock Cancel: performance test"
10227 test_121() { #bug #10589
10228 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10231 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
10232 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
10233 lctl set_param fail_loc=0x310
10234 cancel_lru_locks osc > /dev/null
10235 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
10236 lctl set_param fail_loc=0
10237 [[ $reads -eq $writes ]] ||
10238 error "read $reads blocks, must be $writes blocks"
10240 run_test 121 "read cancel race ========="
10242 test_123a() { # was test 123, statahead(bug 11401)
10243 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10246 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
10247 log "testing UP system. Performance may be lower than expected."
10252 test_mkdir $DIR/$tdir
10253 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
10254 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
10256 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
10257 createmany -o $DIR/$tdir/$tfile $j $((i - j))
10259 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10260 lctl set_param -n llite.*.statahead_max 0
10261 lctl get_param llite.*.statahead_max
10262 cancel_lru_locks mdc
10263 cancel_lru_locks osc
10265 time ls -l $DIR/$tdir | wc -l
10267 delta=$((etime - stime))
10268 log "ls $i files without statahead: $delta sec"
10269 lctl set_param llite.*.statahead_max=$max
10271 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10272 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
10273 cancel_lru_locks mdc
10274 cancel_lru_locks osc
10276 time ls -l $DIR/$tdir | wc -l
10278 delta_sa=$((etime - stime))
10279 log "ls $i files with statahead: $delta_sa sec"
10280 lctl get_param -n llite.*.statahead_stats
10281 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10283 [[ $swrong -lt $ewrong ]] &&
10284 log "statahead was stopped, maybe too many locks held!"
10285 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
10287 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10288 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10289 lctl set_param -n llite.*.statahead_max 0
10290 lctl get_param llite.*.statahead_max
10291 cancel_lru_locks mdc
10292 cancel_lru_locks osc
10294 time ls -l $DIR/$tdir | wc -l
10296 delta=$((etime - stime))
10297 log "ls $i files again without statahead: $delta sec"
10298 lctl set_param llite.*.statahead_max=$max
10299 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10300 if [ $SLOWOK -eq 0 ]; then
10301 error "ls $i files is slower with statahead!"
10303 log "ls $i files is slower with statahead!"
10309 [ $delta -gt 20 ] && break
10310 [ $delta -gt 8 ] && MULT=$((50 / delta))
10311 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
10319 delta=$((etime - stime))
10320 log "rm -r $DIR/$tdir/: $delta seconds"
10322 lctl get_param -n llite.*.statahead_stats
10324 run_test 123a "verify statahead work"
10326 test_123b () { # statahead(bug 15027)
10327 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10329 test_mkdir $DIR/$tdir
10330 createmany -o $DIR/$tdir/$tfile-%d 1000
10332 cancel_lru_locks mdc
10333 cancel_lru_locks osc
10335 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
10336 lctl set_param fail_loc=0x80000803
10337 ls -lR $DIR/$tdir > /dev/null
10339 lctl set_param fail_loc=0x0
10340 lctl get_param -n llite.*.statahead_stats
10345 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
10348 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10349 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10350 skip_env "no lru resize on server"
10354 test_mkdir $DIR/$tdir
10356 log "create $NR files at $DIR/$tdir"
10357 createmany -o $DIR/$tdir/f $NR ||
10358 error "failed to create $NR files in $DIR/$tdir"
10360 cancel_lru_locks mdc
10361 ls -l $DIR/$tdir > /dev/null
10365 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
10366 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
10367 LRU_SIZE=$($LCTL get_param -n $PARAM)
10368 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
10369 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
10371 log "NS=$(basename $NSDIR)"
10376 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
10377 skip "Not enough cached locks created!"
10379 log "LRU=$LRU_SIZE"
10383 # We know that lru resize allows one client to hold $LIMIT locks
10384 # for 10h. After that locks begin to be killed by client.
10386 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
10388 if [ $LIMIT -lt $LRU_SIZE ]; then
10389 skip "Limit is too small $LIMIT"
10392 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
10393 # killing locks. Some time was spent for creating locks. This means
10394 # that up to the moment of sleep finish we must have killed some of
10395 # them (10-100 locks). This depends on how fast ther were created.
10396 # Many of them were touched in almost the same moment and thus will
10397 # be killed in groups.
10398 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
10400 # Use $LRU_SIZE_B here to take into account real number of locks
10401 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
10402 local LRU_SIZE_B=$LRU_SIZE
10404 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
10405 log "OLD_LVF=$OLD_LVF"
10406 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
10408 # Let's make sure that we really have some margin. Client checks
10409 # cached locks every 10 sec.
10410 SLEEP=$((SLEEP+20))
10411 log "Sleep ${SLEEP} sec"
10413 while ((SEC<$SLEEP)); do
10417 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
10418 echo -n "$LRU_SIZE"
10421 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
10422 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
10424 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
10425 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
10426 unlinkmany $DIR/$tdir/f $NR
10430 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
10431 log "unlink $NR files at $DIR/$tdir"
10432 unlinkmany $DIR/$tdir/f $NR
10434 run_test 124a "lru resize ======================================="
10436 get_max_pool_limit()
10438 local limit=$($LCTL get_param \
10439 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
10441 for l in $limit; do
10442 if [[ $l -gt $max ]]; then
10450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10451 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10452 skip_env "no lru resize on server"
10454 LIMIT=$(get_max_pool_limit)
10456 NR=$(($(default_lru_size)*20))
10457 if [[ $NR -gt $LIMIT ]]; then
10458 log "Limit lock number by $LIMIT locks"
10462 IFree=$(mdsrate_inodes_available)
10463 if [ $IFree -lt $NR ]; then
10464 log "Limit lock number by $IFree inodes"
10468 lru_resize_disable mdc
10469 test_mkdir -p $DIR/$tdir/disable_lru_resize
10471 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
10472 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
10473 cancel_lru_locks mdc
10476 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10479 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10482 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10486 nolruresize_delta=$((etime-stime))
10487 log "ls -la time: $nolruresize_delta seconds"
10488 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10489 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
10491 lru_resize_enable mdc
10492 test_mkdir -p $DIR/$tdir/enable_lru_resize
10494 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
10495 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
10496 cancel_lru_locks mdc
10499 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10502 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10505 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10509 lruresize_delta=$((etime-stime))
10510 log "ls -la time: $lruresize_delta seconds"
10511 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10513 if [ $lruresize_delta -gt $nolruresize_delta ]; then
10514 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
10515 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
10516 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
10518 log "lru resize performs the same with no lru resize"
10520 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
10522 run_test 124b "lru resize (performance test) ======================="
10525 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10526 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10527 skip_env "no lru resize on server"
10529 # cache ununsed locks on client
10531 cancel_lru_locks mdc
10532 test_mkdir $DIR/$tdir
10533 createmany -o $DIR/$tdir/f $nr ||
10534 error "failed to create $nr files in $DIR/$tdir"
10535 ls -l $DIR/$tdir > /dev/null
10537 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10538 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10539 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10540 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10541 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10543 # set lru_max_age to 1 sec
10544 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10545 echo "sleep $((recalc_p * 2)) seconds..."
10546 sleep $((recalc_p * 2))
10548 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10549 # restore lru_max_age
10550 $LCTL set_param -n $nsdir.lru_max_age $max_age
10551 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10552 unlinkmany $DIR/$tdir/f $nr
10554 run_test 124c "LRUR cancel very aged locks"
10556 test_125() { # 13358
10557 $LCTL get_param -n llite.*.client_type | grep -q local ||
10558 skip "must run as local client"
10559 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
10560 skip_env "must have acl enabled"
10561 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
10563 test_mkdir $DIR/$tdir
10564 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
10565 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
10566 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
10568 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
10570 test_126() { # bug 12829/13455
10571 $GSS && skip_env "must run as gss disabled"
10572 $LCTL get_param -n llite.*.client_type | grep -q local ||
10573 skip "must run as local client"
10574 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
10576 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
10577 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
10579 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
10581 run_test 126 "check that the fsgid provided by the client is taken into account"
10583 test_127a() { # bug 15521
10584 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10586 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
10587 $LCTL set_param osc.*.stats=0
10588 FSIZE=$((2048 * 1024))
10589 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10590 cancel_lru_locks osc
10591 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
10593 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
10594 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
10595 echo "got $COUNT $NAME"
10596 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
10597 eval $NAME=$COUNT || error "Wrong proc format"
10600 read_bytes|write_bytes)
10601 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
10602 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
10603 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
10604 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
10605 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
10606 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
10607 error "sumsquare is too small: $SUMSQ"
10608 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
10609 error "sumsquare is too big: $SUMSQ"
10613 done < $DIR/${tfile}.tmp
10615 #check that we actually got some stats
10616 [ "$read_bytes" ] || error "Missing read_bytes stats"
10617 [ "$write_bytes" ] || error "Missing write_bytes stats"
10618 [ "$read_bytes" != 0 ] || error "no read done"
10619 [ "$write_bytes" != 0 ] || error "no write done"
10621 run_test 127a "verify the client stats are sane"
10623 test_127b() { # bug LU-333
10624 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10625 local name count samp unit min max sum sumsq
10627 $LCTL set_param llite.*.stats=0
10629 # perform 2 reads and writes so MAX is different from SUM.
10630 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
10631 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
10632 cancel_lru_locks osc
10633 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
10634 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
10636 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
10637 while read name count samp unit min max sum sumsq; do
10638 echo "got $count $name"
10639 eval $name=$count || error "Wrong proc format"
10643 [ $count -ne 2 ] && error "count is not 2: $count"
10644 [ $min -ne $PAGE_SIZE ] &&
10645 error "min is not $PAGE_SIZE: $min"
10646 [ $max -ne $PAGE_SIZE ] &&
10647 error "max is incorrect: $max"
10648 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
10649 error "sum is wrong: $sum"
10652 [ $count -ne 2 ] && error "count is not 2: $count"
10653 [ $min -ne $PAGE_SIZE ] &&
10654 error "min is not $PAGE_SIZE: $min"
10655 [ $max -ne $PAGE_SIZE ] &&
10656 error "max is incorrect: $max"
10657 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
10658 error "sum is wrong: $sum"
10662 done < $TMP/$tfile.tmp
10664 #check that we actually got some stats
10665 [ "$read_bytes" ] || error "Missing read_bytes stats"
10666 [ "$write_bytes" ] || error "Missing write_bytes stats"
10667 [ "$read_bytes" != 0 ] || error "no read done"
10668 [ "$write_bytes" != 0 ] || error "no write done"
10670 rm -f $TMP/${tfile}.tmp
10672 run_test 127b "verify the llite client stats are sane"
10674 test_128() { # bug 15212
10676 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
10681 result=$(grep error $TMP/$tfile.log)
10682 rm -f $DIR/$tfile $TMP/$tfile.log
10683 [ -z "$result" ] ||
10684 error "consecutive find's under interactive lfs failed"
10686 run_test 128 "interactive lfs for 2 consecutive find's"
10688 set_dir_limits () {
10693 local ldproc=/proc/fs/ldiskfs
10694 local facets=$(get_facets MDS)
10696 for facet in ${facets//,/ }; do
10697 canondev=$(ldiskfs_canon \
10698 *.$(convert_facet2label $facet).mntdev $facet)
10699 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
10700 ldproc=/sys/fs/ldiskfs
10701 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
10702 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
10706 check_mds_dmesg() {
10707 local facets=$(get_facets MDS)
10708 for facet in ${facets//,/ }; do
10709 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
10715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10716 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
10717 skip "Need MDS version with at least 2.5.56"
10718 if [ "$mds1_FSTYPE" != ldiskfs ]; then
10719 skip_env "ldiskfs only test"
10721 remote_mds_nodsh && skip "remote MDS with nodsh"
10725 local has_warning=false
10728 mkdir -p $DIR/$tdir
10730 # block size of mds1
10731 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
10732 set_dir_limits $maxsize $maxsize
10733 local dirsize=$(stat -c%s "$DIR/$tdir")
10735 while [[ $dirsize -le $maxsize ]]; do
10736 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
10738 if ! $has_warning; then
10739 check_mds_dmesg '"is approaching"' && has_warning=true
10741 # check two errors:
10742 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
10743 # EFBIG for previous versions included in ldiskfs series
10744 if [ $rc -eq $EFBIG ] || [ $rc -eq $ENOSPC ]; then
10746 echo "return code $rc received as expected"
10748 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
10749 error_exit "create failed w/o dir size limit"
10751 check_mds_dmesg '"has reached"' ||
10752 error_exit "reached message should be output"
10754 [ $has_warning = "false" ] &&
10755 error_exit "warning message should be output"
10757 dirsize=$(stat -c%s "$DIR/$tdir")
10759 [[ $dirsize -ge $maxsize ]] && return 0
10760 error_exit "current dir size $dirsize, " \
10761 "previous limit $maxsize"
10762 elif [ $rc -ne 0 ]; then
10764 error_exit "return $rc received instead of expected " \
10765 "$EFBIG or $ENOSPC, files in dir $dirsize"
10767 nfiles=$((nfiles + 1))
10768 dirsize=$(stat -c%s "$DIR/$tdir")
10772 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
10774 run_test 129 "test directory size limit ========================"
10783 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10784 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10786 trap cleanup_130 EXIT RETURN
10788 local fm_file=$DIR/$tfile
10789 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
10790 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
10791 error "dd failed for $fm_file"
10793 # LU-1795: test filefrag/FIEMAP once, even if unsupported
10794 filefrag -ves $fm_file
10796 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10797 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10798 [ $RC != 0 ] && error "filefrag $fm_file failed"
10800 filefrag_op=$(filefrag -ve -k $fm_file |
10801 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10802 lun=$($LFS getstripe -i $fm_file)
10804 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
10807 for line in $filefrag_op
10809 frag_lun=`echo $line | cut -d: -f5`
10810 ext_len=`echo $line | cut -d: -f4`
10811 if (( $frag_lun != $lun )); then
10813 error "FIEMAP on 1-stripe file($fm_file) failed"
10816 (( tot_len += ext_len ))
10819 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
10821 error "FIEMAP on 1-stripe file($fm_file) failed;"
10827 echo "FIEMAP on single striped file succeeded"
10829 run_test 130a "FIEMAP (1-stripe file)"
10832 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
10834 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10835 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10837 trap cleanup_130 EXIT RETURN
10839 local fm_file=$DIR/$tfile
10840 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
10841 error "setstripe on $fm_file"
10842 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10843 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10845 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
10846 error "dd failed on $fm_file"
10848 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10849 filefrag_op=$(filefrag -ve -k $fm_file |
10850 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10852 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10853 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10858 for line in $filefrag_op
10860 frag_lun=$(echo $line | cut -d: -f5 |
10861 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10862 ext_len=$(echo $line | cut -d: -f4)
10863 if (( $frag_lun != $last_lun )); then
10864 if (( tot_len != 1024 )); then
10866 error "FIEMAP on $fm_file failed; returned " \
10867 "len $tot_len for OST $last_lun instead of 1024"
10870 (( num_luns += 1 ))
10874 (( tot_len += ext_len ))
10877 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
10879 error "FIEMAP on $fm_file failed; returned wrong number of " \
10880 "luns or wrong len for OST $last_lun"
10886 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
10888 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
10891 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10893 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10894 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10896 trap cleanup_130 EXIT RETURN
10898 local fm_file=$DIR/$tfile
10899 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
10900 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10901 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10903 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
10904 error "dd failed on $fm_file"
10906 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10907 filefrag_op=$(filefrag -ve -k $fm_file |
10908 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10910 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10911 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10916 for line in $filefrag_op
10918 frag_lun=$(echo $line | cut -d: -f5 |
10919 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10920 ext_len=$(echo $line | cut -d: -f4)
10921 if (( $frag_lun != $last_lun )); then
10922 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
10923 if (( logical != 512 )); then
10925 error "FIEMAP on $fm_file failed; returned " \
10926 "logical start for lun $logical instead of 512"
10929 if (( tot_len != 512 )); then
10931 error "FIEMAP on $fm_file failed; returned " \
10932 "len $tot_len for OST $last_lun instead of 1024"
10935 (( num_luns += 1 ))
10939 (( tot_len += ext_len ))
10942 if (( num_luns != 2 || tot_len != 512 )); then
10944 error "FIEMAP on $fm_file failed; returned wrong number of " \
10945 "luns or wrong len for OST $last_lun"
10951 echo "FIEMAP on 2-stripe file with hole succeeded"
10953 run_test 130c "FIEMAP (2-stripe file with hole)"
10956 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
10958 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10959 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10961 trap cleanup_130 EXIT RETURN
10963 local fm_file=$DIR/$tfile
10964 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
10965 error "setstripe on $fm_file"
10966 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10967 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10969 local actual_stripe_count=$($LFS getstripe -c $fm_file)
10970 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
10971 error "dd failed on $fm_file"
10973 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10974 filefrag_op=$(filefrag -ve -k $fm_file |
10975 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10977 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10978 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10983 for line in $filefrag_op
10985 frag_lun=$(echo $line | cut -d: -f5 |
10986 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10987 ext_len=$(echo $line | cut -d: -f4)
10988 if (( $frag_lun != $last_lun )); then
10989 if (( tot_len != 1024 )); then
10991 error "FIEMAP on $fm_file failed; returned " \
10992 "len $tot_len for OST $last_lun instead of 1024"
10995 (( num_luns += 1 ))
10999 (( tot_len += ext_len ))
11002 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
11004 error "FIEMAP on $fm_file failed; returned wrong number of " \
11005 "luns or wrong len for OST $last_lun"
11011 echo "FIEMAP on N-stripe file succeeded"
11013 run_test 130d "FIEMAP (N-stripe file)"
11016 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11018 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11019 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11021 trap cleanup_130 EXIT RETURN
11023 local fm_file=$DIR/$tfile
11024 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
11025 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11026 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11029 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
11030 for ((i = 0; i < $NUM_BLKS; i++))
11032 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
11035 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11036 filefrag_op=$(filefrag -ve -k $fm_file |
11037 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11039 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11040 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11045 for line in $filefrag_op
11047 frag_lun=$(echo $line | cut -d: -f5 |
11048 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11049 ext_len=$(echo $line | cut -d: -f4)
11050 if (( $frag_lun != $last_lun )); then
11051 if (( tot_len != $EXPECTED_LEN )); then
11053 error "FIEMAP on $fm_file failed; returned " \
11054 "len $tot_len for OST $last_lun instead " \
11058 (( num_luns += 1 ))
11062 (( tot_len += ext_len ))
11065 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
11067 error "FIEMAP on $fm_file failed; returned wrong number " \
11068 "of luns or wrong len for OST $last_lun"
11074 echo "FIEMAP with continuation calls succeeded"
11076 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
11079 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11080 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11082 local fm_file=$DIR/$tfile
11083 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
11084 error "multiop create with lov_delay_create on $fm_file"
11086 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11087 filefrag_extents=$(filefrag -vek $fm_file |
11088 awk '/extents? found/ { print $2 }')
11089 if [[ "$filefrag_extents" != "0" ]]; then
11090 error "FIEMAP on $fm_file failed; " \
11091 "returned $filefrag_extents expected 0"
11096 run_test 130f "FIEMAP (unstriped file)"
11098 # Test for writev/readv
11100 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
11101 error "writev test failed"
11102 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
11103 error "readv failed"
11106 run_test 131a "test iov's crossing stripe boundary for writev/readv"
11109 local fsize=$((524288 + 1048576 + 1572864))
11110 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
11111 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11112 error "append writev test failed"
11114 ((fsize += 1572864 + 1048576))
11115 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
11116 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11117 error "append writev test failed"
11120 run_test 131b "test append writev"
11123 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
11126 run_test 131c "test read/write on file w/o objects"
11129 rwv -f $DIR/$tfile -w -n 1 1572864
11130 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
11131 if [ "$NOB" != 1572864 ]; then
11132 error "Short read filed: read $NOB bytes instead of 1572864"
11136 run_test 131d "test short read"
11139 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
11140 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
11141 error "read hitting hole failed"
11144 run_test 131e "test read hitting hole"
11153 mds*) res=$(do_facet $facet \
11154 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
11156 ost*) res=$(do_facet $facet \
11157 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
11159 *) error "Wrong facet '$facet'" ;;
11161 [ "$res" ] || error "The counter for $op on $facet was not incremented"
11162 # if the argument $3 is zero, it means any stat increment is ok.
11163 if [[ $want -gt 0 ]]; then
11164 local count=$(echo $res | awk '{ print $2 }')
11165 [[ $count -ne $want ]] &&
11166 error "The $op counter on $facet is $count, not $want"
11171 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11172 remote_ost_nodsh && skip "remote OST with nodsh"
11173 remote_mds_nodsh && skip "remote MDS with nodsh"
11174 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11175 skip_env "MDS doesn't support rename stats"
11177 local testdir=$DIR/${tdir}/stats_testdir
11179 mkdir -p $DIR/${tdir}
11182 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11183 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11185 # verify mdt stats first.
11186 mkdir ${testdir} || error "mkdir failed"
11187 check_stats $SINGLEMDS "mkdir" 1
11188 touch ${testdir}/${tfile} || error "touch failed"
11189 check_stats $SINGLEMDS "open" 1
11190 check_stats $SINGLEMDS "close" 1
11191 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
11192 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
11193 check_stats $SINGLEMDS "mknod" 2
11195 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
11196 check_stats $SINGLEMDS "unlink" 1
11197 rm -f ${testdir}/${tfile} || error "file remove failed"
11198 check_stats $SINGLEMDS "unlink" 2
11200 # remove working dir and check mdt stats again.
11201 rmdir ${testdir} || error "rmdir failed"
11202 check_stats $SINGLEMDS "rmdir" 1
11204 local testdir1=$DIR/${tdir}/stats_testdir1
11205 mkdir -p ${testdir}
11206 mkdir -p ${testdir1}
11207 touch ${testdir1}/test1
11208 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
11209 check_stats $SINGLEMDS "crossdir_rename" 1
11211 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
11212 check_stats $SINGLEMDS "samedir_rename" 1
11214 rm -rf $DIR/${tdir}
11216 run_test 133a "Verifying MDT stats ========================================"
11221 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11222 remote_ost_nodsh && skip "remote OST with nodsh"
11223 remote_mds_nodsh && skip "remote MDS with nodsh"
11225 local testdir=$DIR/${tdir}/stats_testdir
11227 mkdir -p ${testdir} || error "mkdir failed"
11228 touch ${testdir}/${tfile} || error "touch failed"
11229 cancel_lru_locks mdc
11232 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11233 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11235 # extra mdt stats verification.
11236 chmod 444 ${testdir}/${tfile} || error "chmod failed"
11237 check_stats $SINGLEMDS "setattr" 1
11238 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11239 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
11241 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
11242 check_stats $SINGLEMDS "getattr" 1
11244 rm -rf $DIR/${tdir}
11246 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
11247 # so the check below is not reliable
11248 [ $MDSCOUNT -eq 1 ] || return 0
11250 # Sleep to avoid a cached response.
11251 #define OBD_STATFS_CACHE_SECONDS 1
11253 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11254 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11255 $LFS df || error "lfs failed"
11256 check_stats $SINGLEMDS "statfs" 1
11258 # check aggregated statfs (LU-10018)
11259 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
11261 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
11264 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11265 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11267 check_stats $SINGLEMDS "statfs" 1
11269 # We want to check that the client didn't send OST_STATFS to
11270 # ost1 but the MDT also uses OST_STATFS for precreate. So some
11271 # extra care is needed here.
11272 if remote_mds; then
11273 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
11274 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
11276 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
11277 [ "$res" ] && error "OST got STATFS"
11282 run_test 133b "Verifying extra MDT stats =================================="
11285 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11286 remote_ost_nodsh && skip "remote OST with nodsh"
11287 remote_mds_nodsh && skip "remote MDS with nodsh"
11289 local testdir=$DIR/$tdir/stats_testdir
11291 test_mkdir -p $testdir
11293 # verify obdfilter stats.
11294 $LFS setstripe -c 1 -i 0 $testdir/$tfile
11296 cancel_lru_locks osc
11297 wait_delete_completed
11300 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11301 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11303 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
11306 cancel_lru_locks osc
11307 check_stats ost1 "write" 1
11309 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
11310 check_stats ost1 "read" 1
11312 > $testdir/$tfile || error "truncate failed"
11313 check_stats ost1 "punch" 1
11315 rm -f $testdir/$tfile || error "file remove failed"
11316 wait_delete_completed
11317 check_stats ost1 "destroy" 1
11321 run_test 133c "Verifying OST stats ========================================"
11328 while [ $value -ge 2 ]; do
11333 if [ $orig -gt $order ]; then
11341 local size=('K' 'M' 'G' 'T');
11343 local size_string=$value
11345 while [ $value -ge 1024 ]; do
11346 if [ $i -gt 3 ]; then
11347 #T is the biggest unit we get here, if that is bigger,
11349 size_string=${value}T
11352 value=$((value >> 10))
11353 if [ $value -lt 1024 ]; then
11354 size_string=${value}${size[$i]}
11363 get_rename_size() {
11365 local context=${2:-.}
11366 local sample=$(do_facet $SINGLEMDS $LCTL \
11367 get_param mdt.$FSNAME-MDT0000.rename_stats |
11368 grep -A1 $context |
11369 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
11374 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11375 remote_ost_nodsh && skip "remote OST with nodsh"
11376 remote_mds_nodsh && skip "remote MDS with nodsh"
11377 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11378 skip_env "MDS doesn't support rename stats"
11380 local testdir1=$DIR/${tdir}/stats_testdir1
11381 local testdir2=$DIR/${tdir}/stats_testdir2
11382 mkdir -p $DIR/${tdir}
11384 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11386 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
11387 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
11389 createmany -o $testdir1/test 512 || error "createmany failed"
11391 # check samedir rename size
11392 mv ${testdir1}/test0 ${testdir1}/test_0
11394 local testdir1_size=$(ls -l $DIR/${tdir} |
11395 awk '/stats_testdir1/ {print $5}')
11396 local testdir2_size=$(ls -l $DIR/${tdir} |
11397 awk '/stats_testdir2/ {print $5}')
11399 testdir1_size=$(order_2 $testdir1_size)
11400 testdir2_size=$(order_2 $testdir2_size)
11402 testdir1_size=$(size_in_KMGT $testdir1_size)
11403 testdir2_size=$(size_in_KMGT $testdir2_size)
11405 echo "source rename dir size: ${testdir1_size}"
11406 echo "target rename dir size: ${testdir2_size}"
11408 local cmd="do_facet $SINGLEMDS $LCTL "
11409 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
11411 eval $cmd || error "$cmd failed"
11412 local samedir=$($cmd | grep 'same_dir')
11413 local same_sample=$(get_rename_size $testdir1_size)
11414 [ -z "$samedir" ] && error "samedir_rename_size count error"
11415 [[ $same_sample -eq 1 ]] ||
11416 error "samedir_rename_size error $same_sample"
11417 echo "Check same dir rename stats success"
11419 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11421 # check crossdir rename size
11422 mv ${testdir1}/test_0 ${testdir2}/test_0
11424 testdir1_size=$(ls -l $DIR/${tdir} |
11425 awk '/stats_testdir1/ {print $5}')
11426 testdir2_size=$(ls -l $DIR/${tdir} |
11427 awk '/stats_testdir2/ {print $5}')
11429 testdir1_size=$(order_2 $testdir1_size)
11430 testdir2_size=$(order_2 $testdir2_size)
11432 testdir1_size=$(size_in_KMGT $testdir1_size)
11433 testdir2_size=$(size_in_KMGT $testdir2_size)
11435 echo "source rename dir size: ${testdir1_size}"
11436 echo "target rename dir size: ${testdir2_size}"
11438 eval $cmd || error "$cmd failed"
11439 local crossdir=$($cmd | grep 'crossdir')
11440 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
11441 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
11442 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
11443 [[ $src_sample -eq 1 ]] ||
11444 error "crossdir_rename_size error $src_sample"
11445 [[ $tgt_sample -eq 1 ]] ||
11446 error "crossdir_rename_size error $tgt_sample"
11447 echo "Check cross dir rename stats success"
11448 rm -rf $DIR/${tdir}
11450 run_test 133d "Verifying rename_stats ========================================"
11453 remote_mds_nodsh && skip "remote MDS with nodsh"
11454 remote_ost_nodsh && skip "remote OST with nodsh"
11455 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11457 local testdir=$DIR/${tdir}/stats_testdir
11458 local ctr f0 f1 bs=32768 count=42 sum
11460 mkdir -p ${testdir} || error "mkdir failed"
11462 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
11464 for ctr in {write,read}_bytes; do
11466 cancel_lru_locks osc
11468 do_facet ost1 $LCTL set_param -n \
11469 "obdfilter.*.exports.clear=clear"
11471 if [ $ctr = write_bytes ]; then
11473 f1=${testdir}/${tfile}
11475 f0=${testdir}/${tfile}
11479 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
11482 cancel_lru_locks osc
11484 sum=$(do_facet ost1 $LCTL get_param \
11485 "obdfilter.*.exports.*.stats" |
11486 awk -v ctr=$ctr 'BEGIN { sum = 0 }
11487 $1 == ctr { sum += $7 }
11488 END { printf("%0.0f", sum) }')
11490 if ((sum != bs * count)); then
11491 error "Bad $ctr sum, expected $((bs * count)), got $sum"
11495 rm -rf $DIR/${tdir}
11497 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
11499 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
11501 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
11502 # not honor the -ignore_readdir_race option correctly. So we call
11503 # error_ignore() rather than error() in these cases. See LU-11152.
11505 if (find --version; do_facet mds1 find --version) |
11506 grep -q '\b4\.5\.1[1-4]\b'; then
11507 error_ignore LU-11152 "$@"
11514 # First without trusting modes.
11515 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
11516 echo "proc_dirs='$proc_dirs'"
11517 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
11518 find $proc_dirs -exec cat '{}' \; &> /dev/null
11520 # Second verifying readability.
11521 $LCTL get_param -R '*' &> /dev/null
11523 # Verifing writability with badarea_io.
11525 -ignore_readdir_race \
11527 -not -name force_lbug \
11528 -not -name changelog_mask \
11529 -exec badarea_io '{}' \; ||
11530 error_133 "find $proc_dirs failed"
11532 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
11535 remote_mds_nodsh && skip "remote MDS with nodsh"
11536 remote_ost_nodsh && skip "remote OST with nodsh"
11538 # eventually, this can also be replaced with "lctl get_param -R",
11539 # but not until that option is always available on the server
11541 for facet in mds1 ost1; do
11542 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
11543 skip_noexit "Too old lustre on $facet"
11544 local facet_proc_dirs=$(do_facet $facet \
11545 \\\ls -d $proc_regexp 2>/dev/null)
11546 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11547 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11548 do_facet $facet find $facet_proc_dirs \
11549 ! -name req_history \
11550 -exec cat '{}' \\\; &> /dev/null
11552 do_facet $facet find $facet_proc_dirs \
11553 ! -name req_history \
11555 -exec cat '{}' \\\; &> /dev/null ||
11556 error "proc file read failed"
11558 do_facet $facet find $facet_proc_dirs \
11559 -ignore_readdir_race \
11561 -not -name force_lbug \
11562 -not -name changelog_mask \
11563 -exec badarea_io '{}' \\\; ||
11564 error_133 "$facet find $facet_proc_dirs failed"
11567 # remount the FS in case writes/reads /proc break the FS
11568 cleanup || error "failed to unmount"
11569 setup || error "failed to setup"
11572 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
11575 remote_mds_nodsh && skip "remote MDS with nodsh"
11576 remote_ost_nodsh && skip "remote OST with nodsh"
11577 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
11578 skip "Need MDS version at least 2.9.54"
11582 for facet in client mds1 ost1; do
11583 local facet_proc_dirs=$(do_facet $facet \
11584 \\\ls -d $proc_regexp 2> /dev/null)
11585 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11586 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11587 # Get the list of files that are missing the terminating newline
11588 local missing=($(do_facet $facet \
11589 find ${facet_proc_dirs} -type f \| \
11590 while read F\; do \
11591 awk -v FS='\v' -v RS='\v\v' \
11592 "'END { if(NR>0 && \
11593 \\\$NF !~ /.*\\\n\$/) \
11594 print FILENAME}'" \
11597 [ ${#missing[*]} -eq 0 ] ||
11598 error "files do not end with newline: ${missing[*]}"
11601 run_test 133h "Proc files should end with newlines"
11604 remote_mds_nodsh && skip "remote MDS with nodsh"
11605 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
11606 skip "Need MDS version at least 2.7.54"
11608 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11609 cancel_lru_locks mdc
11611 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11612 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11613 [ $unused -eq 0 ] || error "$unused locks are not cleared"
11616 createmany -o $DIR/$tdir/f $nr ||
11617 error "failed to create $nr files in $DIR/$tdir"
11618 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11620 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
11621 do_facet mds1 $LCTL set_param fail_loc=0x327
11622 do_facet mds1 $LCTL set_param fail_val=500
11625 echo "sleep 10 seconds ..."
11627 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
11629 do_facet mds1 $LCTL set_param fail_loc=0
11630 do_facet mds1 $LCTL set_param fail_val=0
11631 [ $lck_cnt -lt $unused ] ||
11632 error "No locks reclaimed, before:$unused, after:$lck_cnt"
11635 unlinkmany $DIR/$tdir/f $nr
11637 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
11640 remote_mds_nodsh && skip "remote MDS with nodsh"
11641 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
11642 skip "Need MDS version at least 2.7.54"
11644 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11645 cancel_lru_locks mdc
11647 local low_wm=$(do_facet mds1 $LCTL get_param -n \
11648 ldlm.lock_reclaim_threshold_mb)
11649 # disable reclaim temporarily
11650 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
11652 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
11653 do_facet mds1 $LCTL set_param fail_loc=0x328
11654 do_facet mds1 $LCTL set_param fail_val=500
11656 $LCTL set_param debug=+trace
11659 createmany -o $DIR/$tdir/f $nr &
11660 local create_pid=$!
11662 echo "Sleep $TIMEOUT seconds ..."
11664 if ! ps -p $create_pid > /dev/null 2>&1; then
11665 do_facet mds1 $LCTL set_param fail_loc=0
11666 do_facet mds1 $LCTL set_param fail_val=0
11667 do_facet mds1 $LCTL set_param \
11668 ldlm.lock_reclaim_threshold_mb=${low_wm}m
11669 error "createmany finished incorrectly!"
11671 do_facet mds1 $LCTL set_param fail_loc=0
11672 do_facet mds1 $LCTL set_param fail_val=0
11673 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
11674 wait $create_pid || return 1
11676 unlinkmany $DIR/$tdir/f $nr
11678 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
11680 test_140() { #bug-17379
11681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11683 test_mkdir $DIR/$tdir
11684 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
11685 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
11687 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
11688 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
11690 while i=$((i + 1)); do
11692 cd $i || error "Changing to $i"
11693 ln -s ../stat stat || error "Creating stat symlink"
11694 # Read the symlink until ELOOP present,
11695 # not LBUGing the system is considered success,
11696 # we didn't overrun the stack.
11697 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
11698 if [ $ret -ne 0 ]; then
11699 if [ $ret -eq 40 ]; then
11702 error "Open stat symlink"
11708 echo "The symlink depth = $i"
11709 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
11710 error "Invalid symlink depth"
11712 # Test recursive symlink
11713 ln -s symlink_self symlink_self
11714 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
11715 echo "open symlink_self returns $ret"
11716 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
11718 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
11721 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11723 local TF="$TMP/$tfile"
11725 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11727 cancel_lru_locks $OSC
11728 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
11729 remount_client $MOUNT
11731 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
11734 $TRUNCATE $DIR/$tfile 6000
11735 cancel_lru_locks $OSC
11736 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
11739 echo "12345" >>$DIR/$tfile
11740 cancel_lru_locks $OSC
11741 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
11744 echo "12345" >>$DIR/$tfile
11745 cancel_lru_locks $OSC
11746 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
11751 run_test 150 "truncate/append tests"
11753 #LU-2902 roc_hit was not able to read all values from lproc
11754 function roc_hit_init() {
11755 local list=$(comma_list $(osts_nodes))
11756 local dir=$DIR/$tdir-check
11757 local file=$dir/$tfile
11763 #use setstripe to do a write to every ost
11764 for i in $(seq 0 $((OSTCOUNT-1))); do
11765 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
11766 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
11767 idx=$(printf %04x $i)
11768 BEFORE=$(get_osd_param $list *OST*$idx stats |
11769 awk '$1 == "cache_access" {sum += $7}
11770 END { printf("%0.0f", sum) }')
11772 cancel_lru_locks osc
11773 cat $file >/dev/null
11775 AFTER=$(get_osd_param $list *OST*$idx stats |
11776 awk '$1 == "cache_access" {sum += $7}
11777 END { printf("%0.0f", sum) }')
11779 echo BEFORE:$BEFORE AFTER:$AFTER
11780 if ! let "AFTER - BEFORE == 4"; then
11782 error "roc_hit is not safe to use"
11790 function roc_hit() {
11791 local list=$(comma_list $(osts_nodes))
11792 echo $(get_osd_param $list '' stats |
11793 awk '$1 == "cache_hit" {sum += $7}
11794 END { printf("%0.0f", sum) }')
11797 function set_cache() {
11800 if [ "$2" == "off" ]; then
11803 local list=$(comma_list $(osts_nodes))
11804 set_osd_param $list '' $1_cache_enable $on
11806 cancel_lru_locks osc
11810 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11811 remote_ost_nodsh && skip "remote OST with nodsh"
11814 local list=$(comma_list $(osts_nodes))
11816 # check whether obdfilter is cache capable at all
11817 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
11818 skip "not cache-capable obdfilter"
11821 # check cache is enabled on all obdfilters
11822 if get_osd_param $list '' read_cache_enable | grep 0; then
11823 skip "oss cache is disabled"
11826 set_osd_param $list '' writethrough_cache_enable 1
11828 # check write cache is enabled on all obdfilters
11829 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
11830 skip "oss write cache is NOT enabled"
11835 #define OBD_FAIL_OBD_NO_LRU 0x609
11836 do_nodes $list $LCTL set_param fail_loc=0x609
11838 # pages should be in the case right after write
11839 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
11842 local BEFORE=$(roc_hit)
11843 cancel_lru_locks osc
11844 cat $DIR/$tfile >/dev/null
11845 local AFTER=$(roc_hit)
11847 do_nodes $list $LCTL set_param fail_loc=0
11849 if ! let "AFTER - BEFORE == CPAGES"; then
11850 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11853 # the following read invalidates the cache
11854 cancel_lru_locks osc
11855 set_osd_param $list '' read_cache_enable 0
11856 cat $DIR/$tfile >/dev/null
11858 # now data shouldn't be found in the cache
11860 cancel_lru_locks osc
11861 cat $DIR/$tfile >/dev/null
11863 if let "AFTER - BEFORE != 0"; then
11864 error "IN CACHE: before: $BEFORE, after: $AFTER"
11867 set_osd_param $list '' read_cache_enable 1
11870 run_test 151 "test cache on oss and controls ==============================="
11873 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11875 local TF="$TMP/$tfile"
11877 # simulate ENOMEM during write
11878 #define OBD_FAIL_OST_NOMEM 0x226
11879 lctl set_param fail_loc=0x80000226
11880 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11882 sync || error "sync failed"
11883 lctl set_param fail_loc=0
11885 # discard client's cache
11886 cancel_lru_locks osc
11888 # simulate ENOMEM during read
11889 lctl set_param fail_loc=0x80000226
11890 cmp $TF $DIR/$tfile || error "cmp failed"
11891 lctl set_param fail_loc=0
11895 run_test 152 "test read/write with enomem ============================"
11898 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
11900 run_test 153 "test if fdatasync does not crash ======================="
11902 dot_lustre_fid_permission_check() {
11904 local ffid=$MOUNT/.lustre/fid/$fid
11907 echo "stat fid $fid"
11908 stat $ffid > /dev/null || error "stat $ffid failed."
11909 echo "touch fid $fid"
11910 touch $ffid || error "touch $ffid failed."
11911 echo "write to fid $fid"
11912 cat /etc/hosts > $ffid || error "write $ffid failed."
11913 echo "read fid $fid"
11914 diff /etc/hosts $ffid || error "read $ffid failed."
11915 echo "append write to fid $fid"
11916 cat /etc/hosts >> $ffid || error "append write $ffid failed."
11917 echo "rename fid $fid"
11918 mv $ffid $test_dir/$tfile.1 &&
11919 error "rename $ffid to $tfile.1 should fail."
11920 touch $test_dir/$tfile.1
11921 mv $test_dir/$tfile.1 $ffid &&
11922 error "rename $tfile.1 to $ffid should fail."
11923 rm -f $test_dir/$tfile.1
11924 echo "truncate fid $fid"
11925 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
11926 echo "link fid $fid"
11927 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
11928 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
11929 echo "setfacl fid $fid"
11930 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
11931 echo "getfacl fid $fid"
11932 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
11934 echo "unlink fid $fid"
11935 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
11936 echo "mknod fid $fid"
11937 mknod $ffid c 1 3 && error "mknod $ffid should fail."
11939 fid=[0xf00000400:0x1:0x0]
11940 ffid=$MOUNT/.lustre/fid/$fid
11942 echo "stat non-exist fid $fid"
11943 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
11944 echo "write to non-exist fid $fid"
11945 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
11946 echo "link new fid $fid"
11947 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
11949 mkdir -p $test_dir/$tdir
11950 touch $test_dir/$tdir/$tfile
11951 fid=$($LFS path2fid $test_dir/$tdir)
11954 error "error: could not get fid for $test_dir/$dir/$tfile."
11956 ffid=$MOUNT/.lustre/fid/$fid
11959 ls $ffid > /dev/null || error "ls $ffid failed."
11960 echo "touch $fid/$tfile.1"
11961 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
11963 echo "touch $MOUNT/.lustre/fid/$tfile"
11964 touch $MOUNT/.lustre/fid/$tfile && \
11965 error "touch $MOUNT/.lustre/fid/$tfile should fail."
11967 echo "setxattr to $MOUNT/.lustre/fid"
11968 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
11970 echo "listxattr for $MOUNT/.lustre/fid"
11971 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
11973 echo "delxattr from $MOUNT/.lustre/fid"
11974 setfattr -x trusted.name1 $MOUNT/.lustre/fid
11976 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
11977 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
11978 error "touch invalid fid should fail."
11980 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
11981 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
11982 error "touch non-normal fid should fail."
11984 echo "rename $tdir to $MOUNT/.lustre/fid"
11985 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
11986 error "rename to $MOUNT/.lustre/fid should fail."
11988 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
11990 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
11991 local new_obf_mode=777
11993 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
11994 chmod $new_obf_mode $DIR/.lustre/fid ||
11995 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
11997 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
11998 [ $obf_mode -eq $new_obf_mode ] ||
11999 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
12001 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
12002 chmod $old_obf_mode $DIR/.lustre/fid ||
12003 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
12006 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
12007 fid=$($LFS path2fid $test_dir/$tfile-2)
12009 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
12011 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
12012 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
12013 error "create lov data thru .lustre failed"
12015 echo "cp /etc/passwd $test_dir/$tfile-2"
12016 cp /etc/passwd $test_dir/$tfile-2 ||
12017 error "copy to $test_dir/$tfile-2 failed."
12018 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
12019 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
12020 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
12022 rm -rf $test_dir/tfile.lnk
12023 rm -rf $test_dir/$tfile-2
12027 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12028 skip "Need MDS version at least 2.4.1"
12030 local tf=$DIR/$tfile
12033 local fid=$($LFS path2fid $tf)
12034 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
12036 # check that we get the same pathname back
12037 local found=$($LFS fid2path $MOUNT "$fid")
12038 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
12039 [ "$found" == "$tf" ] ||
12040 error "fid2path($fid=path2fid($tf)) = $found != $tf"
12042 run_test 154A "lfs path2fid and fid2path basic checks"
12045 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12046 skip "Need MDS version at least 2.4.1"
12048 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
12049 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
12050 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
12051 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
12053 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
12054 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
12056 # check that we get the same pathname
12057 echo "PFID: $PFID, name: $name"
12058 local FOUND=$($LFS fid2path $MOUNT "$PFID")
12059 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
12060 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
12061 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
12063 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
12065 run_test 154B "verify the ll_decode_linkea tool"
12068 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12069 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12070 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12071 skip "Need MDS version at least 2.2.51"
12072 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
12074 cp /etc/hosts $DIR/$tfile
12076 fid=$($LFS path2fid $DIR/$tfile)
12078 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
12080 dot_lustre_fid_permission_check "$fid" $DIR ||
12081 error "dot lustre permission check $fid failed"
12083 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
12085 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
12087 touch $MOUNT/.lustre/file &&
12088 error "creation is not allowed under .lustre"
12090 mkdir $MOUNT/.lustre/dir &&
12091 error "mkdir is not allowed under .lustre"
12095 run_test 154a "Open-by-FID"
12098 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12099 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12100 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12101 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12102 skip "Need MDS version at least 2.2.51"
12104 local remote_dir=$DIR/$tdir/remote_dir
12108 mkdir -p $DIR/$tdir
12109 $LFS mkdir -i $MDTIDX $remote_dir ||
12110 error "create remote directory failed"
12112 cp /etc/hosts $remote_dir/$tfile
12114 fid=$($LFS path2fid $remote_dir/$tfile)
12116 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
12118 dot_lustre_fid_permission_check "$fid" $remote_dir ||
12119 error "dot lustre permission check $fid failed"
12122 run_test 154b "Open-by-FID for remote directory"
12125 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12126 skip "Need MDS version at least 2.4.1"
12128 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
12129 local FID1=$($LFS path2fid $DIR/$tfile.1)
12130 local FID2=$($LFS path2fid $DIR/$tfile.2)
12131 local FID3=$($LFS path2fid $DIR/$tfile.3)
12134 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
12135 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
12136 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
12138 [ "$FID" = "${!want}" ] ||
12139 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
12143 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
12145 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
12146 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
12150 run_test 154c "lfs path2fid and fid2path multiple arguments"
12153 remote_mds_nodsh && skip "remote MDS with nodsh"
12154 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
12155 skip "Need MDS version at least 2.5.53"
12157 if remote_mds; then
12158 nid=$($LCTL list_nids | sed "s/\./\\\./g")
12162 local proc_ofile="mdt.*.exports.'$nid'.open_files"
12169 local fid=$($LFS path2fid $DIR/$tfile)
12172 cmd="exec $fd<$DIR/$tfile"
12174 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
12175 echo "$fid_list" | grep "$fid"
12178 cmd="exec $fd>/dev/null"
12180 if [ $rc -ne 0 ]; then
12181 error "FID $fid not found in open files list $fid_list"
12184 run_test 154d "Verify open file fid"
12188 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
12189 skip "Need MDS version at least 2.6.50"
12191 if ls -a $MOUNT | grep -q '^\.lustre$'; then
12192 error ".lustre returned by readdir"
12195 run_test 154e ".lustre is not returned by readdir"
12198 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12200 # create parent directory on a single MDT to avoid cross-MDT hardlinks
12201 test_mkdir -p -c1 $DIR/$tdir/d
12202 # test dirs inherit from its stripe
12203 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
12204 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
12205 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
12206 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
12209 # get fid of parents
12210 local FID0=$($LFS path2fid $DIR/$tdir/d)
12211 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
12212 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
12213 local FID3=$($LFS path2fid $DIR)
12215 # check that path2fid --parents returns expected <parent_fid>/name
12216 # 1) test for a directory (single parent)
12217 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
12218 [ "$parent" == "$FID0/foo1" ] ||
12219 error "expected parent: $FID0/foo1, got: $parent"
12221 # 2) test for a file with nlink > 1 (multiple parents)
12222 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
12223 echo "$parent" | grep -F "$FID1/$tfile" ||
12224 error "$FID1/$tfile not returned in parent list"
12225 echo "$parent" | grep -F "$FID2/link" ||
12226 error "$FID2/link not returned in parent list"
12228 # 3) get parent by fid
12229 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
12230 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12231 echo "$parent" | grep -F "$FID1/$tfile" ||
12232 error "$FID1/$tfile not returned in parent list (by fid)"
12233 echo "$parent" | grep -F "$FID2/link" ||
12234 error "$FID2/link not returned in parent list (by fid)"
12236 # 4) test for entry in root directory
12237 parent=$($LFS path2fid --parents $DIR/f)
12238 echo "$parent" | grep -F "$FID3/f" ||
12239 error "$FID3/f not returned in parent list"
12241 # 5) test it on root directory
12242 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
12243 error "$MOUNT should not have parents"
12245 # enable xattr caching and check that linkea is correctly updated
12246 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12247 save_lustre_params client "llite.*.xattr_cache" > $save
12248 lctl set_param llite.*.xattr_cache 1
12250 # 6.1) linkea update on rename
12251 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
12253 # get parents by fid
12254 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12255 # foo1 should no longer be returned in parent list
12256 echo "$parent" | grep -F "$FID1" &&
12257 error "$FID1 should no longer be in parent list"
12258 # the new path should appear
12259 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
12260 error "$FID2/$tfile.moved is not in parent list"
12262 # 6.2) linkea update on unlink
12263 rm -f $DIR/$tdir/d/foo2/link
12264 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12265 # foo2/link should no longer be returned in parent list
12266 echo "$parent" | grep -F "$FID2/link" &&
12267 error "$FID2/link should no longer be in parent list"
12271 restore_lustre_params < $save
12274 run_test 154f "get parent fids by reading link ea"
12278 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12279 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
12280 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
12281 skip "Need MDS version at least 2.6.92"
12283 mkdir -p $DIR/$tdir
12284 llapi_fid_test -d $DIR/$tdir
12286 run_test 154g "various llapi FID tests"
12288 test_155_small_load() {
12289 local temp=$TMP/$tfile
12290 local file=$DIR/$tfile
12292 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
12293 error "dd of=$temp bs=6096 count=1 failed"
12295 cancel_lru_locks $OSC
12296 cmp $temp $file || error "$temp $file differ"
12298 $TRUNCATE $temp 6000
12299 $TRUNCATE $file 6000
12300 cmp $temp $file || error "$temp $file differ (truncate1)"
12302 echo "12345" >>$temp
12303 echo "12345" >>$file
12304 cmp $temp $file || error "$temp $file differ (append1)"
12306 echo "12345" >>$temp
12307 echo "12345" >>$file
12308 cmp $temp $file || error "$temp $file differ (append2)"
12314 test_155_big_load() {
12315 remote_ost_nodsh && skip "remote OST with nodsh"
12317 local temp=$TMP/$tfile
12318 local file=$DIR/$tfile
12321 local cache_size=$(do_facet ost$((MAXI+1)) \
12322 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
12323 local large_file_size=$((cache_size * 2))
12325 echo "OSS cache size: $cache_size KB"
12326 echo "Large file size: $large_file_size KB"
12328 [ $MAXV -le $large_file_size ] &&
12329 skip_env "max available OST size needs > $large_file_size KB"
12331 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
12333 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
12334 error "dd of=$temp bs=$large_file_size count=1k failed"
12337 cancel_lru_locks osc
12338 cmp $temp $file || error "$temp $file differ"
12344 save_writethrough() {
12345 local facets=$(get_facets OST)
12347 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
12351 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12353 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12355 save_writethrough $p
12358 set_cache writethrough on
12359 test_155_small_load
12360 restore_lustre_params < $p
12363 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
12366 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12368 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12370 save_writethrough $p
12373 set_cache writethrough off
12374 test_155_small_load
12375 restore_lustre_params < $p
12378 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
12381 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12383 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12385 save_writethrough $p
12388 set_cache writethrough on
12389 test_155_small_load
12390 restore_lustre_params < $p
12393 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
12396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12398 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12400 save_writethrough $p
12403 set_cache writethrough off
12404 test_155_small_load
12405 restore_lustre_params < $p
12408 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
12411 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12413 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12415 save_writethrough $p
12418 set_cache writethrough on
12420 restore_lustre_params < $p
12423 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
12426 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12428 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12430 save_writethrough $p
12433 set_cache writethrough off
12435 restore_lustre_params < $p
12438 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
12441 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12443 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12445 save_writethrough $p
12448 set_cache writethrough on
12450 restore_lustre_params < $p
12453 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
12456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12458 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12460 save_writethrough $p
12463 set_cache writethrough off
12465 restore_lustre_params < $p
12468 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
12471 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12472 remote_ost_nodsh && skip "remote OST with nodsh"
12473 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
12474 skip "stats not implemented on old servers"
12475 [ "$ost1_FSTYPE" = "zfs" ] &&
12476 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
12481 local file="$DIR/$tfile"
12482 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12484 save_writethrough $p
12487 log "Turn on read and write cache"
12489 set_cache writethrough on
12491 log "Write data and read it back."
12492 log "Read should be satisfied from the cache."
12493 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12495 cancel_lru_locks osc
12496 cat $file >/dev/null
12498 if ! let "AFTER - BEFORE == CPAGES"; then
12499 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12501 log "cache hits:: before: $BEFORE, after: $AFTER"
12504 log "Read again; it should be satisfied from the cache."
12506 cancel_lru_locks osc
12507 cat $file >/dev/null
12509 if ! let "AFTER - BEFORE == CPAGES"; then
12510 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12512 log "cache hits:: before: $BEFORE, after: $AFTER"
12515 log "Turn off the read cache and turn on the write cache"
12517 set_cache writethrough on
12519 log "Read again; it should be satisfied from the cache."
12521 cancel_lru_locks osc
12522 cat $file >/dev/null
12524 if ! let "AFTER - BEFORE == CPAGES"; then
12525 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12527 log "cache hits:: before: $BEFORE, after: $AFTER"
12530 log "Read again; it should not be satisfied from the cache."
12532 cancel_lru_locks osc
12533 cat $file >/dev/null
12535 if ! let "AFTER - BEFORE == 0"; then
12536 error "IN CACHE: before: $BEFORE, after: $AFTER"
12538 log "cache hits:: before: $BEFORE, after: $AFTER"
12541 log "Write data and read it back."
12542 log "Read should be satisfied from the cache."
12543 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12545 cancel_lru_locks osc
12546 cat $file >/dev/null
12548 if ! let "AFTER - BEFORE == CPAGES"; then
12549 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12551 log "cache hits:: before: $BEFORE, after: $AFTER"
12554 log "Read again; it should not be satisfied from the cache."
12556 cancel_lru_locks osc
12557 cat $file >/dev/null
12559 if ! let "AFTER - BEFORE == 0"; then
12560 error "IN CACHE: before: $BEFORE, after: $AFTER"
12562 log "cache hits:: before: $BEFORE, after: $AFTER"
12565 log "Turn off read and write cache"
12567 set_cache writethrough off
12569 log "Write data and read it back"
12570 log "It should not be satisfied from the cache."
12572 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12573 cancel_lru_locks osc
12575 cat $file >/dev/null
12577 if ! let "AFTER - BEFORE == 0"; then
12578 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12580 log "cache hits:: before: $BEFORE, after: $AFTER"
12583 log "Turn on the read cache and turn off the write cache"
12585 set_cache writethrough off
12587 log "Write data and read it back"
12588 log "It should not be satisfied from the cache."
12590 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12592 cancel_lru_locks osc
12593 cat $file >/dev/null
12595 if ! let "AFTER - BEFORE == 0"; then
12596 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12598 log "cache hits:: before: $BEFORE, after: $AFTER"
12601 log "Read again; it should be satisfied from the cache."
12603 cancel_lru_locks osc
12604 cat $file >/dev/null
12606 if ! let "AFTER - BEFORE == CPAGES"; then
12607 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12609 log "cache hits:: before: $BEFORE, after: $AFTER"
12612 restore_lustre_params < $p
12615 run_test 156 "Verification of tunables"
12618 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12619 remote_mds_nodsh && skip "remote MDS with nodsh"
12620 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
12621 skip "Need MDS version at least 2.2.0"
12623 changelog_register || error "changelog_register failed"
12624 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12625 changelog_users $SINGLEMDS | grep -q $cl_user ||
12626 error "User $cl_user not found in changelog_users"
12629 test_mkdir -p $DIR/$tdir/pics/2008/zachy
12630 changelog_clear 0 || error "changelog_clear failed"
12631 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
12632 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
12633 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
12634 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
12635 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
12636 rm $DIR/$tdir/pics/desktop.jpg
12638 changelog_dump | tail -10
12640 echo "verifying changelog mask"
12641 changelog_chmask "-MKDIR"
12642 changelog_chmask "-CLOSE"
12644 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
12645 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
12647 changelog_chmask "+MKDIR"
12648 changelog_chmask "+CLOSE"
12650 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
12651 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
12653 changelog_dump | tail -10
12654 MKDIRS=$(changelog_dump | grep -c "MKDIR")
12655 CLOSES=$(changelog_dump | grep -c "CLOSE")
12656 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
12657 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
12660 echo "verifying target fid"
12661 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
12662 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
12663 [ "$fidc" == "$fidf" ] ||
12664 error "changelog '$tfile' fid $fidc != file fid $fidf"
12665 echo "verifying parent fid"
12666 # The FID returned from the Changelog may be the directory shard on
12667 # a different MDT, and not the FID returned by path2fid on the parent.
12668 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
12669 # since this is what will matter when recreating this file in the tree.
12670 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
12671 local pathp=$($LFS fid2path $MOUNT "$fidp")
12672 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
12673 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
12675 echo "getting records for $cl_user"
12676 changelog_users $SINGLEMDS
12677 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
12679 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
12680 error "changelog_clear failed"
12681 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
12682 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
12683 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
12684 error "user index expect $user_rec1 + $nclr != $user_rec2"
12686 local min0_rec=$(changelog_users $SINGLEMDS |
12687 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
12688 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
12689 awk '{ print $1; exit; }')
12691 changelog_dump | tail -n 5
12692 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
12693 [ $first_rec == $((min0_rec + 1)) ] ||
12694 error "first index should be $min0_rec + 1 not $first_rec"
12696 # LU-3446 changelog index reset on MDT restart
12697 local cur_rec1=$(changelog_users $SINGLEMDS |
12698 awk '/^current.index:/ { print $NF }')
12699 changelog_clear 0 ||
12700 error "clear all changelog records for $cl_user failed"
12701 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
12702 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
12703 error "Fail to start $SINGLEMDS"
12704 local cur_rec2=$(changelog_users $SINGLEMDS |
12705 awk '/^current.index:/ { print $NF }')
12706 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
12707 [ $cur_rec1 == $cur_rec2 ] ||
12708 error "current index should be $cur_rec1 not $cur_rec2"
12710 echo "verifying users from this test are deregistered"
12711 changelog_deregister || error "changelog_deregister failed"
12712 changelog_users $SINGLEMDS | grep -q $cl_user &&
12713 error "User '$cl_user' still in changelog_users"
12715 # lctl get_param -n mdd.*.changelog_users
12716 # current index: 144
12717 # ID index (idle seconds)
12719 if ! changelog_users $SINGLEMDS | grep "^cl"; then
12720 # this is the normal case where all users were deregistered
12721 # make sure no new records are added when no users are present
12722 local last_rec1=$(changelog_users $SINGLEMDS |
12723 awk '/^current.index:/ { print $NF }')
12724 touch $DIR/$tdir/chloe
12725 local last_rec2=$(changelog_users $SINGLEMDS |
12726 awk '/^current.index:/ { print $NF }')
12727 echo "verify changelogs are off: $last_rec1 == $last_rec2"
12728 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
12730 # any changelog users must be leftovers from a previous test
12731 changelog_users $SINGLEMDS
12732 echo "other changelog users; can't verify off"
12735 run_test 160a "changelog sanity"
12737 test_160b() { # LU-3587
12738 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12739 remote_mds_nodsh && skip "remote MDS with nodsh"
12740 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
12741 skip "Need MDS version at least 2.2.0"
12743 changelog_register || error "changelog_register failed"
12744 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12745 changelog_users $SINGLEMDS | grep -q $cl_user ||
12746 error "User '$cl_user' not found in changelog_users"
12748 local longname1=$(str_repeat a 255)
12749 local longname2=$(str_repeat b 255)
12752 echo "creating very long named file"
12753 touch $longname1 || error "create of '$longname1' failed"
12754 echo "renaming very long named file"
12755 mv $longname1 $longname2
12757 changelog_dump | grep RENME | tail -n 5
12760 run_test 160b "Verify that very long rename doesn't crash in changelog"
12763 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12764 remote_mds_nodsh && skip "remote MDS with nodsh"
12766 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
12767 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
12768 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
12769 skip "Need MDS version at least 2.5.58 or 2.5.2+"
12773 # Registration step
12774 changelog_register || error "changelog_register failed"
12777 mkdir -p $DIR/$tdir
12778 $MCREATE $DIR/$tdir/foo_160c
12779 changelog_chmask "-TRUNC"
12780 $TRUNCATE $DIR/$tdir/foo_160c 200
12781 changelog_chmask "+TRUNC"
12782 $TRUNCATE $DIR/$tdir/foo_160c 199
12783 changelog_dump | tail -n 5
12784 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
12785 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
12787 run_test 160c "verify that changelog log catch the truncate event"
12790 remote_mds_nodsh && skip "remote MDS with nodsh"
12791 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12793 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
12794 skip "Need MDS version at least 2.7.60"
12796 # Registration step
12797 changelog_register || error "changelog_register failed"
12799 mkdir -p $DIR/$tdir/migrate_dir
12800 changelog_clear 0 || error "changelog_clear failed"
12802 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
12803 changelog_dump | tail -n 5
12804 local migrates=$(changelog_dump | grep -c "MIGRT")
12805 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
12807 run_test 160d "verify that changelog log catch the migrate event"
12810 remote_mds_nodsh && skip "remote MDS with nodsh"
12813 changelog_register || error "changelog_register failed"
12815 # Delete a future user (expect fail)
12816 local MDT0=$(facet_svc $SINGLEMDS)
12817 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
12820 if [ $rc -eq 0 ]; then
12821 error "Deleted non-existant user cl77"
12822 elif [ $rc -ne 2 ]; then
12823 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
12826 # Clear to a bad index (1 billion should be safe)
12827 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
12830 if [ $rc -eq 0 ]; then
12831 error "Successfully cleared to invalid CL index"
12832 elif [ $rc -ne 22 ]; then
12833 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
12836 run_test 160e "changelog negative testing (should return errors)"
12839 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12840 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
12841 skip "Need MDS version at least 2.10.56"
12843 local mdts=$(comma_list $(mdts_nodes))
12846 changelog_register || error "first changelog_register failed"
12847 changelog_register || error "second changelog_register failed"
12849 declare -A cl_user1
12850 declare -A cl_user2
12855 # generate some changelog records to accumulate on each MDT
12856 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
12857 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12858 error "create $DIR/$tdir/$tfile failed"
12860 # check changelogs have been generated
12861 local nbcl=$(changelog_dump | wc -l)
12862 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12864 for param in "changelog_max_idle_time=10" \
12866 "changelog_min_gc_interval=2" \
12867 "changelog_min_free_cat_entries=3"; do
12868 local MDT0=$(facet_svc $SINGLEMDS)
12869 local var="${param%=*}"
12870 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12872 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12873 do_nodes $mdts $LCTL set_param mdd.*.$param
12876 # force cl_user2 to be idle (1st part)
12879 # simulate changelog catalog almost full
12880 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12881 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12883 for i in $(seq $MDSCOUNT); do
12884 cl_users=(${CL_USERS[mds$i]})
12885 cl_user1[mds$i]="${cl_users[0]}"
12886 cl_user2[mds$i]="${cl_users[1]}"
12888 [ -n "${cl_user1[mds$i]}" ] ||
12889 error "mds$i: no user registered"
12890 [ -n "${cl_user2[mds$i]}" ] ||
12891 error "mds$i: only ${cl_user2[mds$i]} is registered"
12893 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12894 [ -n "$user_rec1" ] ||
12895 error "mds$i: User ${cl_user1[mds$i]} not registered"
12896 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12897 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12898 [ -n "$user_rec2" ] ||
12899 error "mds$i: User ${cl_user1[mds$i]} not registered"
12900 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12901 "$user_rec1 + 2 == $user_rec2"
12902 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12903 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12904 "$user_rec1 + 2, but is $user_rec2"
12905 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12906 [ -n "$user_rec2" ] ||
12907 error "mds$i: User ${cl_user2[mds$i]} not registered"
12908 [ $user_rec1 == $user_rec2 ] ||
12909 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12910 "$user_rec1, but is $user_rec2"
12913 # force cl_user2 to be idle (2nd part) and to reach
12914 # changelog_max_idle_time
12917 # generate one more changelog to trigger fail_loc
12918 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12919 error "create $DIR/$tdir/${tfile}bis failed"
12921 # ensure gc thread is done
12922 for i in $(mdts_nodes); do
12924 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
12925 error "$i: GC-thread not done"
12929 for i in $(seq $MDSCOUNT); do
12930 # check cl_user1 still registered
12931 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12932 error "mds$i: User ${cl_user1[mds$i]} not registered"
12933 # check cl_user2 unregistered
12934 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12935 error "mds$i: User ${cl_user2[mds$i]} still registered"
12937 # check changelogs are present and starting at $user_rec1 + 1
12938 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12939 [ -n "$user_rec1" ] ||
12940 error "mds$i: User ${cl_user1[mds$i]} not registered"
12941 first_rec=$($LFS changelog $(facet_svc mds$i) |
12942 awk '{ print $1; exit; }')
12944 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12945 [ $((user_rec1 + 1)) == $first_rec ] ||
12946 error "mds$i: first index should be $user_rec1 + 1, " \
12947 "but is $first_rec"
12950 run_test 160f "changelog garbage collect (timestamped users)"
12953 remote_mds_nodsh && skip "remote MDS with nodsh"
12954 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
12955 skip "Need MDS version at least 2.10.56"
12957 local mdts=$(comma_list $(mdts_nodes))
12959 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
12960 do_nodes $mdts $LCTL set_param fail_loc=0x1314
12963 changelog_register || error "first changelog_register failed"
12964 changelog_register || error "second changelog_register failed"
12966 declare -A cl_user1
12967 declare -A cl_user2
12972 # generate some changelog records to accumulate on each MDT
12973 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
12974 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12975 error "create $DIR/$tdir/$tfile failed"
12977 # check changelogs have been generated
12978 local nbcl=$(changelog_dump | wc -l)
12979 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12981 # reduce the max_idle_indexes value to make sure we exceed it
12982 max_ndx=$((nbcl / 2 - 1))
12984 for param in "changelog_max_idle_indexes=$max_ndx" \
12986 "changelog_min_gc_interval=2" \
12987 "changelog_min_free_cat_entries=3"; do
12988 local MDT0=$(facet_svc $SINGLEMDS)
12989 local var="${param%=*}"
12990 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12992 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12993 do_nodes $mdts $LCTL set_param mdd.*.$param ||
12994 error "unable to set mdd.*.$param"
12997 # simulate changelog catalog almost full
12998 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12999 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13001 for i in $(seq $MDSCOUNT); do
13002 cl_users=(${CL_USERS[mds$i]})
13003 cl_user1[mds$i]="${cl_users[0]}"
13004 cl_user2[mds$i]="${cl_users[1]}"
13006 [ -n "${cl_user1[mds$i]}" ] ||
13007 error "mds$i: no user registered"
13008 [ -n "${cl_user2[mds$i]}" ] ||
13009 error "mds$i: only ${cl_user1[mds$i]} is registered"
13011 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13012 [ -n "$user_rec1" ] ||
13013 error "mds$i: User ${cl_user1[mds$i]} not registered"
13014 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13015 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13016 [ -n "$user_rec2" ] ||
13017 error "mds$i: User ${cl_user1[mds$i]} not registered"
13018 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13019 "$user_rec1 + 2 == $user_rec2"
13020 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13021 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13022 "$user_rec1 + 2, but is $user_rec2"
13023 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13024 [ -n "$user_rec2" ] ||
13025 error "mds$i: User ${cl_user2[mds$i]} not registered"
13026 [ $user_rec1 == $user_rec2 ] ||
13027 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13028 "$user_rec1, but is $user_rec2"
13031 # ensure we are past the previous changelog_min_gc_interval set above
13034 # generate one more changelog to trigger fail_loc
13035 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13036 error "create $DIR/$tdir/${tfile}bis failed"
13038 # ensure gc thread is done
13039 for i in $(mdts_nodes); do
13041 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13042 error "$i: GC-thread not done"
13046 for i in $(seq $MDSCOUNT); do
13047 # check cl_user1 still registered
13048 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13049 error "mds$i: User ${cl_user1[mds$i]} not registered"
13050 # check cl_user2 unregistered
13051 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13052 error "mds$i: User ${cl_user2[mds$i]} still registered"
13054 # check changelogs are present and starting at $user_rec1 + 1
13055 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13056 [ -n "$user_rec1" ] ||
13057 error "mds$i: User ${cl_user1[mds$i]} not registered"
13058 first_rec=$($LFS changelog $(facet_svc mds$i) |
13059 awk '{ print $1; exit; }')
13061 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13062 [ $((user_rec1 + 1)) == $first_rec ] ||
13063 error "mds$i: first index should be $user_rec1 + 1, " \
13064 "but is $first_rec"
13067 run_test 160g "changelog garbage collect (old users)"
13070 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13071 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13072 skip "Need MDS version at least 2.10.56"
13074 local mdts=$(comma_list $(mdts_nodes))
13077 changelog_register || error "first changelog_register failed"
13078 changelog_register || error "second changelog_register failed"
13080 declare -A cl_user1
13081 declare -A cl_user2
13086 # generate some changelog records to accumulate on each MDT
13087 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13088 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13089 error "create $DIR/$tdir/$tfile failed"
13091 # check changelogs have been generated
13092 local nbcl=$(changelog_dump | wc -l)
13093 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13095 for param in "changelog_max_idle_time=10" \
13097 "changelog_min_gc_interval=2"; do
13098 local MDT0=$(facet_svc $SINGLEMDS)
13099 local var="${param%=*}"
13100 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13102 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13103 do_nodes $mdts $LCTL set_param mdd.*.$param
13106 # force cl_user2 to be idle (1st part)
13109 for i in $(seq $MDSCOUNT); do
13110 cl_users=(${CL_USERS[mds$i]})
13111 cl_user1[mds$i]="${cl_users[0]}"
13112 cl_user2[mds$i]="${cl_users[1]}"
13114 [ -n "${cl_user1[mds$i]}" ] ||
13115 error "mds$i: no user registered"
13116 [ -n "${cl_user2[mds$i]}" ] ||
13117 error "mds$i: only ${cl_user2[mds$i]} is registered"
13119 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13120 [ -n "$user_rec1" ] ||
13121 error "mds$i: User ${cl_user1[mds$i]} not registered"
13122 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13123 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13124 [ -n "$user_rec2" ] ||
13125 error "mds$i: User ${cl_user1[mds$i]} not registered"
13126 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13127 "$user_rec1 + 2 == $user_rec2"
13128 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13129 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13130 "$user_rec1 + 2, but is $user_rec2"
13131 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13132 [ -n "$user_rec2" ] ||
13133 error "mds$i: User ${cl_user2[mds$i]} not registered"
13134 [ $user_rec1 == $user_rec2 ] ||
13135 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13136 "$user_rec1, but is $user_rec2"
13139 # force cl_user2 to be idle (2nd part) and to reach
13140 # changelog_max_idle_time
13143 # force each GC-thread start and block then
13144 # one per MDT/MDD, set fail_val accordingly
13145 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
13146 do_nodes $mdts $LCTL set_param fail_loc=0x1316
13148 # generate more changelogs to trigger fail_loc
13149 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13150 error "create $DIR/$tdir/${tfile}bis failed"
13152 # stop MDT to stop GC-thread, should be done in back-ground as it will
13153 # block waiting for the thread to be released and exit
13154 declare -A stop_pids
13155 for i in $(seq $MDSCOUNT); do
13157 stop_pids[mds$i]=$!
13160 for i in $(mdts_nodes); do
13163 local facets=$(facets_up_on_host $i)
13165 for facet in ${facets//,/ }; do
13166 if [[ $facet == mds* ]]; then
13170 # ensure each MDS's gc threads are still present and all in "R"
13171 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
13172 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
13173 error "$i: expected $nb GC-thread"
13175 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
13177 error "$i: GC-thread not found in R-state"
13178 # check umounts of each MDT on MDS have reached kthread_stop()
13179 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
13180 error "$i: expected $nb umount"
13182 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
13183 error "$i: umount not found in D-state"
13186 # release all GC-threads
13187 do_nodes $mdts $LCTL set_param fail_loc=0
13189 # wait for MDT stop to complete
13190 for i in $(seq $MDSCOUNT); do
13191 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
13195 # may try to check if any orphan changelog records are present
13196 # via ldiskfs/zfs and llog_reader...
13198 # re-start/mount MDTs
13199 for i in $(seq $MDSCOUNT); do
13200 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
13201 error "Fail to start mds$i"
13205 for i in $(seq $MDSCOUNT); do
13206 # check cl_user1 still registered
13207 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13208 error "mds$i: User ${cl_user1[mds$i]} not registered"
13209 # check cl_user2 unregistered
13210 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13211 error "mds$i: User ${cl_user2[mds$i]} still registered"
13213 # check changelogs are present and starting at $user_rec1 + 1
13214 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13215 [ -n "$user_rec1" ] ||
13216 error "mds$i: User ${cl_user1[mds$i]} not registered"
13217 first_rec=$($LFS changelog $(facet_svc mds$i) |
13218 awk '{ print $1; exit; }')
13220 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13221 [ $((user_rec1 + 1)) == $first_rec ] ||
13222 error "mds$i: first index should be $user_rec1 + 1, " \
13223 "but is $first_rec"
13226 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
13231 local mdts=$(comma_list $(mdts_nodes))
13233 changelog_register || error "first changelog_register failed"
13235 # generate some changelog records to accumulate on each MDT
13236 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13237 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13238 error "create $DIR/$tdir/$tfile failed"
13240 # check changelogs have been generated
13241 local nbcl=$(changelog_dump | wc -l)
13242 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13244 # simulate race between register and unregister
13245 # XXX as fail_loc is set per-MDS, with DNE configs the race
13246 # simulation will only occur for one MDT per MDS and for the
13247 # others the normal race scenario will take place
13248 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
13249 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
13250 do_nodes $mdts $LCTL set_param fail_val=1
13252 # unregister 1st user
13253 changelog_deregister &
13255 # wait some time for deregister work to reach race rdv
13257 # register 2nd user
13258 changelog_register || error "2nd user register failed"
13260 wait $pid1 || error "1st user deregister failed"
13264 declare -A LAST_REC
13265 for i in $(seq $MDSCOUNT); do
13266 if changelog_users mds$i | grep "^cl"; then
13267 # make sure new records are added with one user present
13268 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
13269 awk '/^current.index:/ { print $NF }')
13271 error "mds$i has no user registered"
13275 # generate more changelog records to accumulate on each MDT
13276 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13277 error "create $DIR/$tdir/${tfile}bis failed"
13279 for i in $(seq $MDSCOUNT); do
13280 last_rec=$(changelog_users $SINGLEMDS |
13281 awk '/^current.index:/ { print $NF }')
13282 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
13283 [ $last_rec != ${LAST_REC[mds$i]} ] ||
13284 error "changelogs are off on mds$i"
13287 run_test 160i "changelog user register/unregister race"
13290 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13292 test_mkdir -c1 $DIR/$tdir
13293 cp /etc/hosts $DIR/$tdir/$tfile
13294 test_mkdir -c1 $DIR/$tdir/foo1
13295 test_mkdir -c1 $DIR/$tdir/foo2
13296 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
13297 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
13298 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
13299 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
13300 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
13301 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13302 $LFS fid2path $DIR $FID
13303 error "bad link ea"
13306 rm $DIR/$tdir/foo2/zachary
13308 rm $DIR/$tdir/foo2/thor
13310 rm $DIR/$tdir/$tfile
13312 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
13313 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
13314 { $LFS fid2path $DIR $FID; error "bad link rename"; }
13315 rm $DIR/$tdir/foo2/maggie
13318 local longname=$tfile.avg_len_is_thirty_two_
13319 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
13320 error_noexit 'failed to unlink many hardlinks'" EXIT
13321 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
13322 error "failed to hardlink many files"
13323 links=$($LFS fid2path $DIR $FID | wc -l)
13324 echo -n "${links}/1000 links in link EA"
13325 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
13327 run_test 161a "link ea sanity"
13330 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13331 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
13334 local remote_dir=$DIR/$tdir/remote_dir
13336 mkdir -p $DIR/$tdir
13337 $LFS mkdir -i $MDTIDX $remote_dir ||
13338 error "create remote directory failed"
13340 cp /etc/hosts $remote_dir/$tfile
13341 mkdir -p $remote_dir/foo1
13342 mkdir -p $remote_dir/foo2
13343 ln $remote_dir/$tfile $remote_dir/foo1/sofia
13344 ln $remote_dir/$tfile $remote_dir/foo2/zachary
13345 ln $remote_dir/$tfile $remote_dir/foo1/luna
13346 ln $remote_dir/$tfile $remote_dir/foo2/thor
13348 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
13350 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13351 $LFS fid2path $DIR $FID
13352 error "bad link ea"
13355 rm $remote_dir/foo2/zachary
13357 rm $remote_dir/foo2/thor
13359 rm $remote_dir/$tfile
13361 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
13362 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
13363 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
13364 $LFS fid2path $DIR $FID
13365 error "bad link rename"
13367 rm $remote_dir/foo2/maggie
13370 local longname=filename_avg_len_is_thirty_two_
13371 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
13372 error "failed to hardlink many files"
13373 links=$($LFS fid2path $DIR $FID | wc -l)
13374 echo -n "${links}/1000 links in link EA"
13375 [[ ${links} -gt 60 ]] ||
13376 error "expected at least 60 links in link EA"
13377 unlinkmany $remote_dir/foo2/$longname 1000 ||
13378 error "failed to unlink many hardlinks"
13380 run_test 161b "link ea sanity under remote directory"
13383 remote_mds_nodsh && skip "remote MDS with nodsh"
13384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13385 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
13386 skip "Need MDS version at least 2.1.5"
13388 # define CLF_RENAME_LAST 0x0001
13389 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
13390 changelog_register || error "changelog_register failed"
13393 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
13394 touch $DIR/$tdir/foo_161c
13395 touch $DIR/$tdir/bar_161c
13396 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13397 changelog_dump | grep RENME | tail -n 5
13398 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13399 changelog_clear 0 || error "changelog_clear failed"
13400 if [ x$flags != "x0x1" ]; then
13401 error "flag $flags is not 0x1"
13404 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
13405 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
13406 touch $DIR/$tdir/foo_161c
13407 touch $DIR/$tdir/bar_161c
13408 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13409 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13410 changelog_dump | grep RENME | tail -n 5
13411 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13412 changelog_clear 0 || error "changelog_clear failed"
13413 if [ x$flags != "x0x0" ]; then
13414 error "flag $flags is not 0x0"
13416 echo "rename overwrite a target having nlink > 1," \
13417 "changelog record has flags of $flags"
13419 # rename doesn't overwrite a target (changelog flag 0x0)
13420 touch $DIR/$tdir/foo_161c
13421 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
13422 changelog_dump | grep RENME | tail -n 5
13423 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
13424 changelog_clear 0 || error "changelog_clear failed"
13425 if [ x$flags != "x0x0" ]; then
13426 error "flag $flags is not 0x0"
13428 echo "rename doesn't overwrite a target," \
13429 "changelog record has flags of $flags"
13431 # define CLF_UNLINK_LAST 0x0001
13432 # unlink a file having nlink = 1 (changelog flag 0x1)
13433 rm -f $DIR/$tdir/foo2_161c
13434 changelog_dump | grep UNLNK | tail -n 5
13435 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13436 changelog_clear 0 || error "changelog_clear failed"
13437 if [ x$flags != "x0x1" ]; then
13438 error "flag $flags is not 0x1"
13440 echo "unlink a file having nlink = 1," \
13441 "changelog record has flags of $flags"
13443 # unlink a file having nlink > 1 (changelog flag 0x0)
13444 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13445 rm -f $DIR/$tdir/foobar_161c
13446 changelog_dump | grep UNLNK | tail -n 5
13447 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13448 changelog_clear 0 || error "changelog_clear failed"
13449 if [ x$flags != "x0x0" ]; then
13450 error "flag $flags is not 0x0"
13452 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
13454 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
13457 remote_mds_nodsh && skip "remote MDS with nodsh"
13458 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
13463 changelog_register || error "changelog_register failed"
13465 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
13466 # interfer with $MOUNT/.lustre/fid/ access
13468 [[ $? -eq 0 ]] || error "mkdir failed"
13470 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
13471 $LCTL set_param fail_loc=0x8000140c
13473 $LCTL set_param fail_val=5
13476 echo foofoo > $DIR/$tdir/$tfile &
13479 # wait for create to be delayed
13483 [[ $? -eq 0 ]] || error "create should be blocked"
13485 local tempfile=$(mktemp)
13486 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
13487 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
13488 # some delay may occur during ChangeLog publishing and file read just
13489 # above, that could allow file write to happen finally
13490 [[ -s $tempfile ]] && echo "file should be empty"
13492 $LCTL set_param fail_loc=0
13495 [[ $? -eq 0 ]] || error "create failed"
13497 run_test 161d "create with concurrent .lustre/fid access"
13500 local expected="$1"
13505 path=$($LFS fid2path "$@")
13508 if [ $rc -ne 0 ]; then
13509 error "path looked up of '$expected' failed: rc=$rc"
13510 elif [ "$path" != "$expected" ]; then
13511 error "path looked up '$path' instead of '$expected'"
13513 echo "FID '$fid' resolves to path '$path' as expected"
13517 test_162a() { # was test_162
13518 test_mkdir -p -c1 $DIR/$tdir/d2
13519 touch $DIR/$tdir/d2/$tfile
13520 touch $DIR/$tdir/d2/x1
13521 touch $DIR/$tdir/d2/x2
13522 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
13523 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
13525 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
13526 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
13529 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
13530 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
13531 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
13533 # softlink to wrong file
13534 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
13535 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
13536 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
13539 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
13540 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
13541 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
13542 # fid2path dir/fsname should both work
13543 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
13544 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
13546 # hardlink count: check that there are 2 links
13547 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
13548 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
13550 # hardlink indexing: remove the first link
13551 rm $DIR/$tdir/d2/p/q/r/hlink
13552 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
13554 run_test 162a "path lookup sanity"
13557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13558 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13561 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
13562 error "create striped dir failed"
13564 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
13565 tail -n 1 | awk '{print $2}')
13566 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
13568 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
13569 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
13572 for ((i=0;i<5;i++)); do
13573 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
13574 error "get fid for f$i failed"
13575 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
13577 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
13578 error "get fid for d$i failed"
13579 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
13584 run_test 162b "striped directory path lookup sanity"
13586 # LU-4239: Verify fid2path works with paths 100 or more directories deep
13588 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
13589 skip "Need MDS version at least 2.7.51"
13591 local lpath=$tdir.local
13592 local rpath=$tdir.remote
13594 test_mkdir $DIR/$lpath
13595 test_mkdir $DIR/$rpath
13597 for ((i = 0; i <= 101; i++)); do
13600 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
13601 error "get fid for local directory $DIR/$lpath failed"
13602 check_path "$DIR/$lpath" $MOUNT $FID --link 0
13605 test_mkdir $DIR/$rpath
13606 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
13607 error "get fid for remote directory $DIR/$rpath failed"
13608 check_path "$DIR/$rpath" $MOUNT $FID --link 0
13613 run_test 162c "fid2path works with paths 100 or more directories deep"
13616 # do directio so as not to populate the page cache
13617 log "creating a 10 Mb file"
13618 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13619 log "starting reads"
13620 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13621 log "truncating the file"
13622 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13624 kill %+ || true # reads might have finished
13625 echo "wait until dd is finished"
13627 log "removing the temporary file"
13628 rm -rf $DIR/$tfile || error "tmp file removal failed"
13630 run_test 169 "parallel read and truncate should not deadlock"
13633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13635 $LCTL clear # bug 18514
13636 $LCTL debug_daemon start $TMP/${tfile}_log_good
13638 $LCTL debug_daemon stop
13639 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
13640 error "sed failed to read log_good"
13642 $LCTL debug_daemon start $TMP/${tfile}_log_good
13644 $LCTL debug_daemon stop
13646 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
13647 error "lctl df log_bad failed"
13649 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13650 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13652 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
13653 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
13655 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
13656 error "bad_line good_line1 good_line2 are empty"
13658 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13659 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
13660 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13662 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
13663 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13664 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13666 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
13667 error "bad_line_new good_line_new are empty"
13669 local expected_good=$((good_line1 + good_line2*2))
13671 rm -f $TMP/${tfile}*
13672 # LU-231, short malformed line may not be counted into bad lines
13673 if [ $bad_line -ne $bad_line_new ] &&
13674 [ $bad_line -ne $((bad_line_new - 1)) ]; then
13675 error "expected $bad_line bad lines, but got $bad_line_new"
13679 if [ $expected_good -ne $good_line_new ]; then
13680 error "expected $expected_good good lines, but got $good_line_new"
13685 run_test 170 "test lctl df to handle corrupted log ====================="
13687 test_171() { # bug20592
13688 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13690 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
13691 $LCTL set_param fail_loc=0x50e
13692 $LCTL set_param fail_val=3000
13693 multiop_bg_pause $DIR/$tfile O_s || true
13695 kill -USR1 $MULTIPID
13699 if dmesg | grep "recursive fault"; then
13700 error "caught a recursive fault"
13702 $LCTL set_param fail_loc=0
13705 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
13707 # it would be good to share it with obdfilter-survey/iokit-libecho code
13708 setup_obdecho_osc () {
13711 local obdfilter_name=$2
13712 echo "Creating new osc for $obdfilter_name on $ost_nid"
13713 # make sure we can find loopback nid
13714 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
13716 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
13717 ${obdfilter_name}_osc_UUID || rc=2; }
13718 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
13719 ${obdfilter_name}_UUID $ost_nid || rc=3; }
13723 cleanup_obdecho_osc () {
13724 local obdfilter_name=$1
13725 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
13726 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
13733 local pages=${3:-64}
13738 local obd_size=$(get_obd_size $node $OBD)
13739 local page_size=$(get_page_size $node)
13740 if [[ -n "$obd_size" ]]; then
13741 local new_count=$((obd_size / (pages * page_size / 1024)))
13742 [[ $new_count -ge $count ]] || count=$new_count
13745 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
13746 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
13748 if [ $rc -eq 0 ]; then
13749 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
13750 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
13752 echo "New object id is $id"
13753 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
13755 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
13756 "test_brw $count w v $pages $id" || rc=4; }
13757 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
13759 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
13760 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
13761 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
13762 { do_facet $node "$LCTL --device ec detach" || rc=6; }
13763 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
13768 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13770 if ! module_loaded obdecho; then
13771 load_module obdecho/obdecho &&
13772 stack_trap "rmmod obdecho" EXIT ||
13773 error "unable to load obdecho on client"
13776 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
13777 local host=$($LCTL get_param -n osc.$osc.import |
13778 awk '/current_connection:/ { print $2 }' )
13779 local target=$($LCTL get_param -n osc.$osc.import |
13780 awk '/target:/ { print $2 }' )
13781 target=${target%_UUID}
13783 if [ -n "$target" ]; then
13784 setup_obdecho_osc $host $target &&
13785 stack_trap "cleanup_obdecho_osc $target" EXIT ||
13786 { error "obdecho setup failed with $?"; return; }
13788 obdecho_test ${target}_osc client ||
13789 error "obdecho_test failed on ${target}_osc"
13791 $LCTL get_param osc.$osc.import
13792 error "there is no osc.$osc.import target"
13795 run_test 180a "test obdecho on osc"
13798 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13799 remote_ost_nodsh && skip "remote OST with nodsh"
13801 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13802 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13803 error "failed to load module obdecho"
13805 local target=$(do_facet ost1 $LCTL dl |
13806 awk '/obdfilter/ { print $4; exit; }')
13808 if [ -n "$target" ]; then
13809 obdecho_test $target ost1 || error "obdecho_test failed with $?"
13811 do_facet ost1 $LCTL dl
13812 error "there is no obdfilter target on ost1"
13815 run_test 180b "test obdecho directly on obdfilter"
13817 test_180c() { # LU-2598
13818 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13819 remote_ost_nodsh && skip "remote OST with nodsh"
13820 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
13821 skip "Need MDS version at least 2.4.0"
13823 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13824 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13825 error "failed to load module obdecho"
13827 local target=$(do_facet ost1 $LCTL dl |
13828 awk '/obdfilter/ { print $4; exit; }')
13830 if [ -n "$target" ]; then
13831 local pages=16384 # 64MB bulk I/O RPC size
13833 obdecho_test "$target" ost1 "$pages" ||
13834 error "obdecho_test with pages=$pages failed with $?"
13836 do_facet ost1 $LCTL dl
13837 error "there is no obdfilter target on ost1"
13840 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
13842 test_181() { # bug 22177
13843 test_mkdir $DIR/$tdir
13844 # create enough files to index the directory
13845 createmany -o $DIR/$tdir/foobar 4000
13846 # print attributes for debug purpose
13849 multiop_bg_pause $DIR/$tdir D_Sc || return 1
13851 # remove the files & current working dir
13852 unlinkmany $DIR/$tdir/foobar 4000
13854 kill -USR1 $MULTIPID
13856 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
13859 run_test 181 "Test open-unlinked dir ========================"
13865 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13867 $LCTL set_param mdc.*.rpc_stats=clear
13869 for (( i = 0; i < $tcount; i++ )) ; do
13870 mkdir $DIR/$tdir/$i
13873 for (( i = 0; i < $tcount; i++ )) ; do
13874 createmany -o $DIR/$tdir/$i/f- $fcount &
13878 for (( i = 0; i < $tcount; i++ )) ; do
13879 unlinkmany $DIR/$tdir/$i/f- $fcount &
13883 $LCTL get_param mdc.*.rpc_stats
13887 run_test 182 "Test parallel modify metadata operations ================"
13889 test_183() { # LU-2275
13890 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13891 remote_mds_nodsh && skip "remote MDS with nodsh"
13892 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
13893 skip "Need MDS version at least 2.3.56"
13895 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13896 echo aaa > $DIR/$tdir/$tfile
13898 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
13899 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
13901 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
13902 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
13904 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13906 # Flush negative dentry cache
13907 touch $DIR/$tdir/$tfile
13909 # We are not checking for any leaked references here, they'll
13910 # become evident next time we do cleanup with module unload.
13913 run_test 183 "No crash or request leak in case of strange dispositions ========"
13915 # test suite 184 is for LU-2016, LU-2017
13917 check_swap_layouts_support
13919 dir0=$DIR/$tdir/$testnum
13920 test_mkdir -p -c1 $dir0
13925 $LFS setstripe -c1 $file1
13927 $LFS setstripe -c2 $file2
13929 gen1=$($LFS getstripe -g $file1)
13930 gen2=$($LFS getstripe -g $file2)
13932 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
13933 gen=$($LFS getstripe -g $file1)
13934 [[ $gen1 != $gen ]] ||
13935 "Layout generation on $file1 does not change"
13936 gen=$($LFS getstripe -g $file2)
13937 [[ $gen2 != $gen ]] ||
13938 "Layout generation on $file2 does not change"
13940 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
13941 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13943 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
13945 run_test 184a "Basic layout swap"
13948 check_swap_layouts_support
13950 dir0=$DIR/$tdir/$testnum
13951 mkdir -p $dir0 || error "creating dir $dir0"
13958 $LFS setstripe -c1 $file1
13959 $LFS setstripe -c2 $file2
13960 $LFS setstripe -c1 $file3
13961 chown $RUNAS_ID $file3
13962 gen1=$($LFS getstripe -g $file1)
13963 gen2=$($LFS getstripe -g $file2)
13965 $LFS swap_layouts $dir1 $dir2 &&
13966 error "swap of directories layouts should fail"
13967 $LFS swap_layouts $dir1 $file1 &&
13968 error "swap of directory and file layouts should fail"
13969 $RUNAS $LFS swap_layouts $file1 $file2 &&
13970 error "swap of file we cannot write should fail"
13971 $LFS swap_layouts $file1 $file3 &&
13972 error "swap of file with different owner should fail"
13973 /bin/true # to clear error code
13975 run_test 184b "Forbidden layout swap (will generate errors)"
13978 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
13979 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
13980 check_swap_layouts_support
13982 local dir0=$DIR/$tdir/$testnum
13983 mkdir -p $dir0 || error "creating dir $dir0"
13985 local ref1=$dir0/ref1
13986 local ref2=$dir0/ref2
13987 local file1=$dir0/file1
13988 local file2=$dir0/file2
13989 # create a file large enough for the concurrent test
13990 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
13991 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
13992 echo "ref file size: ref1($(stat -c %s $ref1))," \
13993 "ref2($(stat -c %s $ref2))"
13996 dd if=$ref1 of=$file1 bs=16k &
13999 # Make sure dd starts to copy file
14000 while [ ! -f $file1 ]; do sleep 0.1; done
14002 $LFS swap_layouts $file1 $file2
14005 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
14006 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
14008 # how many bytes copied before swapping layout
14009 local copied=$(stat -c %s $file2)
14010 local remaining=$(stat -c %s $ref1)
14011 remaining=$((remaining - copied))
14012 echo "Copied $copied bytes before swapping layout..."
14014 cmp -n $copied $file1 $ref2 | grep differ &&
14015 error "Content mismatch [0, $copied) of ref2 and file1"
14016 cmp -n $copied $file2 $ref1 ||
14017 error "Content mismatch [0, $copied) of ref1 and file2"
14018 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
14019 error "Content mismatch [$copied, EOF) of ref1 and file1"
14022 rm -f $ref1 $ref2 $file1 $file2
14024 run_test 184c "Concurrent write and layout swap"
14027 check_swap_layouts_support
14028 [ -z "$(which getfattr 2>/dev/null)" ] &&
14029 skip_env "no getfattr command"
14031 local file1=$DIR/$tdir/$tfile-1
14032 local file2=$DIR/$tdir/$tfile-2
14033 local file3=$DIR/$tdir/$tfile-3
14037 mkdir -p $DIR/$tdir
14038 touch $file1 || error "create $file1 failed"
14039 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14040 error "create $file2 failed"
14041 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14042 error "create $file3 failed"
14043 lovea1=$(get_layout_param $file1)
14045 $LFS swap_layouts $file2 $file3 ||
14046 error "swap $file2 $file3 layouts failed"
14047 $LFS swap_layouts $file1 $file2 ||
14048 error "swap $file1 $file2 layouts failed"
14050 lovea2=$(get_layout_param $file2)
14053 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
14055 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14056 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
14058 run_test 184d "allow stripeless layouts swap"
14061 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
14062 skip "Need MDS version at least 2.6.94"
14063 check_swap_layouts_support
14064 [ -z "$(which getfattr 2>/dev/null)" ] &&
14065 skip_env "no getfattr command"
14067 local file1=$DIR/$tdir/$tfile-1
14068 local file2=$DIR/$tdir/$tfile-2
14069 local file3=$DIR/$tdir/$tfile-3
14072 mkdir -p $DIR/$tdir
14073 touch $file1 || error "create $file1 failed"
14074 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14075 error "create $file2 failed"
14076 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14077 error "create $file3 failed"
14079 $LFS swap_layouts $file1 $file2 ||
14080 error "swap $file1 $file2 layouts failed"
14082 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14083 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
14085 echo 123 > $file1 || error "Should be able to write into $file1"
14087 $LFS swap_layouts $file1 $file3 ||
14088 error "swap $file1 $file3 layouts failed"
14090 echo 123 > $file1 || error "Should be able to write into $file1"
14092 rm -rf $file1 $file2 $file3
14094 run_test 184e "Recreate layout after stripeless layout swaps"
14097 # Create a file with name longer than sizeof(struct stat) ==
14098 # 144 to see if we can get chars from the file name to appear
14099 # in the returned striping. Note that 'f' == 0x66.
14100 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
14102 mkdir -p $DIR/$tdir
14103 mcreate $DIR/$tdir/$file
14104 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
14105 error "IOC_MDC_GETFILEINFO returned garbage striping"
14108 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
14110 test_185() { # LU-2441
14111 # LU-3553 - no volatile file support in old servers
14112 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
14113 skip "Need MDS version at least 2.3.60"
14115 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14116 touch $DIR/$tdir/spoo
14117 local mtime1=$(stat -c "%Y" $DIR/$tdir)
14118 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
14119 error "cannot create/write a volatile file"
14120 [ "$FILESET" == "" ] &&
14121 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
14122 error "FID is still valid after close"
14124 multiop_bg_pause $DIR/$tdir vVw4096_c
14131 # assume that the next FID for this client is sequential, since stdout
14132 # is unfortunately eaten by multiop_bg_pause
14133 local n=$((${fidv[1]} + 1))
14134 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
14135 if [ "$FILESET" == "" ]; then
14136 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
14137 error "FID is missing before close"
14139 kill -USR1 $multi_pid
14140 # 1 second delay, so if mtime change we will see it
14142 local mtime2=$(stat -c "%Y" $DIR/$tdir)
14143 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
14145 run_test 185 "Volatile file support"
14148 remote_mds_nodsh && skip "remote MDS with nodsh"
14149 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14150 skip "Need MDS version at least 2.3.0"
14152 local dir0=$DIR/$tdir/$testnum
14153 mkdir -p $dir0 || error "creating dir $dir0"
14155 local file=$dir0/file1
14156 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
14157 local dv1=$($LFS data_version $file)
14158 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
14159 local dv2=$($LFS data_version $file)
14160 [[ $dv1 != $dv2 ]] ||
14161 error "data version did not change on write $dv1 == $dv2"
14166 run_test 187a "Test data version change"
14169 remote_mds_nodsh && skip "remote MDS with nodsh"
14170 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14171 skip "Need MDS version at least 2.3.0"
14173 local dir0=$DIR/$tdir/$testnum
14174 mkdir -p $dir0 || error "creating dir $dir0"
14176 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
14177 [[ ${DV[0]} != ${DV[1]} ]] ||
14178 error "data version did not change on write"\
14179 " ${DV[0]} == ${DV[1]}"
14184 run_test 187b "Test data version change on volatile file"
14187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14188 remote_mgs_nodsh && skip "remote MGS with nodsh"
14189 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14191 local POOL=${POOL:-cea1}
14192 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
14193 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
14196 local last_ost=$(($OSTCOUNT - 1))
14198 local ost_list=$(seq $first_ost $ost_step $last_ost)
14199 local ost_range="$first_ost $last_ost $ost_step"
14200 local test_path=$POOL_ROOT/$POOL_DIR_NAME
14201 local file_dir=$POOL_ROOT/file_tst
14202 local subdir=$test_path/subdir
14205 if ! combined_mgs_mds ; then
14210 # former test_200a test_200b
14211 pool_add $POOL || { rc=$? ; break; }
14212 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
14213 # former test_200c test_200d
14214 mkdir -p $test_path
14215 pool_set_dir $POOL $test_path || { rc=$? ; break; }
14216 pool_check_dir $POOL $test_path || { rc=$? ; break; }
14218 pool_check_dir $POOL $subdir || { rc=$? ; break; }
14219 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
14220 || { rc=$? ; break; }
14221 # former test_200e test_200f
14222 local files=$((OSTCOUNT*3))
14223 pool_alloc_files $POOL $test_path $files "$ost_list" \
14224 || { rc=$? ; break; }
14225 pool_create_files $POOL $file_dir $files "$ost_list" \
14226 || { rc=$? ; break; }
14227 # former test_200g test_200h
14228 pool_lfs_df $POOL || { rc=$? ; break; }
14229 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
14231 # former test_201a test_201b test_201c
14232 pool_remove_first_target $POOL || { rc=$? ; break; }
14234 local f=$test_path/$tfile
14235 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
14236 pool_remove $POOL $f || { rc=$? ; break; }
14242 if ! combined_mgs_mds ; then
14247 run_test 200 "OST pools"
14249 # usage: default_attr <count | size | offset>
14251 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
14254 # usage: check_default_stripe_attr
14255 check_default_stripe_attr() {
14256 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
14259 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
14261 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
14265 error "unknown getstripe attr '$1'"
14268 [ $ACTUAL == $EXPECTED ] ||
14269 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
14273 test_mkdir $DIR/$tdir
14274 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
14276 check_default_stripe_attr --stripe-count
14277 check_default_stripe_attr --stripe-size
14278 check_default_stripe_attr --stripe-index
14280 run_test 204a "Print default stripe attributes"
14283 test_mkdir $DIR/$tdir
14284 $LFS setstripe --stripe-count 1 $DIR/$tdir
14286 check_default_stripe_attr --stripe-size
14287 check_default_stripe_attr --stripe-index
14289 run_test 204b "Print default stripe size and offset"
14292 test_mkdir $DIR/$tdir
14293 $LFS setstripe --stripe-size 65536 $DIR/$tdir
14295 check_default_stripe_attr --stripe-count
14296 check_default_stripe_attr --stripe-index
14298 run_test 204c "Print default stripe count and offset"
14301 test_mkdir $DIR/$tdir
14302 $LFS setstripe --stripe-index 0 $DIR/$tdir
14304 check_default_stripe_attr --stripe-count
14305 check_default_stripe_attr --stripe-size
14307 run_test 204d "Print default stripe count and size"
14310 test_mkdir $DIR/$tdir
14311 $LFS setstripe -d $DIR/$tdir
14313 check_default_stripe_attr --stripe-count --raw
14314 check_default_stripe_attr --stripe-size --raw
14315 check_default_stripe_attr --stripe-index --raw
14317 run_test 204e "Print raw stripe attributes"
14320 test_mkdir $DIR/$tdir
14321 $LFS setstripe --stripe-count 1 $DIR/$tdir
14323 check_default_stripe_attr --stripe-size --raw
14324 check_default_stripe_attr --stripe-index --raw
14326 run_test 204f "Print raw stripe size and offset"
14329 test_mkdir $DIR/$tdir
14330 $LFS setstripe --stripe-size 65536 $DIR/$tdir
14332 check_default_stripe_attr --stripe-count --raw
14333 check_default_stripe_attr --stripe-index --raw
14335 run_test 204g "Print raw stripe count and offset"
14338 test_mkdir $DIR/$tdir
14339 $LFS setstripe --stripe-index 0 $DIR/$tdir
14341 check_default_stripe_attr --stripe-count --raw
14342 check_default_stripe_attr --stripe-size --raw
14344 run_test 204h "Print raw stripe count and size"
14346 # Figure out which job scheduler is being used, if any,
14347 # or use a fake one
14348 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
14349 JOBENV=SLURM_JOB_ID
14350 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
14352 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
14354 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
14355 JOBENV=LOADL_STEP_ID
14356 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
14359 $LCTL list_param jobid_name > /dev/null 2>&1
14360 if [ $? -eq 0 ]; then
14366 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
14368 verify_jobstats() {
14373 # we don't really need to clear the stats for this test to work, since each
14374 # command has a unique jobid, but it makes debugging easier if needed.
14375 # for facet in $facets; do
14376 # local dev=$(convert_facet2label $facet)
14377 # # clear old jobstats
14378 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
14381 # use a new JobID for each test, or we might see an old one
14382 [ "$JOBENV" = "FAKE_JOBID" ] &&
14383 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
14385 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
14387 [ "$JOBENV" = "nodelocal" ] && {
14388 FAKE_JOBID=id.$testnum.%e.$RANDOM
14389 $LCTL set_param jobid_name=$FAKE_JOBID
14390 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
14393 log "Test: ${cmd[*]}"
14394 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
14396 if [ $JOBENV = "FAKE_JOBID" ]; then
14397 FAKE_JOBID=$JOBVAL ${cmd[*]}
14402 # all files are created on OST0000
14403 for facet in $facets; do
14404 local stats="*.$(convert_facet2label $facet).job_stats"
14406 # strip out libtool wrappers for in-tree executables
14407 if [ $(do_facet $facet lctl get_param $stats |
14408 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
14409 do_facet $facet lctl get_param $stats
14410 error "No jobstats for $JOBVAL found on $facet::$stats"
14416 local new_jobenv=$1
14418 set_persistent_param_and_check client "jobid_var" \
14419 "$FSNAME.sys.jobid_var" $new_jobenv
14422 test_205() { # Job stats
14423 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14424 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
14425 skip "Need MDS version with at least 2.7.1"
14426 remote_mgs_nodsh && skip "remote MGS with nodsh"
14427 remote_mds_nodsh && skip "remote MDS with nodsh"
14428 remote_ost_nodsh && skip "remote OST with nodsh"
14429 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
14430 skip "Server doesn't support jobstats"
14431 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
14433 local old_jobenv=$($LCTL get_param -n jobid_var)
14434 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
14436 if [[ $PERM_CMD == *"set_param -P"* ]]; then
14437 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
14439 stack_trap "do_facet mgs $PERM_CMD \
14440 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
14444 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
14445 mdt.*.job_cleanup_interval | head -n 1)
14446 local new_interval=5
14447 do_facet $SINGLEMDS \
14448 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
14449 stack_trap "do_facet $SINGLEMDS \
14450 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
14451 local start=$SECONDS
14455 cmd="mkdir $DIR/$tdir"
14456 verify_jobstats "$cmd" "$SINGLEMDS"
14458 cmd="rmdir $DIR/$tdir"
14459 verify_jobstats "$cmd" "$SINGLEMDS"
14460 # mkdir on secondary MDT
14461 if [ $MDSCOUNT -gt 1 ]; then
14462 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
14463 verify_jobstats "$cmd" "mds2"
14466 cmd="mknod $DIR/$tfile c 1 3"
14467 verify_jobstats "$cmd" "$SINGLEMDS"
14469 cmd="rm -f $DIR/$tfile"
14470 verify_jobstats "$cmd" "$SINGLEMDS"
14471 # create all files on OST0000 so verify_jobstats can find OST stats
14473 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
14474 verify_jobstats "$cmd" "$SINGLEMDS"
14476 cmd="touch $DIR/$tfile"
14477 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14479 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
14480 verify_jobstats "$cmd" "ost1"
14482 cancel_lru_locks osc
14483 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
14484 verify_jobstats "$cmd" "ost1"
14486 cmd="$TRUNCATE $DIR/$tfile 0"
14487 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14489 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
14490 verify_jobstats "$cmd" "$SINGLEMDS"
14491 # jobstats expiry - sleep until old stats should be expired
14492 local left=$((new_interval + 5 - (SECONDS - start)))
14493 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
14494 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
14496 cmd="mkdir $DIR/$tdir.expire"
14497 verify_jobstats "$cmd" "$SINGLEMDS"
14498 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
14499 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
14501 # Ensure that jobid are present in changelog (if supported by MDS)
14502 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
14503 changelog_dump | tail -10
14504 jobids=$(changelog_dump | tail -9 | grep -c "j=")
14505 [ $jobids -eq 9 ] ||
14506 error "Wrong changelog jobid count $jobids != 9"
14510 jobstats_set $JOBENV
14512 changelog_dump | grep $tfile
14513 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
14514 [ $jobids -eq 0 ] ||
14515 error "Unexpected jobids when jobid_var=$JOBENV"
14518 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
14519 JOBENV="JOBCOMPLEX"
14520 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
14522 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
14524 run_test 205 "Verify job stats"
14526 # LU-1480, LU-1773 and LU-1657
14528 mkdir -p $DIR/$tdir
14529 $LFS setstripe -c -1 $DIR/$tdir
14530 #define OBD_FAIL_LOV_INIT 0x1403
14531 $LCTL set_param fail_loc=0xa0001403
14532 $LCTL set_param fail_val=1
14533 touch $DIR/$tdir/$tfile || true
14535 run_test 206 "fail lov_init_raid0() doesn't lbug"
14538 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
14539 local fsz=`stat -c %s $DIR/$tfile`
14540 cancel_lru_locks mdc
14542 # do not return layout in getattr intent
14543 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
14544 $LCTL set_param fail_loc=0x170
14545 local sz=`stat -c %s $DIR/$tfile`
14547 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
14551 run_test 207a "can refresh layout at glimpse"
14554 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
14555 local cksum=`md5sum $DIR/$tfile`
14556 local fsz=`stat -c %s $DIR/$tfile`
14557 cancel_lru_locks mdc
14558 cancel_lru_locks osc
14560 # do not return layout in getattr intent
14561 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
14562 $LCTL set_param fail_loc=0x171
14564 # it will refresh layout after the file is opened but before read issues
14565 echo checksum is "$cksum"
14566 echo "$cksum" |md5sum -c --quiet || error "file differs"
14570 run_test 207b "can refresh layout at open"
14573 # FIXME: in this test suite, only RD lease is used. This is okay
14574 # for now as only exclusive open is supported. After generic lease
14575 # is done, this test suite should be revised. - Jinshan
14577 remote_mds_nodsh && skip "remote MDS with nodsh"
14578 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
14579 skip "Need MDS version at least 2.4.52"
14581 echo "==== test 1: verify get lease work"
14582 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
14584 echo "==== test 2: verify lease can be broken by upcoming open"
14585 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14589 $MULTIOP $DIR/$tfile oO_RDONLY:c
14590 kill -USR1 $PID && wait $PID || error "break lease error"
14592 echo "==== test 3: verify lease can't be granted if an open already exists"
14593 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
14597 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
14598 kill -USR1 $PID && wait $PID || error "open file error"
14600 echo "==== test 4: lease can sustain over recovery"
14601 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
14607 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
14609 echo "==== test 5: lease broken can't be regained by replay"
14610 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14614 # open file to break lease and then recovery
14615 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
14618 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
14622 run_test 208 "Exclusive open"
14625 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
14626 skip_env "must have disp_stripe"
14629 sync; sleep 5; sync;
14631 echo 3 > /proc/sys/vm/drop_caches
14632 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14634 # open/close 500 times
14635 for i in $(seq 500); do
14639 echo 3 > /proc/sys/vm/drop_caches
14640 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14642 echo "before: $req_before, after: $req_after"
14643 [ $((req_after - req_before)) -ge 300 ] &&
14644 error "open/close requests are not freed"
14647 run_test 209 "read-only open/close requests should be freed promptly"
14651 size=$((size % 8192 + 1))
14652 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
14653 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
14654 rm -f $DIR/f212 $DIR/f212.xyz
14656 run_test 212 "Sendfile test ============================================"
14659 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
14660 cancel_lru_locks osc
14661 lctl set_param fail_loc=0x8000040f
14662 # generate a read lock
14663 cat $DIR/$tfile > /dev/null
14664 # write to the file, it will try to cancel the above read lock.
14665 cat /etc/hosts >> $DIR/$tfile
14667 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
14669 test_214() { # for bug 20133
14670 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
14671 for (( i=0; i < 340; i++ )) ; do
14672 touch $DIR/$tdir/d214c/a$i
14675 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
14676 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
14677 ls $DIR/d214c || error "ls $DIR/d214c failed"
14678 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
14679 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
14681 run_test 214 "hash-indexed directory test - bug 20133"
14683 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
14684 create_lnet_proc_files() {
14685 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
14688 # counterpart of create_lnet_proc_files
14689 remove_lnet_proc_files() {
14690 rm -f $TMP/lnet_$1.sys
14693 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14694 # 3rd arg as regexp for body
14695 check_lnet_proc_stats() {
14696 local l=$(cat "$TMP/lnet_$1" |wc -l)
14697 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
14699 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
14702 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14703 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
14704 # optional and can be regexp for 2nd line (lnet.routes case)
14705 check_lnet_proc_entry() {
14706 local blp=2 # blp stands for 'position of 1st line of body'
14707 [ -z "$5" ] || blp=3 # lnet.routes case
14709 local l=$(cat "$TMP/lnet_$1" |wc -l)
14710 # subtracting one from $blp because the body can be empty
14711 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
14713 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
14714 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
14716 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
14717 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
14719 # bail out if any unexpected line happened
14720 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
14721 [ "$?" != 0 ] || error "$2 misformatted"
14724 test_215() { # for bugs 18102, 21079, 21517
14725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14727 local N='(0|[1-9][0-9]*)' # non-negative numeric
14728 local P='[1-9][0-9]*' # positive numeric
14729 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
14730 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
14731 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
14732 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
14734 local L1 # regexp for 1st line
14735 local L2 # regexp for 2nd line (optional)
14736 local BR # regexp for the rest (body)
14738 # lnet.stats should look as 11 space-separated non-negative numerics
14739 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
14740 create_lnet_proc_files "stats"
14741 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
14742 remove_lnet_proc_files "stats"
14744 # lnet.routes should look like this:
14745 # Routing disabled/enabled
14746 # net hops priority state router
14747 # where net is a string like tcp0, hops > 0, priority >= 0,
14748 # state is up/down,
14749 # router is a string like 192.168.1.1@tcp2
14750 L1="^Routing (disabled|enabled)$"
14751 L2="^net +hops +priority +state +router$"
14752 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
14753 create_lnet_proc_files "routes"
14754 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
14755 remove_lnet_proc_files "routes"
14757 # lnet.routers should look like this:
14758 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
14759 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
14760 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
14761 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
14762 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
14763 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
14764 create_lnet_proc_files "routers"
14765 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
14766 remove_lnet_proc_files "routers"
14768 # lnet.peers should look like this:
14769 # nid refs state last max rtr min tx min queue
14770 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
14771 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
14772 # numeric (0 or >0 or <0), queue >= 0.
14773 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
14774 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
14775 create_lnet_proc_files "peers"
14776 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
14777 remove_lnet_proc_files "peers"
14779 # lnet.buffers should look like this:
14780 # pages count credits min
14781 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
14782 L1="^pages +count +credits +min$"
14783 BR="^ +$N +$N +$I +$I$"
14784 create_lnet_proc_files "buffers"
14785 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
14786 remove_lnet_proc_files "buffers"
14788 # lnet.nis should look like this:
14789 # nid status alive refs peer rtr max tx min
14790 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
14791 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
14792 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
14793 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
14794 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
14795 create_lnet_proc_files "nis"
14796 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
14797 remove_lnet_proc_files "nis"
14799 # can we successfully write to lnet.stats?
14800 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
14802 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
14804 test_216() { # bug 20317
14805 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14806 remote_ost_nodsh && skip "remote OST with nodsh"
14809 local facets=$(get_facets OST)
14810 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14812 save_lustre_params client "osc.*.contention_seconds" > $p
14813 save_lustre_params $facets \
14814 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
14815 save_lustre_params $facets \
14816 "ldlm.namespaces.filter-*.contended_locks" >> $p
14817 save_lustre_params $facets \
14818 "ldlm.namespaces.filter-*.contention_seconds" >> $p
14819 clear_stats osc.*.osc_stats
14821 # agressive lockless i/o settings
14822 do_nodes $(comma_list $(osts_nodes)) \
14823 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
14824 ldlm.namespaces.filter-*.contended_locks=0 \
14825 ldlm.namespaces.filter-*.contention_seconds=60"
14826 lctl set_param -n osc.*.contention_seconds=60
14828 $DIRECTIO write $DIR/$tfile 0 10 4096
14829 $CHECKSTAT -s 40960 $DIR/$tfile
14831 # disable lockless i/o
14832 do_nodes $(comma_list $(osts_nodes)) \
14833 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
14834 ldlm.namespaces.filter-*.contended_locks=32 \
14835 ldlm.namespaces.filter-*.contention_seconds=0"
14836 lctl set_param -n osc.*.contention_seconds=0
14837 clear_stats osc.*.osc_stats
14839 dd if=/dev/zero of=$DIR/$tfile count=0
14840 $CHECKSTAT -s 0 $DIR/$tfile
14842 restore_lustre_params <$p
14846 run_test 216 "check lockless direct write updates file size and kms correctly"
14848 test_217() { # bug 22430
14849 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14854 for node in $(nodes_list); do
14855 nid=$(host_nids_address $node $NETTYPE)
14856 if [[ $nid = *-* ]] ; then
14857 echo "lctl ping $(h2nettype $nid)"
14858 lctl ping $(h2nettype $nid)
14860 echo "skipping $node (no hyphen detected)"
14864 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
14867 # do directio so as not to populate the page cache
14868 log "creating a 10 Mb file"
14869 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14870 log "starting reads"
14871 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14872 log "truncating the file"
14873 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14875 kill %+ || true # reads might have finished
14876 echo "wait until dd is finished"
14878 log "removing the temporary file"
14879 rm -rf $DIR/$tfile || error "tmp file removal failed"
14881 run_test 218 "parallel read and truncate should not deadlock"
14884 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14886 # write one partial page
14887 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
14888 # set no grant so vvp_io_commit_write will do sync write
14889 $LCTL set_param fail_loc=0x411
14890 # write a full page at the end of file
14891 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
14893 $LCTL set_param fail_loc=0
14894 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
14895 $LCTL set_param fail_loc=0x411
14896 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
14899 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
14900 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
14902 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
14904 test_220() { #LU-325
14905 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14906 remote_ost_nodsh && skip "remote OST with nodsh"
14907 remote_mds_nodsh && skip "remote MDS with nodsh"
14908 remote_mgs_nodsh && skip "remote MGS with nodsh"
14912 # create on MDT0000 so the last_id and next_id are correct
14914 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
14918 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
14919 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
14920 osc.$mdtosc_proc1.prealloc_last_id)
14921 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
14922 osc.$mdtosc_proc1.prealloc_next_id)
14926 if ! combined_mgs_mds ; then
14930 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
14931 #define OBD_FAIL_OST_ENOINO 0x229
14932 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
14933 create_pool $FSNAME.$TESTNAME || return 1
14934 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
14936 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
14938 MDSOBJS=$((last_id - next_id))
14939 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
14941 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
14942 echo "OST still has $count kbytes free"
14944 echo "create $MDSOBJS files @next_id..."
14945 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
14947 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14948 osc.$mdtosc_proc1.prealloc_last_id)
14949 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14950 osc.$mdtosc_proc1.prealloc_next_id)
14952 echo "after creation, last_id=$last_id2, next_id=$next_id2"
14957 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
14958 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
14960 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
14961 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
14962 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14963 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
14964 echo "unlink $MDSOBJS files @$next_id..."
14965 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
14967 if ! combined_mgs_mds ; then
14971 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
14974 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14976 dd if=`which date` of=$MOUNT/date oflag=sync
14977 chmod +x $MOUNT/date
14979 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
14980 $LCTL set_param fail_loc=0x80001401
14982 $MOUNT/date > /dev/null
14985 run_test 221 "make sure fault and truncate race to not cause OOM"
14988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14991 test_mkdir $DIR/$tdir
14992 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14993 createmany -o $DIR/$tdir/$tfile 10
14994 cancel_lru_locks mdc
14995 cancel_lru_locks osc
14996 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
14997 $LCTL set_param fail_loc=0x31a
14998 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
14999 $LCTL set_param fail_loc=0
15002 run_test 222a "AGL for ls should not trigger CLIO lock failure"
15005 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15008 test_mkdir $DIR/$tdir
15009 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15010 createmany -o $DIR/$tdir/$tfile 10
15011 cancel_lru_locks mdc
15012 cancel_lru_locks osc
15013 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15014 $LCTL set_param fail_loc=0x31a
15015 rm -r $DIR/$tdir || error "AGL for rmdir failed"
15016 $LCTL set_param fail_loc=0
15018 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
15021 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15024 test_mkdir $DIR/$tdir
15025 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15026 createmany -o $DIR/$tdir/$tfile 10
15027 cancel_lru_locks mdc
15028 cancel_lru_locks osc
15029 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
15030 $LCTL set_param fail_loc=0x31b
15031 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
15032 $LCTL set_param fail_loc=0
15035 run_test 223 "osc reenqueue if without AGL lock granted ======================="
15037 test_224a() { # LU-1039, MRP-303
15038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15040 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
15041 $LCTL set_param fail_loc=0x508
15042 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
15043 $LCTL set_param fail_loc=0
15046 run_test 224a "Don't panic on bulk IO failure"
15048 test_224b() { # LU-1039, MRP-303
15049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15051 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
15052 cancel_lru_locks osc
15053 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
15054 $LCTL set_param fail_loc=0x515
15055 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
15056 $LCTL set_param fail_loc=0
15059 run_test 224b "Don't panic on bulk IO failure"
15061 test_224c() { # LU-6441
15062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15063 remote_mds_nodsh && skip "remote MDS with nodsh"
15065 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15066 save_writethrough $p
15067 set_cache writethrough on
15069 local pages_per_rpc=$($LCTL get_param \
15070 osc.*.max_pages_per_rpc)
15071 local at_max=$($LCTL get_param -n at_max)
15072 local timeout=$($LCTL get_param -n timeout)
15073 local test_at="at_max"
15074 local param_at="$FSNAME.sys.at_max"
15075 local test_timeout="timeout"
15076 local param_timeout="$FSNAME.sys.timeout"
15078 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
15080 set_persistent_param_and_check client "$test_at" "$param_at" 0
15081 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
15083 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
15084 do_facet ost1 "$LCTL set_param fail_loc=0x520"
15085 $LFS setstripe -c 1 -i 0 $DIR/$tfile
15086 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
15088 do_facet ost1 "$LCTL set_param fail_loc=0"
15090 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
15091 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
15094 $LCTL set_param -n $pages_per_rpc
15095 restore_lustre_params < $p
15098 run_test 224c "Don't hang if one of md lost during large bulk RPC"
15100 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
15102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15103 if [ -z ${MDSSURVEY} ]; then
15104 skip_env "mds-survey not found"
15106 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15107 skip "Need MDS version at least 2.2.51"
15109 local mds=$(facet_host $SINGLEMDS)
15110 local target=$(do_nodes $mds 'lctl dl' |
15111 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15113 local cmd1="file_count=1000 thrhi=4"
15114 local cmd2="dir_count=2 layer=mdd stripe_count=0"
15115 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15116 local cmd="$cmd1 $cmd2 $cmd3"
15118 rm -f ${TMP}/mds_survey*
15120 eval $cmd || error "mds-survey with zero-stripe failed"
15121 cat ${TMP}/mds_survey*
15122 rm -f ${TMP}/mds_survey*
15124 run_test 225a "Metadata survey sanity with zero-stripe"
15127 if [ -z ${MDSSURVEY} ]; then
15128 skip_env "mds-survey not found"
15130 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15131 skip "Need MDS version at least 2.2.51"
15132 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15133 remote_mds_nodsh && skip "remote MDS with nodsh"
15134 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
15135 skip_env "Need to mount OST to test"
15138 local mds=$(facet_host $SINGLEMDS)
15139 local target=$(do_nodes $mds 'lctl dl' |
15140 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15142 local cmd1="file_count=1000 thrhi=4"
15143 local cmd2="dir_count=2 layer=mdd stripe_count=1"
15144 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15145 local cmd="$cmd1 $cmd2 $cmd3"
15147 rm -f ${TMP}/mds_survey*
15149 eval $cmd || error "mds-survey with stripe_count failed"
15150 cat ${TMP}/mds_survey*
15151 rm -f ${TMP}/mds_survey*
15153 run_test 225b "Metadata survey sanity with stripe_count = 1"
15155 mcreate_path2fid () {
15161 local path=$DIR/$tdir/$name
15166 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
15167 error "cannot create $desc"
15169 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
15171 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
15173 fid_path=$($LFS fid2path $MOUNT $fid)
15175 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
15177 [ "$path" == "$fid_path" ] ||
15178 error "fid2path returned $fid_path, expected $path"
15180 echo "pass with $path and $fid"
15185 mkdir -p $DIR/$tdir
15187 mcreate_path2fid 0010666 0 0 fifo "FIFO"
15188 mcreate_path2fid 0020666 1 3 null "character special file (null)"
15189 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
15190 mcreate_path2fid 0040666 0 0 dir "directory"
15191 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
15192 mcreate_path2fid 0100666 0 0 file "regular file"
15193 mcreate_path2fid 0120666 0 0 link "symbolic link"
15194 mcreate_path2fid 0140666 0 0 sock "socket"
15196 run_test 226a "call path2fid and fid2path on files of all type"
15199 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15204 mkdir -p $DIR/$tdir
15205 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
15206 error "create remote directory failed"
15207 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
15208 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
15209 "character special file (null)"
15210 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
15211 "character special file (no device)"
15212 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
15213 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
15214 "block special file (loop)"
15215 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
15216 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
15217 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
15219 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
15221 # LU-1299 Executing or running ldd on a truncated executable does not
15222 # cause an out-of-memory condition.
15224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15225 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
15227 dd if=$(which date) of=$MOUNT/date bs=1k count=1
15228 chmod +x $MOUNT/date
15230 $MOUNT/date > /dev/null
15231 ldd $MOUNT/date > /dev/null
15234 run_test 227 "running truncated executable does not cause OOM"
15236 # LU-1512 try to reuse idle OI blocks
15238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15239 remote_mds_nodsh && skip "remote MDS with nodsh"
15240 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15242 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15243 local myDIR=$DIR/$tdir
15246 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15247 $LCTL set_param fail_loc=0x80001002
15248 createmany -o $myDIR/t- 10000
15249 $LCTL set_param fail_loc=0
15250 # The guard is current the largest FID holder
15252 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15254 local IDX=$(($SEQ % 64))
15256 do_facet $SINGLEMDS sync
15257 # Make sure journal flushed.
15259 local blk1=$(do_facet $SINGLEMDS \
15260 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15261 grep Blockcount | awk '{print $4}')
15263 # Remove old files, some OI blocks will become idle.
15264 unlinkmany $myDIR/t- 10000
15265 # Create new files, idle OI blocks should be reused.
15266 createmany -o $myDIR/t- 2000
15267 do_facet $SINGLEMDS sync
15268 # Make sure journal flushed.
15270 local blk2=$(do_facet $SINGLEMDS \
15271 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15272 grep Blockcount | awk '{print $4}')
15274 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15276 run_test 228a "try to reuse idle OI blocks"
15279 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15280 remote_mds_nodsh && skip "remote MDS with nodsh"
15281 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15283 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15284 local myDIR=$DIR/$tdir
15287 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15288 $LCTL set_param fail_loc=0x80001002
15289 createmany -o $myDIR/t- 10000
15290 $LCTL set_param fail_loc=0
15291 # The guard is current the largest FID holder
15293 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15295 local IDX=$(($SEQ % 64))
15297 do_facet $SINGLEMDS sync
15298 # Make sure journal flushed.
15300 local blk1=$(do_facet $SINGLEMDS \
15301 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15302 grep Blockcount | awk '{print $4}')
15304 # Remove old files, some OI blocks will become idle.
15305 unlinkmany $myDIR/t- 10000
15308 stop $SINGLEMDS || error "Fail to stop MDT."
15310 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
15312 df $MOUNT || error "Fail to df."
15313 # Create new files, idle OI blocks should be reused.
15314 createmany -o $myDIR/t- 2000
15315 do_facet $SINGLEMDS sync
15316 # Make sure journal flushed.
15318 local blk2=$(do_facet $SINGLEMDS \
15319 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15320 grep Blockcount | awk '{print $4}')
15322 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15324 run_test 228b "idle OI blocks can be reused after MDT restart"
15328 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15329 remote_mds_nodsh && skip "remote MDS with nodsh"
15330 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15332 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15333 local myDIR=$DIR/$tdir
15336 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15337 $LCTL set_param fail_loc=0x80001002
15338 # 20000 files can guarantee there are index nodes in the OI file
15339 createmany -o $myDIR/t- 20000
15340 $LCTL set_param fail_loc=0
15341 # The guard is current the largest FID holder
15343 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15345 local IDX=$(($SEQ % 64))
15347 do_facet $SINGLEMDS sync
15348 # Make sure journal flushed.
15350 local blk1=$(do_facet $SINGLEMDS \
15351 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15352 grep Blockcount | awk '{print $4}')
15354 # Remove old files, some OI blocks will become idle.
15355 unlinkmany $myDIR/t- 20000
15357 # The OI file should become empty now
15359 # Create new files, idle OI blocks should be reused.
15360 createmany -o $myDIR/t- 2000
15361 do_facet $SINGLEMDS sync
15362 # Make sure journal flushed.
15364 local blk2=$(do_facet $SINGLEMDS \
15365 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15366 grep Blockcount | awk '{print $4}')
15368 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15370 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
15372 test_229() { # LU-2482, LU-3448
15373 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15374 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
15375 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
15376 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
15380 # Create a file with a released layout and stripe count 2.
15381 $MULTIOP $DIR/$tfile H2c ||
15382 error "failed to create file with released layout"
15384 $LFS getstripe -v $DIR/$tfile
15386 local pattern=$($LFS getstripe -L $DIR/$tfile)
15387 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
15389 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
15391 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
15392 stat $DIR/$tfile || error "failed to stat released file"
15394 chown $RUNAS_ID $DIR/$tfile ||
15395 error "chown $RUNAS_ID $DIR/$tfile failed"
15397 chgrp $RUNAS_ID $DIR/$tfile ||
15398 error "chgrp $RUNAS_ID $DIR/$tfile failed"
15400 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
15401 rm $DIR/$tfile || error "failed to remove released file"
15403 run_test 229 "getstripe/stat/rm/attr changes work on released files"
15406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15407 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15408 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15409 skip "Need MDS version at least 2.11.52"
15413 test_mkdir $DIR/$tdir
15414 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
15415 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
15416 [ $mdt_idx -ne 0 ] &&
15417 error "create local directory on wrong MDT $mdt_idx"
15419 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
15420 error "create remote directory failed"
15421 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
15422 [ $mdt_idx -ne $MDTIDX ] &&
15423 error "create remote directory on wrong MDT $mdt_idx"
15425 createmany -o $DIR/$tdir/test_230/t- 10 ||
15426 error "create files on remote directory failed"
15427 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
15428 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
15429 rm -r $DIR/$tdir || error "unlink remote directory failed"
15431 run_test 230a "Create remote directory and files under the remote directory"
15434 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15435 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15436 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15437 skip "Need MDS version at least 2.11.52"
15445 local migrate_dir=$DIR/$tdir/migrate_dir
15446 local other_dir=$DIR/$tdir/other_dir
15448 test_mkdir $DIR/$tdir
15449 test_mkdir -i0 -c1 $migrate_dir
15450 test_mkdir -i0 -c1 $other_dir
15451 for ((i=0; i<10; i++)); do
15452 mkdir -p $migrate_dir/dir_${i}
15453 createmany -o $migrate_dir/dir_${i}/f 10 ||
15454 error "create files under remote dir failed $i"
15457 cp /etc/passwd $migrate_dir/$tfile
15458 cp /etc/passwd $other_dir/$tfile
15459 chattr +SAD $migrate_dir
15460 chattr +SAD $migrate_dir/$tfile
15462 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15463 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15464 local old_dir_mode=$(stat -c%f $migrate_dir)
15465 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
15467 mkdir -p $migrate_dir/dir_default_stripe2
15468 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
15469 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
15471 mkdir -p $other_dir
15472 ln $migrate_dir/$tfile $other_dir/luna
15473 ln $migrate_dir/$tfile $migrate_dir/sofia
15474 ln $other_dir/$tfile $migrate_dir/david
15475 ln -s $migrate_dir/$tfile $other_dir/zachary
15476 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
15477 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
15479 $LFS migrate -m $MDTIDX $migrate_dir ||
15480 error "fails on migrating remote dir to MDT1"
15482 echo "migratate to MDT1, then checking.."
15483 for ((i = 0; i < 10; i++)); do
15484 for file in $(find $migrate_dir/dir_${i}); do
15485 mdt_index=$($LFS getstripe -m $file)
15486 [ $mdt_index == $MDTIDX ] ||
15487 error "$file is not on MDT${MDTIDX}"
15491 # the multiple link file should still in MDT0
15492 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
15493 [ $mdt_index == 0 ] ||
15494 error "$file is not on MDT${MDTIDX}"
15496 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15497 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15498 error " expect $old_dir_flag get $new_dir_flag"
15500 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15501 [ "$old_file_flag" = "$new_file_flag" ] ||
15502 error " expect $old_file_flag get $new_file_flag"
15504 local new_dir_mode=$(stat -c%f $migrate_dir)
15505 [ "$old_dir_mode" = "$new_dir_mode" ] ||
15506 error "expect mode $old_dir_mode get $new_dir_mode"
15508 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
15509 [ "$old_file_mode" = "$new_file_mode" ] ||
15510 error "expect mode $old_file_mode get $new_file_mode"
15512 diff /etc/passwd $migrate_dir/$tfile ||
15513 error "$tfile different after migration"
15515 diff /etc/passwd $other_dir/luna ||
15516 error "luna different after migration"
15518 diff /etc/passwd $migrate_dir/sofia ||
15519 error "sofia different after migration"
15521 diff /etc/passwd $migrate_dir/david ||
15522 error "david different after migration"
15524 diff /etc/passwd $other_dir/zachary ||
15525 error "zachary different after migration"
15527 diff /etc/passwd $migrate_dir/${tfile}_ln ||
15528 error "${tfile}_ln different after migration"
15530 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
15531 error "${tfile}_ln_other different after migration"
15533 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
15534 [ $stripe_count = 2 ] ||
15535 error "dir strpe_count $d != 2 after migration."
15537 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
15538 [ $stripe_count = 2 ] ||
15539 error "file strpe_count $d != 2 after migration."
15541 #migrate back to MDT0
15544 $LFS migrate -m $MDTIDX $migrate_dir ||
15545 error "fails on migrating remote dir to MDT0"
15547 echo "migrate back to MDT0, checking.."
15548 for file in $(find $migrate_dir); do
15549 mdt_index=$($LFS getstripe -m $file)
15550 [ $mdt_index == $MDTIDX ] ||
15551 error "$file is not on MDT${MDTIDX}"
15554 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15555 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15556 error " expect $old_dir_flag get $new_dir_flag"
15558 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15559 [ "$old_file_flag" = "$new_file_flag" ] ||
15560 error " expect $old_file_flag get $new_file_flag"
15562 local new_dir_mode=$(stat -c%f $migrate_dir)
15563 [ "$old_dir_mode" = "$new_dir_mode" ] ||
15564 error "expect mode $old_dir_mode get $new_dir_mode"
15566 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
15567 [ "$old_file_mode" = "$new_file_mode" ] ||
15568 error "expect mode $old_file_mode get $new_file_mode"
15570 diff /etc/passwd ${migrate_dir}/$tfile ||
15571 error "$tfile different after migration"
15573 diff /etc/passwd ${other_dir}/luna ||
15574 error "luna different after migration"
15576 diff /etc/passwd ${migrate_dir}/sofia ||
15577 error "sofia different after migration"
15579 diff /etc/passwd ${other_dir}/zachary ||
15580 error "zachary different after migration"
15582 diff /etc/passwd $migrate_dir/${tfile}_ln ||
15583 error "${tfile}_ln different after migration"
15585 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
15586 error "${tfile}_ln_other different after migration"
15588 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
15589 [ $stripe_count = 2 ] ||
15590 error "dir strpe_count $d != 2 after migration."
15592 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
15593 [ $stripe_count = 2 ] ||
15594 error "file strpe_count $d != 2 after migration."
15596 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15598 run_test 230b "migrate directory"
15601 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15602 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15603 remote_mds_nodsh && skip "remote MDS with nodsh"
15604 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15605 skip "Need MDS version at least 2.11.52"
15611 local migrate_dir=$DIR/$tdir/migrate_dir
15613 #If migrating directory fails in the middle, all entries of
15614 #the directory is still accessiable.
15615 test_mkdir $DIR/$tdir
15616 test_mkdir -i0 -c1 $migrate_dir
15617 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
15619 createmany -o $migrate_dir/f $total ||
15620 error "create files under ${migrate_dir} failed"
15622 # fail after migrating top dir, and this will fail only once, so the
15623 # first sub file migration will fail (currently f3), others succeed.
15624 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
15625 do_facet mds1 lctl set_param fail_loc=0x1801
15626 local t=$(ls $migrate_dir | wc -l)
15627 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
15628 error "migrate should fail"
15629 local u=$(ls $migrate_dir | wc -l)
15630 [ "$u" == "$t" ] || error "$u != $t during migration"
15632 # add new dir/file should succeed
15633 mkdir $migrate_dir/dir ||
15634 error "mkdir failed under migrating directory"
15635 touch $migrate_dir/file ||
15636 error "create file failed under migrating directory"
15638 # add file with existing name should fail
15639 for file in $migrate_dir/f*; do
15640 stat $file > /dev/null || error "stat $file failed"
15641 $OPENFILE -f O_CREAT:O_EXCL $file &&
15642 error "open(O_CREAT|O_EXCL) $file should fail"
15643 $MULTIOP $file m && error "create $file should fail"
15644 touch $DIR/$tdir/remote_dir/$tfile ||
15645 error "touch $tfile failed"
15646 ln $DIR/$tdir/remote_dir/$tfile $file &&
15647 error "link $file should fail"
15648 mdt_index=$($LFS getstripe -m $file)
15649 if [ $mdt_index == 0 ]; then
15650 # file failed to migrate is not allowed to rename to
15651 mv $DIR/$tdir/remote_dir/$tfile $file &&
15652 error "rename to $file should fail"
15654 mv $DIR/$tdir/remote_dir/$tfile $file ||
15655 error "rename to $file failed"
15657 echo hello >> $file || error "write $file failed"
15660 # resume migration with different options should fail
15661 $LFS migrate -m 0 $migrate_dir &&
15662 error "migrate -m 0 $migrate_dir should fail"
15664 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
15665 error "migrate -c 2 $migrate_dir should fail"
15667 # resume migration should succeed
15668 $LFS migrate -m $MDTIDX $migrate_dir ||
15669 error "migrate $migrate_dir failed"
15671 echo "Finish migration, then checking.."
15672 for file in $(find $migrate_dir); do
15673 mdt_index=$($LFS getstripe -m $file)
15674 [ $mdt_index == $MDTIDX ] ||
15675 error "$file is not on MDT${MDTIDX}"
15678 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15680 run_test 230c "check directory accessiblity if migration failed"
15683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15684 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15685 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15686 skip "Need MDS version at least 2.11.52"
15688 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
15690 local migrate_dir=$DIR/$tdir/migrate_dir
15700 old_index=$((RANDOM % MDSCOUNT))
15701 old_count=$((MDSCOUNT - old_index))
15702 new_index=$((RANDOM % MDSCOUNT))
15703 new_count=$((MDSCOUNT - new_index))
15704 new_hash="all_char"
15706 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
15707 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
15709 test_mkdir $DIR/$tdir
15710 test_mkdir -i $old_index -c $old_count $migrate_dir
15712 for ((i=0; i<100; i++)); do
15713 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
15714 createmany -o $migrate_dir/dir_${i}/f 100 ||
15715 error "create files under remote dir failed $i"
15718 echo -n "Migrate from MDT$old_index "
15719 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
15720 echo -n "to MDT$new_index"
15721 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
15724 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
15725 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
15726 error "migrate remote dir error"
15728 echo "Finish migration, then checking.."
15729 for file in $(find $migrate_dir); do
15730 mdt_index=$($LFS getstripe -m $file)
15731 if [ $mdt_index -lt $new_index ] ||
15732 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
15733 error "$file is on MDT$mdt_index"
15737 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15739 run_test 230d "check migrate big directory"
15742 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15743 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15744 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15745 skip "Need MDS version at least 2.11.52"
15752 mkdir -p $DIR/$tdir
15753 mkdir $DIR/$tdir/migrate_dir
15754 mkdir $DIR/$tdir/other_dir
15755 touch $DIR/$tdir/migrate_dir/a
15756 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
15757 ls $DIR/$tdir/other_dir
15759 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15760 error "migrate dir fails"
15762 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15763 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15765 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15766 [ $mdt_index == 0 ] || error "a is not on MDT0"
15768 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
15769 error "migrate dir fails"
15771 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
15772 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
15774 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15775 [ $mdt_index == 1 ] || error "a is not on MDT1"
15777 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
15778 [ $mdt_index == 1 ] || error "b is not on MDT1"
15780 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15781 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
15783 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
15785 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15787 run_test 230e "migrate mulitple local link files"
15790 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15791 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15792 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15793 skip "Need MDS version at least 2.11.52"
15798 mkdir -p $DIR/$tdir
15799 mkdir $DIR/$tdir/migrate_dir
15800 $LFS mkdir -i1 $DIR/$tdir/other_dir
15801 touch $DIR/$tdir/migrate_dir/a
15802 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
15803 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
15804 ls $DIR/$tdir/other_dir
15806 # a should be migrated to MDT1, since no other links on MDT0
15807 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15808 error "#1 migrate dir fails"
15809 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15810 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15811 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15812 [ $mdt_index == 1 ] || error "a is not on MDT1"
15814 # a should stay on MDT1, because it is a mulitple link file
15815 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15816 error "#2 migrate dir fails"
15817 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15818 [ $mdt_index == 1 ] || error "a is not on MDT1"
15820 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15821 error "#3 migrate dir fails"
15823 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15824 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
15825 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
15827 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
15828 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
15830 # a should be migrated to MDT0, since no other links on MDT1
15831 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15832 error "#4 migrate dir fails"
15833 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15834 [ $mdt_index == 0 ] || error "a is not on MDT0"
15836 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15838 run_test 230f "migrate mulitple remote link files"
15841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15842 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15843 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15844 skip "Need MDS version at least 2.11.52"
15846 mkdir -p $DIR/$tdir/migrate_dir
15848 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
15849 error "migrating dir to non-exist MDT succeeds"
15852 run_test 230g "migrate dir to non-exist MDT"
15855 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15856 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15857 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15858 skip "Need MDS version at least 2.11.52"
15862 mkdir -p $DIR/$tdir/migrate_dir
15864 $LFS migrate -m1 $DIR &&
15865 error "migrating mountpoint1 should fail"
15867 $LFS migrate -m1 $DIR/$tdir/.. &&
15868 error "migrating mountpoint2 should fail"
15871 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
15872 error "migrating $tdir/migrate_dir/.. should fail"
15876 run_test 230h "migrate .. and root"
15879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15880 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15881 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15882 skip "Need MDS version at least 2.11.52"
15884 mkdir -p $DIR/$tdir/migrate_dir
15886 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
15887 error "migration fails with a tailing slash"
15889 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
15890 error "migration fails with two tailing slashes"
15892 run_test 230i "lfs migrate -m tolerates trailing slashes"
15895 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
15896 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15897 skip "Need MDS version at least 2.11.52"
15899 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
15900 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
15901 error "create $tfile failed"
15902 cat /etc/passwd > $DIR/$tdir/$tfile
15904 $LFS migrate -m 1 $DIR/$tdir
15906 cmp /etc/passwd $DIR/$tdir/$tfile ||
15907 error "DoM file mismatch after migration"
15909 run_test 230j "DoM file data not changed after dir migration"
15912 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
15913 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
15914 skip "Need MDS version at least 2.11.56"
15917 local files_on_starting_mdt=0
15919 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
15920 $LFS getdirstripe $DIR/$tdir
15921 for i in $(seq $total); do
15922 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
15923 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
15924 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15927 echo "$files_on_starting_mdt files on MDT0"
15929 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
15930 $LFS getdirstripe $DIR/$tdir
15932 files_on_starting_mdt=0
15933 for i in $(seq $total); do
15934 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
15935 error "file $tfile.$i mismatch after migration"
15936 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
15937 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15940 echo "$files_on_starting_mdt files on MDT1 after migration"
15941 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
15943 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
15944 $LFS getdirstripe $DIR/$tdir
15946 files_on_starting_mdt=0
15947 for i in $(seq $total); do
15948 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
15949 error "file $tfile.$i mismatch after 2nd migration"
15950 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
15951 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15954 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
15955 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
15959 run_test 230k "file data not changed after dir migration"
15962 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
15963 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
15964 skip "Need MDS version at least 2.11.56"
15966 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
15967 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
15968 error "create files under remote dir failed $i"
15969 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
15971 run_test 230l "readdir between MDTs won't crash"
15975 # For simplicity this test assumes that max_pages_per_rpc
15976 # is the same across all OSCs
15977 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
15978 local bulk_size=$((max_pages * PAGE_SIZE))
15979 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
15982 mkdir -p $DIR/$tdir
15983 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
15984 error "failed to set stripe with -S ${brw_size}M option"
15986 # clear the OSC stats
15987 $LCTL set_param osc.*.stats=0 &>/dev/null
15990 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
15991 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
15992 oflag=direct &>/dev/null || error "dd failed"
15994 sync; sleep 1; sync # just to be safe
15995 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
15996 if [ x$nrpcs != "x1" ]; then
15997 $LCTL get_param osc.*.stats
15998 error "found $nrpcs ost_write RPCs, not 1 as expected"
16002 # Drop the OSC cache, otherwise we will read from it
16003 cancel_lru_locks osc
16005 # clear the OSC stats
16006 $LCTL set_param osc.*.stats=0 &>/dev/null
16008 # Client reads $bulk_size.
16009 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
16010 iflag=direct &>/dev/null || error "dd failed"
16012 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
16013 if [ x$nrpcs != "x1" ]; then
16014 $LCTL get_param osc.*.stats
16015 error "found $nrpcs ost_read RPCs, not 1 as expected"
16018 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
16021 mkdir -p $DIR/$tdir
16023 for i in {0..1023}; do
16024 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
16025 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
16026 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
16030 run_test 231b "must not assert on fully utilized OST request buffer"
16033 mkdir -p $DIR/$tdir
16034 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16036 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16037 do_facet ost1 $LCTL set_param fail_loc=0x31c
16039 # ignore dd failure
16040 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
16042 do_facet ost1 $LCTL set_param fail_loc=0
16043 umount_client $MOUNT || error "umount failed"
16044 mount_client $MOUNT || error "mount failed"
16045 stop ost1 || error "cannot stop ost1"
16046 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16048 run_test 232a "failed lock should not block umount"
16051 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
16052 skip "Need MDS version at least 2.10.58"
16054 mkdir -p $DIR/$tdir
16055 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16056 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
16058 cancel_lru_locks osc
16060 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16061 do_facet ost1 $LCTL set_param fail_loc=0x31c
16064 $LFS data_version $DIR/$tdir/$tfile || true
16066 do_facet ost1 $LCTL set_param fail_loc=0
16067 umount_client $MOUNT || error "umount failed"
16068 mount_client $MOUNT || error "mount failed"
16069 stop ost1 || error "cannot stop ost1"
16070 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16072 run_test 232b "failed data version lock should not block umount"
16075 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
16076 skip "Need MDS version at least 2.3.64"
16077 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16079 local fid=$($LFS path2fid $MOUNT)
16081 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16082 error "cannot access $MOUNT using its FID '$fid'"
16084 run_test 233a "checking that OBF of the FS root succeeds"
16087 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
16088 skip "Need MDS version at least 2.5.90"
16089 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16091 local fid=$($LFS path2fid $MOUNT/.lustre)
16093 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16094 error "cannot access $MOUNT/.lustre using its FID '$fid'"
16096 fid=$($LFS path2fid $MOUNT/.lustre/fid)
16097 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16098 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
16100 run_test 233b "checking that OBF of the FS .lustre succeeds"
16103 local p="$TMP/sanityN-$TESTNAME.parameters"
16104 save_lustre_params client "llite.*.xattr_cache" > $p
16105 lctl set_param llite.*.xattr_cache 1 ||
16106 skip_env "xattr cache is not supported"
16108 mkdir -p $DIR/$tdir || error "mkdir failed"
16109 touch $DIR/$tdir/$tfile || error "touch failed"
16110 # OBD_FAIL_LLITE_XATTR_ENOMEM
16111 $LCTL set_param fail_loc=0x1405
16112 getfattr -n user.attr $DIR/$tdir/$tfile &&
16113 error "getfattr should have failed with ENOMEM"
16114 $LCTL set_param fail_loc=0x0
16117 restore_lustre_params < $p
16120 run_test 234 "xattr cache should not crash on ENOMEM"
16123 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
16124 skip "Need MDS version at least 2.4.52"
16126 flock_deadlock $DIR/$tfile
16131 124) error "process hangs on a deadlock"
16133 *) error "error executing flock_deadlock $DIR/$tfile"
16137 run_test 235 "LU-1715: flock deadlock detection does not work properly"
16141 check_swap_layouts_support
16143 local ref1=/etc/passwd
16144 local ref2=/etc/group
16145 local file1=$DIR/$tdir/f1
16146 local file2=$DIR/$tdir/f2
16148 test_mkdir -c1 $DIR/$tdir
16149 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
16150 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
16151 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
16152 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
16153 local fd=$(free_fd)
16154 local cmd="exec $fd<>$file2"
16157 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
16158 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
16161 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
16166 run_test 236 "Layout swap on open unlinked file"
16168 # LU-4659 linkea consistency
16170 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16171 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16172 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16173 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16176 ln $DIR/$tfile $DIR/$tfile.lnk
16177 touch $DIR/$tfile.new
16178 mv $DIR/$tfile.new $DIR/$tfile
16179 local fid1=$($LFS path2fid $DIR/$tfile)
16180 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
16181 local path1=$($LFS fid2path $FSNAME "$fid1")
16182 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
16183 local path2=$($LFS fid2path $FSNAME "$fid2")
16184 [ $tfile.lnk == $path2 ] ||
16185 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
16188 run_test 238 "Verify linkea consistency"
16190 test_239A() { # was test_239
16191 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
16192 skip "Need MDS version at least 2.5.60"
16194 local list=$(comma_list $(mdts_nodes))
16196 mkdir -p $DIR/$tdir
16197 createmany -o $DIR/$tdir/f- 5000
16198 unlinkmany $DIR/$tdir/f- 5000
16199 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
16200 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
16201 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
16202 osp.*MDT*.sync_in_flight" | calc_sum)
16203 [ "$changes" -eq 0 ] || error "$changes not synced"
16205 run_test 239A "osp_sync test"
16207 test_239a() { #LU-5297
16208 remote_mds_nodsh && skip "remote MDS with nodsh"
16211 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
16212 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
16213 chgrp $RUNAS_GID $DIR/$tfile
16214 wait_delete_completed
16216 run_test 239a "process invalid osp sync record correctly"
16218 test_239b() { #LU-5297
16219 remote_mds_nodsh && skip "remote MDS with nodsh"
16222 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
16223 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
16224 chgrp $RUNAS_GID $DIR/$tfile1
16225 wait_delete_completed
16226 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16228 chgrp $RUNAS_GID $DIR/$tfile2
16229 wait_delete_completed
16231 run_test 239b "process osp sync record with ENOMEM error correctly"
16234 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16235 remote_mds_nodsh && skip "remote MDS with nodsh"
16237 mkdir -p $DIR/$tdir
16239 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
16240 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
16241 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
16242 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
16244 umount_client $MOUNT || error "umount failed"
16245 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
16246 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
16247 mount_client $MOUNT || error "failed to mount client"
16249 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
16250 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
16252 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
16258 for LOOP in $(seq $count); do
16259 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
16260 cancel_lru_locks $OSC || true
16268 for LOOP in $(seq $1); do
16269 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
16274 test_241a() { # was test_241
16275 local bsize=$PAGE_SIZE
16277 (( bsize < 40960 )) && bsize=40960
16278 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
16280 cancel_lru_locks $OSC
16281 test_241_bio 1000 $bsize &
16283 test_241_dio 1000 $bsize
16286 run_test 241a "bio vs dio"
16289 local bsize=$PAGE_SIZE
16291 (( bsize < 40960 )) && bsize=40960
16292 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
16294 test_241_dio 1000 $bsize &
16296 test_241_dio 1000 $bsize
16299 run_test 241b "dio vs dio"
16302 remote_mds_nodsh && skip "remote MDS with nodsh"
16304 mkdir -p $DIR/$tdir
16305 touch $DIR/$tdir/$tfile
16307 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
16308 do_facet mds1 lctl set_param fail_loc=0x105
16309 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
16311 do_facet mds1 lctl set_param fail_loc=0
16312 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
16314 run_test 242 "mdt_readpage failure should not cause directory unreadable"
16318 test_mkdir $DIR/$tdir
16319 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
16321 run_test 243 "various group lock tests"
16325 test_mkdir $DIR/$tdir
16326 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
16327 sendfile_grouplock $DIR/$tdir/$tfile || \
16328 error "sendfile+grouplock failed"
16331 run_test 244 "sendfile with group lock tests"
16334 local flagname="multi_mod_rpcs"
16335 local connect_data_name="max_mod_rpcs"
16338 # check if multiple modify RPCs flag is set
16339 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
16340 grep "connect_flags:")
16343 echo "$out" | grep -qw $flagname
16344 if [ $? -ne 0 ]; then
16345 echo "connect flag $flagname is not set"
16349 # check if multiple modify RPCs data is set
16350 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
16353 echo "$out" | grep -qw $connect_data_name ||
16354 error "import should have connect data $connect_data_name"
16356 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
16358 test_246() { # LU-7371
16359 remote_ost_nodsh && skip "remote OST with nodsh"
16360 [ $OST1_VERSION -lt $(version_code 2.7.62) ] &&
16361 skip "Need OST version >= 2.7.62"
16363 do_facet ost1 $LCTL set_param fail_val=4095
16364 #define OBD_FAIL_OST_READ_SIZE 0x234
16365 do_facet ost1 $LCTL set_param fail_loc=0x234
16366 $LFS setstripe $DIR/$tfile -i 0 -c 1
16367 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
16368 cancel_lru_locks $FSNAME-OST0000
16369 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
16371 run_test 246 "Read file of size 4095 should return right length"
16377 umount_client $submount
16382 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16384 skip_env "Fileset feature is not supported"
16386 local submount=${MOUNT}_$tdir
16389 mkdir -p $submount || error "mkdir $submount failed"
16390 FILESET="$FILESET/$tdir" mount_client $submount ||
16391 error "mount $submount failed"
16392 trap "cleanup_247 $submount" EXIT
16393 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
16394 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
16395 error "read $MOUNT/$tdir/$tfile failed"
16396 cleanup_247 $submount
16398 run_test 247a "mount subdir as fileset"
16401 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16402 skip_env "Fileset feature is not supported"
16404 local submount=${MOUNT}_$tdir
16406 rm -rf $MOUNT/$tdir
16407 mkdir -p $submount || error "mkdir $submount failed"
16409 FILESET="$FILESET/$tdir" mount_client $submount &&
16410 error "mount $submount should fail"
16413 run_test 247b "mount subdir that dose not exist"
16416 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16417 skip_env "Fileset feature is not supported"
16419 local submount=${MOUNT}_$tdir
16421 mkdir -p $MOUNT/$tdir/dir1
16422 mkdir -p $submount || error "mkdir $submount failed"
16423 trap "cleanup_247 $submount" EXIT
16424 FILESET="$FILESET/$tdir" mount_client $submount ||
16425 error "mount $submount failed"
16426 local fid=$($LFS path2fid $MOUNT/)
16427 $LFS fid2path $submount $fid && error "fid2path should fail"
16428 cleanup_247 $submount
16430 run_test 247c "running fid2path outside root"
16433 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16434 skip "Fileset feature is not supported"
16436 local submount=${MOUNT}_$tdir
16438 mkdir -p $MOUNT/$tdir/dir1
16439 mkdir -p $submount || error "mkdir $submount failed"
16440 FILESET="$FILESET/$tdir" mount_client $submount ||
16441 error "mount $submount failed"
16442 trap "cleanup_247 $submount" EXIT
16443 local fid=$($LFS path2fid $submount/dir1)
16444 $LFS fid2path $submount $fid || error "fid2path should succeed"
16445 cleanup_247 $submount
16447 run_test 247d "running fid2path inside root"
16451 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16453 skip "Fileset feature is not supported"
16455 local submount=${MOUNT}_$tdir
16458 mkdir -p $submount || error "mkdir $submount failed"
16459 FILESET="$FILESET/.." mount_client $submount &&
16460 error "mount $submount should fail"
16463 run_test 247e "mount .. as fileset"
16466 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
16467 [ -z "$fast_read_sav" ] && skip "no fast read support"
16469 # create a large file for fast read verification
16470 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
16472 # make sure the file is created correctly
16473 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
16474 { rm -f $DIR/$tfile; skip "file creation error"; }
16476 echo "Test 1: verify that fast read is 4 times faster on cache read"
16478 # small read with fast read enabled
16479 $LCTL set_param -n llite.*.fast_read=1
16480 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16481 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16482 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16483 # small read with fast read disabled
16484 $LCTL set_param -n llite.*.fast_read=0
16485 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16486 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16487 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16489 # verify that fast read is 4 times faster for cache read
16490 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
16491 error_not_in_vm "fast read was not 4 times faster: " \
16492 "$t_fast vs $t_slow"
16494 echo "Test 2: verify the performance between big and small read"
16495 $LCTL set_param -n llite.*.fast_read=1
16497 # 1k non-cache read
16498 cancel_lru_locks osc
16499 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16500 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16501 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16503 # 1M non-cache read
16504 cancel_lru_locks osc
16505 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16506 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16507 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16509 # verify that big IO is not 4 times faster than small IO
16510 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
16511 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
16513 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
16516 run_test 248 "fast read verification"
16518 test_249() { # LU-7890
16519 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
16520 skip "Need at least version 2.8.54"
16523 $LFS setstripe -c 1 $DIR/$tfile
16524 # Offset 2T == 4k * 512M
16525 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
16526 error "dd to 2T offset failed"
16528 run_test 249 "Write above 2T file size"
16531 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
16532 && skip "no 16TB file size limit on ZFS"
16534 $LFS setstripe -c 1 $DIR/$tfile
16535 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
16536 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
16537 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
16538 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
16539 conv=notrunc,fsync && error "append succeeded"
16542 run_test 250 "Write above 16T limit"
16545 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
16547 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
16548 #Skip once - writing the first stripe will succeed
16549 $LCTL set_param fail_loc=0xa0001407 fail_val=1
16550 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
16551 error "short write happened"
16553 $LCTL set_param fail_loc=0xa0001407 fail_val=1
16554 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
16555 error "short read happened"
16559 run_test 251 "Handling short read and write correctly"
16562 remote_mds_nodsh && skip "remote MDS with nodsh"
16563 remote_ost_nodsh && skip "remote OST with nodsh"
16564 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
16565 skip_env "ldiskfs only test"
16575 # check lr_reader on OST0000
16577 dev=$(facet_device $tgt)
16578 out=$(do_facet $tgt $LR_READER $dev)
16579 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16581 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
16582 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
16583 error "Invalid uuid returned by $LR_READER on target $tgt"
16584 echo -e "uuid returned by $LR_READER is '$uuid'\n"
16586 # check lr_reader -c on MDT0000
16588 dev=$(facet_device $tgt)
16589 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
16590 skip "$LR_READER does not support additional options"
16592 out=$(do_facet $tgt $LR_READER -c $dev)
16593 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16595 num=$(echo "$out" | grep -c "mdtlov")
16596 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
16597 error "Invalid number of mdtlov clients returned by $LR_READER"
16598 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
16600 # check lr_reader -cr on MDT0000
16601 out=$(do_facet $tgt $LR_READER -cr $dev)
16602 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16604 echo "$out" | grep -q "^reply_data:$" ||
16605 error "$LR_READER should have returned 'reply_data' section"
16606 num=$(echo "$out" | grep -c "client_generation")
16607 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
16609 run_test 252 "check lr_reader tool"
16611 test_253_fill_ost() {
16612 local size_mb #how many MB should we write to pass watermark
16613 local lwm=$3 #low watermark
16614 local free_10mb #10% of free space
16616 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
16617 size_mb=$((free_kb / 1024 - lwm))
16618 free_10mb=$((free_kb / 10240))
16619 #If 10% of free space cross low watermark use it
16620 if (( free_10mb > size_mb )); then
16623 #At least we need to store 1.1 of difference between
16624 #free space and low watermark
16625 size_mb=$((size_mb + size_mb / 10))
16627 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
16628 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
16629 oflag=append conv=notrunc
16634 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
16635 echo "OST still has $((free_kb / 1024)) mbytes free"
16639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16640 remote_mds_nodsh && skip "remote MDS with nodsh"
16641 remote_mgs_nodsh && skip "remote MGS with nodsh"
16646 local ost_name=$($LFS osts |
16647 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
16649 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
16650 do_facet $SINGLEMDS $LCTL get_param -n \
16651 osp.$mdtosc_proc1.reserved_mb_high ||
16652 skip "remote MDS does not support reserved_mb_high"
16656 wait_delete_completed
16659 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
16660 osp.$mdtosc_proc1.reserved_mb_high)
16661 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
16662 osp.$mdtosc_proc1.reserved_mb_low)
16663 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
16665 if ! combined_mgs_mds ; then
16668 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
16669 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
16670 error "Adding $ost_name to pool failed"
16672 # Wait for client to see a OST at pool
16673 wait_update $HOSTNAME "$LCTL get_param -n
16674 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
16675 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
16676 error "Client can not see the pool"
16677 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
16678 error "Setstripe failed"
16680 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
16681 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
16682 echo "OST still has $((blocks/1024)) mbytes free"
16684 local new_lwm=$((blocks/1024-10))
16685 do_facet $SINGLEMDS $LCTL set_param \
16686 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
16687 do_facet $SINGLEMDS $LCTL set_param \
16688 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
16690 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
16692 #First enospc could execute orphan deletion so repeat.
16693 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
16695 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
16696 osp.$mdtosc_proc1.prealloc_status)
16697 echo "prealloc_status $oa_status"
16699 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
16700 error "File creation should fail"
16701 #object allocation was stopped, but we still able to append files
16702 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
16703 error "Append failed"
16704 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
16706 wait_delete_completed
16710 for i in $(seq 10 12); do
16711 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
16712 error "File creation failed after rm";
16715 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
16716 osp.$mdtosc_proc1.prealloc_status)
16717 echo "prealloc_status $oa_status"
16719 if (( oa_status != 0 )); then
16720 error "Object allocation still disable after rm"
16722 do_facet $SINGLEMDS $LCTL set_param \
16723 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
16724 do_facet $SINGLEMDS $LCTL set_param \
16725 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
16728 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
16729 error "Remove $ost_name from pool failed"
16730 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
16731 error "Pool destroy fialed"
16733 if ! combined_mgs_mds ; then
16737 run_test 253 "Check object allocation limit"
16740 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16741 remote_mds_nodsh && skip "remote MDS with nodsh"
16742 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
16743 skip "MDS does not support changelog_size"
16746 local MDT0=$(facet_svc $SINGLEMDS)
16748 changelog_register || error "changelog_register failed"
16750 changelog_clear 0 || error "changelog_clear failed"
16752 local size1=$(do_facet $SINGLEMDS \
16753 $LCTL get_param -n mdd.$MDT0.changelog_size)
16754 echo "Changelog size $size1"
16757 $LFS mkdir -i 0 $DIR/$tdir
16759 mkdir -p $DIR/$tdir/pics/2008/zachy
16760 touch $DIR/$tdir/pics/2008/zachy/timestamp
16761 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
16762 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16763 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16764 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16765 rm $DIR/$tdir/pics/desktop.jpg
16767 local size2=$(do_facet $SINGLEMDS \
16768 $LCTL get_param -n mdd.$MDT0.changelog_size)
16769 echo "Changelog size after work $size2"
16771 (( $size2 > $size1 )) ||
16772 error "new Changelog size=$size2 less than old size=$size1"
16774 run_test 254 "Check changelog size"
16781 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
16782 awk -F: '{print $2}' | grep $type > /dev/null
16783 if [ $? -ne 0 ]; then
16793 lfs ladvise -a willread $file > /dev/null 2>&1
16794 if [ $? -eq 0 ]; then
16798 lfs ladvise -a willread $file 2>&1 |
16799 grep "Inappropriate ioctl for device" > /dev/null
16800 if [ $? -eq 0 ]; then
16807 bc <<<"scale=2; ($1 - $2) * 100 / $2"
16810 # run a random read IO workload
16811 # usage: random_read_iops <filename> <filesize> <iosize>
16812 random_read_iops() {
16815 local iosize=${3:-4096}
16817 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
16818 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
16821 drop_file_oss_cache() {
16825 $LFS ladvise -a dontneed $file 2>/dev/null ||
16826 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
16829 ladvise_willread_performance()
16832 local average_origin=0
16833 local average_cache=0
16834 local average_ladvise=0
16836 for ((i = 1; i <= $repeat; i++)); do
16837 echo "Iter $i/$repeat: reading without willread hint"
16838 cancel_lru_locks osc
16839 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16840 local speed_origin=$(random_read_iops $DIR/$tfile $size)
16841 echo "Iter $i/$repeat: uncached speed: $speed_origin"
16842 average_origin=$(bc <<<"$average_origin + $speed_origin")
16844 cancel_lru_locks osc
16845 local speed_cache=$(random_read_iops $DIR/$tfile $size)
16846 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
16847 average_cache=$(bc <<<"$average_cache + $speed_cache")
16849 cancel_lru_locks osc
16850 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16851 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
16852 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
16853 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
16854 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
16856 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
16857 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
16858 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
16860 speedup_cache=$(percent $average_cache $average_origin)
16861 speedup_ladvise=$(percent $average_ladvise $average_origin)
16863 echo "Average uncached read: $average_origin"
16864 echo "Average speedup with OSS cached read: " \
16865 "$average_cache = +$speedup_cache%"
16866 echo "Average speedup with ladvise willread: " \
16867 "$average_ladvise = +$speedup_ladvise%"
16869 local lowest_speedup=20
16870 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
16871 echo "Speedup with OSS cached read less than $lowest_speedup%," \
16872 "got $average_cache%. Skipping ladvise willread check."
16876 # the test won't work on ZFS until it supports 'ladvise dontneed', but
16877 # it is still good to run until then to exercise 'ladvise willread'
16878 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16879 [ "$ost1_FSTYPE" = "zfs" ] &&
16880 echo "osd-zfs does not support dontneed or drop_caches" &&
16883 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
16884 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
16885 error_not_in_vm "Speedup with willread is less than " \
16886 "$lowest_speedup%, got $average_ladvise%"
16890 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
16891 skip "lustre < 2.8.54 does not support ladvise "
16892 remote_ost_nodsh && skip "remote OST with nodsh"
16894 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
16896 ladvise_no_type willread $DIR/$tfile &&
16897 skip "willread ladvise is not supported"
16899 ladvise_no_ioctl $DIR/$tfile &&
16900 skip "ladvise ioctl is not supported"
16903 local size=$((size_mb * 1048576))
16904 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
16905 error "dd to $DIR/$tfile failed"
16907 lfs ladvise -a willread $DIR/$tfile ||
16908 error "Ladvise failed with no range argument"
16910 lfs ladvise -a willread -s 0 $DIR/$tfile ||
16911 error "Ladvise failed with no -l or -e argument"
16913 lfs ladvise -a willread -e 1 $DIR/$tfile ||
16914 error "Ladvise failed with only -e argument"
16916 lfs ladvise -a willread -l 1 $DIR/$tfile ||
16917 error "Ladvise failed with only -l argument"
16919 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
16920 error "End offset should not be smaller than start offset"
16922 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
16923 error "End offset should not be equal to start offset"
16925 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
16926 error "Ladvise failed with overflowing -s argument"
16928 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
16929 error "Ladvise failed with overflowing -e argument"
16931 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
16932 error "Ladvise failed with overflowing -l argument"
16934 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
16935 error "Ladvise succeeded with conflicting -l and -e arguments"
16937 echo "Synchronous ladvise should wait"
16939 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
16940 do_nodes $(comma_list $(osts_nodes)) \
16941 $LCTL set_param fail_val=$delay fail_loc=0x237
16943 local start_ts=$SECONDS
16944 lfs ladvise -a willread $DIR/$tfile ||
16945 error "Ladvise failed with no range argument"
16946 local end_ts=$SECONDS
16947 local inteval_ts=$((end_ts - start_ts))
16949 if [ $inteval_ts -lt $(($delay - 1)) ]; then
16950 error "Synchronous advice didn't wait reply"
16953 echo "Asynchronous ladvise shouldn't wait"
16954 local start_ts=$SECONDS
16955 lfs ladvise -a willread -b $DIR/$tfile ||
16956 error "Ladvise failed with no range argument"
16957 local end_ts=$SECONDS
16958 local inteval_ts=$((end_ts - start_ts))
16960 if [ $inteval_ts -gt $(($delay / 2)) ]; then
16961 error "Asynchronous advice blocked"
16964 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
16965 ladvise_willread_performance
16967 run_test 255a "check 'lfs ladvise -a willread'"
16973 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
16977 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
16978 skip "lustre < 2.8.54 does not support ladvise "
16979 remote_ost_nodsh && skip "remote OST with nodsh"
16981 lfs setstripe -c 1 -i 0 $DIR/$tfile
16983 ladvise_no_type dontneed $DIR/$tfile &&
16984 skip "dontneed ladvise is not supported"
16986 ladvise_no_ioctl $DIR/$tfile &&
16987 skip "ladvise ioctl is not supported"
16989 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16990 [ "$ost1_FSTYPE" = "zfs" ] &&
16991 skip "zfs-osd does not support 'ladvise dontneed'"
16994 local size=$((size_mb * 1048576))
16995 # In order to prevent disturbance of other processes, only check 3/4
16996 # of the memory usage
16997 local kibibytes=$((size_mb * 1024 * 3 / 4))
16999 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17000 error "dd to $DIR/$tfile failed"
17002 #force write to complete before dropping OST cache & checking memory
17005 local total=$(facet_meminfo ost1 MemTotal)
17006 echo "Total memory: $total KiB"
17008 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
17009 local before_read=$(facet_meminfo ost1 Cached)
17010 echo "Cache used before read: $before_read KiB"
17012 lfs ladvise -a willread $DIR/$tfile ||
17013 error "Ladvise willread failed"
17014 local after_read=$(facet_meminfo ost1 Cached)
17015 echo "Cache used after read: $after_read KiB"
17017 lfs ladvise -a dontneed $DIR/$tfile ||
17018 error "Ladvise dontneed again failed"
17019 local no_read=$(facet_meminfo ost1 Cached)
17020 echo "Cache used after dontneed ladvise: $no_read KiB"
17022 if [ $total -lt $((before_read + kibibytes)) ]; then
17023 echo "Memory is too small, abort checking"
17027 if [ $((before_read + kibibytes)) -gt $after_read ]; then
17028 error "Ladvise willread should use more memory" \
17029 "than $kibibytes KiB"
17032 if [ $((no_read + kibibytes)) -gt $after_read ]; then
17033 error "Ladvise dontneed should release more memory" \
17034 "than $kibibytes KiB"
17037 run_test 255b "check 'lfs ladvise -a dontneed'"
17040 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
17041 skip "lustre < 2.10.53 does not support lockahead"
17049 test_mkdir -p $DIR/$tdir
17050 $LFS setstripe -i 0 -c 1 $DIR/$tdir
17052 #test 10 returns only success/failure
17054 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17056 if [ $rc -eq 255 ]; then
17057 error "Ladvise test${i} failed, ${rc}"
17060 #test 11 counts lock enqueue requests, all others count new locks
17062 count=$(do_facet ost1 \
17063 $LCTL get_param -n ost.OSS.ost.stats)
17064 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
17066 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17068 if [ $rc -eq 255 ]; then
17069 error "Ladvise test${i} failed, ${rc}"
17072 new_count=$(do_facet ost1 \
17073 $LCTL get_param -n ost.OSS.ost.stats)
17074 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
17075 awk '{ print $2 }')
17077 difference="$((new_count - count))"
17078 if [ $difference -ne $rc ]; then
17079 error "Ladvise test${i}, bad enqueue count, returned " \
17080 "${rc}, actual ${difference}"
17083 for i in $(seq 12 21); do
17084 # If we do not do this, we run the risk of having too many
17085 # locks and starting lock cancellation while we are checking
17087 cancel_lru_locks osc
17089 count=$($LCTL get_param -n \
17090 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
17092 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17094 if [ $rc -eq 255 ]; then
17095 error "Ladvise test ${i} failed, ${rc}"
17098 new_count=$($LCTL get_param -n \
17099 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
17100 difference="$((new_count - count))"
17102 # Test 15 output is divided by 100 to map down to valid return
17103 if [ $i -eq 15 ]; then
17107 if [ $difference -ne $rc ]; then
17108 error "Ladvise test ${i}, bad lock count, returned " \
17109 "${rc}, actual ${difference}"
17113 #test 22 returns only success/failure
17115 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17117 if [ $rc -eq 255 ]; then
17118 error "Ladvise test${i} failed, ${rc}"
17121 run_test 255c "suite of ladvise lockahead tests"
17124 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17125 remote_mds_nodsh && skip "remote MDS with nodsh"
17126 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
17127 changelog_users $SINGLEMDS | grep "^cl" &&
17128 skip "active changelog user"
17134 mdt_dev=$(mdsdevname 1)
17137 changelog_register || error "changelog_register failed"
17140 mkdir -p $DIR/$tdir
17142 changelog_clear 0 || error "changelog_clear failed"
17145 touch $DIR/$tdir/{1..10}
17148 stop $SINGLEMDS || error "Fail to stop MDT"
17152 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
17154 #after mount new plainllog is used
17155 touch $DIR/$tdir/{11..19}
17156 local tmpfile=$(mktemp -u $tfile.XXXXXX)
17157 cat_sl=$(do_facet $SINGLEMDS "sync; \
17158 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
17159 llog_reader $tmpfile | grep -c type=1064553b")
17160 do_facet $SINGLEMDS llog_reader $tmpfile
17162 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
17164 changelog_clear 0 || error "changelog_clear failed"
17166 cat_sl=$(do_facet $SINGLEMDS "sync; \
17167 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
17168 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
17170 if (( cat_sl == 2 )); then
17171 error "Empty plain llog was not deleted from changelog catalog"
17172 elif (( cat_sl != 1 )); then
17173 error "Active plain llog shouldn't be deleted from catalog"
17176 run_test 256 "Check llog delete for empty and not full state"
17179 remote_mds_nodsh && skip "remote MDS with nodsh"
17180 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
17181 skip "Need MDS version at least 2.8.55"
17183 test_mkdir $DIR/$tdir
17185 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
17186 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
17189 #define OBD_FAIL_MDS_XATTR_REP 0x161
17190 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
17191 local facet=mds$((mdtidx + 1))
17192 set_nodes_failloc $(facet_active_host $facet) 0x80000161
17193 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
17195 stop $facet || error "stop MDS failed"
17196 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
17197 error "start MDS fail"
17198 wait_recovery_complete $facet
17200 run_test 257 "xattr locks are not lost"
17202 # Verify we take the i_mutex when security requires it
17204 #define OBD_FAIL_IMUTEX_SEC 0x141c
17205 $LCTL set_param fail_loc=0x141c
17207 chmod u+s $DIR/$tfile
17208 chmod a+rwx $DIR/$tfile
17209 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
17211 if [ $RC -ne 0 ]; then
17212 error "error, failed to take i_mutex, rc=$?"
17218 # Verify we do NOT take the i_mutex in the normal case
17220 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
17221 $LCTL set_param fail_loc=0x141d
17224 chmod a+rw $DIR/$tfile
17225 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
17227 if [ $RC -ne 0 ]; then
17228 error "error, took i_mutex unnecessarily, rc=$?"
17233 run_test 258b "verify i_mutex security behavior"
17236 local file=$DIR/$tfile
17240 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
17242 stack_trap "rm -f $file" EXIT
17244 wait_delete_completed
17245 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17246 echo "before: $before"
17248 $LFS setstripe -i 0 -c 1 $file
17249 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
17251 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17252 echo "after write: $after"
17254 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
17255 do_facet ost1 $LCTL set_param fail_loc=0x2301
17257 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17258 echo "after truncate: $after"
17261 do_facet ost1 $LCTL set_param fail_loc=0
17262 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
17264 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17265 echo "after restart: $after"
17266 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
17267 error "missing truncate?"
17271 run_test 259 "crash at delayed truncate"
17274 #define OBD_FAIL_MDC_CLOSE 0x806
17275 $LCTL set_param fail_loc=0x80000806
17279 run_test 260 "Check mdc_close fail"
17281 ### Data-on-MDT sanity tests ###
17283 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17284 skip "Need MDS version at least 2.10.55 for DoM"
17287 local dom=$DIR/$tdir/dom_file
17288 local tmp=$DIR/$tdir/tmp_file
17290 mkdir -p $DIR/$tdir
17292 # basic checks for DoM component creation
17293 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
17294 error "Can set MDT layout to non-first entry"
17296 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
17297 error "Can define multiple entries as MDT layout"
17299 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
17301 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
17302 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
17303 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
17305 local mdtidx=$($LFS getstripe -m $dom)
17306 local mdtname=MDT$(printf %04x $mdtidx)
17307 local facet=mds$((mdtidx + 1))
17308 local space_check=1
17310 # Skip free space checks with ZFS
17311 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
17315 local size_tmp=$((65536 * 3))
17316 local mdtfree1=$(do_facet $facet \
17317 lctl get_param -n osd*.*$mdtname.kbytesfree)
17319 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17320 # check also direct IO along write
17321 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
17322 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17324 cmp $tmp $dom || error "file data is different"
17325 [ $(stat -c%s $dom) == $size_tmp ] ||
17326 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17327 if [ $space_check == 1 ]; then
17328 local mdtfree2=$(do_facet $facet \
17329 lctl get_param -n osd*.*$mdtname.kbytesfree)
17331 # increase in usage from by $size_tmp
17332 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17333 error "MDT free space wrong after write: " \
17334 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17338 local size_dom=10000
17340 $TRUNCATE $dom $size_dom
17341 [ $(stat -c%s $dom) == $size_dom ] ||
17342 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
17343 if [ $space_check == 1 ]; then
17344 mdtfree1=$(do_facet $facet \
17345 lctl get_param -n osd*.*$mdtname.kbytesfree)
17346 # decrease in usage from $size_tmp to new $size_dom
17347 [ $(($mdtfree1 - $mdtfree2)) -ge \
17348 $(((size_tmp - size_dom) / 1024)) ] ||
17349 error "MDT free space is wrong after truncate: " \
17350 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
17356 size_dom=$((size_dom + size_tmp))
17357 [ $(stat -c%s $dom) == $size_dom ] ||
17358 error "bad size after append: $(stat -c%s $dom) != $size_dom"
17359 if [ $space_check == 1 ]; then
17360 mdtfree2=$(do_facet $facet \
17361 lctl get_param -n osd*.*$mdtname.kbytesfree)
17362 # increase in usage by $size_tmp from previous
17363 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17364 error "MDT free space is wrong after append: " \
17365 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17370 if [ $space_check == 1 ]; then
17371 mdtfree1=$(do_facet $facet \
17372 lctl get_param -n osd*.*$mdtname.kbytesfree)
17373 # decrease in usage by $size_dom from previous
17374 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
17375 error "MDT free space is wrong after removal: " \
17376 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
17379 # combined striping
17380 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
17381 error "Can't create DoM + OST striping"
17383 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
17384 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17385 # check also direct IO along write
17386 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17388 cmp $tmp $dom || error "file data is different"
17389 [ $(stat -c%s $dom) == $size_tmp ] ||
17390 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17395 run_test 270a "DoM: basic functionality tests"
17398 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17399 skip "Need MDS version at least 2.10.55"
17401 local dom=$DIR/$tdir/dom_file
17402 local max_size=1048576
17404 mkdir -p $DIR/$tdir
17405 $LFS setstripe -E $max_size -L mdt $dom
17407 # truncate over the limit
17408 $TRUNCATE $dom $(($max_size + 1)) &&
17409 error "successful truncate over the maximum size"
17410 # write over the limit
17411 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
17412 error "successful write over the maximum size"
17413 # append over the limit
17414 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
17415 echo "12345" >> $dom && error "successful append over the maximum size"
17420 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
17423 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17424 skip "Need MDS version at least 2.10.55"
17426 mkdir -p $DIR/$tdir
17427 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17429 # check files inherit DoM EA
17430 touch $DIR/$tdir/first
17431 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
17432 error "bad pattern"
17433 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
17434 error "bad stripe count"
17435 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
17436 error "bad stripe size"
17438 # check directory inherits DoM EA and uses it as default
17439 mkdir $DIR/$tdir/subdir
17440 touch $DIR/$tdir/subdir/second
17441 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
17442 error "bad pattern in sub-directory"
17443 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
17444 error "bad stripe count in sub-directory"
17445 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
17446 error "bad stripe size in sub-directory"
17449 run_test 270c "DoM: DoM EA inheritance tests"
17452 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17453 skip "Need MDS version at least 2.10.55"
17455 mkdir -p $DIR/$tdir
17456 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17458 # inherit default DoM striping
17459 mkdir $DIR/$tdir/subdir
17460 touch $DIR/$tdir/subdir/f1
17462 # change default directory striping
17463 $LFS setstripe -c 1 $DIR/$tdir/subdir
17464 touch $DIR/$tdir/subdir/f2
17465 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
17466 error "wrong default striping in file 2"
17467 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
17468 error "bad pattern in file 2"
17471 run_test 270d "DoM: change striping from DoM to RAID0"
17474 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17475 skip "Need MDS version at least 2.10.55"
17477 mkdir -p $DIR/$tdir/dom
17478 mkdir -p $DIR/$tdir/norm
17481 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
17482 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
17484 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
17485 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
17487 # find DoM files by layout
17488 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
17489 [ $NUM -eq $DOMFILES ] ||
17490 error "lfs find -L: found $NUM, expected $DOMFILES"
17491 echo "Test 1: lfs find 20 DOM files by layout: OK"
17493 # there should be 1 dir with default DOM striping
17494 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
17496 error "lfs find -L: found $NUM, expected 1 dir"
17497 echo "Test 2: lfs find 1 DOM dir by layout: OK"
17499 # find DoM files by stripe size
17500 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
17501 [ $NUM -eq $DOMFILES ] ||
17502 error "lfs find -S: found $NUM, expected $DOMFILES"
17503 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
17505 # find files by stripe offset except DoM files
17506 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
17507 [ $NUM -eq $NORMFILES ] ||
17508 error "lfs find -i: found $NUM, expected $NORMFILES"
17509 echo "Test 5: lfs find no DOM files by stripe index: OK"
17512 run_test 270e "DoM: lfs find with DoM files test"
17515 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17516 skip "Need MDS version at least 2.10.55"
17518 local mdtname=${FSNAME}-MDT0000-mdtlov
17519 local dom=$DIR/$tdir/dom_file
17520 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
17521 lod.$mdtname.dom_stripesize)
17522 local dom_limit=131072
17524 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
17525 local dom_current=$(do_facet mds1 $LCTL get_param -n \
17526 lod.$mdtname.dom_stripesize)
17527 [ ${dom_limit} -eq ${dom_current} ] ||
17528 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
17530 $LFS mkdir -i 0 -c 1 $DIR/$tdir
17531 $LFS setstripe -d $DIR/$tdir
17532 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
17533 error "Can't set directory default striping"
17535 # exceed maximum stripe size
17536 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
17537 error "Can't create file with $((dom_limit * 2)) DoM stripe"
17538 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
17539 error "Able to create DoM component size more than LOD limit"
17541 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
17542 dom_current=$(do_facet mds1 $LCTL get_param -n \
17543 lod.$mdtname.dom_stripesize)
17544 [ 0 -eq ${dom_current} ] ||
17545 error "Can't set zero DoM stripe limit"
17548 # attempt to create DoM file on server with disabled DoM should
17549 # remove DoM entry from layout and be succeed
17550 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
17551 error "Can't create DoM file (DoM is disabled)"
17552 [ $($LFS getstripe -L $dom) == "mdt" ] &&
17553 error "File has DoM component while DoM is disabled"
17556 # attempt to create DoM file with only DoM stripe should return error
17557 $LFS setstripe -E $dom_limit -L mdt $dom &&
17558 error "Able to create DoM-only file while DoM is disabled"
17560 # too low values to be aligned with smallest stripe size 64K
17561 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
17562 dom_current=$(do_facet mds1 $LCTL get_param -n \
17563 lod.$mdtname.dom_stripesize)
17564 [ 30000 -eq ${dom_current} ] &&
17565 error "Can set too small DoM stripe limit"
17567 # 64K is a minimal stripe size in Lustre, expect limit of that size
17568 [ 65536 -eq ${dom_current} ] ||
17569 error "Limit is not set to 64K but ${dom_current}"
17571 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
17572 dom_current=$(do_facet mds1 $LCTL get_param -n \
17573 lod.$mdtname.dom_stripesize)
17575 [ 2147483648 -eq ${dom_current} ] &&
17576 error "Can set too large DoM stripe limit"
17578 do_facet mds1 $LCTL set_param -n \
17579 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
17580 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
17581 error "Can't create DoM component size after limit change"
17582 do_facet mds1 $LCTL set_param -n \
17583 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
17584 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
17585 error "Can't create DoM file after limit decrease"
17586 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
17587 error "Can create big DoM component after limit decrease"
17588 touch ${dom}_def ||
17589 error "Can't create file with old default layout"
17591 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
17594 run_test 270f "DoM: maximum DoM stripe size checks"
17597 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17598 skip "Need MDS version at least 2.10.55"
17600 local dom=$DIR/$tdir/dom
17602 mkdir -p $DIR/$tdir
17604 $LFS setstripe -E 1024K -L mdt $dom
17606 lctl set_param -n mdc.*.stats=clear
17607 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
17608 cat $dom > /dev/null
17609 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
17610 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
17614 run_test 271a "DoM: data is cached for read after write"
17617 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17618 skip "Need MDS version at least 2.10.55"
17620 local dom=$DIR/$tdir/dom
17622 mkdir -p $DIR/$tdir
17624 $LFS setstripe -E 1024K -L mdt -E EOF $dom
17626 lctl set_param -n mdc.*.stats=clear
17627 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
17628 cancel_lru_locks mdc
17629 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
17630 # second stat to check size is cached on client
17631 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
17632 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
17633 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
17636 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
17639 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17640 skip "Need MDS version at least 2.10.55"
17642 local dom=$DIR/$tdir/dom
17644 mkdir -p $DIR/$tdir
17646 $LFS setstripe -E 1024K -L mdt -E EOF $dom
17648 lctl set_param -n mdc.*.stats=clear
17649 lctl set_param -n osc.*.stats=clear
17650 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
17651 cancel_lru_locks mdc
17652 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
17653 # second stat to check size is cached on client
17654 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
17655 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
17656 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
17657 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
17658 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
17661 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
17667 local mdt=MDT$(printf %04x $mdtidx)
17669 if [ -z $param ]; then
17670 lctl get_param -n mdc.*$mdt*.stats
17672 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
17677 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17678 skip "Need MDS version at least 2.10.55"
17680 local dom=$DIR/$tdir/dom
17682 mkdir -p $DIR/$tdir
17684 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17686 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
17687 local facet=mds$((mdtidx + 1))
17689 cancel_lru_locks mdc
17690 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
17691 createmany -o $dom 1000
17692 lctl set_param -n mdc.*.stats=clear
17693 smalliomany -w $dom 1000 200
17694 get_mdc_stats $mdtidx
17695 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
17696 # Each file has 1 open, 1 IO enqueues, total 2000
17697 # but now we have also +1 getxattr for security.capability, total 3000
17698 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
17699 unlinkmany $dom 1000
17701 cancel_lru_locks mdc
17702 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
17703 createmany -o $dom 1000
17704 lctl set_param -n mdc.*.stats=clear
17705 smalliomany -w $dom 1000 200
17706 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
17707 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
17708 # for OPEN and IO lock.
17709 [ $((enq - enq_2)) -ge 1000 ] ||
17710 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
17711 unlinkmany $dom 1000
17714 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
17716 cleanup_271def_tests() {
17722 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
17723 skip "Need MDS version at least 2.10.57"
17725 local dom=$DIR/$tdir/dom
17726 local tmp=$TMP/$tfile
17727 trap "cleanup_271def_tests $tmp" EXIT
17729 mkdir -p $DIR/$tdir
17731 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17733 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
17735 cancel_lru_locks mdc
17736 dd if=/dev/urandom of=$tmp bs=1000 count=1
17737 dd if=$tmp of=$dom bs=1000 count=1
17738 cancel_lru_locks mdc
17740 cat /etc/hosts >> $tmp
17741 lctl set_param -n mdc.*.stats=clear
17743 # append data to the same file it should update local page
17744 echo "Append to the same page"
17745 cat /etc/hosts >> $dom
17746 local num=$(get_mdc_stats $mdtidx ost_read)
17747 local ra=$(get_mdc_stats $mdtidx req_active)
17748 local rw=$(get_mdc_stats $mdtidx req_waittime)
17750 [ -z $num ] || error "$num READ RPC occured"
17751 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17755 cmp $tmp $dom || error "file miscompare"
17757 cancel_lru_locks mdc
17758 lctl set_param -n mdc.*.stats=clear
17760 echo "Open and read file"
17761 cat $dom > /dev/null
17762 local num=$(get_mdc_stats $mdtidx ost_read)
17763 local ra=$(get_mdc_stats $mdtidx req_active)
17764 local rw=$(get_mdc_stats $mdtidx req_waittime)
17766 [ -z $num ] || error "$num READ RPC occured"
17767 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17771 cmp $tmp $dom || error "file miscompare"
17775 run_test 271d "DoM: read on open (1K file in reply buffer)"
17778 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
17779 skip "Need MDS version at least 2.10.57"
17781 local dom=$DIR/$tdir/dom
17782 local tmp=$TMP/$tfile
17783 trap "cleanup_271def_tests $tmp" EXIT
17785 mkdir -p $DIR/$tdir
17787 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17789 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
17791 cancel_lru_locks mdc
17792 dd if=/dev/urandom of=$tmp bs=200000 count=1
17793 dd if=$tmp of=$dom bs=200000 count=1
17794 cancel_lru_locks mdc
17795 cat /etc/hosts >> $tmp
17796 lctl set_param -n mdc.*.stats=clear
17798 echo "Append to the same page"
17799 cat /etc/hosts >> $dom
17800 local num=$(get_mdc_stats $mdtidx ost_read)
17801 local ra=$(get_mdc_stats $mdtidx req_active)
17802 local rw=$(get_mdc_stats $mdtidx req_waittime)
17804 [ -z $num ] || error "$num READ RPC occured"
17805 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17809 cmp $tmp $dom || error "file miscompare"
17811 cancel_lru_locks mdc
17812 lctl set_param -n mdc.*.stats=clear
17814 echo "Open and read file"
17815 cat $dom > /dev/null
17816 local num=$(get_mdc_stats $mdtidx ost_read)
17817 local ra=$(get_mdc_stats $mdtidx req_active)
17818 local rw=$(get_mdc_stats $mdtidx req_waittime)
17820 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
17821 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17825 cmp $tmp $dom || error "file miscompare"
17829 run_test 271f "DoM: read on open (200K file and read tail)"
17832 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17833 skip "Need MDS version at least 2.11.50"
17835 local dom=$DIR/$tdir/dom
17836 mkdir -p $DIR/$tdir
17838 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
17839 dd if=/dev/urandom of=$dom bs=512K count=1 ||
17840 error "failed to write data into $dom"
17841 local old_md5=$(md5sum $dom)
17843 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
17844 error "failed to migrate to the same DoM component"
17846 local new_md5=$(md5sum $dom)
17848 [ "$old_md5" == "$new_md5" ] ||
17849 error "md5sum differ: $old_md5, $new_md5"
17851 [ $($LFS getstripe -c $dom) -eq 2 ] ||
17852 error "migrate stripe count bad: $(LFS getstripe -c $dom) != 2"
17854 run_test 272a "DoM migration: new layout with the same DOM component"
17857 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17858 skip "Need MDS version at least 2.11.50"
17860 local dom=$DIR/$tdir/dom
17861 mkdir -p $DIR/$tdir
17862 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
17864 local mdtidx=$($LFS getstripe -m $dom)
17865 local mdtname=MDT$(printf %04x $mdtidx)
17866 local facet=mds$((mdtidx + 1))
17868 local mdtfree1=$(do_facet $facet \
17869 lctl get_param -n osd*.*$mdtname.kbytesfree)
17870 dd if=/dev/urandom of=$dom bs=2M count=1 ||
17871 error "failed to write data into $dom"
17872 local old_md5=$(md5sum $dom)
17873 cancel_lru_locks mdc
17874 local mdtfree1=$(do_facet $facet \
17875 lctl get_param -n osd*.*$mdtname.kbytesfree)
17877 $LFS migrate -c2 $dom ||
17878 error "failed to migrate to the new composite layout"
17879 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
17880 error "MDT stripe was not removed"
17882 cancel_lru_locks mdc
17883 local new_md5=$(md5sum $dom)
17884 [ "$old_md5" != "$new_md5" ] &&
17885 error "$old_md5 != $new_md5"
17887 # Skip free space checks with ZFS
17888 if [ "$(facet_fstype $facet)" != "zfs" ]; then
17889 local mdtfree2=$(do_facet $facet \
17890 lctl get_param -n osd*.*$mdtname.kbytesfree)
17891 [ $mdtfree2 -gt $mdtfree1 ] ||
17892 error "MDT space is not freed after migration"
17896 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
17899 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17900 skip "Need MDS version at least 2.11.50"
17902 local dom=$DIR/$tdir/$tfile
17903 mkdir -p $DIR/$tdir
17904 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
17906 local mdtidx=$($LFS getstripe -m $dom)
17907 local mdtname=MDT$(printf %04x $mdtidx)
17908 local facet=mds$((mdtidx + 1))
17910 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
17911 error "failed to write data into $dom"
17912 local old_md5=$(md5sum $dom)
17913 cancel_lru_locks mdc
17914 local mdtfree1=$(do_facet $facet \
17915 lctl get_param -n osd*.*$mdtname.kbytesfree)
17917 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
17918 error "failed to migrate to the new composite layout"
17919 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
17920 error "MDT stripe was not removed"
17922 cancel_lru_locks mdc
17923 local new_md5=$(md5sum $dom)
17924 [ "$old_md5" != "$new_md5" ] &&
17925 error "$old_md5 != $new_md5"
17927 # Skip free space checks with ZFS
17928 if [ "$(facet_fstype $facet)" != "zfs" ]; then
17929 local mdtfree2=$(do_facet $facet \
17930 lctl get_param -n osd*.*$mdtname.kbytesfree)
17931 [ $mdtfree2 -gt $mdtfree1 ] ||
17932 error "MDS space is not freed after migration"
17936 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
17939 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17940 skip "Need MDS version at least 2.11.50"
17942 # Layout swap cannot be done if either file has DOM component,
17943 # this will never be supported, migration should be used instead
17945 local dom=$DIR/$tdir/$tfile
17946 mkdir -p $DIR/$tdir
17948 $LFS setstripe -c2 ${dom}_plain
17949 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
17950 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
17951 error "can swap layout with DoM component"
17952 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
17953 error "can swap layout with DoM component"
17955 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
17956 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
17957 error "can swap layout with DoM component"
17958 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
17959 error "can swap layout with DoM component"
17962 run_test 273a "DoM: layout swapping should fail with DOM"
17965 remote_ost_nodsh && skip "remote OST with nodsh"
17966 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
17967 skip "Need OST version >= 2.10.57"
17969 local file=$DIR/$tfile
17972 oss=$(comma_list $(osts_nodes))
17974 dd if=/dev/urandom of=$file bs=1M count=2 ||
17975 error "failed to create a file"
17976 cancel_lru_locks osc
17979 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
17980 error "failed to read a file"
17982 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
17983 $LCTL set_param fail_loc=0x8000031f
17985 cancel_lru_locks osc &
17988 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
17989 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
17990 #IO takes another lock, but matches the PENDING one
17991 #and places it to the IO RPC
17992 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
17993 error "failed to read a file with PENDING lock"
17995 run_test 275 "Read on a canceled duplicate lock"
17998 remote_ost_nodsh && skip "remote OST with nodsh"
18001 do_facet ost1 "(while true; do \
18002 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
18003 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
18006 for LOOP in $(seq 20); do
18008 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
18011 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
18012 rm $TMP/sanity_276_pid"
18014 run_test 276 "Race between mount and obd_statfs"
18016 cleanup_test_300() {
18020 test_striped_dir() {
18025 mkdir -p $DIR/$tdir
18027 SAVE_UMASK=$(umask)
18028 trap cleanup_test_300 RETURN EXIT
18030 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
18031 $DIR/$tdir/striped_dir ||
18032 error "set striped dir error"
18034 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
18035 [ "$mode" = "755" ] || error "expect 755 got $mode"
18037 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
18038 error "getdirstripe failed"
18039 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
18040 if [ "$stripe_count" != "2" ]; then
18041 error "1:stripe_count is $stripe_count, expect 2"
18043 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
18044 if [ "$stripe_count" != "2" ]; then
18045 error "2:stripe_count is $stripe_count, expect 2"
18048 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
18049 if [ "$stripe_index" != "$mdt_index" ]; then
18050 error "stripe_index is $stripe_index, expect $mdt_index"
18053 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18054 error "nlink error after create striped dir"
18056 mkdir $DIR/$tdir/striped_dir/a
18057 mkdir $DIR/$tdir/striped_dir/b
18059 stat $DIR/$tdir/striped_dir/a ||
18060 error "create dir under striped dir failed"
18061 stat $DIR/$tdir/striped_dir/b ||
18062 error "create dir under striped dir failed"
18064 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
18065 error "nlink error after mkdir"
18067 rmdir $DIR/$tdir/striped_dir/a
18068 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
18069 error "nlink error after rmdir"
18071 rmdir $DIR/$tdir/striped_dir/b
18072 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18073 error "nlink error after rmdir"
18075 chattr +i $DIR/$tdir/striped_dir
18076 createmany -o $DIR/$tdir/striped_dir/f 10 &&
18077 error "immutable flags not working under striped dir!"
18078 chattr -i $DIR/$tdir/striped_dir
18080 rmdir $DIR/$tdir/striped_dir ||
18081 error "rmdir striped dir error"
18089 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18090 skip "skipped for lustre < 2.7.0"
18091 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18092 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18094 test_striped_dir 0 || error "failed on striped dir on MDT0"
18095 test_striped_dir 1 || error "failed on striped dir on MDT0"
18097 run_test 300a "basic striped dir sanity test"
18100 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18101 skip "skipped for lustre < 2.7.0"
18102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18103 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18110 test_mkdir $DIR/$tdir || error "mkdir fail"
18111 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18112 error "set striped dir error"
18113 for i in {0..9}; do
18114 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
18116 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
18117 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
18118 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
18120 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
18121 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
18122 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
18126 run_test 300b "check ctime/mtime for striped dir"
18129 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18130 skip "skipped for lustre < 2.7.0"
18131 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18132 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18136 mkdir -p $DIR/$tdir
18137 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
18138 error "set striped dir error"
18140 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
18141 error "chown striped dir failed"
18143 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
18144 error "create 5k files failed"
18146 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
18148 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
18152 run_test 300c "chown && check ls under striped directory"
18155 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18156 skip "skipped for lustre < 2.7.0"
18157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18158 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18163 mkdir -p $DIR/$tdir
18164 $LFS setstripe -c 2 $DIR/$tdir
18166 #local striped directory
18167 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18168 error "set striped dir error"
18169 createmany -o $DIR/$tdir/striped_dir/f 10 ||
18170 error "create 10 files failed"
18172 #remote striped directory
18173 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
18174 error "set striped dir error"
18175 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
18176 error "create 10 files failed"
18178 for file in $(find $DIR/$tdir); do
18179 stripe_count=$($LFS getstripe -c $file)
18180 [ $stripe_count -eq 2 ] ||
18181 error "wrong stripe $stripe_count for $file"
18186 run_test 300d "check default stripe under striped directory"
18189 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18190 skip "Need MDS version at least 2.7.55"
18191 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18192 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18197 mkdir -p $DIR/$tdir
18199 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18200 error "set striped dir error"
18202 touch $DIR/$tdir/striped_dir/a
18203 touch $DIR/$tdir/striped_dir/b
18204 touch $DIR/$tdir/striped_dir/c
18206 mkdir $DIR/$tdir/striped_dir/dir_a
18207 mkdir $DIR/$tdir/striped_dir/dir_b
18208 mkdir $DIR/$tdir/striped_dir/dir_c
18210 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
18211 error "set striped adir under striped dir error"
18213 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
18214 error "set striped bdir under striped dir error"
18216 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
18217 error "set striped cdir under striped dir error"
18219 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
18220 error "rename dir under striped dir fails"
18222 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
18223 error "rename dir under different stripes fails"
18225 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
18226 error "rename file under striped dir should succeed"
18228 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
18229 error "rename dir under striped dir should succeed"
18233 run_test 300e "check rename under striped directory"
18236 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18237 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18238 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18239 skip "Need MDS version at least 2.7.55"
18245 mkdir -p $DIR/$tdir
18247 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18248 error "set striped dir error"
18250 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
18251 error "set striped dir error"
18253 touch $DIR/$tdir/striped_dir/a
18254 mkdir $DIR/$tdir/striped_dir/dir_a
18255 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
18256 error "create striped dir under striped dir fails"
18258 touch $DIR/$tdir/striped_dir1/b
18259 mkdir $DIR/$tdir/striped_dir1/dir_b
18260 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
18261 error "create striped dir under striped dir fails"
18263 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
18264 error "rename dir under different striped dir should fail"
18266 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
18267 error "rename striped dir under diff striped dir should fail"
18269 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
18270 error "rename file under diff striped dirs fails"
18274 run_test 300f "check rename cross striped directory"
18276 test_300_check_default_striped_dir()
18279 local default_count=$2
18280 local default_index=$3
18283 local dir_stripe_index
18286 echo "checking $dirname $default_count $default_index"
18287 $LFS setdirstripe -D -c $default_count -i $default_index \
18288 -t all_char $DIR/$tdir/$dirname ||
18289 error "set default stripe on striped dir error"
18290 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
18291 [ $stripe_count -eq $default_count ] ||
18292 error "expect $default_count get $stripe_count for $dirname"
18294 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
18295 [ $stripe_index -eq $default_index ] ||
18296 error "expect $default_index get $stripe_index for $dirname"
18298 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
18299 error "create dirs failed"
18301 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
18302 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
18303 for dir in $(find $DIR/$tdir/$dirname/*); do
18304 stripe_count=$($LFS getdirstripe -c $dir)
18305 [ $stripe_count -eq $default_count ] ||
18306 [ $stripe_count -eq 0 ] || [ $default_count -eq 1 ] ||
18307 error "stripe count $default_count != $stripe_count for $dir"
18309 stripe_index=$($LFS getdirstripe -i $dir)
18310 [ $default_index -eq -1 ] ||
18311 [ $stripe_index -eq $default_index ] ||
18312 error "$stripe_index != $default_index for $dir"
18314 #check default stripe
18315 stripe_count=$($LFS getdirstripe -D -c $dir)
18316 [ $stripe_count -eq $default_count ] ||
18317 error "default count $default_count != $stripe_count for $dir"
18319 stripe_index=$($LFS getdirstripe -D -i $dir)
18320 [ $stripe_index -eq $default_index ] ||
18321 error "default index $default_index != $stripe_index for $dir"
18323 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
18327 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18328 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18329 skip "Need MDS version at least 2.7.55"
18336 mkdir $DIR/$tdir/normal_dir
18338 #Checking when client cache stripe index
18339 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
18340 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
18341 error "create striped_dir failed"
18343 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
18344 error "create dir0 fails"
18345 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
18346 [ $stripe_index -eq 0 ] ||
18347 error "dir0 expect index 0 got $stripe_index"
18349 mkdir $DIR/$tdir/striped_dir/dir1 ||
18350 error "create dir1 fails"
18351 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
18352 [ $stripe_index -eq 1 ] ||
18353 error "dir1 expect index 1 got $stripe_index"
18355 #check default stripe count/stripe index
18356 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
18357 test_300_check_default_striped_dir normal_dir 1 0
18358 test_300_check_default_striped_dir normal_dir 2 1
18359 test_300_check_default_striped_dir normal_dir 2 -1
18361 #delete default stripe information
18362 echo "delete default stripeEA"
18363 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
18364 error "set default stripe on striped dir error"
18366 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
18367 for dir in $(find $DIR/$tdir/normal_dir/*); do
18368 stripe_count=$($LFS getdirstripe -c $dir)
18369 [ $stripe_count -eq 0 ] ||
18370 error "expect 1 get $stripe_count for $dir"
18371 stripe_index=$($LFS getdirstripe -i $dir)
18372 [ $stripe_index -eq 0 ] ||
18373 error "expect 0 get $stripe_index for $dir"
18376 run_test 300g "check default striped directory for normal directory"
18379 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18380 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18381 skip "Need MDS version at least 2.7.55"
18387 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18388 error "set striped dir error"
18390 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
18391 test_300_check_default_striped_dir striped_dir 1 0
18392 test_300_check_default_striped_dir striped_dir 2 1
18393 test_300_check_default_striped_dir striped_dir 2 -1
18395 #delete default stripe information
18396 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
18397 error "set default stripe on striped dir error"
18399 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
18400 for dir in $(find $DIR/$tdir/striped_dir/*); do
18401 stripe_count=$($LFS getdirstripe -c $dir)
18402 [ $stripe_count -eq 0 ] ||
18403 error "expect 1 get $stripe_count for $dir"
18406 run_test 300h "check default striped directory for striped directory"
18409 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18410 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18411 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18412 skip "Need MDS version at least 2.7.55"
18419 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18420 error "set striped dir error"
18422 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18423 error "create files under striped dir failed"
18425 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
18426 error "set striped hashdir error"
18428 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
18429 error "create dir0 under hash dir failed"
18430 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
18431 error "create dir1 under hash dir failed"
18433 # unfortunately, we need to umount to clear dir layout cache for now
18434 # once we fully implement dir layout, we can drop this
18435 umount_client $MOUNT || error "umount failed"
18436 mount_client $MOUNT || error "mount failed"
18438 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
18439 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
18440 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
18442 #set the stripe to be unknown hash type
18443 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
18444 $LCTL set_param fail_loc=0x1901
18445 for ((i = 0; i < 10; i++)); do
18446 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
18447 error "stat f-$i failed"
18448 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
18451 touch $DIR/$tdir/striped_dir/f0 &&
18452 error "create under striped dir with unknown hash should fail"
18454 $LCTL set_param fail_loc=0
18456 umount_client $MOUNT || error "umount failed"
18457 mount_client $MOUNT || error "mount failed"
18461 run_test 300i "client handle unknown hash type striped directory"
18464 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18465 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18466 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18467 skip "Need MDS version at least 2.7.55"
18474 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
18475 $LCTL set_param fail_loc=0x1702
18476 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18477 error "set striped dir error"
18479 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18480 error "create files under striped dir failed"
18482 $LCTL set_param fail_loc=0
18484 rm -rf $DIR/$tdir || error "unlink striped dir fails"
18488 run_test 300j "test large update record"
18491 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18492 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18493 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18494 skip "Need MDS version at least 2.7.55"
18496 # this test needs a huge transaction
18498 kb=$(do_facet $SINGLEMDS lctl get_param -n osd*.lustre-MDT0000.kbytestotal)
18499 [ $kb -lt $((1024*1024)) ] && skip "too small mds: $kb"
18506 #define OBD_FAIL_LARGE_STRIPE 0x1703
18507 $LCTL set_param fail_loc=0x1703
18508 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
18509 error "set striped dir error"
18510 $LCTL set_param fail_loc=0
18512 $LFS getdirstripe $DIR/$tdir/striped_dir ||
18513 error "getstripeddir fails"
18514 rm -rf $DIR/$tdir/striped_dir ||
18515 error "unlink striped dir fails"
18519 run_test 300k "test large striped directory"
18522 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18523 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18524 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18525 skip "Need MDS version at least 2.7.55"
18529 test_mkdir -p $DIR/$tdir/striped_dir
18530 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
18531 error "chown $RUNAS_ID failed"
18532 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
18533 error "set default striped dir failed"
18535 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
18536 $LCTL set_param fail_loc=0x80000158
18537 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
18539 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
18540 [ $stripe_index -eq 1 ] ||
18541 error "expect 1 get $stripe_index for $dir"
18543 run_test 300l "non-root user to create dir under striped dir with stale layout"
18546 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18547 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
18548 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18549 skip "Need MDS version at least 2.7.55"
18551 mkdir -p $DIR/$tdir/striped_dir
18552 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
18553 error "set default stripes dir error"
18555 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
18557 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
18558 [ $stripe_count -eq 0 ] ||
18559 error "expect 0 get $stripe_count for a"
18561 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
18562 error "set default stripes dir error"
18564 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
18566 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
18567 [ $stripe_count -eq 0 ] ||
18568 error "expect 0 get $stripe_count for b"
18570 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
18571 error "set default stripes dir error"
18573 mkdir $DIR/$tdir/striped_dir/c &&
18574 error "default stripe_index is invalid, mkdir c should fails"
18576 rm -rf $DIR/$tdir || error "rmdir fails"
18578 run_test 300m "setstriped directory on single MDT FS"
18581 local list=$(comma_list $(mdts_nodes))
18584 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18589 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18590 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18591 skip "Need MDS version at least 2.7.55"
18592 remote_mds_nodsh && skip "remote MDS with nodsh"
18595 local list=$(comma_list $(mdts_nodes))
18597 trap cleanup_300n RETURN EXIT
18598 mkdir -p $DIR/$tdir
18599 chmod 777 $DIR/$tdir
18600 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
18601 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
18602 error "create striped dir succeeds with gid=0"
18604 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
18605 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
18606 error "create striped dir fails with gid=-1"
18608 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18609 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
18610 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
18611 error "set default striped dir succeeds with gid=0"
18614 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
18615 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
18616 error "set default striped dir fails with gid=-1"
18619 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18620 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
18621 error "create test_dir fails"
18622 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
18623 error "create test_dir1 fails"
18624 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
18625 error "create test_dir2 fails"
18628 run_test 300n "non-root user to create dir under striped dir with default EA"
18631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18632 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18633 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18634 skip "Need MDS version at least 2.7.55"
18639 mkdir -p $DIR/$tdir
18641 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
18642 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
18643 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
18644 skip "not enough free inodes $numfree1 $numfree2"
18647 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
18648 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
18649 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
18650 skip "not enough free space $numfree1 $numfree2"
18653 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
18654 error "setdirstripe fails"
18656 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
18657 error "create dirs fails"
18659 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
18660 ls $DIR/$tdir/striped_dir > /dev/null ||
18661 error "ls striped dir fails"
18662 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
18663 error "unlink big striped dir fails"
18665 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
18668 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18669 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18670 remote_mds_nodsh && skip "remote MDS with nodsh"
18672 mkdir -p $DIR/$tdir
18674 #define OBD_FAIL_OUT_ENOSPC 0x1704
18675 do_facet mds2 lctl set_param fail_loc=0x80001704
18676 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
18677 && error "create striped directory should fail"
18679 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
18681 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
18684 run_test 300p "create striped directory without space"
18687 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18688 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18690 local fd=$(free_fd)
18691 local cmd="exec $fd<$tdir"
18693 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
18696 trap "eval $cmd" EXIT
18697 cd $tdir || error "cd $tdir fails"
18698 rmdir ../$tdir || error "rmdir $tdir fails"
18699 mkdir local_dir && error "create dir succeeds"
18700 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
18704 run_test 300q "create remote directory under orphan directory"
18707 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
18708 skip "Need MDS version at least 2.7.55" && return
18709 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
18713 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
18714 error "set striped dir error"
18716 $LFS getdirstripe $DIR/$tdir/striped_dir ||
18717 error "getstripeddir fails"
18720 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
18721 awk '/lmv_stripe_count:/ { print $2 }')
18723 [ $MDSCOUNT -ne $stripe_count ] &&
18724 error "wrong stripe count $stripe_count expected $MDSCOUNT"
18726 rm -rf $DIR/$tdir/striped_dir ||
18727 error "unlink striped dir fails"
18729 run_test 300r "test -1 striped directory"
18731 prepare_remote_file() {
18732 mkdir $DIR/$tdir/src_dir ||
18733 error "create remote source failed"
18735 cp /etc/hosts $DIR/$tdir/src_dir/a ||
18736 error "cp to remote source failed"
18737 touch $DIR/$tdir/src_dir/a
18739 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
18740 error "create remote target dir failed"
18742 touch $DIR/$tdir/tgt_dir/b
18744 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
18745 error "rename dir cross MDT failed!"
18747 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
18748 error "src_child still exists after rename"
18750 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
18751 error "missing file(a) after rename"
18753 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
18754 error "diff after rename"
18758 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
18759 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18761 local remote_file=$DIR/$tdir/tgt_dir/b
18763 mkdir -p $DIR/$tdir
18765 prepare_remote_file || error "prepare remote file failed"
18768 $OPENUNLINK $remote_file $remote_file ||
18769 error "openunlink $remote_file failed"
18770 $CHECKSTAT -a $remote_file || error "$remote_file exists"
18772 run_test 310a "open unlink remote file"
18775 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
18776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18778 local remote_file=$DIR/$tdir/tgt_dir/b
18780 mkdir -p $DIR/$tdir
18782 prepare_remote_file || error "prepare remote file failed"
18784 ln $remote_file $DIR/$tfile || error "link failed for remote file"
18785 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
18786 $CHECKSTAT -t file $remote_file || error "check file failed"
18788 run_test 310b "unlink remote file with multiple links while open"
18791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18792 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
18794 local remote_file=$DIR/$tdir/tgt_dir/b
18796 mkdir -p $DIR/$tdir
18798 prepare_remote_file || error "prepare remote file failed"
18800 ln $remote_file $DIR/$tfile || error "link failed for remote file"
18801 multiop_bg_pause $remote_file O_uc ||
18802 error "mulitop failed for remote file"
18804 $MULTIOP $DIR/$tfile Ouc
18805 kill -USR1 $MULTIPID
18808 run_test 310c "open-unlink remote file with multiple links"
18812 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18813 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
18814 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
18815 skip "lustre < 2.8.54 does not contain LU-4825 fix"
18816 remote_mds_nodsh && skip "remote MDS with nodsh"
18818 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
18819 local mdts=$(comma_list $(mdts_nodes))
18821 mkdir -p $DIR/$tdir
18822 $LFS setstripe -i 0 -c 1 $DIR/$tdir
18823 createmany -o $DIR/$tdir/$tfile. 1000
18825 # statfs data is not real time, let's just calculate it
18826 old_iused=$((old_iused + 1000))
18828 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
18829 osp.*OST0000*MDT0000.create_count")
18830 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
18831 osp.*OST0000*MDT0000.max_create_count")
18832 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
18834 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
18835 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
18836 [ $index -ne 0 ] || error "$tfile stripe index is 0"
18838 unlinkmany $DIR/$tdir/$tfile. 1000
18840 do_nodes $mdts "$LCTL set_param -n \
18841 osp.*OST0000*.max_create_count=$max_count"
18842 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
18843 do_nodes $mdts "$LCTL set_param -n \
18844 osp.*OST0000*.create_count=$count"
18845 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
18846 grep "=0" && error "create_count is zero"
18849 for i in $(seq 120); do
18850 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
18851 # system may be too busy to destroy all objs in time, use
18852 # a somewhat small value to not fail autotest
18853 [ $((old_iused - new_iused)) -gt 400 ] && break
18857 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
18858 [ $((old_iused - new_iused)) -gt 400 ] ||
18859 error "objs not destroyed after unlink"
18861 run_test 311 "disable OSP precreate, and unlink should destroy objs"
18868 local vdevdir=$(dirname $(facet_vdevice $ost))
18869 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
18870 local zfs_zapid=$(do_facet $ost $cmd |
18871 grep -w "/O/0/d$((objid%32))" -C 5 |
18872 awk '/Object/{getline; print $1}')
18873 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
18874 awk "/$objid = /"'{printf $3}')
18879 zfs_object_blksz() {
18883 local vdevdir=$(dirname $(facet_vdevice $ost))
18884 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
18885 local blksz=$(do_facet $ost $cmd $objid |
18886 awk '/dblk/{getline; printf $4}')
18888 case "${blksz: -1}" in
18889 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
18890 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
18897 test_312() { # LU-4856
18898 remote_ost_nodsh && skip "remote OST with nodsh"
18899 [ "$ost1_FSTYPE" = "zfs" ] ||
18900 skip_env "the test only applies to zfs"
18902 local max_blksz=$(do_facet ost1 \
18903 $ZFS get -p recordsize $(facet_device ost1) |
18904 awk '!/VALUE/{print $3}')
18906 # to make life a little bit easier
18907 $LFS mkdir -c 1 -i 0 $DIR/$tdir
18908 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18910 local tf=$DIR/$tdir/$tfile
18912 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18914 # Get ZFS object id
18915 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18916 # block size change by sequential overwrite
18919 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
18920 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
18922 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
18923 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
18927 # block size change by sequential append write
18928 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
18929 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18930 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18933 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
18934 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
18935 oflag=sync conv=notrunc
18937 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18938 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
18939 error "blksz error, actual $blksz, " \
18940 "expected: 2 * $count * $PAGE_SIZE"
18946 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18947 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18949 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
18950 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18951 [ $blksz -eq $PAGE_SIZE ] ||
18952 error "blksz error: $blksz, expected: $PAGE_SIZE"
18954 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
18955 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18956 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
18958 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
18959 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18960 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
18962 run_test 312 "make sure ZFS adjusts its block size by write pattern"
18965 remote_ost_nodsh && skip "remote OST with nodsh"
18967 local file=$DIR/$tfile
18970 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
18972 # define OBD_FAIL_TGT_RCVD_EIO 0x720
18973 do_facet ost1 "$LCTL set_param fail_loc=0x720"
18974 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
18975 error "write should failed"
18976 do_facet ost1 "$LCTL set_param fail_loc=0"
18979 run_test 313 "io should fail after last_rcvd update fail"
18982 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
18984 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
18985 do_facet ost1 "$LCTL set_param fail_loc=0x720"
18987 wait_delete_completed
18988 do_facet ost1 "$LCTL set_param fail_loc=0"
18990 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
18992 test_315() { # LU-618
18993 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
18995 local file=$DIR/$tfile
18998 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
18999 error "multiop file write failed"
19000 $MULTIOP $file oO_RDONLY:r4063232_c &
19005 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
19008 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
19011 run_test 315 "read should be accounted"
19014 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19015 large_xattr_enabled || skip_env "ea_inode feature disabled"
19017 rm -rf $DIR/$tdir/d
19018 mkdir -p $DIR/$tdir/d
19019 chown nobody $DIR/$tdir/d
19020 touch $DIR/$tdir/d/file
19022 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
19024 run_test 316 "lfs mv"
19027 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
19028 skip "Need MDS version at least 2.11.53"
19030 local grant_blk_size
19032 if [ "$(facet_fstype $facet)" == "zfs" ]; then
19033 skip "LU-10370: no implementation for ZFS" && return
19036 stack_trap "rm -f $DIR/$tfile" EXIT
19037 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
19038 awk '/grant_block_size:/ { print $2; exit; }')
19040 # Create File of size 5M. Truncate it to below size's and verify
19043 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
19044 error "Create file : $DIR/$tfile"
19046 for trunc_sz in 2097152 4097 4000 509 0; do
19047 $TRUNCATE $DIR/$tfile $trunc_sz ||
19048 error "truncate $tfile to $trunc_sz failed"
19049 local sz=$(stat --format=%s $DIR/$tfile)
19050 local blk=$(stat --format=%b $DIR/$tfile)
19051 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
19052 grant_blk_size) * 8))
19054 if [[ $blk -ne $trunc_blk ]]; then
19055 $(which stat) $DIR/$tfile
19056 error "Expected Block $trunc_blk got $blk for $tfile"
19059 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
19060 error "Expected Size $trunc_sz got $sz for $tfile"
19065 # Create file with a hole and write actual two blocks. Block count
19068 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
19069 conv=fsync || error "Create file : $DIR/$tfile"
19071 # Calculate the final truncate size.
19072 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
19075 # truncate to size $trunc_sz bytes. Strip the last block
19076 # The block count must drop to 8
19078 $TRUNCATE $DIR/$tfile $trunc_sz ||
19079 error "truncate $tfile to $trunc_sz failed"
19081 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
19082 sz=$(stat --format=%s $DIR/$tfile)
19083 blk=$(stat --format=%b $DIR/$tfile)
19085 if [[ $blk -ne $trunc_bsz ]]; then
19086 $(which stat) $DIR/$tfile
19087 error "Expected Block $trunc_bsz got $blk for $tfile"
19090 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
19091 error "Expected Size $trunc_sz got $sz for $tfile"
19093 run_test 317 "Verify blocks get correctly update after truncate"
19096 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
19098 local before=$(date +%s)
19100 local mdir=$DIR/$tdir
19101 local file=$mdir/xxx
19103 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
19106 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
19107 $LCTL set_param fail_val=5 fail_loc=0x8000032c
19108 $LFS mv -m1 $file &
19111 dd if=$file of=/dev/null
19113 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
19114 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
19116 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
19118 run_test 319 "lost lease lock on migrate error"
19121 local read_write=$1
19122 if [ "$read_write" = "write" ]; then
19123 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
19124 elif [ "$read_write" = "read" ]; then
19125 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
19127 error "argument error"
19130 # turn off debug for performance testing
19131 local saved_debug=$($LCTL get_param -n debug)
19132 $LCTL set_param debug=0
19134 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19136 # get ost1 size - lustre-OST0000
19137 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
19138 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
19139 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
19141 if [ "$read_write" = "read" ]; then
19142 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
19145 local start_time=$(date +%s.%N)
19146 $dd_cmd bs=1M count=$blocks oflag=sync ||
19147 error "real dd $read_write error"
19148 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
19150 if [ "$read_write" = "write" ]; then
19154 # define OBD_FAIL_OST_FAKE_RW 0x238
19155 do_facet ost1 $LCTL set_param fail_loc=0x238
19157 local start_time=$(date +%s.%N)
19158 $dd_cmd bs=1M count=$blocks oflag=sync ||
19159 error "fake dd $read_write error"
19160 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
19162 if [ "$read_write" = "write" ]; then
19164 cancel_lru_locks osc
19165 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
19166 error "$tfile size not $blocks MB"
19168 do_facet ost1 $LCTL set_param fail_loc=0
19170 echo "fake $read_write $duration_fake vs. normal $read_write" \
19171 "$duration in seconds"
19172 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
19173 error_not_in_vm "fake write is slower"
19175 $LCTL set_param -n debug="$saved_debug"
19178 test_399a() { # LU-7655 for OST fake write
19179 remote_ost_nodsh && skip "remote OST with nodsh"
19183 run_test 399a "fake write should not be slower than normal write"
19185 test_399b() { # LU-8726 for OST fake read
19186 remote_ost_nodsh && skip "remote OST with nodsh"
19187 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
19188 skip_env "ldiskfs only test"
19193 run_test 399b "fake read should not be slower than normal read"
19195 test_400a() { # LU-1606, was conf-sanity test_74
19196 if ! which $CC > /dev/null 2>&1; then
19197 skip_env "$CC is not installed"
19200 local extra_flags=''
19201 local out=$TMP/$tfile
19202 local prefix=/usr/include/lustre
19205 if ! [[ -d $prefix ]]; then
19206 # Assume we're running in tree and fixup the include path.
19207 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
19208 extra_flags+=" -L$LUSTRE/utils/.lib"
19211 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
19212 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
19213 error "client api broken"
19217 run_test 400a "Lustre client api program can compile and link"
19219 test_400b() { # LU-1606, LU-5011
19221 local out=$TMP/$tfile
19222 local prefix=/usr/include/linux/lustre
19224 # We use a hard coded prefix so that this test will not fail
19225 # when run in tree. There are headers in lustre/include/lustre/
19226 # that are not packaged (like lustre_idl.h) and have more
19227 # complicated include dependencies (like config.h and lnet/types.h).
19228 # Since this test about correct packaging we just skip them when
19229 # they don't exist (see below) rather than try to fixup cppflags.
19231 if ! which $CC > /dev/null 2>&1; then
19232 skip_env "$CC is not installed"
19235 for header in $prefix/*.h; do
19236 if ! [[ -f "$header" ]]; then
19240 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
19241 continue # lustre_ioctl.h is internal header
19244 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
19245 error "cannot compile '$header'"
19249 run_test 400b "packaged headers can be compiled"
19251 test_401a() { #LU-7437
19252 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
19253 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
19255 #count the number of parameters by "list_param -R"
19256 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
19257 #count the number of parameters by listing proc files
19258 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
19259 echo "proc_dirs='$proc_dirs'"
19260 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
19261 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
19264 [ $params -eq $procs ] ||
19265 error "found $params parameters vs. $procs proc files"
19267 # test the list_param -D option only returns directories
19268 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
19269 #count the number of parameters by listing proc directories
19270 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
19273 [ $params -eq $procs ] ||
19274 error "found $params parameters vs. $procs proc files"
19276 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
19279 local save=$($LCTL get_param -n jobid_var)
19282 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
19283 error "no error returned when setting bad parameters"
19285 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
19286 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
19288 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
19289 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
19290 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
19292 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
19295 local jobid_var_old=$($LCTL get_param -n jobid_var)
19296 local jobid_var_new
19298 $LCTL set_param jobid_var= &&
19299 error "no error returned for 'set_param a='"
19301 jobid_var_new=$($LCTL get_param -n jobid_var)
19302 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
19303 error "jobid_var was changed by setting without value"
19305 $LCTL set_param jobid_var &&
19306 error "no error returned for 'set_param a'"
19308 jobid_var_new=$($LCTL get_param -n jobid_var)
19309 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
19310 error "jobid_var was changed by setting without value"
19312 run_test 401c "Verify 'lctl set_param' without value fails in either format."
19315 local jobid_var_old=$($LCTL get_param -n jobid_var)
19316 local jobid_var_new
19317 local new_value="foo=bar"
19319 $LCTL set_param jobid_var=$new_value ||
19320 error "'set_param a=b' did not accept a value containing '='"
19322 jobid_var_new=$($LCTL get_param -n jobid_var)
19323 [[ "$jobid_var_new" == "$new_value" ]] ||
19324 error "'set_param a=b' failed on a value containing '='"
19326 # Reset the jobid_var to test the other format
19327 $LCTL set_param jobid_var=$jobid_var_old
19328 jobid_var_new=$($LCTL get_param -n jobid_var)
19329 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
19330 error "failed to reset jobid_var"
19332 $LCTL set_param jobid_var $new_value ||
19333 error "'set_param a b' did not accept a value containing '='"
19335 jobid_var_new=$($LCTL get_param -n jobid_var)
19336 [[ "$jobid_var_new" == "$new_value" ]] ||
19337 error "'set_param a b' failed on a value containing '='"
19339 $LCTL set_param jobid_var $jobid_var_old
19340 jobid_var_new=$($LCTL get_param -n jobid_var)
19341 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
19342 error "failed to reset jobid_var"
19344 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
19347 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
19348 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
19349 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
19350 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
19351 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
19352 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
19353 remote_mds_nodsh && skip "remote MDS with nodsh"
19355 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
19356 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
19357 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
19358 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
19359 echo "Touch failed - OK"
19361 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
19364 local file1=$DIR/$tfile.1
19365 local file2=$DIR/$tfile.2
19366 local tfile=$TMP/$tfile
19368 rm -f $file1 $file2 $tfile
19373 # 30 sec OBD_TIMEOUT in ll_getattr()
19374 # right before populating st_nlink
19375 $LCTL set_param fail_loc=0x80001409
19376 stat -c %h $file1 > $tfile &
19378 # create an alias, drop all locks and reclaim the dentry
19380 cancel_lru_locks mdc
19381 cancel_lru_locks osc
19382 sysctl -w vm.drop_caches=2
19386 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
19388 rm -f $tfile $file1 $file2
19390 run_test 403 "i_nlink should not drop to zero due to aliasing"
19392 test_404() { # LU-6601
19393 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
19394 skip "Need server version newer than 2.8.52"
19395 remote_mds_nodsh && skip "remote MDS with nodsh"
19397 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
19398 awk '/osp .*-osc-MDT/ { print $4}')
19401 for osp in $mosps; do
19402 echo "Deactivate: " $osp
19403 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
19404 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19405 awk -vp=$osp '$4 == p { print $2 }')
19406 [ $stat = IN ] || {
19407 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19408 error "deactivate error"
19410 echo "Activate: " $osp
19411 do_facet $SINGLEMDS $LCTL --device %$osp activate
19412 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19413 awk -vp=$osp '$4 == p { print $2 }')
19414 [ $stat = UP ] || {
19415 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19416 error "activate error"
19420 run_test 404 "validate manual {de}activated works properly for OSPs"
19423 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
19424 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
19425 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
19426 skip "Layout swap lock is not supported"
19428 check_swap_layouts_support
19430 test_mkdir $DIR/$tdir
19431 swap_lock_test -d $DIR/$tdir ||
19432 error "One layout swap locked test failed"
19434 run_test 405 "Various layout swap lock tests"
19437 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19438 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
19439 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
19440 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19441 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
19442 skip "Need MDS version at least 2.8.50"
19444 local def_stripe_size=$($LFS getstripe -S $MOUNT)
19445 local test_pool=$TESTNAME
19447 if ! combined_mgs_mds ; then
19450 pool_add $test_pool || error "pool_add failed"
19451 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
19452 error "pool_add_targets failed"
19454 save_layout_restore_at_exit $MOUNT
19456 # parent set default stripe count only, child will stripe from both
19457 # parent and fs default
19458 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
19459 error "setstripe $MOUNT failed"
19460 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
19461 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
19462 for i in $(seq 10); do
19463 local f=$DIR/$tdir/$tfile.$i
19464 touch $f || error "touch failed"
19465 local count=$($LFS getstripe -c $f)
19466 [ $count -eq $OSTCOUNT ] ||
19467 error "$f stripe count $count != $OSTCOUNT"
19468 local offset=$($LFS getstripe -i $f)
19469 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
19470 local size=$($LFS getstripe -S $f)
19471 [ $size -eq $((def_stripe_size * 2)) ] ||
19472 error "$f stripe size $size != $((def_stripe_size * 2))"
19473 local pool=$($LFS getstripe -p $f)
19474 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
19477 # change fs default striping, delete parent default striping, now child
19478 # will stripe from new fs default striping only
19479 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
19480 error "change $MOUNT default stripe failed"
19481 $LFS setstripe -c 0 $DIR/$tdir ||
19482 error "delete $tdir default stripe failed"
19483 for i in $(seq 11 20); do
19484 local f=$DIR/$tdir/$tfile.$i
19485 touch $f || error "touch $f failed"
19486 local count=$($LFS getstripe -c $f)
19487 [ $count -eq 1 ] || error "$f stripe count $count != 1"
19488 local offset=$($LFS getstripe -i $f)
19489 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
19490 local size=$($LFS getstripe -S $f)
19491 [ $size -eq $def_stripe_size ] ||
19492 error "$f stripe size $size != $def_stripe_size"
19493 local pool=$($LFS getstripe -p $f)
19494 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
19497 unlinkmany $DIR/$tdir/$tfile. 1 20
19499 local f=$DIR/$tdir/$tfile
19500 pool_remove_all_targets $test_pool $f
19501 pool_remove $test_pool $f
19503 if ! combined_mgs_mds ; then
19507 run_test 406 "DNE support fs default striping"
19510 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19511 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
19512 skip "Need MDS version at least 2.8.55"
19513 remote_mds_nodsh && skip "remote MDS with nodsh"
19515 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
19516 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
19517 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
19518 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
19519 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
19521 #define OBD_FAIL_DT_TXN_STOP 0x2019
19522 for idx in $(seq $MDSCOUNT); do
19523 do_facet mds$idx "lctl set_param fail_loc=0x2019"
19525 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
19526 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
19527 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
19530 run_test 407 "transaction fail should cause operation fail"
19533 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
19535 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
19536 lctl set_param fail_loc=0x8000040a
19537 # let ll_prepare_partial_page() fail
19538 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
19542 # create at least 100 unused inodes so that
19543 # shrink_icache_memory(0) should not return 0
19544 touch $DIR/$tfile-{0..100}
19545 rm -f $DIR/$tfile-{0..100}
19548 echo 2 > /proc/sys/vm/drop_caches
19550 run_test 408 "drop_caches should not hang due to page leaks"
19554 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19556 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
19557 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
19558 touch $DIR/$tdir/guard || error "(2) Fail to create"
19560 local PREFIX=$(str_repeat 'A' 128)
19561 echo "Create 1K hard links start at $(date)"
19562 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
19563 error "(3) Fail to hard link"
19565 echo "Links count should be right although linkEA overflow"
19566 stat $DIR/$tdir/guard || error "(4) Fail to stat"
19567 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
19568 [ $linkcount -eq 1001 ] ||
19569 error "(5) Unexpected hard links count: $linkcount"
19571 echo "List all links start at $(date)"
19572 ls -l $DIR/$tdir/foo > /dev/null ||
19573 error "(6) Fail to list $DIR/$tdir/foo"
19575 echo "Unlink hard links start at $(date)"
19576 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
19577 error "(7) Fail to unlink"
19578 echo "Unlink hard links finished at $(date)"
19580 run_test 409 "Large amount of cross-MDTs hard links on the same file"
19584 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
19585 skip "Need client version at least 2.9.59"
19587 # Create a file, and stat it from the kernel
19588 local testfile=$DIR/$tfile
19591 local run_id=$RANDOM
19592 local my_ino=$(stat --format "%i" $testfile)
19594 # Try to insert the module. This will always fail as the
19595 # module is designed to not be inserted.
19596 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
19599 # Anything but success is a test failure
19601 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
19602 error "no inode match"
19604 run_test 410 "Test inode number returned from kernel thread"
19606 cleanup_test411_cgroup() {
19612 local cg_basedir=/sys/fs/cgroup/memory
19614 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
19615 skip "no setup for cgroup"
19617 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
19618 error "test file creation failed"
19619 cancel_lru_locks osc
19621 # Create a very small memory cgroup to force a slab allocation error
19622 local cgdir=$cg_basedir/osc_slab_alloc
19623 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
19624 trap "cleanup_test411_cgroup $cgdir" EXIT
19625 echo 2M > $cgdir/memory.kmem.limit_in_bytes
19626 echo 1M > $cgdir/memory.limit_in_bytes
19628 # Should not LBUG, just be killed by oom-killer
19629 # dd will return 0 even allocation failure in some environment.
19630 # So don't check return value
19631 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
19632 cleanup_test411_cgroup $cgdir
19636 run_test 411 "Slab allocation error with cgroup does not LBUG"
19639 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19640 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
19641 skip "Need server version at least 2.10.55"
19644 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
19645 error "mkdir failed"
19646 $LFS getdirstripe $DIR/$tdir
19647 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
19648 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
19649 error "expect $((MDSCOUT - 1)) get $stripe_index"
19650 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
19651 [ $stripe_count -eq 2 ] ||
19652 error "expect 2 get $stripe_count"
19654 run_test 412 "mkdir on specific MDTs"
19657 [ $MDSCOUNT -lt 2 ] &&
19658 skip "We need at least 2 MDTs for this test"
19660 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
19661 skip "Need server version at least 2.10.55"
19664 mkdir $DIR/$tdir || error "mkdir failed"
19666 # find MDT that is the most full
19667 local max=$($LFS df | grep MDT |
19676 END { split(b, c, ":")
19681 for i in $(seq $((MDSCOUNT - 1))); do
19682 $LFS mkdir -c $i $DIR/$tdir/d$i ||
19683 error "mkdir d$i failed"
19684 $LFS getdirstripe $DIR/$tdir/d$i
19685 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
19686 [ $stripe_index -ne $max ] ||
19687 error "don't expect $max"
19690 run_test 413 "mkdir on less full MDTs"
19693 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
19694 $LCTL set_param fail_loc=0x80000521
19695 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
19698 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
19701 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19702 [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
19703 skip "Need server version at least 2.11.52"
19713 # this test may be slow on ZFS
19714 [ "$mds1_FSTYPE" == "zfs" ] && total=100
19716 # though this test is designed for striped directory, let's test normal
19717 # directory too since lock is always saved as CoS lock.
19718 test_mkdir $DIR/$tdir || error "mkdir $tdir"
19719 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
19728 start_time=$(date +%s)
19729 for i in $(seq $total); do
19730 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
19733 end_time=$(date +%s)
19734 duration=$((end_time - start_time))
19736 kill -9 $setattr_pid
19738 echo "rename $total files took $duration sec"
19739 [ $duration -lt 100 ] || error "rename took $duration sec"
19741 run_test 415 "lock revoke is not missing"
19744 [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
19745 skip "Need server version at least 2.11.55"
19747 # define OBD_FAIL_OSD_TXN_START 0x19a
19748 do_facet mds1 lctl set_param fail_loc=0x19a
19750 lfs mkdir -c $MDSCOUNT $DIR/$tdir
19754 run_test 416 "transaction start failure won't cause system hung"
19758 do_nodes $(comma_list $(mdts_nodes)) \
19759 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
19760 do_nodes $(comma_list $(mdts_nodes)) \
19761 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
19762 do_nodes $(comma_list $(mdts_nodes)) \
19763 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
19767 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19768 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
19769 skip "Need MDS version at least 2.11.56"
19771 trap cleanup_417 RETURN EXIT
19773 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
19774 do_nodes $(comma_list $(mdts_nodes)) \
19775 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
19776 $LFS migrate -m 0 $DIR/$tdir.1 &&
19777 error "migrate dir $tdir.1 should fail"
19779 do_nodes $(comma_list $(mdts_nodes)) \
19780 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
19781 $LFS mkdir -i 1 $DIR/$tdir.2 &&
19782 error "create remote dir $tdir.2 should fail"
19784 do_nodes $(comma_list $(mdts_nodes)) \
19785 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
19786 $LFS mkdir -c 2 $DIR/$tdir.3 &&
19787 error "create striped dir $tdir.3 should fail"
19790 run_test 417 "disable remote dir, striped dir and dir migration"
19792 # Checks that the outputs of df [-i] and lfs df [-i] match
19794 # usage: check_lfs_df <blocks | inodes> <mountpoint>
19804 [ "$1" == "blocks" ] && inodes= || inodes="-i"
19806 for count in {1..100}; do
19810 # read the lines of interest
19811 df_out=($(df -P $inodes $dir | tail -n +2)) ||
19812 error "df $inodes $dir | tail -n +2 failed"
19813 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
19814 error "lfs df $inodes $dir | grep summary: failed"
19816 # skip first substrings of each output as they are different
19817 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
19818 # compare the two outputs
19820 for i in {1..5}; do
19821 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
19829 lfs df $inodes $dir
19830 error "df and lfs df $1 output mismatch: " \
19831 "df ${inodes}: ${df_out[*]}, " \
19832 "lfs df ${inodes}: ${lfs_df_out[*]}"
19837 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19839 local dir=$DIR/$tdir
19840 local numfiles=$((RANDOM % 4096 + 2))
19841 local numblocks=$((RANDOM % 256 + 1))
19843 wait_delete_completed
19846 # check block output
19847 check_lfs_df blocks $dir
19848 # check inode output
19849 check_lfs_df inodes $dir
19851 # create a single file and retest
19852 echo "Creating a single file and testing"
19853 createmany -o $dir/$tfile- 1 &>/dev/null ||
19854 error "creating 1 file in $dir failed"
19855 check_lfs_df blocks $dir
19856 check_lfs_df inodes $dir
19858 # create a random number of files
19859 echo "Creating $((numfiles - 1)) files and testing"
19860 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
19861 error "creating $((numfiles - 1)) files in $dir failed"
19863 # write a random number of blocks to the first test file
19864 echo "Writing $numblocks 4K blocks and testing"
19865 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
19866 count=$numblocks &>/dev/null ||
19867 error "dd to $dir/${tfile}-0 failed"
19870 check_lfs_df blocks $dir
19871 check_lfs_df inodes $dir
19873 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
19874 error "unlinking $numfiles files in $dir failed"
19876 run_test 418 "df and lfs df outputs match"
19880 local dir=$DIR/$tdir
19885 cancel_lru_locks mdc
19887 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
19888 $LCTL set_param fail_loc=0x1410
19890 $LCTL set_param fail_loc=0
19893 run_test 419 "Verify open file by name doesn't crash kernel"
19897 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
19898 skip "Need MDS version at least 2.12.53"
19900 local SAVE_UMASK=$(umask)
19901 local dir=$DIR/$tdir
19902 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
19906 mkdir -m03777 $dir/testdir
19907 ls -dn $dir/testdir
19908 local dirperms=$(ls -dn $dir/testdir | awk '{print $1}')
19909 [ $dirperms == "drwxrwsrwt" ] ||
19910 error "incorrect perms on $dir/testdir"
19912 $PDSH ${uname}@localhost "PATH=$LUSTRE/tests:\$PATH; \
19913 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
19914 ls -n $dir/testdir/testfile
19915 local fileperms=$(ls -n $dir/testdir/testfile | awk '{print $1}')
19916 [ $fileperms == "-rwxr-xr-x" ] ||
19917 error "incorrect perms on $dir/testdir/testfile"
19921 run_test 420 "clear SGID bit on non-directories for non-members"
19924 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
19925 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
19926 skip "Need server version at least 2.9.55"
19928 start_full_debug_logging
19932 stop_full_debug_logging
19936 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
19937 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
19938 awk '/The barrier for/ { print $7 }')
19941 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
19946 barrier_expired() {
19949 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
19950 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
19951 awk '/will be expired/ { print $7 }')
19953 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
19962 echo "Start barrier_freeze at: $(date)"
19963 #define OBD_FAIL_BARRIER_DELAY 0x2202
19964 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
19965 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
19968 local b_status=$(barrier_stat)
19969 echo "Got barrier status at: $(date)"
19970 [ "$b_status" = "'freezing_p1'" ] ||
19971 error "(1) unexpected barrier status $b_status"
19973 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
19975 b_status=$(barrier_stat)
19976 [ "$b_status" = "'frozen'" ] ||
19977 error "(2) unexpected barrier status $b_status"
19979 local expired=$(barrier_expired)
19980 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
19981 sleep $((expired + 3))
19983 b_status=$(barrier_stat)
19984 [ "$b_status" = "'expired'" ] ||
19985 error "(3) unexpected barrier status $b_status"
19987 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
19988 error "(4) fail to freeze barrier"
19990 b_status=$(barrier_stat)
19991 [ "$b_status" = "'frozen'" ] ||
19992 error "(5) unexpected barrier status $b_status"
19994 echo "Start barrier_thaw at: $(date)"
19995 #define OBD_FAIL_BARRIER_DELAY 0x2202
19996 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
19997 do_facet mgs $LCTL barrier_thaw $FSNAME &
20000 b_status=$(barrier_stat)
20001 echo "Got barrier status at: $(date)"
20002 [ "$b_status" = "'thawing'" ] ||
20003 error "(6) unexpected barrier status $b_status"
20005 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
20007 b_status=$(barrier_stat)
20008 [ "$b_status" = "'thawed'" ] ||
20009 error "(7) unexpected barrier status $b_status"
20011 #define OBD_FAIL_BARRIER_FAILURE 0x2203
20012 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
20013 do_facet mgs $LCTL barrier_freeze $FSNAME
20015 b_status=$(barrier_stat)
20016 [ "$b_status" = "'failed'" ] ||
20017 error "(8) unexpected barrier status $b_status"
20019 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
20020 do_facet mgs $LCTL barrier_thaw $FSNAME
20024 run_test 801a "write barrier user interfaces and stat machine"
20029 mkdir $DIR/$tdir || error "(1) fail to mkdir"
20030 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
20031 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
20032 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
20033 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
20035 cancel_lru_locks mdc
20037 # 180 seconds should be long enough
20038 do_facet mgs $LCTL barrier_freeze $FSNAME 180
20040 local b_status=$(barrier_stat)
20041 [ "$b_status" = "'frozen'" ] ||
20042 error "(6) unexpected barrier status $b_status"
20044 mkdir $DIR/$tdir/d0/d10 &
20047 touch $DIR/$tdir/d1/f13 &
20050 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
20053 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
20056 rm -f $DIR/$tdir/d4/f12 &
20059 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
20061 # To guarantee taht the 'stat' is not blocked
20062 b_status=$(barrier_stat)
20063 [ "$b_status" = "'frozen'" ] ||
20064 error "(8) unexpected barrier status $b_status"
20066 # let above commands to run at background
20069 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
20070 ps -p $touch_pid || error "(10) touch should be blocked"
20071 ps -p $ln_pid || error "(11) link should be blocked"
20072 ps -p $mv_pid || error "(12) rename should be blocked"
20073 ps -p $rm_pid || error "(13) unlink should be blocked"
20075 b_status=$(barrier_stat)
20076 [ "$b_status" = "'frozen'" ] ||
20077 error "(14) unexpected barrier status $b_status"
20079 do_facet mgs $LCTL barrier_thaw $FSNAME
20080 b_status=$(barrier_stat)
20081 [ "$b_status" = "'thawed'" ] ||
20082 error "(15) unexpected barrier status $b_status"
20084 wait $mkdir_pid || error "(16) mkdir should succeed"
20085 wait $touch_pid || error "(17) touch should succeed"
20086 wait $ln_pid || error "(18) link should succeed"
20087 wait $mv_pid || error "(19) rename should succeed"
20088 wait $rm_pid || error "(20) unlink should succeed"
20092 run_test 801b "modification will be blocked by write barrier"
20095 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
20099 stop mds2 || error "(1) Fail to stop mds2"
20101 do_facet mgs $LCTL barrier_freeze $FSNAME 30
20103 local b_status=$(barrier_stat)
20104 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
20105 do_facet mgs $LCTL barrier_thaw $FSNAME
20106 error "(2) unexpected barrier status $b_status"
20109 do_facet mgs $LCTL barrier_rescan $FSNAME ||
20110 error "(3) Fail to rescan barrier bitmap"
20112 do_facet mgs $LCTL barrier_freeze $FSNAME 10
20114 b_status=$(barrier_stat)
20115 [ "$b_status" = "'frozen'" ] ||
20116 error "(4) unexpected barrier status $b_status"
20118 do_facet mgs $LCTL barrier_thaw $FSNAME
20119 b_status=$(barrier_stat)
20120 [ "$b_status" = "'thawed'" ] ||
20121 error "(5) unexpected barrier status $b_status"
20123 local devname=$(mdsdevname 2)
20125 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
20127 do_facet mgs $LCTL barrier_rescan $FSNAME ||
20128 error "(7) Fail to rescan barrier bitmap"
20132 run_test 801c "rescan barrier bitmap"
20134 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
20135 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
20136 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
20142 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
20143 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
20144 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
20150 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
20151 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
20152 skip "Need server version at least 2.9.55"
20154 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
20156 mkdir $DIR/$tdir || error "(1) fail to mkdir"
20158 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
20159 error "(2) Fail to copy"
20161 trap cleanup_802a EXIT
20163 # sync by force before remount as readonly
20164 sync; sync_all_data; sleep 3; sync_all_data
20168 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
20169 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
20170 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
20172 echo "Mount the server as read only"
20173 setupall server_only || error "(3) Fail to start servers"
20175 echo "Mount client without ro should fail"
20176 mount_client $MOUNT &&
20177 error "(4) Mount client without 'ro' should fail"
20179 echo "Mount client with ro should succeed"
20180 mount_client $MOUNT ro ||
20181 error "(5) Mount client with 'ro' should succeed"
20183 echo "Modify should be refused"
20184 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
20186 echo "Read should be allowed"
20187 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
20188 error "(7) Read should succeed under ro mode"
20192 run_test 802a "simulate readonly device"
20195 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20196 remote_mds_nodsh && skip "remote MDS with nodsh"
20198 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
20199 skip "readonly option not available"
20201 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
20203 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
20204 error "(2) Fail to copy"
20206 # write back all cached data before setting MDT to readonly
20210 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
20211 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
20213 echo "Modify should be refused"
20214 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
20216 echo "Read should be allowed"
20217 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
20218 error "(7) Read should succeed under ro mode"
20221 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
20223 run_test 802b "be able to set MDTs to readonly"
20226 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
20227 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
20228 skip "MDS needs to be newer than 2.10.54"
20230 mkdir -p $DIR/$tdir
20231 # Create some objects on all MDTs to trigger related logs objects
20232 for idx in $(seq $MDSCOUNT); do
20233 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
20234 $DIR/$tdir/dir${idx} ||
20235 error "Fail to create $DIR/$tdir/dir${idx}"
20239 wait_delete_completed # ensure old test cleanups are finished
20240 echo "before create:"
20242 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
20244 for i in {1..10}; do
20245 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
20246 error "Fail to create $DIR/$tdir/foo$i"
20250 echo "after create:"
20252 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
20254 # allow for an llog to be cleaned up during the test
20255 [ $after_used -ge $((before_used + 10 - 1)) ] ||
20256 error "before ($before_used) + 10 > after ($after_used)"
20258 for i in {1..10}; do
20259 rm -rf $DIR/$tdir/foo$i ||
20260 error "Fail to remove $DIR/$tdir/foo$i"
20263 sleep 3 # avoid MDT return cached statfs
20264 wait_delete_completed
20265 echo "after unlink:"
20267 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
20269 # allow for an llog to be created during the test
20270 [ $after_used -le $((before_used + 1)) ] ||
20271 error "after ($after_used) > before ($before_used) + 1"
20273 run_test 803 "verify agent object for remote object"
20276 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
20277 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
20278 skip "MDS needs to be newer than 2.10.54"
20279 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
20281 mkdir -p $DIR/$tdir
20282 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
20283 error "Fail to create $DIR/$tdir/dir0"
20285 local fid=$($LFS path2fid $DIR/$tdir/dir0)
20286 local dev=$(mdsdevname 2)
20288 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20289 grep ${fid} || error "NOT found agent entry for dir0"
20291 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
20292 error "Fail to create $DIR/$tdir/dir1"
20294 touch $DIR/$tdir/dir1/foo0 ||
20295 error "Fail to create $DIR/$tdir/dir1/foo0"
20296 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
20299 for idx in $(seq $MDSCOUNT); do
20300 dev=$(mdsdevname $idx)
20301 do_facet mds${idx} \
20302 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20303 grep ${fid} && rc=$idx
20306 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
20307 error "Fail to rename foo0 to foo1"
20308 if [ $rc -eq 0 ]; then
20309 for idx in $(seq $MDSCOUNT); do
20310 dev=$(mdsdevname $idx)
20311 do_facet mds${idx} \
20312 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20313 grep ${fid} && rc=$idx
20317 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
20318 error "Fail to rename foo1 to foo2"
20319 if [ $rc -eq 0 ]; then
20320 for idx in $(seq $MDSCOUNT); do
20321 dev=$(mdsdevname $idx)
20322 do_facet mds${idx} \
20323 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20324 grep ${fid} && rc=$idx
20328 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
20330 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
20331 error "Fail to link to $DIR/$tdir/dir1/foo2"
20332 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
20333 error "Fail to rename foo2 to foo0"
20334 unlink $DIR/$tdir/dir1/foo0 ||
20335 error "Fail to unlink $DIR/$tdir/dir1/foo0"
20336 rm -rf $DIR/$tdir/dir0 ||
20337 error "Fail to rm $DIR/$tdir/dir0"
20339 for idx in $(seq $MDSCOUNT); do
20340 dev=$(mdsdevname $idx)
20344 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
20346 start mds${idx} $dev $MDS_MOUNT_OPTS ||
20347 error "mount mds$idx failed"
20348 df $MOUNT > /dev/null 2>&1
20350 # e2fsck should not return error
20352 error "e2fsck detected error on MDT${idx}: rc=$rc"
20355 run_test 804 "verify agent entry for remote entry"
20358 do_facet $SINGLEMDS zfs set quota=$old $fsset
20359 unlinkmany $DIR/$tdir/f- 1000000
20364 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
20365 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
20366 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
20367 skip "netfree not implemented before 0.7"
20368 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
20369 skip "Need MDS version at least 2.10.57"
20376 local pref="osd-zfs.lustre-MDT0000."
20378 # limit available space on MDS dataset to meet nospace issue
20379 # quickly. then ZFS 0.7.2 can use reserved space if asked
20380 # properly (using netfree flag in osd_declare_destroy()
20381 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
20382 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
20384 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
20385 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
20386 let "usedkb=usedkb-freekb"
20387 let "freekb=freekb/2"
20388 if let "freekb > 5000"; then
20391 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
20392 trap cleanup_805 EXIT
20394 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
20395 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
20396 rm -rf $DIR/$tdir || error "not able to remove"
20397 do_facet $SINGLEMDS zfs set quota=$old $fsset
20400 run_test 805 "ZFS can remove from full fs"
20406 local size=$($LFS getsom -s $file)
20407 local expect=$(stat -c %s $file)
20409 [[ $size == $expect ]] ||
20410 error "$file expected size: $expect, got: $size"
20412 local blocks=$($LFS getsom -b $file)
20413 expect=$(stat -c %b $file)
20414 [[ $blocks == $expect ]] ||
20415 error "$file expected blocks: $expect, got: $blocks"
20420 local size=$($LFS getsom -s $1)
20423 [[ $size == $expect ]] ||
20424 error "$file expected size: $expect, got: $size"
20428 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20429 skip "Need MDS version at least 2.11.52"
20433 touch $DIR/$tfile || error "touch $tfile failed"
20435 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
20436 save_lustre_params client "llite.*.xattr_cache" > $save
20437 lctl set_param llite.*.xattr_cache=0
20438 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
20440 # single-threaded write
20441 echo "Test SOM for single-threaded write"
20442 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
20443 error "write $tfile failed"
20444 check_lsom_size $DIR/$tfile $bs
20447 local size=$(($num * $bs))
20451 echo "Test SOM for single client multi-threaded($num) write"
20452 $TRUNCATE $DIR/$tfile 0
20453 for ((i = 0; i < $num; i++)); do
20454 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20456 offset=$((offset + $bs))
20458 for (( i=0; i < $num; i++ )); do
20461 check_lsom_size $DIR/$tfile $size
20463 $TRUNCATE $DIR/$tfile 0
20464 for ((i = 0; i < $num; i++)); do
20465 offset=$((offset - $bs))
20466 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20469 for (( i=0; i < $num; i++ )); do
20472 check_lsom_size $DIR/$tfile $size
20474 # multi-client wirtes
20475 num=$(get_node_count ${CLIENTS//,/ })
20476 size=$(($num * $bs))
20480 echo "Test SOM for multi-client ($num) writes"
20481 $TRUNCATE $DIR/$tfile 0
20482 for client in ${CLIENTS//,/ }; do
20483 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20486 offset=$((offset + $bs))
20488 for (( i=0; i < $num; i++ )); do
20491 check_lsom_size $DIR/$tfile $offset
20494 $TRUNCATE $DIR/$tfile 0
20495 for client in ${CLIENTS//,/ }; do
20496 offset=$((offset - $bs))
20497 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20501 for (( i=0; i < $num; i++ )); do
20504 check_lsom_size $DIR/$tfile $size
20507 echo "Test SOM for truncate"
20508 $TRUNCATE $DIR/$tfile 1048576
20509 check_lsom_size $DIR/$tfile 1048576
20510 $TRUNCATE $DIR/$tfile 1234
20511 check_lsom_size $DIR/$tfile 1234
20513 # verify SOM blocks count
20514 echo "Verify SOM block count"
20515 $TRUNCATE $DIR/$tfile 0
20516 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
20517 error "failed to write file $tfile"
20518 check_lsom_data $DIR/$tfile
20520 run_test 806 "Verify Lazy Size on MDS"
20523 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
20524 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20525 skip "Need MDS version at least 2.11.52"
20527 # Registration step
20528 changelog_register || error "changelog_register failed"
20529 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
20530 changelog_users $SINGLEMDS | grep -q $cl_user ||
20531 error "User $cl_user not found in changelog_users"
20533 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
20534 save_lustre_params client "llite.*.xattr_cache" > $save
20535 lctl set_param llite.*.xattr_cache=0
20536 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
20538 rm -rf $DIR/$tdir || error "rm $tdir failed"
20539 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
20540 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
20541 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
20542 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
20543 error "truncate $tdir/trunc failed"
20546 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
20547 error "write $tfile failed"
20549 # multi-client wirtes
20550 local num=$(get_node_count ${CLIENTS//,/ })
20554 echo "Test SOM for multi-client ($num) writes"
20555 touch $DIR/$tfile || error "touch $tfile failed"
20556 $TRUNCATE $DIR/$tfile 0
20557 for client in ${CLIENTS//,/ }; do
20558 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20561 offset=$((offset + $bs))
20563 for (( i=0; i < $num; i++ )); do
20568 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
20569 check_lsom_data $DIR/$tdir/trunc
20570 check_lsom_data $DIR/$tdir/single_dd
20571 check_lsom_data $DIR/$tfile
20574 # Deregistration step
20575 changelog_deregister || error "changelog_deregister failed"
20577 run_test 807 "verify LSOM syncing tool"
20579 check_som_nologged()
20581 local lines=$($LFS changelog $FSNAME-MDT0000 |
20582 grep 'x=trusted.som' | wc -l)
20583 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
20587 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
20588 skip "Need MDS version at least 2.11.55"
20590 # Registration step
20591 changelog_register || error "changelog_register failed"
20593 touch $DIR/$tfile || error "touch $tfile failed"
20596 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
20597 error "write $tfile failed"
20600 $TRUNCATE $DIR/$tfile 1234
20603 $TRUNCATE $DIR/$tfile 1048576
20606 # Deregistration step
20607 changelog_deregister || error "changelog_deregister failed"
20609 run_test 808 "Check trusted.som xattr not logged in Changelogs"
20614 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
20618 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20619 skip "Need MDS version at least 2.11.56"
20621 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
20622 error "failed to create DoM-only file $DIR/$tfile"
20623 touch $DIR/$tfile || error "touch $tfile failed"
20624 check_som_nodata $DIR/$tfile
20626 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
20627 error "write $tfile failed"
20628 check_som_nodata $DIR/$tfile
20630 $TRUNCATE $DIR/$tfile 1234
20631 check_som_nodata $DIR/$tfile
20633 $TRUNCATE $DIR/$tfile 4097
20634 check_som_nodata $DIR/$file
20636 run_test 809 "Verify no SOM xattr store for DoM-only files"
20642 # t10 seem to dislike partial pages
20643 lctl set_param osc.*.checksum_type=adler
20644 lctl set_param fail_loc=0x411
20645 dd if=/dev/urandom of=$DIR/$tfile bs=10240 count=2
20646 ORIG=$(md5sum $DIR/$tfile)
20647 lctl set_param ldlm.namespaces.*osc*.lru_size=clear
20648 CSUM=$(md5sum $DIR/$tfile)
20649 set_checksum_type adler
20650 if [ "$ORIG" != "$CSUM" ]; then
20651 error "$ORIG != $CSUM"
20654 run_test 810 "partial page writes on ZFS (LU-11663)"
20657 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
20658 skip "Need MDS version at least 2.11.56"
20660 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
20661 do_facet mds1 $LCTL set_param fail_loc=0x165
20662 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
20665 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
20668 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) -eq 0 ]] ||
20669 error "MDD orphan cleanup thread not quit"
20671 run_test 811 "orphan name stub can be cleaned up in startup"
20674 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
20675 skip "OST < 2.12.51 doesn't support this fail_loc"
20677 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20678 # ensure ost1 is connected
20679 stat $DIR/$tfile >/dev/null || error "can't stat"
20680 wait_osc_import_state client ost1 FULL
20681 # no locks, no reqs to let the connection idle
20682 cancel_lru_locks osc
20684 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
20685 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
20686 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
20687 wait_osc_import_state client ost1 CONNECTING
20688 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
20690 stat $DIR/$tfile >/dev/null || error "can't stat file"
20692 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
20695 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
20696 [ -z "$file_heat_sav" ] && skip "no file heat support"
20707 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
20708 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
20710 $LCTL set_param -n llite.*.file_heat=1
20711 echo "Turn on file heat"
20712 echo "Period second: $period_second, Decay percentage: $decay_pct"
20714 echo "QQQQ" > $DIR/$tfile
20715 echo "QQQQ" > $DIR/$tfile
20716 echo "QQQQ" > $DIR/$tfile
20717 cat $DIR/$tfile > /dev/null
20718 cat $DIR/$tfile > /dev/null
20719 cat $DIR/$tfile > /dev/null
20720 cat $DIR/$tfile > /dev/null
20722 local out=$($LFS heat_get $DIR/$tfile)
20724 $LFS heat_get $DIR/$tfile
20725 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20726 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20727 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20728 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20730 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
20731 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
20732 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
20733 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
20735 sleep $((period_second + 3))
20736 echo "Sleep $((period_second + 3)) seconds..."
20737 # The recursion formula to calculate the heat of the file f is as
20739 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
20740 # Where Hi is the heat value in the period between time points i*I and
20741 # (i+1)*I; Ci is the access count in the period; the symbol P refers
20742 # to the weight of Ci.
20743 out=$($LFS heat_get $DIR/$tfile)
20744 $LFS heat_get $DIR/$tfile
20745 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20746 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20747 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20748 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20750 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
20751 error "read sample ($readsample) is wrong"
20752 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
20753 error "write sample ($writesample) is wrong"
20754 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
20755 error "read bytes ($readbyte) is wrong"
20756 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
20757 error "write bytes ($writebyte) is wrong"
20759 echo "QQQQ" > $DIR/$tfile
20760 echo "QQQQ" > $DIR/$tfile
20761 echo "QQQQ" > $DIR/$tfile
20762 cat $DIR/$tfile > /dev/null
20763 cat $DIR/$tfile > /dev/null
20764 cat $DIR/$tfile > /dev/null
20765 cat $DIR/$tfile > /dev/null
20767 sleep $((period_second + 3))
20768 echo "Sleep $((period_second + 3)) seconds..."
20770 out=$($LFS heat_get $DIR/$tfile)
20771 $LFS heat_get $DIR/$tfile
20772 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20773 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20774 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20775 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20777 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
20778 4 * $decay_pct) / 100") -eq 1 ] ||
20779 error "read sample ($readsample1) is wrong"
20780 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
20781 3 * $decay_pct) / 100") -eq 1 ] ||
20782 error "write sample ($writesample1) is wrong"
20783 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
20784 20 * $decay_pct) / 100") -eq 1 ] ||
20785 error "read bytes ($readbyte1) is wrong"
20786 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
20787 15 * $decay_pct) / 100") -eq 1 ] ||
20788 error "write bytes ($writebyte1) is wrong"
20790 echo "Turn off file heat for the file $DIR/$tfile"
20791 $LFS heat_set -o $DIR/$tfile
20793 echo "QQQQ" > $DIR/$tfile
20794 echo "QQQQ" > $DIR/$tfile
20795 echo "QQQQ" > $DIR/$tfile
20796 cat $DIR/$tfile > /dev/null
20797 cat $DIR/$tfile > /dev/null
20798 cat $DIR/$tfile > /dev/null
20799 cat $DIR/$tfile > /dev/null
20801 out=$($LFS heat_get $DIR/$tfile)
20802 $LFS heat_get $DIR/$tfile
20803 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20804 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20805 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20806 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20808 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
20809 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
20810 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
20811 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
20813 echo "Trun on file heat for the file $DIR/$tfile"
20814 $LFS heat_set -O $DIR/$tfile
20816 echo "QQQQ" > $DIR/$tfile
20817 echo "QQQQ" > $DIR/$tfile
20818 echo "QQQQ" > $DIR/$tfile
20819 cat $DIR/$tfile > /dev/null
20820 cat $DIR/$tfile > /dev/null
20821 cat $DIR/$tfile > /dev/null
20822 cat $DIR/$tfile > /dev/null
20824 out=$($LFS heat_get $DIR/$tfile)
20825 $LFS heat_get $DIR/$tfile
20826 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20827 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20828 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20829 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20831 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
20832 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
20833 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
20834 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
20836 $LFS heat_set -c $DIR/$tfile
20837 $LCTL set_param -n llite.*.file_heat=0
20838 echo "Turn off file heat support for the Lustre filesystem"
20840 echo "QQQQ" > $DIR/$tfile
20841 echo "QQQQ" > $DIR/$tfile
20842 echo "QQQQ" > $DIR/$tfile
20843 cat $DIR/$tfile > /dev/null
20844 cat $DIR/$tfile > /dev/null
20845 cat $DIR/$tfile > /dev/null
20846 cat $DIR/$tfile > /dev/null
20848 out=$($LFS heat_get $DIR/$tfile)
20849 $LFS heat_get $DIR/$tfile
20850 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20851 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20852 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20853 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20855 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
20856 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
20857 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
20858 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
20860 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
20863 run_test 813 "File heat verfication"
20866 # tests that do cleanup/setup should be run at the end
20870 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20873 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
20874 $LCTL set_param fail_loc=0x903
20876 cancel_lru_locks MGC
20878 FAIL_ON_ERROR=true cleanup
20879 FAIL_ON_ERROR=true setup
20881 run_test 900 "umount should not race with any mgc requeue thread"
20884 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
20885 check_and_cleanup_lustre
20886 if [ "$I_MOUNTED" != "yes" ]; then
20887 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true