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 [ $MDS1_VERSION -le $(version_code 2.12.52) ] ||
6707 skip "Need MDS version at least 2.12.52"
6708 [ $MDSCOUNT -le 2 ] || skip "Need >= 2 MDTs"
6712 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
6713 #define OBD_FAIL_MDS_STRIPE_FID 0x189
6714 for fail_loc in 0x80000188 0x80000189; do
6715 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
6716 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
6717 error "mkdir $dir-$fail_loc failed"
6718 for i in {0..10}; do
6719 # create may fail on missing stripe
6720 echo $i > $DIR/$tdir-$fail_loc/$i
6722 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6723 error "getdirstripe $tdir-$fail_loc failed"
6724 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
6725 error "migrate $tdir-$fail_loc failed"
6726 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6727 error "getdirstripe $tdir-$fail_loc failed"
6728 pushd $DIR/$tdir-$fail_loc
6730 echo $f | cmp $f - || error "$f data mismatch"
6733 rm -rf $DIR/$tdir-$fail_loc
6736 run_test 60h "striped directory with missing stripes can be accessed"
6739 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6742 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
6743 cancel_lru_locks osc
6744 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6747 run_test 61a "mmap() writes don't make sync hang ================"
6750 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
6752 run_test 61b "mmap() of unstriped file is successful"
6754 # bug 2330 - insufficient obd_match error checking causes LBUG
6756 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6760 cancel_lru_locks osc
6761 lctl set_param fail_loc=0x405
6762 cat $f && error "cat succeeded, expect -EIO"
6763 lctl set_param fail_loc=0
6765 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6766 # match every page all of the time.
6767 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6769 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6770 # Though this test is irrelevant anymore, it helped to reveal some
6771 # other grant bugs (LU-4482), let's keep it.
6772 test_63a() { # was test_63
6773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6775 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
6777 for i in `seq 10` ; do
6778 dd if=/dev/zero of=$DIR/f63 bs=8k &
6784 rm -f $DIR/f63 || true
6786 run_test 63a "Verify oig_wait interruption does not crash ======="
6788 # bug 2248 - async write errors didn't return to application on sync
6789 # bug 3677 - async write errors left page locked
6791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6794 lctl set_param debug=-1
6796 # ensure we have a grant to do async writes
6797 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6800 sync # sync lest earlier test intercept the fail_loc
6802 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6803 lctl set_param fail_loc=0x80000406
6804 $MULTIOP $DIR/$tfile Owy && \
6805 error "sync didn't return ENOMEM"
6806 sync; sleep 2; sync # do a real sync this time to flush page
6807 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6808 error "locked page left in cache after async error" || true
6811 run_test 63b "async write errors should be returned to fsync ==="
6814 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6817 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6819 run_test 64a "verify filter grant calculations (in kernel) ====="
6822 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6824 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6826 run_test 64b "check out-of-space detection on client"
6829 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6831 run_test 64c "verify grant shrink"
6833 # this does exactly what osc_request.c:osc_announce_cached() does in
6834 # order to calculate max amount of grants to ask from server
6838 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
6839 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
6841 ((rpc_in_flight ++));
6842 nrpages=$((nrpages * rpc_in_flight))
6844 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
6846 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
6848 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6849 local undirty=$((nrpages * PAGE_SIZE))
6851 local max_extent_pages
6852 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
6853 grep grant_max_extent_size | awk '{print $2}')
6854 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
6855 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6856 local grant_extent_tax
6857 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6858 grep grant_extent_tax | awk '{print $2}')
6860 undirty=$((undirty + nrextents * grant_extent_tax))
6865 # this is size of unit for grant allocation. It should be equal to
6866 # what tgt_grant.c:tgt_grant_chunk() calculates
6870 local grant_extent_tax
6872 max_brw_size=$($LCTL get_param osc.${tgt}.import |
6873 grep max_brw_size | awk '{print $2}')
6875 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6876 grep grant_extent_tax | awk '{print $2}')
6878 echo $(((max_brw_size + grant_extent_tax) * 2))
6882 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
6883 skip "OST < 2.10.55 doesn't limit grants enough"
6885 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
6886 local file=$DIR/$tfile
6888 [[ $($LCTL get_param osc.${tgt}.import |
6889 grep "connect_flags:.*grant_param") ]] ||
6890 skip "no grant_param connect flag"
6892 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
6894 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
6896 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
6897 stack_trap "rm -f $file" EXIT
6899 $LFS setstripe $file -i 0 -c 1
6900 dd if=/dev/zero of=$file bs=1M count=1000 &
6905 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
6906 if [[ $cur_grant -gt $max_cur_granted ]]
6909 error "cur_grant $cur_grant > $max_cur_granted"
6912 [[ $? -ne 0 ]] && break;
6917 wait_delete_completed
6918 $LCTL set_param debug="$olddebug" 2> /dev/null || true
6920 run_test 64d "check grant limit exceed"
6922 # bug 1414 - set/get directories' stripe info
6924 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6926 test_mkdir $DIR/$tdir
6928 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
6930 run_test 65a "directory with no stripe info"
6933 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6935 test_mkdir $DIR/$tdir
6936 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
6938 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6941 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
6943 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
6946 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6947 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
6949 test_mkdir $DIR/$tdir
6950 local stripesize=$($LFS getstripe -S $DIR/$tdir)
6952 $LFS setstripe -S $((stripesize * 4)) -i 1 \
6953 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
6955 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
6957 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
6960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6962 test_mkdir $DIR/$tdir
6963 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
6964 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
6966 if [[ $STRIPECOUNT -le 0 ]]; then
6968 elif [[ $STRIPECOUNT -gt 2000 ]]; then
6969 #LOV_MAX_STRIPE_COUNT is 2000
6970 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
6972 sc=$(($STRIPECOUNT - 1))
6974 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
6975 touch $DIR/$tdir/f4 $DIR/$tdir/f5
6976 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
6977 error "lverify failed"
6979 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
6982 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6984 test_mkdir $DIR/$tdir
6986 $LFS setstripe $DIR/$tdir || error "setstripe"
6987 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6988 error "no stripe info failed"
6990 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
6992 run_test 65e "directory setstripe defaults"
6995 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6997 test_mkdir $DIR/${tdir}f
6998 $RUNAS $LFS setstripe $DIR/${tdir}f &&
6999 error "setstripe succeeded" || true
7001 run_test 65f "dir setstripe permission (should return error) ==="
7004 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7006 test_mkdir $DIR/$tdir
7007 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7009 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7010 error "setstripe -S failed"
7011 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
7012 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7013 error "delete default stripe failed"
7015 run_test 65g "directory setstripe -d"
7018 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7020 test_mkdir $DIR/$tdir
7021 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7023 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7024 error "setstripe -S failed"
7025 test_mkdir $DIR/$tdir/dd1
7026 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
7027 error "stripe info inherit failed"
7029 run_test 65h "directory stripe info inherit ===================="
7032 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7034 save_layout_restore_at_exit $MOUNT
7036 # bug6367: set non-default striping on root directory
7037 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
7039 # bug12836: getstripe on -1 default directory striping
7040 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
7042 # bug12836: getstripe -v on -1 default directory striping
7043 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
7045 # bug12836: new find on -1 default directory striping
7046 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
7048 run_test 65i "various tests to set root directory striping"
7050 test_65j() { # bug6367
7051 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7055 # if we aren't already remounting for each test, do so for this test
7056 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
7057 cleanup || error "failed to unmount"
7061 save_layout_restore_at_exit $MOUNT
7063 $LFS setstripe -d $MOUNT || error "setstripe failed"
7065 run_test 65j "set default striping on root directory (bug 6367)="
7069 wait_delete_completed
7070 do_facet $SINGLEMDS "lctl set_param -n \
7071 osp.$ost*MDT0000.max_create_count=$max_count"
7072 do_facet $SINGLEMDS "lctl set_param -n \
7073 osp.$ost*MDT0000.create_count=$count"
7074 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7075 echo $INACTIVE_OSC "is Activate"
7077 wait_osc_import_state mds ost$ostnum FULL
7080 test_65k() { # bug11679
7081 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7082 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7083 remote_mds_nodsh && skip "remote MDS with nodsh"
7085 local disable_precreate=true
7086 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
7087 disable_precreate=false
7089 echo "Check OST status: "
7090 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
7091 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
7093 for OSC in $MDS_OSCS; do
7094 echo $OSC "is active"
7095 do_facet $SINGLEMDS lctl --device %$OSC activate
7098 for INACTIVE_OSC in $MDS_OSCS; do
7099 local ost=$(osc_to_ost $INACTIVE_OSC)
7100 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
7101 lov.*md*.target_obd |
7102 awk -F: /$ost/'{ print $1 }' | head -n 1)
7105 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
7106 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
7108 echo "Deactivate: " $INACTIVE_OSC
7109 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
7111 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
7112 osp.$ost*MDT0000.create_count")
7113 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
7114 osp.$ost*MDT0000.max_create_count")
7115 $disable_precreate &&
7116 do_facet $SINGLEMDS "lctl set_param -n \
7117 osp.$ost*MDT0000.max_create_count=0"
7119 for idx in $(seq 0 $((OSTCOUNT - 1))); do
7120 [ -f $DIR/$tdir/$idx ] && continue
7121 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
7122 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
7124 error "setstripe $idx should succeed"; }
7125 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
7127 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
7130 do_facet $SINGLEMDS "lctl set_param -n \
7131 osp.$ost*MDT0000.max_create_count=$max_count"
7132 do_facet $SINGLEMDS "lctl set_param -n \
7133 osp.$ost*MDT0000.create_count=$count"
7134 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7135 echo $INACTIVE_OSC "is Activate"
7137 wait_osc_import_state mds ost$ostnum FULL
7140 run_test 65k "validate manual striping works properly with deactivated OSCs"
7142 test_65l() { # bug 12836
7143 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7145 test_mkdir -p $DIR/$tdir/test_dir
7146 $LFS setstripe -c -1 $DIR/$tdir/test_dir
7147 $LFS find -mtime -1 $DIR/$tdir >/dev/null
7149 run_test 65l "lfs find on -1 stripe dir ========================"
7152 local layout=$(save_layout $MOUNT)
7153 $RUNAS $LFS setstripe -c 2 $MOUNT && {
7154 restore_layout $MOUNT $layout
7155 error "setstripe should fail by non-root users"
7159 run_test 65m "normal user can't set filesystem default stripe"
7162 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
7163 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.12.50) ]] ||
7164 skip "Need MDS version at least 2.12.50"
7165 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7167 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7168 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
7169 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
7171 local root_layout=$(save_layout $MOUNT)
7172 stack_trap "restore_layout $MOUNT $root_layout" EXIT
7174 # new subdirectory under root directory should not inherit
7175 # the default layout from root
7176 local dir1=$MOUNT/$tdir-1
7177 mkdir $dir1 || error "mkdir $dir1 failed"
7178 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
7179 error "$dir1 shouldn't have LOV EA"
7181 # delete the default layout on root directory
7182 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
7184 local dir2=$MOUNT/$tdir-2
7185 mkdir $dir2 || error "mkdir $dir2 failed"
7186 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
7187 error "$dir2 shouldn't have LOV EA"
7189 # set a new striping pattern on root directory
7190 local def_stripe_size=$($LFS getstripe -S $MOUNT)
7191 local new_def_stripe_size=$((def_stripe_size * 2))
7192 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
7193 error "set stripe size on $MOUNT failed"
7195 # new file created in $dir2 should inherit the new stripe size from
7196 # the filesystem default
7197 local file2=$dir2/$tfile-2
7198 touch $file2 || error "touch $file2 failed"
7200 local file2_stripe_size=$($LFS getstripe -S $file2)
7201 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
7202 error "$file2 didn't inherit stripe size $new_def_stripe_size"
7204 local dir3=$MOUNT/$tdir-3
7205 mkdir $dir3 || error "mkdir $dir3 failed"
7206 ! getfattr -n trusted.lov $dir3 &> /dev/null ||
7207 error "$dir3 shouldn't have LOV EA"
7209 # set OST pool on root directory
7210 local pool=$TESTNAME
7211 pool_add $pool || error "add $pool failed"
7212 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
7213 error "add targets to $pool failed"
7215 $LFS setstripe -p $pool $MOUNT ||
7216 error "set OST pool on $MOUNT failed"
7218 # new file created in $dir3 should inherit the pool from
7219 # the filesystem default
7220 local file3=$dir3/$tfile-3
7221 touch $file3 || error "touch $file3 failed"
7223 local file3_pool=$($LFS getstripe -p $file3)
7224 [[ "$file3_pool" = "$pool" ]] ||
7225 error "$file3 didn't inherit OST pool $pool"
7227 local dir4=$MOUNT/$tdir-4
7228 mkdir $dir4 || error "mkdir $dir4 failed"
7229 ! getfattr -n trusted.lov $dir4 &> /dev/null ||
7230 error "$dir4 shouldn't have LOV EA"
7232 # new file created in $dir4 should inherit the pool from
7233 # the filesystem default
7234 local file4=$dir4/$tfile-4
7235 touch $file4 || error "touch $file4 failed"
7237 local file4_pool=$($LFS getstripe -p $file4)
7238 [[ "$file4_pool" = "$pool" ]] ||
7239 error "$file4 didn't inherit OST pool $pool"
7241 # new subdirectory under non-root directory should inherit
7242 # the default layout from its parent directory
7243 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
7244 error "set directory layout on $dir4 failed"
7246 local dir5=$dir4/$tdir-5
7247 mkdir $dir5 || error "mkdir $dir5 failed"
7249 local dir4_layout=$(get_layout_param $dir4)
7250 local dir5_layout=$(get_layout_param $dir5)
7251 [[ "$dir4_layout" = "$dir5_layout" ]] ||
7252 error "$dir5 should inherit the default layout from $dir4"
7254 run_test 65n "don't inherit default layout from root for new subdirectories"
7256 # bug 2543 - update blocks count on client
7258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7261 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
7262 sync; sync_all_data; sync; sync_all_data
7263 cancel_lru_locks osc
7264 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
7265 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
7267 run_test 66 "update inode blocks count on client ==============="
7270 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
7274 swapon -s | awk '($1 == "'$1'") { print $4 }'
7277 # bug5265, obdfilter oa2dentry return -ENOENT
7278 # #define OBD_FAIL_SRV_ENOENT 0x217
7280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7281 remote_ost_nodsh && skip "remote OST with nodsh"
7284 $LFS setstripe -c 1 -i 0 $f
7286 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
7288 do_facet ost1 lctl set_param fail_loc=0x217
7289 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
7290 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
7292 do_facet ost1 lctl set_param fail_loc=0
7293 $DIRECTIO write $f 0 2 || error "write error"
7295 cancel_lru_locks osc
7296 $DIRECTIO read $f 0 1 || error "read error"
7298 do_facet ost1 lctl set_param fail_loc=0x217
7299 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
7301 do_facet ost1 lctl set_param fail_loc=0
7304 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
7307 test_mkdir $DIR/$tdir
7308 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
7309 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
7311 run_test 71 "Running dbench on lustre (don't segment fault) ===="
7313 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
7314 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7315 [ "$RUNAS_ID" = "$UID" ] &&
7316 skip_env "RUNAS_ID = UID = $UID -- skipping"
7317 # Check that testing environment is properly set up. Skip if not
7318 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
7319 skip_env "User $RUNAS_ID does not exist - skipping"
7322 chmod 777 $DIR/$tfile
7323 chmod ug+s $DIR/$tfile
7324 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
7325 error "$RUNAS dd $DIR/$tfile failed"
7326 # See if we are still setuid/sgid
7327 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
7328 error "S/gid is not dropped on write"
7329 # Now test that MDS is updated too
7330 cancel_lru_locks mdc
7331 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
7332 error "S/gid is not dropped on MDS"
7335 run_test 72a "Test that remove suid works properly (bug5695) ===="
7337 test_72b() { # bug 24226 -- keep mode setting when size is not changing
7340 [ "$RUNAS_ID" = "$UID" ] &&
7341 skip_env "RUNAS_ID = UID = $UID -- skipping"
7342 [ "$RUNAS_ID" -eq 0 ] &&
7343 skip_env "RUNAS_ID = 0 -- skipping"
7344 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7345 # Check that testing environment is properly set up. Skip if not
7346 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
7347 skip_env "User $RUNAS_ID does not exist - skipping"
7349 touch $DIR/${tfile}-f{g,u}
7350 test_mkdir $DIR/${tfile}-dg
7351 test_mkdir $DIR/${tfile}-du
7352 chmod 770 $DIR/${tfile}-{f,d}{g,u}
7353 chmod g+s $DIR/${tfile}-{f,d}g
7354 chmod u+s $DIR/${tfile}-{f,d}u
7355 for perm in 777 2777 4777; do
7356 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
7357 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
7358 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
7359 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
7363 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
7365 # bug 3462 - multiple simultaneous MDC requests
7367 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7369 test_mkdir $DIR/d73-1
7370 test_mkdir $DIR/d73-2
7371 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
7374 lctl set_param fail_loc=0x80000129
7375 $MULTIOP $DIR/d73-1/f73-2 Oc &
7377 lctl set_param fail_loc=0
7379 $MULTIOP $DIR/d73-2/f73-3 Oc &
7383 wait $pid1 || return 1
7387 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
7388 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
7389 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
7393 run_test 73 "multiple MDC requests (should not deadlock)"
7395 test_74a() { # bug 6149, 6184
7396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7399 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7401 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7402 # will spin in a tight reconnection loop
7403 $LCTL set_param fail_loc=0x8000030e
7404 # get any lock that won't be difficult - lookup works.
7406 $LCTL set_param fail_loc=0
7410 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
7412 test_74b() { # bug 13310
7413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7415 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7417 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7418 # will spin in a tight reconnection loop
7419 $LCTL set_param fail_loc=0x8000030e
7420 # get a "difficult" lock
7422 $LCTL set_param fail_loc=0
7426 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
7429 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7431 #define OBD_FAIL_LDLM_NEW_LOCK
7432 $LCTL set_param fail_loc=0x319
7433 touch $DIR/$tfile && error "touch successful"
7434 $LCTL set_param fail_loc=0
7437 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
7440 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
7443 test_76() { # Now for bug 20433, added originally in bug 1443
7444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7446 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
7448 cancel_lru_locks osc
7449 BEFORE_INODES=$(num_inodes)
7450 echo "before inodes: $BEFORE_INODES"
7452 [ "$SLOW" = "no" ] && COUNT=100
7453 for i in $(seq $COUNT); do
7457 cancel_lru_locks osc
7458 AFTER_INODES=$(num_inodes)
7459 echo "after inodes: $AFTER_INODES"
7461 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
7463 AFTER_INODES=$(num_inodes)
7465 echo "wait $wait seconds inodes: $AFTER_INODES"
7466 if [ $wait -gt 30 ]; then
7467 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
7471 run_test 76 "confirm clients recycle inodes properly ===="
7477 # Note: in sptlrpc modes which enable its own bulk checksum, the
7478 # original crc32_le bulk checksum will be automatically disabled,
7479 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
7480 # will be checked by sptlrpc code against sptlrpc bulk checksum.
7481 # In this case set_checksums() will not be no-op, because sptlrpc
7482 # bulk checksum will be enabled all through the test.
7484 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
7485 lctl set_param -n osc.*.checksums $1
7489 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7490 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
7491 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7492 tr -d [] | head -n1)}
7495 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
7496 log "set checksum type to $1"
7499 F77_TMP=$TMP/f77-temp
7502 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
7503 error "error writing to $F77_TMP"
7506 test_77a() { # bug 10889
7507 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7508 $GSS && skip_env "could not run with gss"
7510 [ ! -f $F77_TMP ] && setup_f77
7512 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
7516 run_test 77a "normal checksum read/write operation"
7518 test_77b() { # bug 10889
7519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7520 $GSS && skip_env "could not run with gss"
7522 [ ! -f $F77_TMP ] && setup_f77
7523 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7524 $LCTL set_param fail_loc=0x80000409
7527 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7528 error "dd error: $?"
7529 $LCTL set_param fail_loc=0
7531 for algo in $CKSUM_TYPES; do
7532 cancel_lru_locks osc
7533 set_checksum_type $algo
7534 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7535 $LCTL set_param fail_loc=0x80000408
7536 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7537 $LCTL set_param fail_loc=0
7540 set_checksum_type $ORIG_CSUM_TYPE
7543 run_test 77b "checksum error on client write, read"
7548 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7550 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7551 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7552 $check_ost && [ -n "$ost_file_prefix" ] &&
7553 do_facet ost1 rm -f ${ost_file_prefix}\*
7557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7558 $GSS && skip_env "could not run with gss"
7559 remote_ost_nodsh && skip "remote OST with nodsh"
7562 local osc_file_prefix
7564 local check_ost=false
7565 local ost_file_prefix
7571 # ensure corruption will occur on first OSS/OST
7572 $LFS setstripe -i 0 $DIR/$tfile
7574 [ ! -f $F77_TMP ] && setup_f77
7575 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7576 error "dd write error: $?"
7577 fid=$($LFS path2fid $DIR/$tfile)
7579 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
7582 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7583 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7585 echo "OSS do not support bulk pages dump upon error"
7588 osc_file_prefix=$($LCTL get_param -n debug_path)
7589 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7591 trap cleanup_77c EXIT
7594 # enable bulk pages dump upon error on Client
7595 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7596 # enable bulk pages dump upon error on OSS
7598 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7600 # flush Client cache to allow next read to reach OSS
7601 cancel_lru_locks osc
7603 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7604 $LCTL set_param fail_loc=0x80000408
7605 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7606 $LCTL set_param fail_loc=0
7610 # check cksum dump on Client
7611 osc_file=$(ls ${osc_file_prefix}*)
7612 [ -n "$osc_file" ] || error "no checksum dump file on Client"
7613 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
7614 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
7615 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
7616 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
7618 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
7619 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7620 error "dump content does not match on Client"
7622 $check_ost || skip "No need to check cksum dump on OSS"
7624 # check cksum dump on OSS
7625 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
7626 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
7627 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
7628 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
7629 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7630 error "dump content does not match on OSS"
7634 run_test 77c "checksum error on client read with debug"
7636 test_77d() { # bug 10889
7637 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7638 $GSS && skip_env "could not run with gss"
7640 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7641 $LCTL set_param fail_loc=0x80000409
7643 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7644 error "direct write: rc=$?"
7645 $LCTL set_param fail_loc=0
7648 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7649 $LCTL set_param fail_loc=0x80000408
7651 cancel_lru_locks osc
7652 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7653 error "direct read: rc=$?"
7654 $LCTL set_param fail_loc=0
7657 run_test 77d "checksum error on OST direct write, read"
7659 test_77f() { # bug 10889
7660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7661 $GSS && skip_env "could not run with gss"
7664 for algo in $CKSUM_TYPES; do
7665 cancel_lru_locks osc
7666 set_checksum_type $algo
7667 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7668 $LCTL set_param fail_loc=0x409
7669 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
7670 error "direct write succeeded"
7671 $LCTL set_param fail_loc=0
7673 set_checksum_type $ORIG_CSUM_TYPE
7676 run_test 77f "repeat checksum error on write (expect error)"
7678 test_77g() { # bug 10889
7679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7680 $GSS && skip_env "could not run with gss"
7681 remote_ost_nodsh && skip "remote OST with nodsh"
7683 [ ! -f $F77_TMP ] && setup_f77
7685 local file=$DIR/$tfile
7686 stack_trap "rm -f $file" EXIT
7688 $LFS setstripe -c 1 -i 0 $file
7689 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
7690 do_facet ost1 lctl set_param fail_loc=0x8000021a
7692 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
7693 error "write error: rc=$?"
7694 do_facet ost1 lctl set_param fail_loc=0
7697 cancel_lru_locks osc
7698 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
7699 do_facet ost1 lctl set_param fail_loc=0x8000021b
7701 cmp $F77_TMP $file || error "file compare failed"
7702 do_facet ost1 lctl set_param fail_loc=0
7705 run_test 77g "checksum error on OST write, read"
7707 test_77k() { # LU-10906
7708 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7709 $GSS && skip_env "could not run with gss"
7711 local cksum_param="osc.$FSNAME*.checksums"
7712 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
7716 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
7717 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
7718 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
7722 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
7723 error "failed to set checksum=$i on MGS"
7724 wait_update $HOSTNAME "$get_checksum" $i
7726 echo "remount client, checksum should be $i"
7727 remount_client $MOUNT || "failed to remount client"
7728 checksum=$(eval $get_checksum)
7729 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7731 # remove persistent param to avoid races with checksum mountopt below
7732 do_facet mgs $LCTL set_param -P -d $cksum_param ||
7733 error "failed to delete checksum on MGS"
7735 for opt in "checksum" "nochecksum"; do
7736 #remount with mount option
7737 echo "remount client with option $opt, checksum should be $i"
7738 umount_client $MOUNT || "failed to umount client"
7739 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
7740 "failed to mount client with option '$opt'"
7741 checksum=$(eval $get_checksum)
7742 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7746 remount_client $MOUNT || "failed to remount client"
7748 run_test 77k "enable/disable checksum correctly"
7750 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
7759 test_78() { # bug 10901
7760 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7761 remote_ost || skip_env "local OST"
7764 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
7765 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
7766 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
7767 echo "MemTotal: $MEMTOTAL"
7769 # reserve 256MB of memory for the kernel and other running processes,
7770 # and then take 1/2 of the remaining memory for the read/write buffers.
7771 if [ $MEMTOTAL -gt 512 ] ;then
7772 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
7774 # for those poor memory-starved high-end clusters...
7775 MEMTOTAL=$((MEMTOTAL / 2))
7777 echo "Mem to use for directio: $MEMTOTAL"
7779 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
7780 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
7781 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
7782 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
7784 echo "Smallest OST: $SMALLESTOST"
7785 [[ $SMALLESTOST -lt 10240 ]] &&
7786 skip "too small OSTSIZE, useless to run large O_DIRECT test"
7788 trap cleanup_test_78 EXIT
7790 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
7791 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
7793 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
7794 echo "File size: $F78SIZE"
7795 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
7796 for i in $(seq 1 $NSEQ); do
7797 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
7798 echo directIO rdwr round $i of $NSEQ
7799 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
7804 run_test 78 "handle large O_DIRECT writes correctly ============"
7806 test_79() { # bug 12743
7807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7809 wait_delete_completed
7811 BKTOTAL=$(calc_osc_kbytes kbytestotal)
7812 BKFREE=$(calc_osc_kbytes kbytesfree)
7813 BKAVAIL=$(calc_osc_kbytes kbytesavail)
7815 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
7816 DFTOTAL=`echo $STRING | cut -d, -f1`
7817 DFUSED=`echo $STRING | cut -d, -f2`
7818 DFAVAIL=`echo $STRING | cut -d, -f3`
7819 DFFREE=$(($DFTOTAL - $DFUSED))
7821 ALLOWANCE=$((64 * $OSTCOUNT))
7823 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
7824 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
7825 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
7827 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
7828 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
7829 error "df free($DFFREE) mismatch OST free($BKFREE)"
7831 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
7832 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
7833 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
7836 run_test 79 "df report consistency check ======================="
7838 test_80() { # bug 10718
7839 remote_ost_nodsh && skip "remote OST with nodsh"
7840 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7842 # relax strong synchronous semantics for slow backends like ZFS
7843 local soc="obdfilter.*.sync_on_lock_cancel"
7844 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
7846 if [ "$soc_old" != "never" ] &&
7847 [ "$ost1_FSTYPE" != "ldiskfs" ]; then
7848 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
7849 facet_active_host $host; done | sort -u)
7850 do_nodes $hosts lctl set_param $soc=never
7853 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
7855 local BEFORE=`date +%s`
7856 cancel_lru_locks osc
7857 local AFTER=`date +%s`
7858 local DIFF=$((AFTER-BEFORE))
7859 if [ $DIFF -gt 1 ] ; then
7860 error "elapsed for 1M@1T = $DIFF"
7863 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
7867 run_test 80 "Page eviction is equally fast at high offsets too ===="
7869 test_81a() { # LU-456
7870 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7871 remote_ost_nodsh && skip "remote OST with nodsh"
7873 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7874 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
7875 do_facet ost1 lctl set_param fail_loc=0x80000228
7877 # write should trigger a retry and success
7878 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7879 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7881 if [ $RC -ne 0 ] ; then
7882 error "write should success, but failed for $RC"
7885 run_test 81a "OST should retry write when get -ENOSPC ==============="
7887 test_81b() { # LU-456
7888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7889 remote_ost_nodsh && skip "remote OST with nodsh"
7891 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7892 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
7893 do_facet ost1 lctl set_param fail_loc=0x228
7895 # write should retry several times and return -ENOSPC finally
7896 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7897 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7900 if [ $RC -ne $ENOSPC ] ; then
7901 error "dd should fail for -ENOSPC, but succeed."
7904 run_test 81b "OST should return -ENOSPC when retry still fails ======="
7906 test_82() { # LU-1031
7907 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
7911 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
7913 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
7915 kill -USR1 $MULTIPID2
7917 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
7918 error "First grouplock does not block second one"
7920 echo "Second grouplock blocks first one"
7922 kill -USR1 $MULTIPID1
7926 run_test 82 "Basic grouplock test"
7929 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
7931 test_mkdir $DIR/$tdir.cvsroot
7932 chown $RUNAS_ID $DIR/$tdir.cvsroot
7935 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
7938 # some versions of cvs import exit(1) when asked to import links or
7939 # files they can't read. ignore those files.
7940 local toignore=$(find . -type l -printf '-I %f\n' -o \
7941 ! -perm /4 -printf '-I %f\n')
7942 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
7943 $tdir.reposname vtag rtag
7946 test_mkdir $DIR/$tdir.reposname
7947 chown $RUNAS_ID $DIR/$tdir.reposname
7948 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
7950 cd $DIR/$tdir.reposname
7952 $RUNAS cvs add -m 'addmsg' foo99
7954 $RUNAS cvs commit -m 'nomsg' foo99
7955 rm -fr $DIR/$tdir.cvsroot
7957 run_test 99 "cvs strange file/directory operations"
7960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7961 [[ "$NETTYPE" =~ tcp ]] ||
7962 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
7963 remote_ost_nodsh && skip "remote OST with nodsh"
7964 remote_mds_nodsh && skip "remote MDS with nodsh"
7966 skip "useless for local single node setup"
7968 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
7969 [ "$PROT" != "tcp" ] && continue
7970 RPORT=$(echo $REMOTE | cut -d: -f2)
7971 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
7974 LPORT=`echo $LOCAL | cut -d: -f2`
7975 if [ $LPORT -ge 1024 ]; then
7976 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
7978 error_exit "local: $LPORT > 1024, remote: $RPORT"
7981 [ "$rc" = 0 ] || error_exit "privileged port not found" )
7983 run_test 100 "check local port using privileged port ==========="
7985 function get_named_value()
7994 echo $line | sed "s/^$tag[ ]*//"
8001 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
8002 awk '/^max_cached_mb/ { print $2 }')
8005 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
8010 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8011 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
8016 local cache_limit=32
8018 $LCTL set_param -n osc.*-osc*.rpc_stats 0
8019 trap cleanup_101a EXIT
8020 $LCTL set_param -n llite.*.read_ahead_stats 0
8021 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
8024 # randomly read 10000 of 64K chunks from file 3x 32MB in size
8026 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
8027 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
8030 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
8031 get_named_value 'read but discarded' | cut -d" " -f1); do
8032 discard=$(($discard + $s))
8036 if [[ $(($discard * 10)) -gt $nreads ]]; then
8037 $LCTL get_param osc.*-osc*.rpc_stats
8038 $LCTL get_param llite.*.read_ahead_stats
8039 error "too many ($discard) discarded pages"
8041 rm -f $DIR/$tfile || true
8043 run_test 101a "check read-ahead for random reads"
8046 test_mkdir $DIR/$tdir
8048 local FILE_LENGTH=$2
8051 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
8053 local list=$(comma_list $(osts_nodes))
8054 set_osd_param $list '' read_cache_enable 0
8055 set_osd_param $list '' writethrough_cache_enable 0
8057 trap cleanup_test101bc EXIT
8058 # prepare the read-ahead file
8059 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
8061 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
8062 count=$FILE_SIZE_MB 2> /dev/null
8066 cleanup_test101bc() {
8071 local list=$(comma_list $(osts_nodes))
8072 set_osd_param $list '' read_cache_enable 1
8073 set_osd_param $list '' writethrough_cache_enable 1
8077 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
8082 local STRIPE_SIZE=$2
8083 local FILE_LENGTH=$3
8084 local RA_INC=1048576
8085 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
8086 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
8087 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
8088 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
8089 get_named_value 'read but discarded' |
8090 cut -d" " -f1 | calc_total)
8091 if [[ $DISCARD -gt $discard_limit ]]; then
8092 $LCTL get_param llite.*.read_ahead_stats
8093 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
8095 echo "Read-ahead success for size ${READ_SIZE}"
8100 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8101 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8103 local STRIPE_SIZE=1048576
8104 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
8106 if [ $SLOW == "yes" ]; then
8107 local FILE_LENGTH=$((STRIDE_SIZE * 64))
8109 local FILE_LENGTH=$((STRIDE_SIZE * 8))
8112 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
8114 # prepare the read-ahead file
8115 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8116 cancel_lru_locks osc
8117 for BIDX in 2 4 8 16 32 64 128 256
8119 local BSIZE=$((BIDX*4096))
8120 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
8121 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
8122 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
8123 $LCTL set_param -n llite.*.read_ahead_stats 0
8124 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
8125 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
8126 cancel_lru_locks osc
8127 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
8132 run_test 101b "check stride-io mode read-ahead ================="
8135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8137 local STRIPE_SIZE=1048576
8138 local FILE_LENGTH=$((STRIPE_SIZE*100))
8143 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8145 cancel_lru_locks osc
8146 $LCTL set_param osc.*.rpc_stats 0
8147 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
8148 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
8149 local stats=$($LCTL get_param -n $osc_rpc_stats)
8150 local lines=$(echo "$stats" | awk 'END {print NR;}')
8153 if [ $lines -le 20 ]; then
8156 for size in 1 2 4 8; do
8157 local rpc=$(echo "$stats" |
8158 awk '($1 == "'$size':") {print $2; exit; }')
8159 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
8160 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
8162 echo "$osc_rpc_stats check passed!"
8167 run_test 101c "check stripe_size aligned read-ahead ================="
8170 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
8171 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
8175 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8177 local file=$DIR/$tfile
8178 local sz_MB=${FILESIZE_101d:-500}
8179 local ra_MB=${READAHEAD_MB:-40}
8181 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
8182 [ $free_MB -lt $sz_MB ] &&
8183 skip "Need free space ${sz_MB}M, have ${free_MB}M"
8185 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
8186 $LFS setstripe -c -1 $file || error "setstripe failed"
8188 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
8189 echo Cancel LRU locks on lustre client to flush the client cache
8190 cancel_lru_locks osc
8192 echo Disable read-ahead
8193 local old_READAHEAD=$(set_read_ahead 0)
8195 echo Reading the test file $file with read-ahead disabled
8196 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8198 echo Cancel LRU locks on lustre client to flush the client cache
8199 cancel_lru_locks osc
8200 echo Enable read-ahead with ${ra_MB}MB
8201 set_read_ahead $ra_MB
8203 echo Reading the test file $file with read-ahead enabled
8204 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8206 echo "read-ahead disabled time read $raOFF"
8207 echo "read-ahead enabled time read $raON"
8209 set_read_ahead $old_READAHEAD
8211 wait_delete_completed
8213 [ $raOFF -le 1 ] || [ $raON -lt $raOFF ] ||
8214 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
8216 run_test 101d "file read with and without read-ahead enabled"
8219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8221 local file=$DIR/$tfile
8222 local size_KB=500 #KB
8226 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
8227 local need_KB=$((count * size_KB))
8228 [[ $free_KB -le $need_KB ]] &&
8229 skip_env "Need free space $need_KB, have $free_KB"
8231 echo "Creating $count ${size_KB}K test files"
8232 for ((i = 0; i < $count; i++)); do
8233 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
8236 echo "Cancel LRU locks on lustre client to flush the client cache"
8237 cancel_lru_locks $OSC
8239 echo "Reset readahead stats"
8240 $LCTL set_param -n llite.*.read_ahead_stats 0
8242 for ((i = 0; i < $count; i++)); do
8243 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
8246 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8247 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8249 for ((i = 0; i < $count; i++)); do
8250 rm -rf $file.$i 2>/dev/null
8253 #10000 means 20% reads are missing in readahead
8254 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
8256 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
8259 which iozone || skip_env "no iozone installed"
8261 local old_debug=$($LCTL get_param debug)
8262 old_debug=${old_debug#*=}
8263 $LCTL set_param debug="reada mmap"
8265 # create a test file
8266 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
8268 echo Cancel LRU locks on lustre client to flush the client cache
8269 cancel_lru_locks osc
8271 echo Reset readahead stats
8272 $LCTL set_param -n llite.*.read_ahead_stats 0
8274 echo mmap read the file with small block size
8275 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
8278 echo checking missing pages
8279 $LCTL get_param llite.*.read_ahead_stats
8280 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8281 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8283 $LCTL set_param debug="$old_debug"
8284 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
8287 run_test 101f "check mmap read performance"
8289 test_101g_brw_size_test() {
8291 local pages=$((mb * 1048576 / PAGE_SIZE))
8292 local file=$DIR/$tfile
8294 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
8295 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
8296 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
8297 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
8301 stack_trap "rm -f $file" EXIT
8302 $LCTL set_param -n osc.*.rpc_stats=0
8304 # 10 RPCs should be enough for the test
8306 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
8307 { error "dd write ${mb} MB blocks failed"; return 3; }
8308 cancel_lru_locks osc
8309 dd of=/dev/null if=$file bs=${mb}M count=$count ||
8310 { error "dd write ${mb} MB blocks failed"; return 4; }
8312 # calculate number of full-sized read and write RPCs
8313 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
8314 sed -n '/pages per rpc/,/^$/p' |
8315 awk '/'$pages':/ { reads += $2; writes += $6 }; \
8316 END { print reads,writes }'))
8317 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
8319 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
8326 remote_ost_nodsh && skip "remote OST with nodsh"
8329 local osts=$(get_facets OST)
8330 local list=$(comma_list $(osts_nodes))
8331 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8332 local brw_size="obdfilter.*.brw_size"
8334 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8336 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
8338 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
8339 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
8340 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
8341 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
8342 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
8343 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
8345 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
8348 if [[ $orig_mb -lt 16 ]]; then
8349 save_lustre_params $osts "$brw_size" > $p
8350 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
8351 error "set 16MB RPC size failed"
8353 echo "remount client to enable new RPC size"
8354 remount_client $MOUNT || error "remount_client failed"
8357 test_101g_brw_size_test 16 || error "16MB RPC test failed"
8358 # should be able to set brw_size=12, but no rpc_stats for that
8359 test_101g_brw_size_test 8 || error "8MB RPC test failed"
8362 test_101g_brw_size_test 4 || error "4MB RPC test failed"
8364 if [[ $orig_mb -lt 16 ]]; then
8365 restore_lustre_params < $p
8366 remount_client $MOUNT || error "remount_client restore failed"
8369 rm -f $p $DIR/$tfile
8371 run_test 101g "Big bulk(4/16 MiB) readahead"
8374 test_mkdir $DIR/$tdir
8375 chown $RUNAS_ID $DIR/$tdir
8378 STRIPE_COUNT=$OSTCOUNT
8379 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
8381 trap cleanup_test102 EXIT
8383 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
8385 for num in 1 2 3 4; do
8386 for count in $(seq 1 $STRIPE_COUNT); do
8387 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
8388 local size=`expr $STRIPE_SIZE \* $num`
8389 local file=file"$num-$idx-$count"
8390 $1 $LFS setstripe -S $size -i $idx -c $count $file
8396 $1 tar cf $TMP/f102.tar $tdir --xattrs
8402 rm -rf $DIR/d0.sanity/d102
8406 [ "$UID" != 0 ] && skip "must run as root"
8407 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
8408 skip_env "must have user_xattr"
8410 [ -z "$(which setfattr 2>/dev/null)" ] &&
8411 skip_env "could not find setfattr"
8413 local testfile=$DIR/$tfile
8416 echo "set/get xattr..."
8417 setfattr -n trusted.name1 -v value1 $testfile ||
8418 error "setfattr -n trusted.name1=value1 $testfile failed"
8419 getfattr -n trusted.name1 $testfile 2> /dev/null |
8420 grep "trusted.name1=.value1" ||
8421 error "$testfile missing trusted.name1=value1"
8423 setfattr -n user.author1 -v author1 $testfile ||
8424 error "setfattr -n user.author1=author1 $testfile failed"
8425 getfattr -n user.author1 $testfile 2> /dev/null |
8426 grep "user.author1=.author1" ||
8427 error "$testfile missing trusted.author1=author1"
8430 setfattr -n trusted.name2 -v value2 $testfile ||
8431 error "$testfile unable to set trusted.name2"
8432 setfattr -n trusted.name3 -v value3 $testfile ||
8433 error "$testfile unable to set trusted.name3"
8434 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
8435 grep "trusted.name" | wc -l) -eq 3 ] ||
8436 error "$testfile missing 3 trusted.name xattrs"
8438 setfattr -n user.author2 -v author2 $testfile ||
8439 error "$testfile unable to set user.author2"
8440 setfattr -n user.author3 -v author3 $testfile ||
8441 error "$testfile unable to set user.author3"
8442 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
8443 grep "user.author" | wc -l) -eq 3 ] ||
8444 error "$testfile missing 3 user.author xattrs"
8446 echo "remove xattr..."
8447 setfattr -x trusted.name1 $testfile ||
8448 error "$testfile error deleting trusted.name1"
8449 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
8450 error "$testfile did not delete trusted.name1 xattr"
8452 setfattr -x user.author1 $testfile ||
8453 error "$testfile error deleting user.author1"
8454 echo "set lustre special xattr ..."
8455 $LFS setstripe -c1 $testfile
8456 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
8457 awk -F "=" '/trusted.lov/ { print $2 }' )
8458 setfattr -n "trusted.lov" -v $lovea $testfile ||
8459 error "$testfile doesn't ignore setting trusted.lov again"
8460 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
8461 error "$testfile allow setting invalid trusted.lov"
8464 run_test 102a "user xattr test =================================="
8467 [ -z "$(which setfattr 2>/dev/null)" ] &&
8468 skip_env "could not find setfattr"
8469 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8471 # b10930: get/set/list trusted.lov xattr
8472 echo "get/set/list trusted.lov xattr ..."
8473 local testfile=$DIR/$tfile
8474 $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8475 error "setstripe failed"
8476 local STRIPECOUNT=$($LFS getstripe -c $testfile) ||
8477 error "getstripe failed"
8478 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
8479 error "can't get trusted.lov from $testfile"
8481 local testfile2=${testfile}2
8482 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
8483 grep "trusted.lov" | sed -e 's/[^=]\+=//')
8486 setfattr -n trusted.lov -v $value $testfile2
8487 local stripe_size=$($LFS getstripe -S $testfile2)
8488 local stripe_count=$($LFS getstripe -c $testfile2)
8489 [[ $stripe_size -eq 65536 ]] ||
8490 error "stripe size $stripe_size != 65536"
8491 [[ $stripe_count -eq $STRIPECOUNT ]] ||
8492 error "stripe count $stripe_count != $STRIPECOUNT"
8495 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
8498 [ -z "$(which setfattr 2>/dev/null)" ] &&
8499 skip_env "could not find setfattr"
8500 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8502 # b10930: get/set/list lustre.lov xattr
8503 echo "get/set/list lustre.lov xattr ..."
8504 test_mkdir $DIR/$tdir
8505 chown $RUNAS_ID $DIR/$tdir
8506 local testfile=$DIR/$tdir/$tfile
8507 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8508 error "setstripe failed"
8509 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
8510 error "getstripe failed"
8511 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
8512 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
8514 local testfile2=${testfile}2
8515 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
8516 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8518 $RUNAS $MCREATE $testfile2
8519 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8520 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
8521 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
8522 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8523 [ $stripe_count -eq $STRIPECOUNT ] ||
8524 error "stripe count $stripe_count != $STRIPECOUNT"
8526 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8528 compare_stripe_info1() {
8529 local stripe_index_all_zero=true
8531 for num in 1 2 3 4; do
8532 for count in $(seq 1 $STRIPE_COUNT); do
8533 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8534 local size=$((STRIPE_SIZE * num))
8535 local file=file"$num-$offset-$count"
8536 stripe_size=$($LFS getstripe -S $PWD/$file)
8537 [[ $stripe_size -ne $size ]] &&
8538 error "$file: size $stripe_size != $size"
8539 stripe_count=$($LFS getstripe -c $PWD/$file)
8540 # allow fewer stripes to be created, ORI-601
8541 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8542 error "$file: count $stripe_count != $count"
8543 stripe_index=$($LFS getstripe -i $PWD/$file)
8544 [[ $stripe_index -ne 0 ]] &&
8545 stripe_index_all_zero=false
8549 $stripe_index_all_zero &&
8550 error "all files are being extracted starting from OST index 0"
8554 have_xattrs_include() {
8555 tar --help | grep -q xattrs-include &&
8556 echo --xattrs-include="lustre.*"
8560 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8561 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8563 XINC=$(have_xattrs_include)
8565 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8567 compare_stripe_info1
8569 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8572 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8573 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8575 XINC=$(have_xattrs_include)
8577 test_mkdir $DIR/$tdir.restore
8579 tar cf - --xattrs $tdir | tar xf - \
8580 -C $DIR/$tdir.restore --xattrs $XINC
8581 cd $DIR/$tdir.restore/$tdir
8582 compare_stripe_info1
8584 run_test 102f "tar copy files, not keep osts"
8587 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8588 skip "must have user_xattr"
8589 [ -z "$(which setfattr 2>/dev/null)" ] &&
8590 skip_env "could not find setfattr"
8591 [ -z "$(which getfattr 2>/dev/null)" ] &&
8592 skip_env "could not find getfattr"
8594 local xsize=${1:-1024} # in bytes
8595 local file=$DIR/$tfile
8596 local value="$(generate_string $xsize)"
8597 local xbig=trusted.big
8601 log "save $xbig on $file"
8604 setfattr -n $xbig -v $value $file ||
8605 error "saving $xbig on $file failed"
8607 setfattr -n $xbig -v $value $file &&
8608 error "saving $xbig on $file succeeded"
8612 local orig=$(get_xattr_value $xbig $file)
8613 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
8615 local xsml=trusted.sml
8616 log "save $xsml on $file"
8617 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
8619 local new=$(get_xattr_value $xbig $file)
8620 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
8622 log "grow $xsml on $file"
8623 setfattr -n $xsml -v "$value" $file ||
8624 error "growing $xsml on $file failed"
8626 new=$(get_xattr_value $xbig $file)
8627 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
8628 log "$xbig still valid after growing $xsml"
8633 test_102h() { # bug 15777
8636 run_test 102h "grow xattr from inside inode to external block"
8639 large_xattr_enabled || skip_env "ea_inode feature disabled"
8641 echo "setting xattr of max xattr size: $(max_xattr_size)"
8642 grow_xattr $(max_xattr_size)
8644 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
8645 echo "This should fail:"
8646 grow_xattr $(($(max_xattr_size) + 10)) 1
8648 run_test 102ha "grow xattr from inside inode to external inode"
8650 test_102i() { # bug 17038
8651 [ -z "$(which getfattr 2>/dev/null)" ] &&
8652 skip "could not find getfattr"
8655 ln -s $DIR/$tfile $DIR/${tfile}link
8656 getfattr -n trusted.lov $DIR/$tfile ||
8657 error "lgetxattr on $DIR/$tfile failed"
8658 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
8659 grep -i "no such attr" ||
8660 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
8661 rm -f $DIR/$tfile $DIR/${tfile}link
8663 run_test 102i "lgetxattr test on symbolic link ============"
8666 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8667 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8669 XINC=$(have_xattrs_include)
8670 setup_test102 "$RUNAS"
8671 chown $RUNAS_ID $DIR/$tdir
8672 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8674 compare_stripe_info1 "$RUNAS"
8676 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
8679 [ -z "$(which setfattr 2>/dev/null)" ] &&
8680 skip "could not find setfattr"
8683 # b22187 just check that does not crash for regular file.
8684 setfattr -n trusted.lov $DIR/$tfile
8685 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
8686 local test_kdir=$DIR/$tdir
8687 test_mkdir $test_kdir
8688 local default_size=$($LFS getstripe -S $test_kdir)
8689 local default_count=$($LFS getstripe -c $test_kdir)
8690 local default_offset=$($LFS getstripe -i $test_kdir)
8691 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
8692 error 'dir setstripe failed'
8693 setfattr -n trusted.lov $test_kdir
8694 local stripe_size=$($LFS getstripe -S $test_kdir)
8695 local stripe_count=$($LFS getstripe -c $test_kdir)
8696 local stripe_offset=$($LFS getstripe -i $test_kdir)
8697 [ $stripe_size -eq $default_size ] ||
8698 error "stripe size $stripe_size != $default_size"
8699 [ $stripe_count -eq $default_count ] ||
8700 error "stripe count $stripe_count != $default_count"
8701 [ $stripe_offset -eq $default_offset ] ||
8702 error "stripe offset $stripe_offset != $default_offset"
8703 rm -rf $DIR/$tfile $test_kdir
8705 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
8708 [ -z "$(which getfattr 2>/dev/null)" ] &&
8709 skip "could not find getfattr"
8711 # LU-532 trusted. xattr is invisible to non-root
8712 local testfile=$DIR/$tfile
8716 echo "listxattr as user..."
8717 chown $RUNAS_ID $testfile
8718 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
8719 grep -q "trusted" &&
8720 error "$testfile trusted xattrs are user visible"
8724 run_test 102l "listxattr size test =================================="
8726 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
8727 local path=$DIR/$tfile
8730 listxattr_size_check $path || error "listattr_size_check $path failed"
8732 run_test 102m "Ensure listxattr fails on small bufffer ========"
8736 getxattr() { # getxattr path name
8737 # Return the base64 encoding of the value of xattr name on path.
8741 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
8743 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8745 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8747 getfattr --absolute-names --encoding=base64 --name=$name $path |
8748 awk -F= -v name=$name '$1 == name {
8749 print substr($0, index($0, "=") + 1);
8753 test_102n() { # LU-4101 mdt: protect internal xattrs
8754 [ -z "$(which setfattr 2>/dev/null)" ] &&
8755 skip "could not find setfattr"
8756 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
8758 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
8761 local file0=$DIR/$tfile.0
8762 local file1=$DIR/$tfile.1
8763 local xattr0=$TMP/$tfile.0
8764 local xattr1=$TMP/$tfile.1
8765 local namelist="lov lma lmv link fid version som hsm"
8769 rm -rf $file0 $file1 $xattr0 $xattr1
8772 # Get 'before' xattrs of $file1.
8773 getfattr --absolute-names --dump --match=- $file1 > $xattr0
8775 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
8776 namelist+=" lfsck_namespace"
8777 for name in $namelist; do
8778 # Try to copy xattr from $file0 to $file1.
8779 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8781 setfattr --name=trusted.$name --value="$value" $file1 ||
8782 error "setxattr 'trusted.$name' failed"
8784 # Try to set a garbage xattr.
8785 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8787 if [[ x$name == "xlov" ]]; then
8788 setfattr --name=trusted.lov --value="$value" $file1 &&
8789 error "setxattr invalid 'trusted.lov' success"
8791 setfattr --name=trusted.$name --value="$value" $file1 ||
8792 error "setxattr invalid 'trusted.$name' failed"
8795 # Try to remove the xattr from $file1. We don't care if this
8796 # appears to succeed or fail, we just don't want there to be
8797 # any changes or crashes.
8798 setfattr --remove=$trusted.$name $file1 2> /dev/null
8801 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
8804 # Try to copy xattr from $file0 to $file1.
8805 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8807 setfattr --name=trusted.$name --value="$value" $file1 ||
8808 error "setxattr 'trusted.$name' failed"
8810 # Try to set a garbage xattr.
8811 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8813 setfattr --name=trusted.$name --value="$value" $file1 ||
8814 error "setxattr 'trusted.$name' failed"
8816 # Try to remove the xattr from $file1. We don't care if this
8817 # appears to succeed or fail, we just don't want there to be
8818 # any changes or crashes.
8819 setfattr --remove=$trusted.$name $file1 2> /dev/null
8822 # Get 'after' xattrs of file1.
8823 getfattr --absolute-names --dump --match=- $file1 > $xattr1
8825 if ! diff $xattr0 $xattr1; then
8826 error "before and after xattrs of '$file1' differ"
8829 rm -rf $file0 $file1 $xattr0 $xattr1
8833 run_test 102n "silently ignore setxattr on internal trusted xattrs"
8835 test_102p() { # LU-4703 setxattr did not check ownership
8836 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
8837 skip "MDS needs to be at least 2.5.56"
8839 local testfile=$DIR/$tfile
8843 echo "setfacl as user..."
8844 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
8845 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
8847 echo "setfattr as user..."
8848 setfacl -m "u:$RUNAS_ID:---" $testfile
8849 $RUNAS setfattr -x system.posix_acl_access $testfile
8850 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
8852 run_test 102p "check setxattr(2) correctly fails without permission"
8855 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
8856 skip "MDS needs to be at least 2.6.92"
8858 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
8860 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
8863 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
8864 skip "MDS needs to be at least 2.6.93"
8866 touch $DIR/$tfile || error "touch"
8867 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
8868 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
8869 rm $DIR/$tfile || error "rm"
8872 mkdir -p $DIR/$tdir || error "mkdir"
8873 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8874 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8875 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8876 error "$testfile error deleting user.author1"
8877 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8878 grep "user.$(basename $tdir)" &&
8879 error "$tdir did not delete user.$(basename $tdir)"
8880 rmdir $DIR/$tdir || error "rmdir"
8883 test_mkdir $DIR/$tdir
8884 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8885 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8886 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8887 error "$testfile error deleting user.author1"
8888 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8889 grep "user.$(basename $tdir)" &&
8890 error "$tdir did not delete user.$(basename $tdir)"
8891 rmdir $DIR/$tdir || error "rm striped dir"
8893 run_test 102r "set EAs with empty values"
8896 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
8897 skip "MDS needs to be at least 2.11.52"
8899 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
8901 save_lustre_params client "llite.*.xattr_cache" > $save
8903 for cache in 0 1; do
8904 lctl set_param llite.*.xattr_cache=$cache
8907 touch $DIR/$tfile || error "touch"
8908 for prefix in lustre security system trusted user; do
8909 # Note getxattr() may fail with 'Operation not
8910 # supported' or 'No such attribute' depending
8911 # on prefix and cache.
8912 getfattr -n $prefix.n102s $DIR/$tfile &&
8913 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
8917 restore_lustre_params < $save
8919 run_test 102s "getting nonexistent xattrs should fail"
8922 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
8923 skip "MDS needs to be at least 2.11.52"
8925 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
8927 save_lustre_params client "llite.*.xattr_cache" > $save
8929 for cache in 0 1; do
8930 lctl set_param llite.*.xattr_cache=$cache
8932 for buf_size in 0 256; do
8934 touch $DIR/$tfile || error "touch"
8935 setfattr -n user.multiop $DIR/$tfile
8936 $MULTIOP $DIR/$tfile oa$buf_size ||
8937 error "cannot get zero length xattr value (buf_size = $buf_size)"
8941 restore_lustre_params < $save
8943 run_test 102t "zero length xattr values handled correctly"
8947 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
8952 [ "$UID" != 0 ] && skip "must run as root"
8953 $GSS && skip_env "could not run under gss"
8954 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
8955 skip_env "must have acl enabled"
8956 [ -z "$(which setfacl 2>/dev/null)" ] &&
8957 skip_env "could not find setfacl"
8958 remote_mds_nodsh && skip "remote MDS with nodsh"
8960 gpasswd -a daemon bin # LU-5641
8961 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
8963 declare -a identity_old
8965 for num in $(seq $MDSCOUNT); do
8966 switch_identity $num true || identity_old[$num]=$?
8974 echo "performing cp ..."
8975 run_acl_subtest cp || error "run_acl_subtest cp failed"
8976 echo "performing getfacl-noacl..."
8977 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
8978 echo "performing misc..."
8979 run_acl_subtest misc || error "misc test failed"
8980 echo "performing permissions..."
8981 run_acl_subtest permissions || error "permissions failed"
8982 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
8983 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
8984 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
8985 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
8987 echo "performing permissions xattr..."
8988 run_acl_subtest permissions_xattr ||
8989 error "permissions_xattr failed"
8991 echo "performing setfacl..."
8992 run_acl_subtest setfacl || error "setfacl test failed"
8994 # inheritance test got from HP
8995 echo "performing inheritance..."
8996 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
8997 chmod +x make-tree || error "chmod +x failed"
8998 run_acl_subtest inheritance || error "inheritance test failed"
9001 echo "LU-974 ignore umask when acl is enabled..."
9002 run_acl_subtest 974 || error "LU-974 umask test failed"
9003 if [ $MDSCOUNT -ge 2 ]; then
9004 run_acl_subtest 974_remote ||
9005 error "LU-974 umask test failed under remote dir"
9008 echo "LU-2561 newly created file is same size as directory..."
9009 if [ "$mds1_FSTYPE" != "zfs" ]; then
9010 run_acl_subtest 2561 || error "LU-2561 test failed"
9012 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
9015 run_acl_subtest 4924 || error "LU-4924 test failed"
9020 for num in $(seq $MDSCOUNT); do
9021 if [ "${identity_old[$num]}" = 1 ]; then
9022 switch_identity $num false || identity_old[$num]=$?
9026 run_test 103a "acl test"
9032 for U in {0..511}; do
9034 local O=$(printf "%04o" $U)
9036 umask $(printf "%04o" $((511 ^ $O)))
9037 $LFS setstripe -c 1 $DIR/$tfile.s$O
9038 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
9040 (( $S == ($O & 0666) )) ||
9041 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
9043 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
9044 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
9045 (( $S == ($O & 0666) )) ||
9046 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
9048 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
9049 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
9050 (( $S == ($O & 0666) )) ||
9051 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
9052 rm -f $DIR/$tfile.[smp]$0
9056 # limit the concurrently running threads to 64. LU-11878
9057 local idx=$((U % 64))
9058 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
9063 run_test 103b "umask lfs setstripe"
9067 cp -rp $DIR/$tdir $DIR/$tdir.bak
9069 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
9070 error "$DIR/$tdir shouldn't contain default ACL"
9071 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
9072 error "$DIR/$tdir.bak shouldn't contain default ACL"
9075 run_test 103c "'cp -rp' won't set empty acl"
9078 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9081 lfs df || error "lfs df failed"
9082 lfs df -ih || error "lfs df -ih failed"
9083 lfs df -h $DIR || error "lfs df -h $DIR failed"
9084 lfs df -i $DIR || error "lfs df -i $DIR failed"
9085 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
9086 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
9088 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
9089 lctl --device %$OSC deactivate
9090 lfs df || error "lfs df with deactivated OSC failed"
9091 lctl --device %$OSC activate
9092 # wait the osc back to normal
9093 wait_osc_import_ready client ost
9095 lfs df || error "lfs df with reactivated OSC failed"
9098 run_test 104a "lfs df [-ih] [path] test ========================="
9101 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9102 [ $RUNAS_ID -eq $UID ] &&
9103 skip_env "RUNAS_ID = UID = $UID -- skipping"
9105 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
9106 grep "Permission denied" | wc -l)))
9107 if [ $denied_cnt -ne 0 ]; then
9108 error "lfs check servers test failed"
9111 run_test 104b "$RUNAS lfs check servers test ===================="
9114 # doesn't work on 2.4 kernels
9116 if $(flock_is_enabled); then
9117 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
9119 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
9123 run_test 105a "flock when mounted without -o flock test ========"
9127 if $(flock_is_enabled); then
9128 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
9130 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
9134 run_test 105b "fcntl when mounted without -o flock test ========"
9138 if $(flock_is_enabled); then
9139 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
9141 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
9145 run_test 105c "lockf when mounted without -o flock test"
9147 test_105d() { # bug 15924
9148 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9150 test_mkdir $DIR/$tdir
9151 flock_is_enabled || skip_env "mount w/o flock enabled"
9152 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
9153 $LCTL set_param fail_loc=0x80000315
9154 flocks_test 2 $DIR/$tdir
9156 run_test 105d "flock race (should not freeze) ========"
9158 test_105e() { # bug 22660 && 22040
9159 flock_is_enabled || skip_env "mount w/o flock enabled"
9162 flocks_test 3 $DIR/$tfile
9164 run_test 105e "Two conflicting flocks from same process"
9166 test_106() { #bug 10921
9167 test_mkdir $DIR/$tdir
9168 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
9169 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
9171 run_test 106 "attempt exec of dir followed by chown of that dir"
9174 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9182 local save_pattern=$(sysctl -n kernel.core_pattern)
9183 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
9184 sysctl -w kernel.core_pattern=$file
9185 sysctl -w kernel.core_uses_pid=0
9193 kill -s 11 $SLEEPPID
9195 if [ -e $file ]; then
9196 size=`stat -c%s $file`
9197 [ $size -eq 0 ] && error "Fail to create core file $file"
9199 error "Fail to create core file $file"
9202 sysctl -w kernel.core_pattern=$save_pattern
9203 sysctl -w kernel.core_uses_pid=$save_uses_pid
9206 run_test 107 "Coredump on SIG"
9209 test_mkdir $DIR/$tdir
9210 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
9211 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
9212 error "mkdir with 256 char should fail, but did not"
9213 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
9214 error "create with 255 char failed"
9215 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
9216 error "create with 256 char should fail, but did not"
9221 run_test 110 "filename length checking"
9224 # Purpose: To verify dynamic thread (OSS) creation.
9227 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9228 remote_ost_nodsh && skip "remote OST with nodsh"
9230 # Lustre does not stop service threads once they are started.
9231 # Reset number of running threads to default.
9236 local save_params="$TMP/sanity-$TESTNAME.parameters"
9238 # Get ll_ost_io count before I/O
9239 OSTIO_pre=$(do_facet ost1 \
9240 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
9241 # Exit if lustre is not running (ll_ost_io not running).
9242 [ -z "$OSTIO_pre" ] && error "no OSS threads"
9244 echo "Starting with $OSTIO_pre threads"
9245 local thread_max=$((OSTIO_pre * 2))
9246 local rpc_in_flight=$((thread_max * 2))
9247 # Number of I/O Process proposed to be started.
9249 local facets=$(get_facets OST)
9251 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
9252 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
9254 # Set in_flight to $rpc_in_flight
9255 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
9256 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
9257 nfiles=${rpc_in_flight}
9258 # Set ost thread_max to $thread_max
9259 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
9261 # 5 Minutes should be sufficient for max number of OSS
9262 # threads(thread_max) to be created.
9266 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
9267 test_mkdir $DIR/$tdir
9268 for i in $(seq $nfiles); do
9269 local file=$DIR/$tdir/${tfile}-$i
9270 $LFS setstripe -c -1 -i 0 $file
9271 ($WTL $file $timeout)&
9274 # I/O Started - Wait for thread_started to reach thread_max or report
9275 # error if thread_started is more than thread_max.
9276 echo "Waiting for thread_started to reach thread_max"
9277 local thread_started=0
9278 local end_time=$((SECONDS + timeout))
9280 while [ $SECONDS -le $end_time ] ; do
9282 # Get ost i/o thread_started count.
9283 thread_started=$(do_facet ost1 \
9285 ost.OSS.ost_io.threads_started | cut -d= -f2")
9286 # Break out if thread_started is equal/greater than thread_max
9287 if [[ $thread_started -ge $thread_max ]]; then
9288 echo ll_ost_io thread_started $thread_started, \
9289 equal/greater than thread_max $thread_max
9295 # Cleanup - We have the numbers, Kill i/o jobs if running.
9296 jobcount=($(jobs -p))
9297 for i in $(seq 0 $((${#jobcount[@]}-1)))
9299 kill -9 ${jobcount[$i]}
9300 if [ $? -ne 0 ] ; then
9302 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
9306 # Cleanup files left by WTL binary.
9307 for i in $(seq $nfiles); do
9308 local file=$DIR/$tdir/${tfile}-$i
9310 if [ $? -ne 0 ] ; then
9311 echo "Warning: Failed to delete file $file"
9315 restore_lustre_params <$save_params
9316 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
9318 # Error out if no new thread has started or Thread started is greater
9320 if [[ $thread_started -le $OSTIO_pre ||
9321 $thread_started -gt $thread_max ]]; then
9322 error "ll_ost_io: thread_started $thread_started" \
9323 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
9324 "No new thread started or thread started greater " \
9328 run_test 115 "verify dynamic thread creation===================="
9331 wait_delete_completed
9332 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
9333 echo "OST kbytes available: ${AVAIL[@]}"
9338 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
9339 #echo OST $i: ${AVAIL[i]}kb
9340 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
9344 if [[ ${AVAIL[i]} -lt $MINV ]]; then
9349 echo "Min free space: OST $MINI: $MINV"
9350 echo "Max free space: OST $MAXI: $MAXV"
9353 test_116a() { # was previously test_116()
9354 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9355 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9356 remote_mds_nodsh && skip "remote MDS with nodsh"
9358 echo -n "Free space priority "
9359 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
9364 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
9365 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
9366 trap simple_cleanup_common EXIT
9368 # Check if we need to generate uneven OSTs
9369 test_mkdir -p $DIR/$tdir/OST${MINI}
9370 local FILL=$((MINV / 4))
9371 local DIFF=$((MAXV - MINV))
9372 local DIFF2=$((DIFF * 100 / MINV))
9374 local threshold=$(do_facet $SINGLEMDS \
9375 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
9376 threshold=${threshold%%%}
9377 echo -n "Check for uneven OSTs: "
9378 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
9380 if [[ $DIFF2 -gt $threshold ]]; then
9382 echo "Don't need to fill OST$MINI"
9384 # generate uneven OSTs. Write 2% over the QOS threshold value
9386 DIFF=$((threshold - DIFF2 + 2))
9387 DIFF2=$((MINV * DIFF / 100))
9388 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
9389 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
9390 error "setstripe failed"
9391 DIFF=$((DIFF2 / 2048))
9393 while [ $i -lt $DIFF ]; do
9395 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
9396 bs=2M count=1 2>/dev/null
9405 DIFF=$((MAXV - MINV))
9406 DIFF2=$((DIFF * 100 / MINV))
9407 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
9408 if [ $DIFF2 -gt $threshold ]; then
9411 echo "failed - QOS mode won't be used"
9412 simple_cleanup_common
9413 skip "QOS imbalance criteria not met"
9421 # now fill using QOS
9422 $LFS setstripe -c 1 $DIR/$tdir
9423 FILL=$((FILL / 200))
9424 if [ $FILL -gt 600 ]; then
9427 echo "writing $FILL files to QOS-assigned OSTs"
9429 while [ $i -lt $FILL ]; do
9431 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
9435 echo "wrote $i 200k files"
9439 echo "Note: free space may not be updated, so measurements might be off"
9441 DIFF2=$((MAXV - MINV))
9442 echo "free space delta: orig $DIFF final $DIFF2"
9443 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
9444 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
9445 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
9446 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
9447 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
9448 if [[ $DIFF -gt 0 ]]; then
9449 FILL=$((DIFF2 * 100 / DIFF - 100))
9450 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
9453 # Figure out which files were written where
9454 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9455 awk '/'$MINI1': / {print $2; exit}')
9457 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9458 echo "$MINC files created on smaller OST $MINI1"
9459 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9460 awk '/'$MAXI1': / {print $2; exit}')
9462 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9463 echo "$MAXC files created on larger OST $MAXI1"
9464 if [[ $MINC -gt 0 ]]; then
9465 FILL=$((MAXC * 100 / MINC - 100))
9466 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
9468 [[ $MAXC -gt $MINC ]] ||
9469 error_ignore LU-9 "stripe QOS didn't balance free space"
9470 simple_cleanup_common
9472 run_test 116a "stripe QOS: free space balance ==================="
9474 test_116b() { # LU-2093
9475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9476 remote_mds_nodsh && skip "remote MDS with nodsh"
9478 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
9479 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
9480 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
9481 [ -z "$old_rr" ] && skip "no QOS"
9482 do_facet $SINGLEMDS lctl set_param \
9483 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
9485 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
9486 createmany -o $DIR/$tdir/f- 20 || error "can't create"
9487 do_facet $SINGLEMDS lctl set_param fail_loc=0
9489 do_facet $SINGLEMDS lctl set_param \
9490 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
9492 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
9494 test_117() # bug 10891
9496 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9498 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
9499 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
9500 lctl set_param fail_loc=0x21e
9501 > $DIR/$tfile || error "truncate failed"
9502 lctl set_param fail_loc=0
9503 echo "Truncate succeeded."
9506 run_test 117 "verify osd extend =========="
9508 NO_SLOW_RESENDCOUNT=4
9509 export OLD_RESENDCOUNT=""
9510 set_resend_count () {
9511 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
9512 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
9513 lctl set_param -n $PROC_RESENDCOUNT $1
9514 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
9517 # for reduce test_118* time (b=14842)
9518 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9520 # Reset async IO behavior after error case
9522 FILE=$DIR/reset_async
9524 # Ensure all OSCs are cleared
9525 $LFS setstripe -c -1 $FILE
9526 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
9531 test_118a() #bug 11710
9533 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9537 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9538 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9539 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9541 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9542 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9547 run_test 118a "verify O_SYNC works =========="
9551 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9552 remote_ost_nodsh && skip "remote OST with nodsh"
9556 #define OBD_FAIL_SRV_ENOENT 0x217
9557 set_nodes_failloc "$(osts_nodes)" 0x217
9558 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9560 set_nodes_failloc "$(osts_nodes)" 0
9561 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9562 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9565 if [[ $RC -eq 0 ]]; then
9566 error "Must return error due to dropped pages, rc=$RC"
9570 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9571 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9575 echo "Dirty pages not leaked on ENOENT"
9577 # Due to the above error the OSC will issue all RPCs syncronously
9578 # until a subsequent RPC completes successfully without error.
9579 $MULTIOP $DIR/$tfile Ow4096yc
9584 run_test 118b "Reclaim dirty pages on fatal error =========="
9588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9590 # for 118c, restore the original resend count, LU-1940
9591 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
9592 set_resend_count $OLD_RESENDCOUNT
9593 remote_ost_nodsh && skip "remote OST with nodsh"
9597 #define OBD_FAIL_OST_EROFS 0x216
9598 set_nodes_failloc "$(osts_nodes)" 0x216
9600 # multiop should block due to fsync until pages are written
9601 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9605 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9606 error "Multiop failed to block on fsync, pid=$MULTIPID"
9609 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9611 if [[ $WRITEBACK -eq 0 ]]; then
9612 error "No page in writeback, writeback=$WRITEBACK"
9615 set_nodes_failloc "$(osts_nodes)" 0
9618 if [[ $RC -ne 0 ]]; then
9619 error "Multiop fsync failed, rc=$RC"
9622 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9623 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9625 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9626 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9630 echo "Dirty pages flushed via fsync on EROFS"
9633 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
9635 # continue to use small resend count to reduce test_118* time (b=14842)
9636 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9641 remote_ost_nodsh && skip "remote OST with nodsh"
9645 #define OBD_FAIL_OST_BRW_PAUSE_BULK
9646 set_nodes_failloc "$(osts_nodes)" 0x214
9647 # multiop should block due to fsync until pages are written
9648 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9652 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9653 error "Multiop failed to block on fsync, pid=$MULTIPID"
9656 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9658 if [[ $WRITEBACK -eq 0 ]]; then
9659 error "No page in writeback, writeback=$WRITEBACK"
9662 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
9663 set_nodes_failloc "$(osts_nodes)" 0
9665 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9666 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9668 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9669 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9673 echo "Dirty pages gaurenteed flushed via fsync"
9676 run_test 118d "Fsync validation inject a delay of the bulk =========="
9679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9683 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
9684 lctl set_param fail_loc=0x8000040a
9686 # Should simulate EINVAL error which is fatal
9687 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9689 if [[ $RC -eq 0 ]]; then
9690 error "Must return error due to dropped pages, rc=$RC"
9693 lctl set_param fail_loc=0x0
9695 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9696 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9697 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9699 if [[ $LOCKED -ne 0 ]]; then
9700 error "Locked pages remain in cache, locked=$LOCKED"
9703 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9704 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9708 echo "No pages locked after fsync"
9713 run_test 118f "Simulate unrecoverable OSC side error =========="
9716 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9720 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9721 lctl set_param fail_loc=0x406
9723 # simulate local -ENOMEM
9724 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9727 lctl set_param fail_loc=0
9728 if [[ $RC -eq 0 ]]; then
9729 error "Must return error due to dropped pages, rc=$RC"
9732 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9733 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9734 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9736 if [[ $LOCKED -ne 0 ]]; then
9737 error "Locked pages remain in cache, locked=$LOCKED"
9740 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9741 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9745 echo "No pages locked after fsync"
9750 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
9753 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9754 remote_ost_nodsh && skip "remote OST with nodsh"
9758 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9759 set_nodes_failloc "$(osts_nodes)" 0x20e
9760 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9761 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9764 set_nodes_failloc "$(osts_nodes)" 0
9765 if [[ $RC -eq 0 ]]; then
9766 error "Must return error due to dropped pages, rc=$RC"
9769 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9770 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9771 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9773 if [[ $LOCKED -ne 0 ]]; then
9774 error "Locked pages remain in cache, locked=$LOCKED"
9777 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9778 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9782 echo "No pages locked after fsync"
9786 run_test 118h "Verify timeout in handling recoverables errors =========="
9788 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9792 remote_ost_nodsh && skip "remote OST with nodsh"
9796 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9797 set_nodes_failloc "$(osts_nodes)" 0x20e
9799 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9800 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9803 set_nodes_failloc "$(osts_nodes)" 0
9807 if [[ $RC -ne 0 ]]; then
9808 error "got error, but should be not, rc=$RC"
9811 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9812 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9813 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9814 if [[ $LOCKED -ne 0 ]]; then
9815 error "Locked pages remain in cache, locked=$LOCKED"
9818 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9819 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9823 echo "No pages locked after fsync"
9827 run_test 118i "Fix error before timeout in recoverable error =========="
9829 [ "$SLOW" = "no" ] && set_resend_count 4
9832 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9833 remote_ost_nodsh && skip "remote OST with nodsh"
9837 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
9838 set_nodes_failloc "$(osts_nodes)" 0x220
9840 # return -EIO from OST
9841 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9843 set_nodes_failloc "$(osts_nodes)" 0x0
9844 if [[ $RC -eq 0 ]]; then
9845 error "Must return error due to dropped pages, rc=$RC"
9848 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9849 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9850 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9851 if [[ $LOCKED -ne 0 ]]; then
9852 error "Locked pages remain in cache, locked=$LOCKED"
9855 # in recoverable error on OST we want resend and stay until it finished
9856 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9857 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9861 echo "No pages locked after fsync"
9865 run_test 118j "Simulate unrecoverable OST side error =========="
9869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9870 remote_ost_nodsh && skip "remote OSTs with nodsh"
9872 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9873 set_nodes_failloc "$(osts_nodes)" 0x20e
9874 test_mkdir $DIR/$tdir
9876 for ((i=0;i<10;i++)); do
9877 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
9878 error "dd to $DIR/$tdir/$tfile-$i failed" )&
9885 set_nodes_failloc "$(osts_nodes)" 0
9888 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
9890 test_118l() # LU-646
9892 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9894 test_mkdir $DIR/$tdir
9895 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
9898 run_test 118l "fsync dir"
9900 test_118m() # LU-3066
9902 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9904 test_mkdir $DIR/$tdir
9905 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
9908 run_test 118m "fdatasync dir ========="
9910 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9918 remote_ost_nodsh && skip "remote OSTs with nodsh"
9920 # Sleep to avoid a cached response.
9921 #define OBD_STATFS_CACHE_SECONDS 1
9924 # Inject a 10 second delay in the OST_STATFS handler.
9925 #define OBD_FAIL_OST_STATFS_DELAY 0x242
9926 set_nodes_failloc "$(osts_nodes)" 0x242
9929 stat --file-system $MOUNT > /dev/null
9932 set_nodes_failloc "$(osts_nodes)" 0
9934 if ((end - begin > 20)); then
9935 error "statfs took $((end - begin)) seconds, expected 10"
9938 run_test 118n "statfs() sends OST_STATFS requests in parallel"
9940 test_119a() # bug 11737
9942 BSIZE=$((512 * 1024))
9943 directio write $DIR/$tfile 0 1 $BSIZE
9944 # We ask to read two blocks, which is more than a file size.
9945 # directio will indicate an error when requested and actual
9946 # sizes aren't equeal (a normal situation in this case) and
9947 # print actual read amount.
9948 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
9949 if [ "$NOB" != "$BSIZE" ]; then
9950 error "read $NOB bytes instead of $BSIZE"
9954 run_test 119a "Short directIO read must return actual read amount"
9956 test_119b() # bug 11737
9958 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9960 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
9961 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
9963 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
9964 error "direct read failed"
9967 run_test 119b "Sparse directIO read must return actual read amount"
9969 test_119c() # bug 13099
9972 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
9973 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
9976 run_test 119c "Testing for direct read hitting hole"
9978 test_119d() # bug 15950
9980 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9982 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
9983 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
9985 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
9986 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
9987 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
9988 lctl set_param fail_loc=0x40d
9989 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
9992 cat $DIR/$tfile > /dev/null &
9993 lctl set_param fail_loc=0
9996 log "the DIO writes have completed, now wait for the reads (should not block very long)"
9998 [ -n "`ps h -p $pid_reads -o comm`" ] && \
9999 error "the read rpcs have not completed in 2s"
10001 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
10003 run_test 119d "The DIO path should try to send a new rpc once one is completed"
10006 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10007 remote_mds_nodsh && skip "remote MDS with nodsh"
10008 test_mkdir -i0 -c1 $DIR/$tdir
10009 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10010 skip_env "no early lock cancel on server"
10012 lru_resize_disable mdc
10013 lru_resize_disable osc
10014 cancel_lru_locks mdc
10015 # asynchronous object destroy at MDT could cause bl ast to client
10016 cancel_lru_locks osc
10018 stat $DIR/$tdir > /dev/null
10019 can1=$(do_facet mds1 \
10020 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10021 awk '/ldlm_cancel/ {print $2}')
10022 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10023 awk '/ldlm_bl_callback/ {print $2}')
10024 test_mkdir -i0 -c1 $DIR/$tdir/d1
10025 can2=$(do_facet mds1 \
10026 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10027 awk '/ldlm_cancel/ {print $2}')
10028 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10029 awk '/ldlm_bl_callback/ {print $2}')
10030 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10031 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10032 lru_resize_enable mdc
10033 lru_resize_enable osc
10035 run_test 120a "Early Lock Cancel: mkdir test"
10038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10039 remote_mds_nodsh && skip "remote MDS with nodsh"
10040 test_mkdir $DIR/$tdir
10041 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10042 skip_env "no early lock cancel on server"
10044 lru_resize_disable mdc
10045 lru_resize_disable osc
10046 cancel_lru_locks mdc
10047 stat $DIR/$tdir > /dev/null
10048 can1=$(do_facet $SINGLEMDS \
10049 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10050 awk '/ldlm_cancel/ {print $2}')
10051 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10052 awk '/ldlm_bl_callback/ {print $2}')
10053 touch $DIR/$tdir/f1
10054 can2=$(do_facet $SINGLEMDS \
10055 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10056 awk '/ldlm_cancel/ {print $2}')
10057 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10058 awk '/ldlm_bl_callback/ {print $2}')
10059 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10060 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10061 lru_resize_enable mdc
10062 lru_resize_enable osc
10064 run_test 120b "Early Lock Cancel: create test"
10067 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10068 remote_mds_nodsh && skip "remote MDS with nodsh"
10069 test_mkdir -i0 -c1 $DIR/$tdir
10070 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10071 skip "no early lock cancel on server"
10073 lru_resize_disable mdc
10074 lru_resize_disable osc
10075 test_mkdir -i0 -c1 $DIR/$tdir/d1
10076 test_mkdir -i0 -c1 $DIR/$tdir/d2
10077 touch $DIR/$tdir/d1/f1
10078 cancel_lru_locks mdc
10079 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
10080 can1=$(do_facet mds1 \
10081 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10082 awk '/ldlm_cancel/ {print $2}')
10083 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10084 awk '/ldlm_bl_callback/ {print $2}')
10085 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10086 can2=$(do_facet mds1 \
10087 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10088 awk '/ldlm_cancel/ {print $2}')
10089 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10090 awk '/ldlm_bl_callback/ {print $2}')
10091 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10092 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10093 lru_resize_enable mdc
10094 lru_resize_enable osc
10096 run_test 120c "Early Lock Cancel: link test"
10099 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10100 remote_mds_nodsh && skip "remote MDS with nodsh"
10101 test_mkdir -i0 -c1 $DIR/$tdir
10102 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10103 skip_env "no early lock cancel on server"
10105 lru_resize_disable mdc
10106 lru_resize_disable osc
10108 cancel_lru_locks mdc
10109 stat $DIR/$tdir > /dev/null
10110 can1=$(do_facet mds1 \
10111 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10112 awk '/ldlm_cancel/ {print $2}')
10113 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10114 awk '/ldlm_bl_callback/ {print $2}')
10115 chmod a+x $DIR/$tdir
10116 can2=$(do_facet mds1 \
10117 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10118 awk '/ldlm_cancel/ {print $2}')
10119 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10120 awk '/ldlm_bl_callback/ {print $2}')
10121 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10122 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10123 lru_resize_enable mdc
10124 lru_resize_enable osc
10126 run_test 120d "Early Lock Cancel: setattr test"
10129 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10130 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10131 skip_env "no early lock cancel on server"
10132 remote_mds_nodsh && skip "remote MDS with nodsh"
10134 local dlmtrace_set=false
10136 test_mkdir -i0 -c1 $DIR/$tdir
10137 lru_resize_disable mdc
10138 lru_resize_disable osc
10139 ! $LCTL get_param debug | grep -q dlmtrace &&
10140 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
10141 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
10142 cancel_lru_locks mdc
10143 cancel_lru_locks osc
10144 dd if=$DIR/$tdir/f1 of=/dev/null
10145 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
10146 # XXX client can not do early lock cancel of OST lock
10147 # during unlink (LU-4206), so cancel osc lock now.
10149 cancel_lru_locks osc
10150 can1=$(do_facet mds1 \
10151 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10152 awk '/ldlm_cancel/ {print $2}')
10153 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10154 awk '/ldlm_bl_callback/ {print $2}')
10155 unlink $DIR/$tdir/f1
10157 can2=$(do_facet mds1 \
10158 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10159 awk '/ldlm_cancel/ {print $2}')
10160 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10161 awk '/ldlm_bl_callback/ {print $2}')
10162 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
10163 $LCTL dk $TMP/cancel.debug.txt
10164 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
10165 $LCTL dk $TMP/blocking.debug.txt
10166 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
10167 lru_resize_enable mdc
10168 lru_resize_enable osc
10170 run_test 120e "Early Lock Cancel: unlink test"
10173 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10174 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10175 skip_env "no early lock cancel on server"
10176 remote_mds_nodsh && skip "remote MDS with nodsh"
10178 test_mkdir -i0 -c1 $DIR/$tdir
10179 lru_resize_disable mdc
10180 lru_resize_disable osc
10181 test_mkdir -i0 -c1 $DIR/$tdir/d1
10182 test_mkdir -i0 -c1 $DIR/$tdir/d2
10183 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
10184 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
10185 cancel_lru_locks mdc
10186 cancel_lru_locks osc
10187 dd if=$DIR/$tdir/d1/f1 of=/dev/null
10188 dd if=$DIR/$tdir/d2/f2 of=/dev/null
10189 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
10190 # XXX client can not do early lock cancel of OST lock
10191 # during rename (LU-4206), so cancel osc lock now.
10193 cancel_lru_locks osc
10194 can1=$(do_facet mds1 \
10195 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10196 awk '/ldlm_cancel/ {print $2}')
10197 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10198 awk '/ldlm_bl_callback/ {print $2}')
10199 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10201 can2=$(do_facet mds1 \
10202 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10203 awk '/ldlm_cancel/ {print $2}')
10204 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10205 awk '/ldlm_bl_callback/ {print $2}')
10206 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10207 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10208 lru_resize_enable mdc
10209 lru_resize_enable osc
10211 run_test 120f "Early Lock Cancel: rename test"
10214 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10215 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10216 skip_env "no early lock cancel on server"
10217 remote_mds_nodsh && skip "remote MDS with nodsh"
10219 lru_resize_disable mdc
10220 lru_resize_disable osc
10222 echo create $count files
10223 test_mkdir $DIR/$tdir
10224 cancel_lru_locks mdc
10225 cancel_lru_locks osc
10228 can0=$(do_facet $SINGLEMDS \
10229 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10230 awk '/ldlm_cancel/ {print $2}')
10231 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10232 awk '/ldlm_bl_callback/ {print $2}')
10233 createmany -o $DIR/$tdir/f $count
10235 can1=$(do_facet $SINGLEMDS \
10236 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10237 awk '/ldlm_cancel/ {print $2}')
10238 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10239 awk '/ldlm_bl_callback/ {print $2}')
10241 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
10242 echo rm $count files
10245 can2=$(do_facet $SINGLEMDS \
10246 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10247 awk '/ldlm_cancel/ {print $2}')
10248 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10249 awk '/ldlm_bl_callback/ {print $2}')
10251 echo total: $count removes in $((t2-t1))
10252 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
10254 # wait for commitment of removal
10255 lru_resize_enable mdc
10256 lru_resize_enable osc
10258 run_test 120g "Early Lock Cancel: performance test"
10260 test_121() { #bug #10589
10261 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10264 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
10265 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
10266 lctl set_param fail_loc=0x310
10267 cancel_lru_locks osc > /dev/null
10268 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
10269 lctl set_param fail_loc=0
10270 [[ $reads -eq $writes ]] ||
10271 error "read $reads blocks, must be $writes blocks"
10273 run_test 121 "read cancel race ========="
10275 test_123a() { # was test 123, statahead(bug 11401)
10276 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10279 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
10280 log "testing UP system. Performance may be lower than expected."
10285 test_mkdir $DIR/$tdir
10286 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
10287 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
10289 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
10290 createmany -o $DIR/$tdir/$tfile $j $((i - j))
10292 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10293 lctl set_param -n llite.*.statahead_max 0
10294 lctl get_param llite.*.statahead_max
10295 cancel_lru_locks mdc
10296 cancel_lru_locks osc
10298 time ls -l $DIR/$tdir | wc -l
10300 delta=$((etime - stime))
10301 log "ls $i files without statahead: $delta sec"
10302 lctl set_param llite.*.statahead_max=$max
10304 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10305 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
10306 cancel_lru_locks mdc
10307 cancel_lru_locks osc
10309 time ls -l $DIR/$tdir | wc -l
10311 delta_sa=$((etime - stime))
10312 log "ls $i files with statahead: $delta_sa sec"
10313 lctl get_param -n llite.*.statahead_stats
10314 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10316 [[ $swrong -lt $ewrong ]] &&
10317 log "statahead was stopped, maybe too many locks held!"
10318 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
10320 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10321 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10322 lctl set_param -n llite.*.statahead_max 0
10323 lctl get_param llite.*.statahead_max
10324 cancel_lru_locks mdc
10325 cancel_lru_locks osc
10327 time ls -l $DIR/$tdir | wc -l
10329 delta=$((etime - stime))
10330 log "ls $i files again without statahead: $delta sec"
10331 lctl set_param llite.*.statahead_max=$max
10332 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10333 if [ $SLOWOK -eq 0 ]; then
10334 error "ls $i files is slower with statahead!"
10336 log "ls $i files is slower with statahead!"
10342 [ $delta -gt 20 ] && break
10343 [ $delta -gt 8 ] && MULT=$((50 / delta))
10344 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
10352 delta=$((etime - stime))
10353 log "rm -r $DIR/$tdir/: $delta seconds"
10355 lctl get_param -n llite.*.statahead_stats
10357 run_test 123a "verify statahead work"
10359 test_123b () { # statahead(bug 15027)
10360 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10362 test_mkdir $DIR/$tdir
10363 createmany -o $DIR/$tdir/$tfile-%d 1000
10365 cancel_lru_locks mdc
10366 cancel_lru_locks osc
10368 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
10369 lctl set_param fail_loc=0x80000803
10370 ls -lR $DIR/$tdir > /dev/null
10372 lctl set_param fail_loc=0x0
10373 lctl get_param -n llite.*.statahead_stats
10378 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
10381 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10382 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10383 skip_env "no lru resize on server"
10387 test_mkdir $DIR/$tdir
10389 log "create $NR files at $DIR/$tdir"
10390 createmany -o $DIR/$tdir/f $NR ||
10391 error "failed to create $NR files in $DIR/$tdir"
10393 cancel_lru_locks mdc
10394 ls -l $DIR/$tdir > /dev/null
10398 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
10399 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
10400 LRU_SIZE=$($LCTL get_param -n $PARAM)
10401 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
10402 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
10404 log "NS=$(basename $NSDIR)"
10409 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
10410 skip "Not enough cached locks created!"
10412 log "LRU=$LRU_SIZE"
10416 # We know that lru resize allows one client to hold $LIMIT locks
10417 # for 10h. After that locks begin to be killed by client.
10419 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
10421 if [ $LIMIT -lt $LRU_SIZE ]; then
10422 skip "Limit is too small $LIMIT"
10425 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
10426 # killing locks. Some time was spent for creating locks. This means
10427 # that up to the moment of sleep finish we must have killed some of
10428 # them (10-100 locks). This depends on how fast ther were created.
10429 # Many of them were touched in almost the same moment and thus will
10430 # be killed in groups.
10431 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
10433 # Use $LRU_SIZE_B here to take into account real number of locks
10434 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
10435 local LRU_SIZE_B=$LRU_SIZE
10437 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
10438 log "OLD_LVF=$OLD_LVF"
10439 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
10441 # Let's make sure that we really have some margin. Client checks
10442 # cached locks every 10 sec.
10443 SLEEP=$((SLEEP+20))
10444 log "Sleep ${SLEEP} sec"
10446 while ((SEC<$SLEEP)); do
10450 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
10451 echo -n "$LRU_SIZE"
10454 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
10455 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
10457 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
10458 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
10459 unlinkmany $DIR/$tdir/f $NR
10463 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
10464 log "unlink $NR files at $DIR/$tdir"
10465 unlinkmany $DIR/$tdir/f $NR
10467 run_test 124a "lru resize ======================================="
10469 get_max_pool_limit()
10471 local limit=$($LCTL get_param \
10472 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
10474 for l in $limit; do
10475 if [[ $l -gt $max ]]; then
10483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10484 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10485 skip_env "no lru resize on server"
10487 LIMIT=$(get_max_pool_limit)
10489 NR=$(($(default_lru_size)*20))
10490 if [[ $NR -gt $LIMIT ]]; then
10491 log "Limit lock number by $LIMIT locks"
10495 IFree=$(mdsrate_inodes_available)
10496 if [ $IFree -lt $NR ]; then
10497 log "Limit lock number by $IFree inodes"
10501 lru_resize_disable mdc
10502 test_mkdir -p $DIR/$tdir/disable_lru_resize
10504 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
10505 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
10506 cancel_lru_locks mdc
10509 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10512 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10515 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10519 nolruresize_delta=$((etime-stime))
10520 log "ls -la time: $nolruresize_delta seconds"
10521 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10522 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
10524 lru_resize_enable mdc
10525 test_mkdir -p $DIR/$tdir/enable_lru_resize
10527 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
10528 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
10529 cancel_lru_locks mdc
10532 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10535 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10538 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10542 lruresize_delta=$((etime-stime))
10543 log "ls -la time: $lruresize_delta seconds"
10544 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10546 if [ $lruresize_delta -gt $nolruresize_delta ]; then
10547 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
10548 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
10549 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
10551 log "lru resize performs the same with no lru resize"
10553 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
10555 run_test 124b "lru resize (performance test) ======================="
10558 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10559 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10560 skip_env "no lru resize on server"
10562 # cache ununsed locks on client
10564 cancel_lru_locks mdc
10565 test_mkdir $DIR/$tdir
10566 createmany -o $DIR/$tdir/f $nr ||
10567 error "failed to create $nr files in $DIR/$tdir"
10568 ls -l $DIR/$tdir > /dev/null
10570 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10571 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10572 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10573 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10574 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10576 # set lru_max_age to 1 sec
10577 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10578 echo "sleep $((recalc_p * 2)) seconds..."
10579 sleep $((recalc_p * 2))
10581 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10582 # restore lru_max_age
10583 $LCTL set_param -n $nsdir.lru_max_age $max_age
10584 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10585 unlinkmany $DIR/$tdir/f $nr
10587 run_test 124c "LRUR cancel very aged locks"
10589 test_125() { # 13358
10590 $LCTL get_param -n llite.*.client_type | grep -q local ||
10591 skip "must run as local client"
10592 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
10593 skip_env "must have acl enabled"
10594 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
10596 test_mkdir $DIR/$tdir
10597 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
10598 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
10599 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
10601 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
10603 test_126() { # bug 12829/13455
10604 $GSS && skip_env "must run as gss disabled"
10605 $LCTL get_param -n llite.*.client_type | grep -q local ||
10606 skip "must run as local client"
10607 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
10609 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
10610 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
10612 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
10614 run_test 126 "check that the fsgid provided by the client is taken into account"
10616 test_127a() { # bug 15521
10617 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10619 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
10620 $LCTL set_param osc.*.stats=0
10621 FSIZE=$((2048 * 1024))
10622 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10623 cancel_lru_locks osc
10624 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
10626 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
10627 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
10628 echo "got $COUNT $NAME"
10629 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
10630 eval $NAME=$COUNT || error "Wrong proc format"
10633 read_bytes|write_bytes)
10634 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
10635 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
10636 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
10637 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
10638 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
10639 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
10640 error "sumsquare is too small: $SUMSQ"
10641 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
10642 error "sumsquare is too big: $SUMSQ"
10646 done < $DIR/${tfile}.tmp
10648 #check that we actually got some stats
10649 [ "$read_bytes" ] || error "Missing read_bytes stats"
10650 [ "$write_bytes" ] || error "Missing write_bytes stats"
10651 [ "$read_bytes" != 0 ] || error "no read done"
10652 [ "$write_bytes" != 0 ] || error "no write done"
10654 run_test 127a "verify the client stats are sane"
10656 test_127b() { # bug LU-333
10657 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10658 local name count samp unit min max sum sumsq
10660 $LCTL set_param llite.*.stats=0
10662 # perform 2 reads and writes so MAX is different from SUM.
10663 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
10664 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
10665 cancel_lru_locks osc
10666 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
10667 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
10669 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
10670 while read name count samp unit min max sum sumsq; do
10671 echo "got $count $name"
10672 eval $name=$count || error "Wrong proc format"
10676 [ $count -ne 2 ] && error "count is not 2: $count"
10677 [ $min -ne $PAGE_SIZE ] &&
10678 error "min is not $PAGE_SIZE: $min"
10679 [ $max -ne $PAGE_SIZE ] &&
10680 error "max is incorrect: $max"
10681 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
10682 error "sum is wrong: $sum"
10685 [ $count -ne 2 ] && error "count is not 2: $count"
10686 [ $min -ne $PAGE_SIZE ] &&
10687 error "min is not $PAGE_SIZE: $min"
10688 [ $max -ne $PAGE_SIZE ] &&
10689 error "max is incorrect: $max"
10690 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
10691 error "sum is wrong: $sum"
10695 done < $TMP/$tfile.tmp
10697 #check that we actually got some stats
10698 [ "$read_bytes" ] || error "Missing read_bytes stats"
10699 [ "$write_bytes" ] || error "Missing write_bytes stats"
10700 [ "$read_bytes" != 0 ] || error "no read done"
10701 [ "$write_bytes" != 0 ] || error "no write done"
10703 rm -f $TMP/${tfile}.tmp
10705 run_test 127b "verify the llite client stats are sane"
10707 test_128() { # bug 15212
10709 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
10714 result=$(grep error $TMP/$tfile.log)
10715 rm -f $DIR/$tfile $TMP/$tfile.log
10716 [ -z "$result" ] ||
10717 error "consecutive find's under interactive lfs failed"
10719 run_test 128 "interactive lfs for 2 consecutive find's"
10721 set_dir_limits () {
10726 local ldproc=/proc/fs/ldiskfs
10727 local facets=$(get_facets MDS)
10729 for facet in ${facets//,/ }; do
10730 canondev=$(ldiskfs_canon \
10731 *.$(convert_facet2label $facet).mntdev $facet)
10732 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
10733 ldproc=/sys/fs/ldiskfs
10734 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
10735 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
10739 check_mds_dmesg() {
10740 local facets=$(get_facets MDS)
10741 for facet in ${facets//,/ }; do
10742 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
10748 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10749 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
10750 skip "Need MDS version with at least 2.5.56"
10751 if [ "$mds1_FSTYPE" != ldiskfs ]; then
10752 skip_env "ldiskfs only test"
10754 remote_mds_nodsh && skip "remote MDS with nodsh"
10758 local has_warning=false
10761 mkdir -p $DIR/$tdir
10763 # block size of mds1
10764 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
10765 set_dir_limits $maxsize $maxsize
10766 local dirsize=$(stat -c%s "$DIR/$tdir")
10768 while [[ $dirsize -le $maxsize ]]; do
10769 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
10771 if ! $has_warning; then
10772 check_mds_dmesg '"is approaching"' && has_warning=true
10774 # check two errors:
10775 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
10776 # EFBIG for previous versions included in ldiskfs series
10777 if [ $rc -eq $EFBIG ] || [ $rc -eq $ENOSPC ]; then
10779 echo "return code $rc received as expected"
10781 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
10782 error_exit "create failed w/o dir size limit"
10784 check_mds_dmesg '"has reached"' ||
10785 error_exit "reached message should be output"
10787 [ $has_warning = "false" ] &&
10788 error_exit "warning message should be output"
10790 dirsize=$(stat -c%s "$DIR/$tdir")
10792 [[ $dirsize -ge $maxsize ]] && return 0
10793 error_exit "current dir size $dirsize, " \
10794 "previous limit $maxsize"
10795 elif [ $rc -ne 0 ]; then
10797 error_exit "return $rc received instead of expected " \
10798 "$EFBIG or $ENOSPC, files in dir $dirsize"
10800 nfiles=$((nfiles + 1))
10801 dirsize=$(stat -c%s "$DIR/$tdir")
10805 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
10807 run_test 129 "test directory size limit ========================"
10816 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10817 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10819 trap cleanup_130 EXIT RETURN
10821 local fm_file=$DIR/$tfile
10822 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
10823 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
10824 error "dd failed for $fm_file"
10826 # LU-1795: test filefrag/FIEMAP once, even if unsupported
10827 filefrag -ves $fm_file
10829 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10830 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10831 [ $RC != 0 ] && error "filefrag $fm_file failed"
10833 filefrag_op=$(filefrag -ve -k $fm_file |
10834 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10835 lun=$($LFS getstripe -i $fm_file)
10837 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
10840 for line in $filefrag_op
10842 frag_lun=`echo $line | cut -d: -f5`
10843 ext_len=`echo $line | cut -d: -f4`
10844 if (( $frag_lun != $lun )); then
10846 error "FIEMAP on 1-stripe file($fm_file) failed"
10849 (( tot_len += ext_len ))
10852 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
10854 error "FIEMAP on 1-stripe file($fm_file) failed;"
10860 echo "FIEMAP on single striped file succeeded"
10862 run_test 130a "FIEMAP (1-stripe file)"
10865 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
10867 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10868 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10870 trap cleanup_130 EXIT RETURN
10872 local fm_file=$DIR/$tfile
10873 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
10874 error "setstripe on $fm_file"
10875 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10876 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10878 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
10879 error "dd failed on $fm_file"
10881 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10882 filefrag_op=$(filefrag -ve -k $fm_file |
10883 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10885 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10886 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10891 for line in $filefrag_op
10893 frag_lun=$(echo $line | cut -d: -f5 |
10894 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10895 ext_len=$(echo $line | cut -d: -f4)
10896 if (( $frag_lun != $last_lun )); then
10897 if (( tot_len != 1024 )); then
10899 error "FIEMAP on $fm_file failed; returned " \
10900 "len $tot_len for OST $last_lun instead of 1024"
10903 (( num_luns += 1 ))
10907 (( tot_len += ext_len ))
10910 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
10912 error "FIEMAP on $fm_file failed; returned wrong number of " \
10913 "luns or wrong len for OST $last_lun"
10919 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
10921 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
10924 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10926 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10927 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10929 trap cleanup_130 EXIT RETURN
10931 local fm_file=$DIR/$tfile
10932 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
10933 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
10934 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10936 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
10937 error "dd failed on $fm_file"
10939 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10940 filefrag_op=$(filefrag -ve -k $fm_file |
10941 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10943 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10944 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10949 for line in $filefrag_op
10951 frag_lun=$(echo $line | cut -d: -f5 |
10952 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10953 ext_len=$(echo $line | cut -d: -f4)
10954 if (( $frag_lun != $last_lun )); then
10955 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
10956 if (( logical != 512 )); then
10958 error "FIEMAP on $fm_file failed; returned " \
10959 "logical start for lun $logical instead of 512"
10962 if (( tot_len != 512 )); then
10964 error "FIEMAP on $fm_file failed; returned " \
10965 "len $tot_len for OST $last_lun instead of 1024"
10968 (( num_luns += 1 ))
10972 (( tot_len += ext_len ))
10975 if (( num_luns != 2 || tot_len != 512 )); then
10977 error "FIEMAP on $fm_file failed; returned wrong number of " \
10978 "luns or wrong len for OST $last_lun"
10984 echo "FIEMAP on 2-stripe file with hole succeeded"
10986 run_test 130c "FIEMAP (2-stripe file with hole)"
10989 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
10991 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10992 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10994 trap cleanup_130 EXIT RETURN
10996 local fm_file=$DIR/$tfile
10997 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
10998 error "setstripe on $fm_file"
10999 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11000 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11002 local actual_stripe_count=$($LFS getstripe -c $fm_file)
11003 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
11004 error "dd failed on $fm_file"
11006 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11007 filefrag_op=$(filefrag -ve -k $fm_file |
11008 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11010 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11011 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11016 for line in $filefrag_op
11018 frag_lun=$(echo $line | cut -d: -f5 |
11019 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11020 ext_len=$(echo $line | cut -d: -f4)
11021 if (( $frag_lun != $last_lun )); then
11022 if (( tot_len != 1024 )); then
11024 error "FIEMAP on $fm_file failed; returned " \
11025 "len $tot_len for OST $last_lun instead of 1024"
11028 (( num_luns += 1 ))
11032 (( tot_len += ext_len ))
11035 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
11037 error "FIEMAP on $fm_file failed; returned wrong number of " \
11038 "luns or wrong len for OST $last_lun"
11044 echo "FIEMAP on N-stripe file succeeded"
11046 run_test 130d "FIEMAP (N-stripe file)"
11049 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11051 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11052 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11054 trap cleanup_130 EXIT RETURN
11056 local fm_file=$DIR/$tfile
11057 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
11058 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11059 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11062 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
11063 for ((i = 0; i < $NUM_BLKS; i++))
11065 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
11068 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11069 filefrag_op=$(filefrag -ve -k $fm_file |
11070 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11072 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11073 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11078 for line in $filefrag_op
11080 frag_lun=$(echo $line | cut -d: -f5 |
11081 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11082 ext_len=$(echo $line | cut -d: -f4)
11083 if (( $frag_lun != $last_lun )); then
11084 if (( tot_len != $EXPECTED_LEN )); then
11086 error "FIEMAP on $fm_file failed; returned " \
11087 "len $tot_len for OST $last_lun instead " \
11091 (( num_luns += 1 ))
11095 (( tot_len += ext_len ))
11098 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
11100 error "FIEMAP on $fm_file failed; returned wrong number " \
11101 "of luns or wrong len for OST $last_lun"
11107 echo "FIEMAP with continuation calls succeeded"
11109 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
11112 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11113 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11115 local fm_file=$DIR/$tfile
11116 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
11117 error "multiop create with lov_delay_create on $fm_file"
11119 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11120 filefrag_extents=$(filefrag -vek $fm_file |
11121 awk '/extents? found/ { print $2 }')
11122 if [[ "$filefrag_extents" != "0" ]]; then
11123 error "FIEMAP on $fm_file failed; " \
11124 "returned $filefrag_extents expected 0"
11129 run_test 130f "FIEMAP (unstriped file)"
11131 # Test for writev/readv
11133 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
11134 error "writev test failed"
11135 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
11136 error "readv failed"
11139 run_test 131a "test iov's crossing stripe boundary for writev/readv"
11142 local fsize=$((524288 + 1048576 + 1572864))
11143 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
11144 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11145 error "append writev test failed"
11147 ((fsize += 1572864 + 1048576))
11148 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
11149 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11150 error "append writev test failed"
11153 run_test 131b "test append writev"
11156 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
11159 run_test 131c "test read/write on file w/o objects"
11162 rwv -f $DIR/$tfile -w -n 1 1572864
11163 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
11164 if [ "$NOB" != 1572864 ]; then
11165 error "Short read filed: read $NOB bytes instead of 1572864"
11169 run_test 131d "test short read"
11172 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
11173 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
11174 error "read hitting hole failed"
11177 run_test 131e "test read hitting hole"
11186 mds*) res=$(do_facet $facet \
11187 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
11189 ost*) res=$(do_facet $facet \
11190 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
11192 *) error "Wrong facet '$facet'" ;;
11194 [ "$res" ] || error "The counter for $op on $facet was not incremented"
11195 # if the argument $3 is zero, it means any stat increment is ok.
11196 if [[ $want -gt 0 ]]; then
11197 local count=$(echo $res | awk '{ print $2 }')
11198 [[ $count -ne $want ]] &&
11199 error "The $op counter on $facet is $count, not $want"
11204 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11205 remote_ost_nodsh && skip "remote OST with nodsh"
11206 remote_mds_nodsh && skip "remote MDS with nodsh"
11207 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11208 skip_env "MDS doesn't support rename stats"
11210 local testdir=$DIR/${tdir}/stats_testdir
11212 mkdir -p $DIR/${tdir}
11215 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11216 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11218 # verify mdt stats first.
11219 mkdir ${testdir} || error "mkdir failed"
11220 check_stats $SINGLEMDS "mkdir" 1
11221 touch ${testdir}/${tfile} || error "touch failed"
11222 check_stats $SINGLEMDS "open" 1
11223 check_stats $SINGLEMDS "close" 1
11224 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
11225 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
11226 check_stats $SINGLEMDS "mknod" 2
11228 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
11229 check_stats $SINGLEMDS "unlink" 1
11230 rm -f ${testdir}/${tfile} || error "file remove failed"
11231 check_stats $SINGLEMDS "unlink" 2
11233 # remove working dir and check mdt stats again.
11234 rmdir ${testdir} || error "rmdir failed"
11235 check_stats $SINGLEMDS "rmdir" 1
11237 local testdir1=$DIR/${tdir}/stats_testdir1
11238 mkdir -p ${testdir}
11239 mkdir -p ${testdir1}
11240 touch ${testdir1}/test1
11241 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
11242 check_stats $SINGLEMDS "crossdir_rename" 1
11244 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
11245 check_stats $SINGLEMDS "samedir_rename" 1
11247 rm -rf $DIR/${tdir}
11249 run_test 133a "Verifying MDT stats ========================================"
11254 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11255 remote_ost_nodsh && skip "remote OST with nodsh"
11256 remote_mds_nodsh && skip "remote MDS with nodsh"
11258 local testdir=$DIR/${tdir}/stats_testdir
11260 mkdir -p ${testdir} || error "mkdir failed"
11261 touch ${testdir}/${tfile} || error "touch failed"
11262 cancel_lru_locks mdc
11265 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11266 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11268 # extra mdt stats verification.
11269 chmod 444 ${testdir}/${tfile} || error "chmod failed"
11270 check_stats $SINGLEMDS "setattr" 1
11271 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11272 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
11274 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
11275 check_stats $SINGLEMDS "getattr" 1
11277 rm -rf $DIR/${tdir}
11279 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
11280 # so the check below is not reliable
11281 [ $MDSCOUNT -eq 1 ] || return 0
11283 # Sleep to avoid a cached response.
11284 #define OBD_STATFS_CACHE_SECONDS 1
11286 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11287 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11288 $LFS df || error "lfs failed"
11289 check_stats $SINGLEMDS "statfs" 1
11291 # check aggregated statfs (LU-10018)
11292 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
11294 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
11297 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11298 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11300 check_stats $SINGLEMDS "statfs" 1
11302 # We want to check that the client didn't send OST_STATFS to
11303 # ost1 but the MDT also uses OST_STATFS for precreate. So some
11304 # extra care is needed here.
11305 if remote_mds; then
11306 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
11307 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
11309 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
11310 [ "$res" ] && error "OST got STATFS"
11315 run_test 133b "Verifying extra MDT stats =================================="
11318 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11319 remote_ost_nodsh && skip "remote OST with nodsh"
11320 remote_mds_nodsh && skip "remote MDS with nodsh"
11322 local testdir=$DIR/$tdir/stats_testdir
11324 test_mkdir -p $testdir
11326 # verify obdfilter stats.
11327 $LFS setstripe -c 1 -i 0 $testdir/$tfile
11329 cancel_lru_locks osc
11330 wait_delete_completed
11333 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11334 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11336 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
11339 cancel_lru_locks osc
11340 check_stats ost1 "write" 1
11342 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
11343 check_stats ost1 "read" 1
11345 > $testdir/$tfile || error "truncate failed"
11346 check_stats ost1 "punch" 1
11348 rm -f $testdir/$tfile || error "file remove failed"
11349 wait_delete_completed
11350 check_stats ost1 "destroy" 1
11354 run_test 133c "Verifying OST stats ========================================"
11361 while [ $value -ge 2 ]; do
11366 if [ $orig -gt $order ]; then
11374 local size=('K' 'M' 'G' 'T');
11376 local size_string=$value
11378 while [ $value -ge 1024 ]; do
11379 if [ $i -gt 3 ]; then
11380 #T is the biggest unit we get here, if that is bigger,
11382 size_string=${value}T
11385 value=$((value >> 10))
11386 if [ $value -lt 1024 ]; then
11387 size_string=${value}${size[$i]}
11396 get_rename_size() {
11398 local context=${2:-.}
11399 local sample=$(do_facet $SINGLEMDS $LCTL \
11400 get_param mdt.$FSNAME-MDT0000.rename_stats |
11401 grep -A1 $context |
11402 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
11407 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11408 remote_ost_nodsh && skip "remote OST with nodsh"
11409 remote_mds_nodsh && skip "remote MDS with nodsh"
11410 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11411 skip_env "MDS doesn't support rename stats"
11413 local testdir1=$DIR/${tdir}/stats_testdir1
11414 local testdir2=$DIR/${tdir}/stats_testdir2
11415 mkdir -p $DIR/${tdir}
11417 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11419 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
11420 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
11422 createmany -o $testdir1/test 512 || error "createmany failed"
11424 # check samedir rename size
11425 mv ${testdir1}/test0 ${testdir1}/test_0
11427 local testdir1_size=$(ls -l $DIR/${tdir} |
11428 awk '/stats_testdir1/ {print $5}')
11429 local testdir2_size=$(ls -l $DIR/${tdir} |
11430 awk '/stats_testdir2/ {print $5}')
11432 testdir1_size=$(order_2 $testdir1_size)
11433 testdir2_size=$(order_2 $testdir2_size)
11435 testdir1_size=$(size_in_KMGT $testdir1_size)
11436 testdir2_size=$(size_in_KMGT $testdir2_size)
11438 echo "source rename dir size: ${testdir1_size}"
11439 echo "target rename dir size: ${testdir2_size}"
11441 local cmd="do_facet $SINGLEMDS $LCTL "
11442 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
11444 eval $cmd || error "$cmd failed"
11445 local samedir=$($cmd | grep 'same_dir')
11446 local same_sample=$(get_rename_size $testdir1_size)
11447 [ -z "$samedir" ] && error "samedir_rename_size count error"
11448 [[ $same_sample -eq 1 ]] ||
11449 error "samedir_rename_size error $same_sample"
11450 echo "Check same dir rename stats success"
11452 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11454 # check crossdir rename size
11455 mv ${testdir1}/test_0 ${testdir2}/test_0
11457 testdir1_size=$(ls -l $DIR/${tdir} |
11458 awk '/stats_testdir1/ {print $5}')
11459 testdir2_size=$(ls -l $DIR/${tdir} |
11460 awk '/stats_testdir2/ {print $5}')
11462 testdir1_size=$(order_2 $testdir1_size)
11463 testdir2_size=$(order_2 $testdir2_size)
11465 testdir1_size=$(size_in_KMGT $testdir1_size)
11466 testdir2_size=$(size_in_KMGT $testdir2_size)
11468 echo "source rename dir size: ${testdir1_size}"
11469 echo "target rename dir size: ${testdir2_size}"
11471 eval $cmd || error "$cmd failed"
11472 local crossdir=$($cmd | grep 'crossdir')
11473 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
11474 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
11475 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
11476 [[ $src_sample -eq 1 ]] ||
11477 error "crossdir_rename_size error $src_sample"
11478 [[ $tgt_sample -eq 1 ]] ||
11479 error "crossdir_rename_size error $tgt_sample"
11480 echo "Check cross dir rename stats success"
11481 rm -rf $DIR/${tdir}
11483 run_test 133d "Verifying rename_stats ========================================"
11486 remote_mds_nodsh && skip "remote MDS with nodsh"
11487 remote_ost_nodsh && skip "remote OST with nodsh"
11488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11490 local testdir=$DIR/${tdir}/stats_testdir
11491 local ctr f0 f1 bs=32768 count=42 sum
11493 mkdir -p ${testdir} || error "mkdir failed"
11495 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
11497 for ctr in {write,read}_bytes; do
11499 cancel_lru_locks osc
11501 do_facet ost1 $LCTL set_param -n \
11502 "obdfilter.*.exports.clear=clear"
11504 if [ $ctr = write_bytes ]; then
11506 f1=${testdir}/${tfile}
11508 f0=${testdir}/${tfile}
11512 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
11515 cancel_lru_locks osc
11517 sum=$(do_facet ost1 $LCTL get_param \
11518 "obdfilter.*.exports.*.stats" |
11519 awk -v ctr=$ctr 'BEGIN { sum = 0 }
11520 $1 == ctr { sum += $7 }
11521 END { printf("%0.0f", sum) }')
11523 if ((sum != bs * count)); then
11524 error "Bad $ctr sum, expected $((bs * count)), got $sum"
11528 rm -rf $DIR/${tdir}
11530 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
11532 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
11534 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
11535 # not honor the -ignore_readdir_race option correctly. So we call
11536 # error_ignore() rather than error() in these cases. See LU-11152.
11538 if (find --version; do_facet mds1 find --version) |
11539 grep -q '\b4\.5\.1[1-4]\b'; then
11540 error_ignore LU-11152 "$@"
11547 # First without trusting modes.
11548 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
11549 echo "proc_dirs='$proc_dirs'"
11550 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
11551 find $proc_dirs -exec cat '{}' \; &> /dev/null
11553 # Second verifying readability.
11554 $LCTL get_param -R '*' &> /dev/null
11556 # Verifing writability with badarea_io.
11558 -ignore_readdir_race \
11560 -not -name force_lbug \
11561 -not -name changelog_mask \
11562 -exec badarea_io '{}' \; ||
11563 error_133 "find $proc_dirs failed"
11565 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
11568 remote_mds_nodsh && skip "remote MDS with nodsh"
11569 remote_ost_nodsh && skip "remote OST with nodsh"
11571 # eventually, this can also be replaced with "lctl get_param -R",
11572 # but not until that option is always available on the server
11574 for facet in mds1 ost1; do
11575 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
11576 skip_noexit "Too old lustre on $facet"
11577 local facet_proc_dirs=$(do_facet $facet \
11578 \\\ls -d $proc_regexp 2>/dev/null)
11579 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11580 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11581 do_facet $facet find $facet_proc_dirs \
11582 ! -name req_history \
11583 -exec cat '{}' \\\; &> /dev/null
11585 do_facet $facet find $facet_proc_dirs \
11586 ! -name req_history \
11588 -exec cat '{}' \\\; &> /dev/null ||
11589 error "proc file read failed"
11591 do_facet $facet find $facet_proc_dirs \
11592 -ignore_readdir_race \
11594 -not -name force_lbug \
11595 -not -name changelog_mask \
11596 -exec badarea_io '{}' \\\; ||
11597 error_133 "$facet find $facet_proc_dirs failed"
11600 # remount the FS in case writes/reads /proc break the FS
11601 cleanup || error "failed to unmount"
11602 setup || error "failed to setup"
11605 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
11608 remote_mds_nodsh && skip "remote MDS with nodsh"
11609 remote_ost_nodsh && skip "remote OST with nodsh"
11610 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
11611 skip "Need MDS version at least 2.9.54"
11615 for facet in client mds1 ost1; do
11616 local facet_proc_dirs=$(do_facet $facet \
11617 \\\ls -d $proc_regexp 2> /dev/null)
11618 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11619 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11620 # Get the list of files that are missing the terminating newline
11621 local missing=($(do_facet $facet \
11622 find ${facet_proc_dirs} -type f \| \
11623 while read F\; do \
11624 awk -v FS='\v' -v RS='\v\v' \
11625 "'END { if(NR>0 && \
11626 \\\$NF !~ /.*\\\n\$/) \
11627 print FILENAME}'" \
11630 [ ${#missing[*]} -eq 0 ] ||
11631 error "files do not end with newline: ${missing[*]}"
11634 run_test 133h "Proc files should end with newlines"
11637 remote_mds_nodsh && skip "remote MDS with nodsh"
11638 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
11639 skip "Need MDS version at least 2.7.54"
11641 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11642 cancel_lru_locks mdc
11644 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11645 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11646 [ $unused -eq 0 ] || error "$unused locks are not cleared"
11649 createmany -o $DIR/$tdir/f $nr ||
11650 error "failed to create $nr files in $DIR/$tdir"
11651 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11653 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
11654 do_facet mds1 $LCTL set_param fail_loc=0x327
11655 do_facet mds1 $LCTL set_param fail_val=500
11658 echo "sleep 10 seconds ..."
11660 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
11662 do_facet mds1 $LCTL set_param fail_loc=0
11663 do_facet mds1 $LCTL set_param fail_val=0
11664 [ $lck_cnt -lt $unused ] ||
11665 error "No locks reclaimed, before:$unused, after:$lck_cnt"
11668 unlinkmany $DIR/$tdir/f $nr
11670 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
11673 remote_mds_nodsh && skip "remote MDS with nodsh"
11674 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
11675 skip "Need MDS version at least 2.7.54"
11677 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11678 cancel_lru_locks mdc
11680 local low_wm=$(do_facet mds1 $LCTL get_param -n \
11681 ldlm.lock_reclaim_threshold_mb)
11682 # disable reclaim temporarily
11683 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
11685 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
11686 do_facet mds1 $LCTL set_param fail_loc=0x328
11687 do_facet mds1 $LCTL set_param fail_val=500
11689 $LCTL set_param debug=+trace
11692 createmany -o $DIR/$tdir/f $nr &
11693 local create_pid=$!
11695 echo "Sleep $TIMEOUT seconds ..."
11697 if ! ps -p $create_pid > /dev/null 2>&1; then
11698 do_facet mds1 $LCTL set_param fail_loc=0
11699 do_facet mds1 $LCTL set_param fail_val=0
11700 do_facet mds1 $LCTL set_param \
11701 ldlm.lock_reclaim_threshold_mb=${low_wm}m
11702 error "createmany finished incorrectly!"
11704 do_facet mds1 $LCTL set_param fail_loc=0
11705 do_facet mds1 $LCTL set_param fail_val=0
11706 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
11707 wait $create_pid || return 1
11709 unlinkmany $DIR/$tdir/f $nr
11711 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
11713 test_140() { #bug-17379
11714 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11716 test_mkdir $DIR/$tdir
11717 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
11718 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
11720 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
11721 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
11723 while i=$((i + 1)); do
11725 cd $i || error "Changing to $i"
11726 ln -s ../stat stat || error "Creating stat symlink"
11727 # Read the symlink until ELOOP present,
11728 # not LBUGing the system is considered success,
11729 # we didn't overrun the stack.
11730 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
11731 if [ $ret -ne 0 ]; then
11732 if [ $ret -eq 40 ]; then
11735 error "Open stat symlink"
11741 echo "The symlink depth = $i"
11742 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
11743 error "Invalid symlink depth"
11745 # Test recursive symlink
11746 ln -s symlink_self symlink_self
11747 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
11748 echo "open symlink_self returns $ret"
11749 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
11751 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
11754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11756 local TF="$TMP/$tfile"
11758 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11760 cancel_lru_locks $OSC
11761 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
11762 remount_client $MOUNT
11764 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
11767 $TRUNCATE $DIR/$tfile 6000
11768 cancel_lru_locks $OSC
11769 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
11772 echo "12345" >>$DIR/$tfile
11773 cancel_lru_locks $OSC
11774 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
11777 echo "12345" >>$DIR/$tfile
11778 cancel_lru_locks $OSC
11779 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
11784 run_test 150 "truncate/append tests"
11786 #LU-2902 roc_hit was not able to read all values from lproc
11787 function roc_hit_init() {
11788 local list=$(comma_list $(osts_nodes))
11789 local dir=$DIR/$tdir-check
11790 local file=$dir/$tfile
11796 #use setstripe to do a write to every ost
11797 for i in $(seq 0 $((OSTCOUNT-1))); do
11798 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
11799 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
11800 idx=$(printf %04x $i)
11801 BEFORE=$(get_osd_param $list *OST*$idx stats |
11802 awk '$1 == "cache_access" {sum += $7}
11803 END { printf("%0.0f", sum) }')
11805 cancel_lru_locks osc
11806 cat $file >/dev/null
11808 AFTER=$(get_osd_param $list *OST*$idx stats |
11809 awk '$1 == "cache_access" {sum += $7}
11810 END { printf("%0.0f", sum) }')
11812 echo BEFORE:$BEFORE AFTER:$AFTER
11813 if ! let "AFTER - BEFORE == 4"; then
11815 error "roc_hit is not safe to use"
11823 function roc_hit() {
11824 local list=$(comma_list $(osts_nodes))
11825 echo $(get_osd_param $list '' stats |
11826 awk '$1 == "cache_hit" {sum += $7}
11827 END { printf("%0.0f", sum) }')
11830 function set_cache() {
11833 if [ "$2" == "off" ]; then
11836 local list=$(comma_list $(osts_nodes))
11837 set_osd_param $list '' $1_cache_enable $on
11839 cancel_lru_locks osc
11843 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11844 remote_ost_nodsh && skip "remote OST with nodsh"
11847 local list=$(comma_list $(osts_nodes))
11849 # check whether obdfilter is cache capable at all
11850 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
11851 skip "not cache-capable obdfilter"
11854 # check cache is enabled on all obdfilters
11855 if get_osd_param $list '' read_cache_enable | grep 0; then
11856 skip "oss cache is disabled"
11859 set_osd_param $list '' writethrough_cache_enable 1
11861 # check write cache is enabled on all obdfilters
11862 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
11863 skip "oss write cache is NOT enabled"
11868 #define OBD_FAIL_OBD_NO_LRU 0x609
11869 do_nodes $list $LCTL set_param fail_loc=0x609
11871 # pages should be in the case right after write
11872 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
11875 local BEFORE=$(roc_hit)
11876 cancel_lru_locks osc
11877 cat $DIR/$tfile >/dev/null
11878 local AFTER=$(roc_hit)
11880 do_nodes $list $LCTL set_param fail_loc=0
11882 if ! let "AFTER - BEFORE == CPAGES"; then
11883 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11886 # the following read invalidates the cache
11887 cancel_lru_locks osc
11888 set_osd_param $list '' read_cache_enable 0
11889 cat $DIR/$tfile >/dev/null
11891 # now data shouldn't be found in the cache
11893 cancel_lru_locks osc
11894 cat $DIR/$tfile >/dev/null
11896 if let "AFTER - BEFORE != 0"; then
11897 error "IN CACHE: before: $BEFORE, after: $AFTER"
11900 set_osd_param $list '' read_cache_enable 1
11903 run_test 151 "test cache on oss and controls ==============================="
11906 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11908 local TF="$TMP/$tfile"
11910 # simulate ENOMEM during write
11911 #define OBD_FAIL_OST_NOMEM 0x226
11912 lctl set_param fail_loc=0x80000226
11913 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11915 sync || error "sync failed"
11916 lctl set_param fail_loc=0
11918 # discard client's cache
11919 cancel_lru_locks osc
11921 # simulate ENOMEM during read
11922 lctl set_param fail_loc=0x80000226
11923 cmp $TF $DIR/$tfile || error "cmp failed"
11924 lctl set_param fail_loc=0
11928 run_test 152 "test read/write with enomem ============================"
11931 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
11933 run_test 153 "test if fdatasync does not crash ======================="
11935 dot_lustre_fid_permission_check() {
11937 local ffid=$MOUNT/.lustre/fid/$fid
11940 echo "stat fid $fid"
11941 stat $ffid > /dev/null || error "stat $ffid failed."
11942 echo "touch fid $fid"
11943 touch $ffid || error "touch $ffid failed."
11944 echo "write to fid $fid"
11945 cat /etc/hosts > $ffid || error "write $ffid failed."
11946 echo "read fid $fid"
11947 diff /etc/hosts $ffid || error "read $ffid failed."
11948 echo "append write to fid $fid"
11949 cat /etc/hosts >> $ffid || error "append write $ffid failed."
11950 echo "rename fid $fid"
11951 mv $ffid $test_dir/$tfile.1 &&
11952 error "rename $ffid to $tfile.1 should fail."
11953 touch $test_dir/$tfile.1
11954 mv $test_dir/$tfile.1 $ffid &&
11955 error "rename $tfile.1 to $ffid should fail."
11956 rm -f $test_dir/$tfile.1
11957 echo "truncate fid $fid"
11958 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
11959 echo "link fid $fid"
11960 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
11961 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
11962 echo "setfacl fid $fid"
11963 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
11964 echo "getfacl fid $fid"
11965 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
11967 echo "unlink fid $fid"
11968 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
11969 echo "mknod fid $fid"
11970 mknod $ffid c 1 3 && error "mknod $ffid should fail."
11972 fid=[0xf00000400:0x1:0x0]
11973 ffid=$MOUNT/.lustre/fid/$fid
11975 echo "stat non-exist fid $fid"
11976 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
11977 echo "write to non-exist fid $fid"
11978 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
11979 echo "link new fid $fid"
11980 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
11982 mkdir -p $test_dir/$tdir
11983 touch $test_dir/$tdir/$tfile
11984 fid=$($LFS path2fid $test_dir/$tdir)
11987 error "error: could not get fid for $test_dir/$dir/$tfile."
11989 ffid=$MOUNT/.lustre/fid/$fid
11992 ls $ffid > /dev/null || error "ls $ffid failed."
11993 echo "touch $fid/$tfile.1"
11994 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
11996 echo "touch $MOUNT/.lustre/fid/$tfile"
11997 touch $MOUNT/.lustre/fid/$tfile && \
11998 error "touch $MOUNT/.lustre/fid/$tfile should fail."
12000 echo "setxattr to $MOUNT/.lustre/fid"
12001 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
12003 echo "listxattr for $MOUNT/.lustre/fid"
12004 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
12006 echo "delxattr from $MOUNT/.lustre/fid"
12007 setfattr -x trusted.name1 $MOUNT/.lustre/fid
12009 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
12010 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
12011 error "touch invalid fid should fail."
12013 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
12014 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
12015 error "touch non-normal fid should fail."
12017 echo "rename $tdir to $MOUNT/.lustre/fid"
12018 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
12019 error "rename to $MOUNT/.lustre/fid should fail."
12021 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
12023 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
12024 local new_obf_mode=777
12026 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
12027 chmod $new_obf_mode $DIR/.lustre/fid ||
12028 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
12030 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
12031 [ $obf_mode -eq $new_obf_mode ] ||
12032 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
12034 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
12035 chmod $old_obf_mode $DIR/.lustre/fid ||
12036 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
12039 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
12040 fid=$($LFS path2fid $test_dir/$tfile-2)
12042 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
12044 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
12045 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
12046 error "create lov data thru .lustre failed"
12048 echo "cp /etc/passwd $test_dir/$tfile-2"
12049 cp /etc/passwd $test_dir/$tfile-2 ||
12050 error "copy to $test_dir/$tfile-2 failed."
12051 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
12052 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
12053 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
12055 rm -rf $test_dir/tfile.lnk
12056 rm -rf $test_dir/$tfile-2
12060 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12061 skip "Need MDS version at least 2.4.1"
12063 local tf=$DIR/$tfile
12066 local fid=$($LFS path2fid $tf)
12067 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
12069 # check that we get the same pathname back
12070 local found=$($LFS fid2path $MOUNT "$fid")
12071 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
12072 [ "$found" == "$tf" ] ||
12073 error "fid2path($fid=path2fid($tf)) = $found != $tf"
12075 run_test 154A "lfs path2fid and fid2path basic checks"
12078 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12079 skip "Need MDS version at least 2.4.1"
12081 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
12082 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
12083 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
12084 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
12086 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
12087 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
12089 # check that we get the same pathname
12090 echo "PFID: $PFID, name: $name"
12091 local FOUND=$($LFS fid2path $MOUNT "$PFID")
12092 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
12093 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
12094 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
12096 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
12098 run_test 154B "verify the ll_decode_linkea tool"
12101 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12102 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12103 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12104 skip "Need MDS version at least 2.2.51"
12105 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
12107 cp /etc/hosts $DIR/$tfile
12109 fid=$($LFS path2fid $DIR/$tfile)
12111 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
12113 dot_lustre_fid_permission_check "$fid" $DIR ||
12114 error "dot lustre permission check $fid failed"
12116 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
12118 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
12120 touch $MOUNT/.lustre/file &&
12121 error "creation is not allowed under .lustre"
12123 mkdir $MOUNT/.lustre/dir &&
12124 error "mkdir is not allowed under .lustre"
12128 run_test 154a "Open-by-FID"
12131 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12132 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12133 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12134 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12135 skip "Need MDS version at least 2.2.51"
12137 local remote_dir=$DIR/$tdir/remote_dir
12141 mkdir -p $DIR/$tdir
12142 $LFS mkdir -i $MDTIDX $remote_dir ||
12143 error "create remote directory failed"
12145 cp /etc/hosts $remote_dir/$tfile
12147 fid=$($LFS path2fid $remote_dir/$tfile)
12149 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
12151 dot_lustre_fid_permission_check "$fid" $remote_dir ||
12152 error "dot lustre permission check $fid failed"
12155 run_test 154b "Open-by-FID for remote directory"
12158 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12159 skip "Need MDS version at least 2.4.1"
12161 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
12162 local FID1=$($LFS path2fid $DIR/$tfile.1)
12163 local FID2=$($LFS path2fid $DIR/$tfile.2)
12164 local FID3=$($LFS path2fid $DIR/$tfile.3)
12167 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
12168 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
12169 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
12171 [ "$FID" = "${!want}" ] ||
12172 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
12176 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
12178 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
12179 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
12183 run_test 154c "lfs path2fid and fid2path multiple arguments"
12186 remote_mds_nodsh && skip "remote MDS with nodsh"
12187 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
12188 skip "Need MDS version at least 2.5.53"
12190 if remote_mds; then
12191 nid=$($LCTL list_nids | sed "s/\./\\\./g")
12195 local proc_ofile="mdt.*.exports.'$nid'.open_files"
12202 local fid=$($LFS path2fid $DIR/$tfile)
12205 cmd="exec $fd<$DIR/$tfile"
12207 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
12208 echo "$fid_list" | grep "$fid"
12211 cmd="exec $fd>/dev/null"
12213 if [ $rc -ne 0 ]; then
12214 error "FID $fid not found in open files list $fid_list"
12217 run_test 154d "Verify open file fid"
12221 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
12222 skip "Need MDS version at least 2.6.50"
12224 if ls -a $MOUNT | grep -q '^\.lustre$'; then
12225 error ".lustre returned by readdir"
12228 run_test 154e ".lustre is not returned by readdir"
12231 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12233 # create parent directory on a single MDT to avoid cross-MDT hardlinks
12234 test_mkdir -p -c1 $DIR/$tdir/d
12235 # test dirs inherit from its stripe
12236 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
12237 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
12238 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
12239 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
12242 # get fid of parents
12243 local FID0=$($LFS path2fid $DIR/$tdir/d)
12244 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
12245 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
12246 local FID3=$($LFS path2fid $DIR)
12248 # check that path2fid --parents returns expected <parent_fid>/name
12249 # 1) test for a directory (single parent)
12250 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
12251 [ "$parent" == "$FID0/foo1" ] ||
12252 error "expected parent: $FID0/foo1, got: $parent"
12254 # 2) test for a file with nlink > 1 (multiple parents)
12255 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
12256 echo "$parent" | grep -F "$FID1/$tfile" ||
12257 error "$FID1/$tfile not returned in parent list"
12258 echo "$parent" | grep -F "$FID2/link" ||
12259 error "$FID2/link not returned in parent list"
12261 # 3) get parent by fid
12262 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
12263 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12264 echo "$parent" | grep -F "$FID1/$tfile" ||
12265 error "$FID1/$tfile not returned in parent list (by fid)"
12266 echo "$parent" | grep -F "$FID2/link" ||
12267 error "$FID2/link not returned in parent list (by fid)"
12269 # 4) test for entry in root directory
12270 parent=$($LFS path2fid --parents $DIR/f)
12271 echo "$parent" | grep -F "$FID3/f" ||
12272 error "$FID3/f not returned in parent list"
12274 # 5) test it on root directory
12275 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
12276 error "$MOUNT should not have parents"
12278 # enable xattr caching and check that linkea is correctly updated
12279 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12280 save_lustre_params client "llite.*.xattr_cache" > $save
12281 lctl set_param llite.*.xattr_cache 1
12283 # 6.1) linkea update on rename
12284 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
12286 # get parents by fid
12287 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12288 # foo1 should no longer be returned in parent list
12289 echo "$parent" | grep -F "$FID1" &&
12290 error "$FID1 should no longer be in parent list"
12291 # the new path should appear
12292 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
12293 error "$FID2/$tfile.moved is not in parent list"
12295 # 6.2) linkea update on unlink
12296 rm -f $DIR/$tdir/d/foo2/link
12297 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12298 # foo2/link should no longer be returned in parent list
12299 echo "$parent" | grep -F "$FID2/link" &&
12300 error "$FID2/link should no longer be in parent list"
12304 restore_lustre_params < $save
12307 run_test 154f "get parent fids by reading link ea"
12311 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12312 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
12313 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
12314 skip "Need MDS version at least 2.6.92"
12316 mkdir -p $DIR/$tdir
12317 llapi_fid_test -d $DIR/$tdir
12319 run_test 154g "various llapi FID tests"
12321 test_155_small_load() {
12322 local temp=$TMP/$tfile
12323 local file=$DIR/$tfile
12325 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
12326 error "dd of=$temp bs=6096 count=1 failed"
12328 cancel_lru_locks $OSC
12329 cmp $temp $file || error "$temp $file differ"
12331 $TRUNCATE $temp 6000
12332 $TRUNCATE $file 6000
12333 cmp $temp $file || error "$temp $file differ (truncate1)"
12335 echo "12345" >>$temp
12336 echo "12345" >>$file
12337 cmp $temp $file || error "$temp $file differ (append1)"
12339 echo "12345" >>$temp
12340 echo "12345" >>$file
12341 cmp $temp $file || error "$temp $file differ (append2)"
12347 test_155_big_load() {
12348 remote_ost_nodsh && skip "remote OST with nodsh"
12350 local temp=$TMP/$tfile
12351 local file=$DIR/$tfile
12354 local cache_size=$(do_facet ost$((MAXI+1)) \
12355 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
12356 local large_file_size=$((cache_size * 2))
12358 echo "OSS cache size: $cache_size KB"
12359 echo "Large file size: $large_file_size KB"
12361 [ $MAXV -le $large_file_size ] &&
12362 skip_env "max available OST size needs > $large_file_size KB"
12364 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
12366 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
12367 error "dd of=$temp bs=$large_file_size count=1k failed"
12370 cancel_lru_locks osc
12371 cmp $temp $file || error "$temp $file differ"
12377 save_writethrough() {
12378 local facets=$(get_facets OST)
12380 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
12384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12386 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12388 save_writethrough $p
12391 set_cache writethrough on
12392 test_155_small_load
12393 restore_lustre_params < $p
12396 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
12399 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12401 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12403 save_writethrough $p
12406 set_cache writethrough off
12407 test_155_small_load
12408 restore_lustre_params < $p
12411 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
12414 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12416 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12418 save_writethrough $p
12421 set_cache writethrough on
12422 test_155_small_load
12423 restore_lustre_params < $p
12426 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
12429 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12431 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12433 save_writethrough $p
12436 set_cache writethrough off
12437 test_155_small_load
12438 restore_lustre_params < $p
12441 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
12444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12446 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12448 save_writethrough $p
12451 set_cache writethrough on
12453 restore_lustre_params < $p
12456 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
12459 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12461 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12463 save_writethrough $p
12466 set_cache writethrough off
12468 restore_lustre_params < $p
12471 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
12474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12476 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12478 save_writethrough $p
12481 set_cache writethrough on
12483 restore_lustre_params < $p
12486 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
12489 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12491 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12493 save_writethrough $p
12496 set_cache writethrough off
12498 restore_lustre_params < $p
12501 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
12504 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12505 remote_ost_nodsh && skip "remote OST with nodsh"
12506 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
12507 skip "stats not implemented on old servers"
12508 [ "$ost1_FSTYPE" = "zfs" ] &&
12509 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
12514 local file="$DIR/$tfile"
12515 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12517 save_writethrough $p
12520 log "Turn on read and write cache"
12522 set_cache writethrough on
12524 log "Write data and read it back."
12525 log "Read should be satisfied from the cache."
12526 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12528 cancel_lru_locks osc
12529 cat $file >/dev/null
12531 if ! let "AFTER - BEFORE == CPAGES"; then
12532 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12534 log "cache hits:: before: $BEFORE, after: $AFTER"
12537 log "Read again; it should be satisfied from the cache."
12539 cancel_lru_locks osc
12540 cat $file >/dev/null
12542 if ! let "AFTER - BEFORE == CPAGES"; then
12543 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12545 log "cache hits:: before: $BEFORE, after: $AFTER"
12548 log "Turn off the read cache and turn on the write cache"
12550 set_cache writethrough on
12552 log "Read again; it should be satisfied from the cache."
12554 cancel_lru_locks osc
12555 cat $file >/dev/null
12557 if ! let "AFTER - BEFORE == CPAGES"; then
12558 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12560 log "cache hits:: before: $BEFORE, after: $AFTER"
12563 log "Read again; it should not be satisfied from the cache."
12565 cancel_lru_locks osc
12566 cat $file >/dev/null
12568 if ! let "AFTER - BEFORE == 0"; then
12569 error "IN CACHE: before: $BEFORE, after: $AFTER"
12571 log "cache hits:: before: $BEFORE, after: $AFTER"
12574 log "Write data and read it back."
12575 log "Read should be satisfied from the cache."
12576 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12578 cancel_lru_locks osc
12579 cat $file >/dev/null
12581 if ! let "AFTER - BEFORE == CPAGES"; then
12582 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12584 log "cache hits:: before: $BEFORE, after: $AFTER"
12587 log "Read again; it should not be satisfied from the cache."
12589 cancel_lru_locks osc
12590 cat $file >/dev/null
12592 if ! let "AFTER - BEFORE == 0"; then
12593 error "IN CACHE: before: $BEFORE, after: $AFTER"
12595 log "cache hits:: before: $BEFORE, after: $AFTER"
12598 log "Turn off read and write cache"
12600 set_cache writethrough off
12602 log "Write data and read it back"
12603 log "It should not be satisfied from the cache."
12605 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12606 cancel_lru_locks osc
12608 cat $file >/dev/null
12610 if ! let "AFTER - BEFORE == 0"; then
12611 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12613 log "cache hits:: before: $BEFORE, after: $AFTER"
12616 log "Turn on the read cache and turn off the write cache"
12618 set_cache writethrough off
12620 log "Write data and read it back"
12621 log "It should not be satisfied from the cache."
12623 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12625 cancel_lru_locks osc
12626 cat $file >/dev/null
12628 if ! let "AFTER - BEFORE == 0"; then
12629 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12631 log "cache hits:: before: $BEFORE, after: $AFTER"
12634 log "Read again; it should be satisfied from the cache."
12636 cancel_lru_locks osc
12637 cat $file >/dev/null
12639 if ! let "AFTER - BEFORE == CPAGES"; then
12640 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12642 log "cache hits:: before: $BEFORE, after: $AFTER"
12645 restore_lustre_params < $p
12648 run_test 156 "Verification of tunables"
12651 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12652 remote_mds_nodsh && skip "remote MDS with nodsh"
12653 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
12654 skip "Need MDS version at least 2.2.0"
12656 changelog_register || error "changelog_register failed"
12657 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12658 changelog_users $SINGLEMDS | grep -q $cl_user ||
12659 error "User $cl_user not found in changelog_users"
12662 test_mkdir -p $DIR/$tdir/pics/2008/zachy
12663 changelog_clear 0 || error "changelog_clear failed"
12664 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
12665 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
12666 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
12667 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
12668 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
12669 rm $DIR/$tdir/pics/desktop.jpg
12671 changelog_dump | tail -10
12673 echo "verifying changelog mask"
12674 changelog_chmask "-MKDIR"
12675 changelog_chmask "-CLOSE"
12677 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
12678 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
12680 changelog_chmask "+MKDIR"
12681 changelog_chmask "+CLOSE"
12683 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
12684 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
12686 changelog_dump | tail -10
12687 MKDIRS=$(changelog_dump | grep -c "MKDIR")
12688 CLOSES=$(changelog_dump | grep -c "CLOSE")
12689 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
12690 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
12693 echo "verifying target fid"
12694 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
12695 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
12696 [ "$fidc" == "$fidf" ] ||
12697 error "changelog '$tfile' fid $fidc != file fid $fidf"
12698 echo "verifying parent fid"
12699 # The FID returned from the Changelog may be the directory shard on
12700 # a different MDT, and not the FID returned by path2fid on the parent.
12701 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
12702 # since this is what will matter when recreating this file in the tree.
12703 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
12704 local pathp=$($LFS fid2path $MOUNT "$fidp")
12705 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
12706 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
12708 echo "getting records for $cl_user"
12709 changelog_users $SINGLEMDS
12710 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
12712 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
12713 error "changelog_clear failed"
12714 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
12715 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
12716 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
12717 error "user index expect $user_rec1 + $nclr != $user_rec2"
12719 local min0_rec=$(changelog_users $SINGLEMDS |
12720 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
12721 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
12722 awk '{ print $1; exit; }')
12724 changelog_dump | tail -n 5
12725 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
12726 [ $first_rec == $((min0_rec + 1)) ] ||
12727 error "first index should be $min0_rec + 1 not $first_rec"
12729 # LU-3446 changelog index reset on MDT restart
12730 local cur_rec1=$(changelog_users $SINGLEMDS |
12731 awk '/^current.index:/ { print $NF }')
12732 changelog_clear 0 ||
12733 error "clear all changelog records for $cl_user failed"
12734 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
12735 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
12736 error "Fail to start $SINGLEMDS"
12737 local cur_rec2=$(changelog_users $SINGLEMDS |
12738 awk '/^current.index:/ { print $NF }')
12739 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
12740 [ $cur_rec1 == $cur_rec2 ] ||
12741 error "current index should be $cur_rec1 not $cur_rec2"
12743 echo "verifying users from this test are deregistered"
12744 changelog_deregister || error "changelog_deregister failed"
12745 changelog_users $SINGLEMDS | grep -q $cl_user &&
12746 error "User '$cl_user' still in changelog_users"
12748 # lctl get_param -n mdd.*.changelog_users
12749 # current index: 144
12750 # ID index (idle seconds)
12752 if ! changelog_users $SINGLEMDS | grep "^cl"; then
12753 # this is the normal case where all users were deregistered
12754 # make sure no new records are added when no users are present
12755 local last_rec1=$(changelog_users $SINGLEMDS |
12756 awk '/^current.index:/ { print $NF }')
12757 touch $DIR/$tdir/chloe
12758 local last_rec2=$(changelog_users $SINGLEMDS |
12759 awk '/^current.index:/ { print $NF }')
12760 echo "verify changelogs are off: $last_rec1 == $last_rec2"
12761 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
12763 # any changelog users must be leftovers from a previous test
12764 changelog_users $SINGLEMDS
12765 echo "other changelog users; can't verify off"
12768 run_test 160a "changelog sanity"
12770 test_160b() { # LU-3587
12771 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12772 remote_mds_nodsh && skip "remote MDS with nodsh"
12773 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
12774 skip "Need MDS version at least 2.2.0"
12776 changelog_register || error "changelog_register failed"
12777 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12778 changelog_users $SINGLEMDS | grep -q $cl_user ||
12779 error "User '$cl_user' not found in changelog_users"
12781 local longname1=$(str_repeat a 255)
12782 local longname2=$(str_repeat b 255)
12785 echo "creating very long named file"
12786 touch $longname1 || error "create of '$longname1' failed"
12787 echo "renaming very long named file"
12788 mv $longname1 $longname2
12790 changelog_dump | grep RENME | tail -n 5
12793 run_test 160b "Verify that very long rename doesn't crash in changelog"
12796 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12797 remote_mds_nodsh && skip "remote MDS with nodsh"
12799 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
12800 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
12801 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
12802 skip "Need MDS version at least 2.5.58 or 2.5.2+"
12806 # Registration step
12807 changelog_register || error "changelog_register failed"
12810 mkdir -p $DIR/$tdir
12811 $MCREATE $DIR/$tdir/foo_160c
12812 changelog_chmask "-TRUNC"
12813 $TRUNCATE $DIR/$tdir/foo_160c 200
12814 changelog_chmask "+TRUNC"
12815 $TRUNCATE $DIR/$tdir/foo_160c 199
12816 changelog_dump | tail -n 5
12817 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
12818 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
12820 run_test 160c "verify that changelog log catch the truncate event"
12823 remote_mds_nodsh && skip "remote MDS with nodsh"
12824 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12825 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12826 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
12827 skip "Need MDS version at least 2.7.60"
12829 # Registration step
12830 changelog_register || error "changelog_register failed"
12832 mkdir -p $DIR/$tdir/migrate_dir
12833 changelog_clear 0 || error "changelog_clear failed"
12835 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
12836 changelog_dump | tail -n 5
12837 local migrates=$(changelog_dump | grep -c "MIGRT")
12838 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
12840 run_test 160d "verify that changelog log catch the migrate event"
12843 remote_mds_nodsh && skip "remote MDS with nodsh"
12846 changelog_register || error "changelog_register failed"
12848 # Delete a future user (expect fail)
12849 local MDT0=$(facet_svc $SINGLEMDS)
12850 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
12853 if [ $rc -eq 0 ]; then
12854 error "Deleted non-existant user cl77"
12855 elif [ $rc -ne 2 ]; then
12856 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
12859 # Clear to a bad index (1 billion should be safe)
12860 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
12863 if [ $rc -eq 0 ]; then
12864 error "Successfully cleared to invalid CL index"
12865 elif [ $rc -ne 22 ]; then
12866 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
12869 run_test 160e "changelog negative testing (should return errors)"
12872 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12873 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
12874 skip "Need MDS version at least 2.10.56"
12876 local mdts=$(comma_list $(mdts_nodes))
12879 changelog_register || error "first changelog_register failed"
12880 changelog_register || error "second changelog_register failed"
12882 declare -A cl_user1
12883 declare -A cl_user2
12888 # generate some changelog records to accumulate on each MDT
12889 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
12890 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12891 error "create $DIR/$tdir/$tfile failed"
12893 # check changelogs have been generated
12894 local nbcl=$(changelog_dump | wc -l)
12895 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12897 for param in "changelog_max_idle_time=10" \
12899 "changelog_min_gc_interval=2" \
12900 "changelog_min_free_cat_entries=3"; do
12901 local MDT0=$(facet_svc $SINGLEMDS)
12902 local var="${param%=*}"
12903 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12905 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12906 do_nodes $mdts $LCTL set_param mdd.*.$param
12909 # force cl_user2 to be idle (1st part)
12912 # simulate changelog catalog almost full
12913 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12914 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12916 for i in $(seq $MDSCOUNT); do
12917 cl_users=(${CL_USERS[mds$i]})
12918 cl_user1[mds$i]="${cl_users[0]}"
12919 cl_user2[mds$i]="${cl_users[1]}"
12921 [ -n "${cl_user1[mds$i]}" ] ||
12922 error "mds$i: no user registered"
12923 [ -n "${cl_user2[mds$i]}" ] ||
12924 error "mds$i: only ${cl_user2[mds$i]} is registered"
12926 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12927 [ -n "$user_rec1" ] ||
12928 error "mds$i: User ${cl_user1[mds$i]} not registered"
12929 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12930 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12931 [ -n "$user_rec2" ] ||
12932 error "mds$i: User ${cl_user1[mds$i]} not registered"
12933 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12934 "$user_rec1 + 2 == $user_rec2"
12935 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12936 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12937 "$user_rec1 + 2, but is $user_rec2"
12938 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12939 [ -n "$user_rec2" ] ||
12940 error "mds$i: User ${cl_user2[mds$i]} not registered"
12941 [ $user_rec1 == $user_rec2 ] ||
12942 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12943 "$user_rec1, but is $user_rec2"
12946 # force cl_user2 to be idle (2nd part) and to reach
12947 # changelog_max_idle_time
12950 # generate one more changelog to trigger fail_loc
12951 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12952 error "create $DIR/$tdir/${tfile}bis failed"
12954 # ensure gc thread is done
12955 for i in $(mdts_nodes); do
12957 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
12958 error "$i: GC-thread not done"
12962 for i in $(seq $MDSCOUNT); do
12963 # check cl_user1 still registered
12964 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12965 error "mds$i: User ${cl_user1[mds$i]} not registered"
12966 # check cl_user2 unregistered
12967 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12968 error "mds$i: User ${cl_user2[mds$i]} still registered"
12970 # check changelogs are present and starting at $user_rec1 + 1
12971 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12972 [ -n "$user_rec1" ] ||
12973 error "mds$i: User ${cl_user1[mds$i]} not registered"
12974 first_rec=$($LFS changelog $(facet_svc mds$i) |
12975 awk '{ print $1; exit; }')
12977 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12978 [ $((user_rec1 + 1)) == $first_rec ] ||
12979 error "mds$i: first index should be $user_rec1 + 1, " \
12980 "but is $first_rec"
12983 run_test 160f "changelog garbage collect (timestamped users)"
12986 remote_mds_nodsh && skip "remote MDS with nodsh"
12987 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
12988 skip "Need MDS version at least 2.10.56"
12990 local mdts=$(comma_list $(mdts_nodes))
12992 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
12993 do_nodes $mdts $LCTL set_param fail_loc=0x1314
12996 changelog_register || error "first changelog_register failed"
12997 changelog_register || error "second changelog_register failed"
12999 declare -A cl_user1
13000 declare -A cl_user2
13005 # generate some changelog records to accumulate on each MDT
13006 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13007 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13008 error "create $DIR/$tdir/$tfile failed"
13010 # check changelogs have been generated
13011 local nbcl=$(changelog_dump | wc -l)
13012 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13014 # reduce the max_idle_indexes value to make sure we exceed it
13015 max_ndx=$((nbcl / 2 - 1))
13017 for param in "changelog_max_idle_indexes=$max_ndx" \
13019 "changelog_min_gc_interval=2" \
13020 "changelog_min_free_cat_entries=3"; do
13021 local MDT0=$(facet_svc $SINGLEMDS)
13022 local var="${param%=*}"
13023 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13025 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13026 do_nodes $mdts $LCTL set_param mdd.*.$param ||
13027 error "unable to set mdd.*.$param"
13030 # simulate changelog catalog almost full
13031 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13032 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13034 for i in $(seq $MDSCOUNT); do
13035 cl_users=(${CL_USERS[mds$i]})
13036 cl_user1[mds$i]="${cl_users[0]}"
13037 cl_user2[mds$i]="${cl_users[1]}"
13039 [ -n "${cl_user1[mds$i]}" ] ||
13040 error "mds$i: no user registered"
13041 [ -n "${cl_user2[mds$i]}" ] ||
13042 error "mds$i: only ${cl_user1[mds$i]} is registered"
13044 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13045 [ -n "$user_rec1" ] ||
13046 error "mds$i: User ${cl_user1[mds$i]} not registered"
13047 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13048 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13049 [ -n "$user_rec2" ] ||
13050 error "mds$i: User ${cl_user1[mds$i]} not registered"
13051 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13052 "$user_rec1 + 2 == $user_rec2"
13053 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13054 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13055 "$user_rec1 + 2, but is $user_rec2"
13056 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13057 [ -n "$user_rec2" ] ||
13058 error "mds$i: User ${cl_user2[mds$i]} not registered"
13059 [ $user_rec1 == $user_rec2 ] ||
13060 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13061 "$user_rec1, but is $user_rec2"
13064 # ensure we are past the previous changelog_min_gc_interval set above
13067 # generate one more changelog to trigger fail_loc
13068 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13069 error "create $DIR/$tdir/${tfile}bis failed"
13071 # ensure gc thread is done
13072 for i in $(mdts_nodes); do
13074 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13075 error "$i: GC-thread not done"
13079 for i in $(seq $MDSCOUNT); do
13080 # check cl_user1 still registered
13081 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13082 error "mds$i: User ${cl_user1[mds$i]} not registered"
13083 # check cl_user2 unregistered
13084 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13085 error "mds$i: User ${cl_user2[mds$i]} still registered"
13087 # check changelogs are present and starting at $user_rec1 + 1
13088 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13089 [ -n "$user_rec1" ] ||
13090 error "mds$i: User ${cl_user1[mds$i]} not registered"
13091 first_rec=$($LFS changelog $(facet_svc mds$i) |
13092 awk '{ print $1; exit; }')
13094 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13095 [ $((user_rec1 + 1)) == $first_rec ] ||
13096 error "mds$i: first index should be $user_rec1 + 1, " \
13097 "but is $first_rec"
13100 run_test 160g "changelog garbage collect (old users)"
13103 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13104 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13105 skip "Need MDS version at least 2.10.56"
13107 local mdts=$(comma_list $(mdts_nodes))
13110 changelog_register || error "first changelog_register failed"
13111 changelog_register || error "second changelog_register failed"
13113 declare -A cl_user1
13114 declare -A cl_user2
13119 # generate some changelog records to accumulate on each MDT
13120 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13121 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13122 error "create $DIR/$tdir/$tfile failed"
13124 # check changelogs have been generated
13125 local nbcl=$(changelog_dump | wc -l)
13126 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13128 for param in "changelog_max_idle_time=10" \
13130 "changelog_min_gc_interval=2"; do
13131 local MDT0=$(facet_svc $SINGLEMDS)
13132 local var="${param%=*}"
13133 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13135 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13136 do_nodes $mdts $LCTL set_param mdd.*.$param
13139 # force cl_user2 to be idle (1st part)
13142 for i in $(seq $MDSCOUNT); do
13143 cl_users=(${CL_USERS[mds$i]})
13144 cl_user1[mds$i]="${cl_users[0]}"
13145 cl_user2[mds$i]="${cl_users[1]}"
13147 [ -n "${cl_user1[mds$i]}" ] ||
13148 error "mds$i: no user registered"
13149 [ -n "${cl_user2[mds$i]}" ] ||
13150 error "mds$i: only ${cl_user2[mds$i]} is registered"
13152 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13153 [ -n "$user_rec1" ] ||
13154 error "mds$i: User ${cl_user1[mds$i]} not registered"
13155 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13156 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13157 [ -n "$user_rec2" ] ||
13158 error "mds$i: User ${cl_user1[mds$i]} not registered"
13159 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13160 "$user_rec1 + 2 == $user_rec2"
13161 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13162 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13163 "$user_rec1 + 2, but is $user_rec2"
13164 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13165 [ -n "$user_rec2" ] ||
13166 error "mds$i: User ${cl_user2[mds$i]} not registered"
13167 [ $user_rec1 == $user_rec2 ] ||
13168 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13169 "$user_rec1, but is $user_rec2"
13172 # force cl_user2 to be idle (2nd part) and to reach
13173 # changelog_max_idle_time
13176 # force each GC-thread start and block then
13177 # one per MDT/MDD, set fail_val accordingly
13178 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
13179 do_nodes $mdts $LCTL set_param fail_loc=0x1316
13181 # generate more changelogs to trigger fail_loc
13182 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13183 error "create $DIR/$tdir/${tfile}bis failed"
13185 # stop MDT to stop GC-thread, should be done in back-ground as it will
13186 # block waiting for the thread to be released and exit
13187 declare -A stop_pids
13188 for i in $(seq $MDSCOUNT); do
13190 stop_pids[mds$i]=$!
13193 for i in $(mdts_nodes); do
13196 local facets=$(facets_up_on_host $i)
13198 for facet in ${facets//,/ }; do
13199 if [[ $facet == mds* ]]; then
13203 # ensure each MDS's gc threads are still present and all in "R"
13204 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
13205 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
13206 error "$i: expected $nb GC-thread"
13208 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
13210 error "$i: GC-thread not found in R-state"
13211 # check umounts of each MDT on MDS have reached kthread_stop()
13212 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
13213 error "$i: expected $nb umount"
13215 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
13216 error "$i: umount not found in D-state"
13219 # release all GC-threads
13220 do_nodes $mdts $LCTL set_param fail_loc=0
13222 # wait for MDT stop to complete
13223 for i in $(seq $MDSCOUNT); do
13224 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
13228 # may try to check if any orphan changelog records are present
13229 # via ldiskfs/zfs and llog_reader...
13231 # re-start/mount MDTs
13232 for i in $(seq $MDSCOUNT); do
13233 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
13234 error "Fail to start mds$i"
13238 for i in $(seq $MDSCOUNT); do
13239 # check cl_user1 still registered
13240 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13241 error "mds$i: User ${cl_user1[mds$i]} not registered"
13242 # check cl_user2 unregistered
13243 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13244 error "mds$i: User ${cl_user2[mds$i]} still registered"
13246 # check changelogs are present and starting at $user_rec1 + 1
13247 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13248 [ -n "$user_rec1" ] ||
13249 error "mds$i: User ${cl_user1[mds$i]} not registered"
13250 first_rec=$($LFS changelog $(facet_svc mds$i) |
13251 awk '{ print $1; exit; }')
13253 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13254 [ $((user_rec1 + 1)) == $first_rec ] ||
13255 error "mds$i: first index should be $user_rec1 + 1, " \
13256 "but is $first_rec"
13259 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
13264 local mdts=$(comma_list $(mdts_nodes))
13266 changelog_register || error "first changelog_register failed"
13268 # generate some changelog records to accumulate on each MDT
13269 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13270 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13271 error "create $DIR/$tdir/$tfile failed"
13273 # check changelogs have been generated
13274 local nbcl=$(changelog_dump | wc -l)
13275 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13277 # simulate race between register and unregister
13278 # XXX as fail_loc is set per-MDS, with DNE configs the race
13279 # simulation will only occur for one MDT per MDS and for the
13280 # others the normal race scenario will take place
13281 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
13282 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
13283 do_nodes $mdts $LCTL set_param fail_val=1
13285 # unregister 1st user
13286 changelog_deregister &
13288 # wait some time for deregister work to reach race rdv
13290 # register 2nd user
13291 changelog_register || error "2nd user register failed"
13293 wait $pid1 || error "1st user deregister failed"
13297 declare -A LAST_REC
13298 for i in $(seq $MDSCOUNT); do
13299 if changelog_users mds$i | grep "^cl"; then
13300 # make sure new records are added with one user present
13301 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
13302 awk '/^current.index:/ { print $NF }')
13304 error "mds$i has no user registered"
13308 # generate more changelog records to accumulate on each MDT
13309 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13310 error "create $DIR/$tdir/${tfile}bis failed"
13312 for i in $(seq $MDSCOUNT); do
13313 last_rec=$(changelog_users $SINGLEMDS |
13314 awk '/^current.index:/ { print $NF }')
13315 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
13316 [ $last_rec != ${LAST_REC[mds$i]} ] ||
13317 error "changelogs are off on mds$i"
13320 run_test 160i "changelog user register/unregister race"
13323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13325 test_mkdir -c1 $DIR/$tdir
13326 cp /etc/hosts $DIR/$tdir/$tfile
13327 test_mkdir -c1 $DIR/$tdir/foo1
13328 test_mkdir -c1 $DIR/$tdir/foo2
13329 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
13330 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
13331 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
13332 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
13333 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
13334 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13335 $LFS fid2path $DIR $FID
13336 error "bad link ea"
13339 rm $DIR/$tdir/foo2/zachary
13341 rm $DIR/$tdir/foo2/thor
13343 rm $DIR/$tdir/$tfile
13345 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
13346 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
13347 { $LFS fid2path $DIR $FID; error "bad link rename"; }
13348 rm $DIR/$tdir/foo2/maggie
13351 local longname=$tfile.avg_len_is_thirty_two_
13352 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
13353 error_noexit 'failed to unlink many hardlinks'" EXIT
13354 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
13355 error "failed to hardlink many files"
13356 links=$($LFS fid2path $DIR $FID | wc -l)
13357 echo -n "${links}/1000 links in link EA"
13358 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
13360 run_test 161a "link ea sanity"
13363 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13364 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
13367 local remote_dir=$DIR/$tdir/remote_dir
13369 mkdir -p $DIR/$tdir
13370 $LFS mkdir -i $MDTIDX $remote_dir ||
13371 error "create remote directory failed"
13373 cp /etc/hosts $remote_dir/$tfile
13374 mkdir -p $remote_dir/foo1
13375 mkdir -p $remote_dir/foo2
13376 ln $remote_dir/$tfile $remote_dir/foo1/sofia
13377 ln $remote_dir/$tfile $remote_dir/foo2/zachary
13378 ln $remote_dir/$tfile $remote_dir/foo1/luna
13379 ln $remote_dir/$tfile $remote_dir/foo2/thor
13381 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
13383 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13384 $LFS fid2path $DIR $FID
13385 error "bad link ea"
13388 rm $remote_dir/foo2/zachary
13390 rm $remote_dir/foo2/thor
13392 rm $remote_dir/$tfile
13394 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
13395 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
13396 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
13397 $LFS fid2path $DIR $FID
13398 error "bad link rename"
13400 rm $remote_dir/foo2/maggie
13403 local longname=filename_avg_len_is_thirty_two_
13404 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
13405 error "failed to hardlink many files"
13406 links=$($LFS fid2path $DIR $FID | wc -l)
13407 echo -n "${links}/1000 links in link EA"
13408 [[ ${links} -gt 60 ]] ||
13409 error "expected at least 60 links in link EA"
13410 unlinkmany $remote_dir/foo2/$longname 1000 ||
13411 error "failed to unlink many hardlinks"
13413 run_test 161b "link ea sanity under remote directory"
13416 remote_mds_nodsh && skip "remote MDS with nodsh"
13417 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13418 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
13419 skip "Need MDS version at least 2.1.5"
13421 # define CLF_RENAME_LAST 0x0001
13422 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
13423 changelog_register || error "changelog_register failed"
13426 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
13427 touch $DIR/$tdir/foo_161c
13428 touch $DIR/$tdir/bar_161c
13429 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13430 changelog_dump | grep RENME | tail -n 5
13431 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13432 changelog_clear 0 || error "changelog_clear failed"
13433 if [ x$flags != "x0x1" ]; then
13434 error "flag $flags is not 0x1"
13437 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
13438 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
13439 touch $DIR/$tdir/foo_161c
13440 touch $DIR/$tdir/bar_161c
13441 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13442 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13443 changelog_dump | grep RENME | tail -n 5
13444 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13445 changelog_clear 0 || error "changelog_clear failed"
13446 if [ x$flags != "x0x0" ]; then
13447 error "flag $flags is not 0x0"
13449 echo "rename overwrite a target having nlink > 1," \
13450 "changelog record has flags of $flags"
13452 # rename doesn't overwrite a target (changelog flag 0x0)
13453 touch $DIR/$tdir/foo_161c
13454 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
13455 changelog_dump | grep RENME | tail -n 5
13456 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
13457 changelog_clear 0 || error "changelog_clear failed"
13458 if [ x$flags != "x0x0" ]; then
13459 error "flag $flags is not 0x0"
13461 echo "rename doesn't overwrite a target," \
13462 "changelog record has flags of $flags"
13464 # define CLF_UNLINK_LAST 0x0001
13465 # unlink a file having nlink = 1 (changelog flag 0x1)
13466 rm -f $DIR/$tdir/foo2_161c
13467 changelog_dump | grep UNLNK | tail -n 5
13468 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13469 changelog_clear 0 || error "changelog_clear failed"
13470 if [ x$flags != "x0x1" ]; then
13471 error "flag $flags is not 0x1"
13473 echo "unlink a file having nlink = 1," \
13474 "changelog record has flags of $flags"
13476 # unlink a file having nlink > 1 (changelog flag 0x0)
13477 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13478 rm -f $DIR/$tdir/foobar_161c
13479 changelog_dump | grep UNLNK | tail -n 5
13480 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13481 changelog_clear 0 || error "changelog_clear failed"
13482 if [ x$flags != "x0x0" ]; then
13483 error "flag $flags is not 0x0"
13485 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
13487 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
13490 remote_mds_nodsh && skip "remote MDS with nodsh"
13491 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
13496 changelog_register || error "changelog_register failed"
13498 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
13499 # interfer with $MOUNT/.lustre/fid/ access
13501 [[ $? -eq 0 ]] || error "mkdir failed"
13503 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
13504 $LCTL set_param fail_loc=0x8000140c
13506 $LCTL set_param fail_val=5
13509 echo foofoo > $DIR/$tdir/$tfile &
13512 # wait for create to be delayed
13516 [[ $? -eq 0 ]] || error "create should be blocked"
13518 local tempfile=$(mktemp)
13519 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
13520 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
13521 # some delay may occur during ChangeLog publishing and file read just
13522 # above, that could allow file write to happen finally
13523 [[ -s $tempfile ]] && echo "file should be empty"
13525 $LCTL set_param fail_loc=0
13528 [[ $? -eq 0 ]] || error "create failed"
13530 run_test 161d "create with concurrent .lustre/fid access"
13533 local expected="$1"
13538 path=$($LFS fid2path "$@")
13541 if [ $rc -ne 0 ]; then
13542 error "path looked up of '$expected' failed: rc=$rc"
13543 elif [ "$path" != "$expected" ]; then
13544 error "path looked up '$path' instead of '$expected'"
13546 echo "FID '$fid' resolves to path '$path' as expected"
13550 test_162a() { # was test_162
13551 test_mkdir -p -c1 $DIR/$tdir/d2
13552 touch $DIR/$tdir/d2/$tfile
13553 touch $DIR/$tdir/d2/x1
13554 touch $DIR/$tdir/d2/x2
13555 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
13556 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
13558 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
13559 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
13562 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
13563 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
13564 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
13566 # softlink to wrong file
13567 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
13568 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
13569 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
13572 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
13573 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
13574 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
13575 # fid2path dir/fsname should both work
13576 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
13577 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
13579 # hardlink count: check that there are 2 links
13580 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
13581 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
13583 # hardlink indexing: remove the first link
13584 rm $DIR/$tdir/d2/p/q/r/hlink
13585 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
13587 run_test 162a "path lookup sanity"
13590 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13591 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13594 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
13595 error "create striped dir failed"
13597 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
13598 tail -n 1 | awk '{print $2}')
13599 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
13601 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
13602 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
13605 for ((i=0;i<5;i++)); do
13606 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
13607 error "get fid for f$i failed"
13608 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
13610 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
13611 error "get fid for d$i failed"
13612 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
13617 run_test 162b "striped directory path lookup sanity"
13619 # LU-4239: Verify fid2path works with paths 100 or more directories deep
13621 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
13622 skip "Need MDS version at least 2.7.51"
13624 local lpath=$tdir.local
13625 local rpath=$tdir.remote
13627 test_mkdir $DIR/$lpath
13628 test_mkdir $DIR/$rpath
13630 for ((i = 0; i <= 101; i++)); do
13633 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
13634 error "get fid for local directory $DIR/$lpath failed"
13635 check_path "$DIR/$lpath" $MOUNT $FID --link 0
13638 test_mkdir $DIR/$rpath
13639 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
13640 error "get fid for remote directory $DIR/$rpath failed"
13641 check_path "$DIR/$rpath" $MOUNT $FID --link 0
13646 run_test 162c "fid2path works with paths 100 or more directories deep"
13649 # do directio so as not to populate the page cache
13650 log "creating a 10 Mb file"
13651 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13652 log "starting reads"
13653 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13654 log "truncating the file"
13655 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13657 kill %+ || true # reads might have finished
13658 echo "wait until dd is finished"
13660 log "removing the temporary file"
13661 rm -rf $DIR/$tfile || error "tmp file removal failed"
13663 run_test 169 "parallel read and truncate should not deadlock"
13666 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13668 $LCTL clear # bug 18514
13669 $LCTL debug_daemon start $TMP/${tfile}_log_good
13671 $LCTL debug_daemon stop
13672 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
13673 error "sed failed to read log_good"
13675 $LCTL debug_daemon start $TMP/${tfile}_log_good
13677 $LCTL debug_daemon stop
13679 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
13680 error "lctl df log_bad failed"
13682 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13683 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13685 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
13686 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
13688 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
13689 error "bad_line good_line1 good_line2 are empty"
13691 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13692 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
13693 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13695 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
13696 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13697 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13699 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
13700 error "bad_line_new good_line_new are empty"
13702 local expected_good=$((good_line1 + good_line2*2))
13704 rm -f $TMP/${tfile}*
13705 # LU-231, short malformed line may not be counted into bad lines
13706 if [ $bad_line -ne $bad_line_new ] &&
13707 [ $bad_line -ne $((bad_line_new - 1)) ]; then
13708 error "expected $bad_line bad lines, but got $bad_line_new"
13712 if [ $expected_good -ne $good_line_new ]; then
13713 error "expected $expected_good good lines, but got $good_line_new"
13718 run_test 170 "test lctl df to handle corrupted log ====================="
13720 test_171() { # bug20592
13721 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13723 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
13724 $LCTL set_param fail_loc=0x50e
13725 $LCTL set_param fail_val=3000
13726 multiop_bg_pause $DIR/$tfile O_s || true
13728 kill -USR1 $MULTIPID
13732 if dmesg | grep "recursive fault"; then
13733 error "caught a recursive fault"
13735 $LCTL set_param fail_loc=0
13738 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
13740 # it would be good to share it with obdfilter-survey/iokit-libecho code
13741 setup_obdecho_osc () {
13744 local obdfilter_name=$2
13745 echo "Creating new osc for $obdfilter_name on $ost_nid"
13746 # make sure we can find loopback nid
13747 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
13749 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
13750 ${obdfilter_name}_osc_UUID || rc=2; }
13751 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
13752 ${obdfilter_name}_UUID $ost_nid || rc=3; }
13756 cleanup_obdecho_osc () {
13757 local obdfilter_name=$1
13758 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
13759 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
13766 local pages=${3:-64}
13771 local obd_size=$(get_obd_size $node $OBD)
13772 local page_size=$(get_page_size $node)
13773 if [[ -n "$obd_size" ]]; then
13774 local new_count=$((obd_size / (pages * page_size / 1024)))
13775 [[ $new_count -ge $count ]] || count=$new_count
13778 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
13779 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
13781 if [ $rc -eq 0 ]; then
13782 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
13783 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
13785 echo "New object id is $id"
13786 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
13788 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
13789 "test_brw $count w v $pages $id" || rc=4; }
13790 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
13792 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
13793 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
13794 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
13795 { do_facet $node "$LCTL --device ec detach" || rc=6; }
13796 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
13801 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13803 if ! module_loaded obdecho; then
13804 load_module obdecho/obdecho &&
13805 stack_trap "rmmod obdecho" EXIT ||
13806 error "unable to load obdecho on client"
13809 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
13810 local host=$($LCTL get_param -n osc.$osc.import |
13811 awk '/current_connection:/ { print $2 }' )
13812 local target=$($LCTL get_param -n osc.$osc.import |
13813 awk '/target:/ { print $2 }' )
13814 target=${target%_UUID}
13816 if [ -n "$target" ]; then
13817 setup_obdecho_osc $host $target &&
13818 stack_trap "cleanup_obdecho_osc $target" EXIT ||
13819 { error "obdecho setup failed with $?"; return; }
13821 obdecho_test ${target}_osc client ||
13822 error "obdecho_test failed on ${target}_osc"
13824 $LCTL get_param osc.$osc.import
13825 error "there is no osc.$osc.import target"
13828 run_test 180a "test obdecho on osc"
13831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13832 remote_ost_nodsh && skip "remote OST with nodsh"
13834 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13835 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13836 error "failed to load module obdecho"
13838 local target=$(do_facet ost1 $LCTL dl |
13839 awk '/obdfilter/ { print $4; exit; }')
13841 if [ -n "$target" ]; then
13842 obdecho_test $target ost1 || error "obdecho_test failed with $?"
13844 do_facet ost1 $LCTL dl
13845 error "there is no obdfilter target on ost1"
13848 run_test 180b "test obdecho directly on obdfilter"
13850 test_180c() { # LU-2598
13851 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13852 remote_ost_nodsh && skip "remote OST with nodsh"
13853 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
13854 skip "Need MDS version at least 2.4.0"
13856 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13857 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13858 error "failed to load module obdecho"
13860 local target=$(do_facet ost1 $LCTL dl |
13861 awk '/obdfilter/ { print $4; exit; }')
13863 if [ -n "$target" ]; then
13864 local pages=16384 # 64MB bulk I/O RPC size
13866 obdecho_test "$target" ost1 "$pages" ||
13867 error "obdecho_test with pages=$pages failed with $?"
13869 do_facet ost1 $LCTL dl
13870 error "there is no obdfilter target on ost1"
13873 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
13875 test_181() { # bug 22177
13876 test_mkdir $DIR/$tdir
13877 # create enough files to index the directory
13878 createmany -o $DIR/$tdir/foobar 4000
13879 # print attributes for debug purpose
13882 multiop_bg_pause $DIR/$tdir D_Sc || return 1
13884 # remove the files & current working dir
13885 unlinkmany $DIR/$tdir/foobar 4000
13887 kill -USR1 $MULTIPID
13889 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
13892 run_test 181 "Test open-unlinked dir ========================"
13898 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13900 $LCTL set_param mdc.*.rpc_stats=clear
13902 for (( i = 0; i < $tcount; i++ )) ; do
13903 mkdir $DIR/$tdir/$i
13906 for (( i = 0; i < $tcount; i++ )) ; do
13907 createmany -o $DIR/$tdir/$i/f- $fcount &
13911 for (( i = 0; i < $tcount; i++ )) ; do
13912 unlinkmany $DIR/$tdir/$i/f- $fcount &
13916 $LCTL get_param mdc.*.rpc_stats
13920 run_test 182 "Test parallel modify metadata operations ================"
13922 test_183() { # LU-2275
13923 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13924 remote_mds_nodsh && skip "remote MDS with nodsh"
13925 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
13926 skip "Need MDS version at least 2.3.56"
13928 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13929 echo aaa > $DIR/$tdir/$tfile
13931 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
13932 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
13934 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
13935 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
13937 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13939 # Flush negative dentry cache
13940 touch $DIR/$tdir/$tfile
13942 # We are not checking for any leaked references here, they'll
13943 # become evident next time we do cleanup with module unload.
13946 run_test 183 "No crash or request leak in case of strange dispositions ========"
13948 # test suite 184 is for LU-2016, LU-2017
13950 check_swap_layouts_support
13952 dir0=$DIR/$tdir/$testnum
13953 test_mkdir -p -c1 $dir0
13958 $LFS setstripe -c1 $file1
13960 $LFS setstripe -c2 $file2
13962 gen1=$($LFS getstripe -g $file1)
13963 gen2=$($LFS getstripe -g $file2)
13965 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
13966 gen=$($LFS getstripe -g $file1)
13967 [[ $gen1 != $gen ]] ||
13968 "Layout generation on $file1 does not change"
13969 gen=$($LFS getstripe -g $file2)
13970 [[ $gen2 != $gen ]] ||
13971 "Layout generation on $file2 does not change"
13973 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
13974 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13976 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
13978 run_test 184a "Basic layout swap"
13981 check_swap_layouts_support
13983 dir0=$DIR/$tdir/$testnum
13984 mkdir -p $dir0 || error "creating dir $dir0"
13991 $LFS setstripe -c1 $file1
13992 $LFS setstripe -c2 $file2
13993 $LFS setstripe -c1 $file3
13994 chown $RUNAS_ID $file3
13995 gen1=$($LFS getstripe -g $file1)
13996 gen2=$($LFS getstripe -g $file2)
13998 $LFS swap_layouts $dir1 $dir2 &&
13999 error "swap of directories layouts should fail"
14000 $LFS swap_layouts $dir1 $file1 &&
14001 error "swap of directory and file layouts should fail"
14002 $RUNAS $LFS swap_layouts $file1 $file2 &&
14003 error "swap of file we cannot write should fail"
14004 $LFS swap_layouts $file1 $file3 &&
14005 error "swap of file with different owner should fail"
14006 /bin/true # to clear error code
14008 run_test 184b "Forbidden layout swap (will generate errors)"
14011 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
14012 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
14013 check_swap_layouts_support
14015 local dir0=$DIR/$tdir/$testnum
14016 mkdir -p $dir0 || error "creating dir $dir0"
14018 local ref1=$dir0/ref1
14019 local ref2=$dir0/ref2
14020 local file1=$dir0/file1
14021 local file2=$dir0/file2
14022 # create a file large enough for the concurrent test
14023 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
14024 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
14025 echo "ref file size: ref1($(stat -c %s $ref1))," \
14026 "ref2($(stat -c %s $ref2))"
14029 dd if=$ref1 of=$file1 bs=16k &
14032 # Make sure dd starts to copy file
14033 while [ ! -f $file1 ]; do sleep 0.1; done
14035 $LFS swap_layouts $file1 $file2
14038 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
14039 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
14041 # how many bytes copied before swapping layout
14042 local copied=$(stat -c %s $file2)
14043 local remaining=$(stat -c %s $ref1)
14044 remaining=$((remaining - copied))
14045 echo "Copied $copied bytes before swapping layout..."
14047 cmp -n $copied $file1 $ref2 | grep differ &&
14048 error "Content mismatch [0, $copied) of ref2 and file1"
14049 cmp -n $copied $file2 $ref1 ||
14050 error "Content mismatch [0, $copied) of ref1 and file2"
14051 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
14052 error "Content mismatch [$copied, EOF) of ref1 and file1"
14055 rm -f $ref1 $ref2 $file1 $file2
14057 run_test 184c "Concurrent write and layout swap"
14060 check_swap_layouts_support
14061 [ -z "$(which getfattr 2>/dev/null)" ] &&
14062 skip_env "no getfattr command"
14064 local file1=$DIR/$tdir/$tfile-1
14065 local file2=$DIR/$tdir/$tfile-2
14066 local file3=$DIR/$tdir/$tfile-3
14070 mkdir -p $DIR/$tdir
14071 touch $file1 || error "create $file1 failed"
14072 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14073 error "create $file2 failed"
14074 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14075 error "create $file3 failed"
14076 lovea1=$(get_layout_param $file1)
14078 $LFS swap_layouts $file2 $file3 ||
14079 error "swap $file2 $file3 layouts failed"
14080 $LFS swap_layouts $file1 $file2 ||
14081 error "swap $file1 $file2 layouts failed"
14083 lovea2=$(get_layout_param $file2)
14086 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
14088 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14089 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
14091 run_test 184d "allow stripeless layouts swap"
14094 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
14095 skip "Need MDS version at least 2.6.94"
14096 check_swap_layouts_support
14097 [ -z "$(which getfattr 2>/dev/null)" ] &&
14098 skip_env "no getfattr command"
14100 local file1=$DIR/$tdir/$tfile-1
14101 local file2=$DIR/$tdir/$tfile-2
14102 local file3=$DIR/$tdir/$tfile-3
14105 mkdir -p $DIR/$tdir
14106 touch $file1 || error "create $file1 failed"
14107 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14108 error "create $file2 failed"
14109 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14110 error "create $file3 failed"
14112 $LFS swap_layouts $file1 $file2 ||
14113 error "swap $file1 $file2 layouts failed"
14115 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14116 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
14118 echo 123 > $file1 || error "Should be able to write into $file1"
14120 $LFS swap_layouts $file1 $file3 ||
14121 error "swap $file1 $file3 layouts failed"
14123 echo 123 > $file1 || error "Should be able to write into $file1"
14125 rm -rf $file1 $file2 $file3
14127 run_test 184e "Recreate layout after stripeless layout swaps"
14130 # Create a file with name longer than sizeof(struct stat) ==
14131 # 144 to see if we can get chars from the file name to appear
14132 # in the returned striping. Note that 'f' == 0x66.
14133 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
14135 mkdir -p $DIR/$tdir
14136 mcreate $DIR/$tdir/$file
14137 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
14138 error "IOC_MDC_GETFILEINFO returned garbage striping"
14141 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
14143 test_185() { # LU-2441
14144 # LU-3553 - no volatile file support in old servers
14145 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
14146 skip "Need MDS version at least 2.3.60"
14148 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14149 touch $DIR/$tdir/spoo
14150 local mtime1=$(stat -c "%Y" $DIR/$tdir)
14151 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
14152 error "cannot create/write a volatile file"
14153 [ "$FILESET" == "" ] &&
14154 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
14155 error "FID is still valid after close"
14157 multiop_bg_pause $DIR/$tdir vVw4096_c
14164 # assume that the next FID for this client is sequential, since stdout
14165 # is unfortunately eaten by multiop_bg_pause
14166 local n=$((${fidv[1]} + 1))
14167 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
14168 if [ "$FILESET" == "" ]; then
14169 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
14170 error "FID is missing before close"
14172 kill -USR1 $multi_pid
14173 # 1 second delay, so if mtime change we will see it
14175 local mtime2=$(stat -c "%Y" $DIR/$tdir)
14176 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
14178 run_test 185 "Volatile file support"
14181 remote_mds_nodsh && skip "remote MDS with nodsh"
14182 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14183 skip "Need MDS version at least 2.3.0"
14185 local dir0=$DIR/$tdir/$testnum
14186 mkdir -p $dir0 || error "creating dir $dir0"
14188 local file=$dir0/file1
14189 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
14190 local dv1=$($LFS data_version $file)
14191 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
14192 local dv2=$($LFS data_version $file)
14193 [[ $dv1 != $dv2 ]] ||
14194 error "data version did not change on write $dv1 == $dv2"
14199 run_test 187a "Test data version change"
14202 remote_mds_nodsh && skip "remote MDS with nodsh"
14203 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14204 skip "Need MDS version at least 2.3.0"
14206 local dir0=$DIR/$tdir/$testnum
14207 mkdir -p $dir0 || error "creating dir $dir0"
14209 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
14210 [[ ${DV[0]} != ${DV[1]} ]] ||
14211 error "data version did not change on write"\
14212 " ${DV[0]} == ${DV[1]}"
14217 run_test 187b "Test data version change on volatile file"
14220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14221 remote_mgs_nodsh && skip "remote MGS with nodsh"
14222 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14224 local POOL=${POOL:-cea1}
14225 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
14226 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
14229 local last_ost=$(($OSTCOUNT - 1))
14231 local ost_list=$(seq $first_ost $ost_step $last_ost)
14232 local ost_range="$first_ost $last_ost $ost_step"
14233 local test_path=$POOL_ROOT/$POOL_DIR_NAME
14234 local file_dir=$POOL_ROOT/file_tst
14235 local subdir=$test_path/subdir
14238 if ! combined_mgs_mds ; then
14243 # former test_200a test_200b
14244 pool_add $POOL || { rc=$? ; break; }
14245 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
14246 # former test_200c test_200d
14247 mkdir -p $test_path
14248 pool_set_dir $POOL $test_path || { rc=$? ; break; }
14249 pool_check_dir $POOL $test_path || { rc=$? ; break; }
14251 pool_check_dir $POOL $subdir || { rc=$? ; break; }
14252 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
14253 || { rc=$? ; break; }
14254 # former test_200e test_200f
14255 local files=$((OSTCOUNT*3))
14256 pool_alloc_files $POOL $test_path $files "$ost_list" \
14257 || { rc=$? ; break; }
14258 pool_create_files $POOL $file_dir $files "$ost_list" \
14259 || { rc=$? ; break; }
14260 # former test_200g test_200h
14261 pool_lfs_df $POOL || { rc=$? ; break; }
14262 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
14264 # former test_201a test_201b test_201c
14265 pool_remove_first_target $POOL || { rc=$? ; break; }
14267 local f=$test_path/$tfile
14268 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
14269 pool_remove $POOL $f || { rc=$? ; break; }
14275 if ! combined_mgs_mds ; then
14280 run_test 200 "OST pools"
14282 # usage: default_attr <count | size | offset>
14284 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
14287 # usage: check_default_stripe_attr
14288 check_default_stripe_attr() {
14289 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
14292 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
14294 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
14298 error "unknown getstripe attr '$1'"
14301 [ $ACTUAL == $EXPECTED ] ||
14302 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
14306 test_mkdir $DIR/$tdir
14307 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
14309 check_default_stripe_attr --stripe-count
14310 check_default_stripe_attr --stripe-size
14311 check_default_stripe_attr --stripe-index
14313 run_test 204a "Print default stripe attributes"
14316 test_mkdir $DIR/$tdir
14317 $LFS setstripe --stripe-count 1 $DIR/$tdir
14319 check_default_stripe_attr --stripe-size
14320 check_default_stripe_attr --stripe-index
14322 run_test 204b "Print default stripe size and offset"
14325 test_mkdir $DIR/$tdir
14326 $LFS setstripe --stripe-size 65536 $DIR/$tdir
14328 check_default_stripe_attr --stripe-count
14329 check_default_stripe_attr --stripe-index
14331 run_test 204c "Print default stripe count and offset"
14334 test_mkdir $DIR/$tdir
14335 $LFS setstripe --stripe-index 0 $DIR/$tdir
14337 check_default_stripe_attr --stripe-count
14338 check_default_stripe_attr --stripe-size
14340 run_test 204d "Print default stripe count and size"
14343 test_mkdir $DIR/$tdir
14344 $LFS setstripe -d $DIR/$tdir
14346 check_default_stripe_attr --stripe-count --raw
14347 check_default_stripe_attr --stripe-size --raw
14348 check_default_stripe_attr --stripe-index --raw
14350 run_test 204e "Print raw stripe attributes"
14353 test_mkdir $DIR/$tdir
14354 $LFS setstripe --stripe-count 1 $DIR/$tdir
14356 check_default_stripe_attr --stripe-size --raw
14357 check_default_stripe_attr --stripe-index --raw
14359 run_test 204f "Print raw stripe size and offset"
14362 test_mkdir $DIR/$tdir
14363 $LFS setstripe --stripe-size 65536 $DIR/$tdir
14365 check_default_stripe_attr --stripe-count --raw
14366 check_default_stripe_attr --stripe-index --raw
14368 run_test 204g "Print raw stripe count and offset"
14371 test_mkdir $DIR/$tdir
14372 $LFS setstripe --stripe-index 0 $DIR/$tdir
14374 check_default_stripe_attr --stripe-count --raw
14375 check_default_stripe_attr --stripe-size --raw
14377 run_test 204h "Print raw stripe count and size"
14379 # Figure out which job scheduler is being used, if any,
14380 # or use a fake one
14381 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
14382 JOBENV=SLURM_JOB_ID
14383 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
14385 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
14387 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
14388 JOBENV=LOADL_STEP_ID
14389 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
14392 $LCTL list_param jobid_name > /dev/null 2>&1
14393 if [ $? -eq 0 ]; then
14399 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
14401 verify_jobstats() {
14406 # we don't really need to clear the stats for this test to work, since each
14407 # command has a unique jobid, but it makes debugging easier if needed.
14408 # for facet in $facets; do
14409 # local dev=$(convert_facet2label $facet)
14410 # # clear old jobstats
14411 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
14414 # use a new JobID for each test, or we might see an old one
14415 [ "$JOBENV" = "FAKE_JOBID" ] &&
14416 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
14418 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
14420 [ "$JOBENV" = "nodelocal" ] && {
14421 FAKE_JOBID=id.$testnum.%e.$RANDOM
14422 $LCTL set_param jobid_name=$FAKE_JOBID
14423 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
14426 log "Test: ${cmd[*]}"
14427 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
14429 if [ $JOBENV = "FAKE_JOBID" ]; then
14430 FAKE_JOBID=$JOBVAL ${cmd[*]}
14435 # all files are created on OST0000
14436 for facet in $facets; do
14437 local stats="*.$(convert_facet2label $facet).job_stats"
14439 # strip out libtool wrappers for in-tree executables
14440 if [ $(do_facet $facet lctl get_param $stats |
14441 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
14442 do_facet $facet lctl get_param $stats
14443 error "No jobstats for $JOBVAL found on $facet::$stats"
14449 local new_jobenv=$1
14451 set_persistent_param_and_check client "jobid_var" \
14452 "$FSNAME.sys.jobid_var" $new_jobenv
14455 test_205() { # Job stats
14456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14457 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
14458 skip "Need MDS version with at least 2.7.1"
14459 remote_mgs_nodsh && skip "remote MGS with nodsh"
14460 remote_mds_nodsh && skip "remote MDS with nodsh"
14461 remote_ost_nodsh && skip "remote OST with nodsh"
14462 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
14463 skip "Server doesn't support jobstats"
14464 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
14466 local old_jobenv=$($LCTL get_param -n jobid_var)
14467 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
14469 if [[ $PERM_CMD == *"set_param -P"* ]]; then
14470 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
14472 stack_trap "do_facet mgs $PERM_CMD \
14473 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
14477 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
14478 mdt.*.job_cleanup_interval | head -n 1)
14479 local new_interval=5
14480 do_facet $SINGLEMDS \
14481 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
14482 stack_trap "do_facet $SINGLEMDS \
14483 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
14484 local start=$SECONDS
14488 cmd="mkdir $DIR/$tdir"
14489 verify_jobstats "$cmd" "$SINGLEMDS"
14491 cmd="rmdir $DIR/$tdir"
14492 verify_jobstats "$cmd" "$SINGLEMDS"
14493 # mkdir on secondary MDT
14494 if [ $MDSCOUNT -gt 1 ]; then
14495 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
14496 verify_jobstats "$cmd" "mds2"
14499 cmd="mknod $DIR/$tfile c 1 3"
14500 verify_jobstats "$cmd" "$SINGLEMDS"
14502 cmd="rm -f $DIR/$tfile"
14503 verify_jobstats "$cmd" "$SINGLEMDS"
14504 # create all files on OST0000 so verify_jobstats can find OST stats
14506 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
14507 verify_jobstats "$cmd" "$SINGLEMDS"
14509 cmd="touch $DIR/$tfile"
14510 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14512 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
14513 verify_jobstats "$cmd" "ost1"
14515 cancel_lru_locks osc
14516 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
14517 verify_jobstats "$cmd" "ost1"
14519 cmd="$TRUNCATE $DIR/$tfile 0"
14520 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14522 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
14523 verify_jobstats "$cmd" "$SINGLEMDS"
14524 # jobstats expiry - sleep until old stats should be expired
14525 local left=$((new_interval + 5 - (SECONDS - start)))
14526 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
14527 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
14529 cmd="mkdir $DIR/$tdir.expire"
14530 verify_jobstats "$cmd" "$SINGLEMDS"
14531 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
14532 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
14534 # Ensure that jobid are present in changelog (if supported by MDS)
14535 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
14536 changelog_dump | tail -10
14537 jobids=$(changelog_dump | tail -9 | grep -c "j=")
14538 [ $jobids -eq 9 ] ||
14539 error "Wrong changelog jobid count $jobids != 9"
14543 jobstats_set $JOBENV
14545 changelog_dump | grep $tfile
14546 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
14547 [ $jobids -eq 0 ] ||
14548 error "Unexpected jobids when jobid_var=$JOBENV"
14551 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
14552 JOBENV="JOBCOMPLEX"
14553 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
14555 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
14557 run_test 205 "Verify job stats"
14559 # LU-1480, LU-1773 and LU-1657
14561 mkdir -p $DIR/$tdir
14562 $LFS setstripe -c -1 $DIR/$tdir
14563 #define OBD_FAIL_LOV_INIT 0x1403
14564 $LCTL set_param fail_loc=0xa0001403
14565 $LCTL set_param fail_val=1
14566 touch $DIR/$tdir/$tfile || true
14568 run_test 206 "fail lov_init_raid0() doesn't lbug"
14571 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
14572 local fsz=`stat -c %s $DIR/$tfile`
14573 cancel_lru_locks mdc
14575 # do not return layout in getattr intent
14576 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
14577 $LCTL set_param fail_loc=0x170
14578 local sz=`stat -c %s $DIR/$tfile`
14580 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
14584 run_test 207a "can refresh layout at glimpse"
14587 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
14588 local cksum=`md5sum $DIR/$tfile`
14589 local fsz=`stat -c %s $DIR/$tfile`
14590 cancel_lru_locks mdc
14591 cancel_lru_locks osc
14593 # do not return layout in getattr intent
14594 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
14595 $LCTL set_param fail_loc=0x171
14597 # it will refresh layout after the file is opened but before read issues
14598 echo checksum is "$cksum"
14599 echo "$cksum" |md5sum -c --quiet || error "file differs"
14603 run_test 207b "can refresh layout at open"
14606 # FIXME: in this test suite, only RD lease is used. This is okay
14607 # for now as only exclusive open is supported. After generic lease
14608 # is done, this test suite should be revised. - Jinshan
14610 remote_mds_nodsh && skip "remote MDS with nodsh"
14611 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
14612 skip "Need MDS version at least 2.4.52"
14614 echo "==== test 1: verify get lease work"
14615 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
14617 echo "==== test 2: verify lease can be broken by upcoming open"
14618 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14622 $MULTIOP $DIR/$tfile oO_RDONLY:c
14623 kill -USR1 $PID && wait $PID || error "break lease error"
14625 echo "==== test 3: verify lease can't be granted if an open already exists"
14626 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
14630 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
14631 kill -USR1 $PID && wait $PID || error "open file error"
14633 echo "==== test 4: lease can sustain over recovery"
14634 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
14640 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
14642 echo "==== test 5: lease broken can't be regained by replay"
14643 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14647 # open file to break lease and then recovery
14648 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
14651 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
14655 run_test 208 "Exclusive open"
14658 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
14659 skip_env "must have disp_stripe"
14662 sync; sleep 5; sync;
14664 echo 3 > /proc/sys/vm/drop_caches
14665 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14667 # open/close 500 times
14668 for i in $(seq 500); do
14672 echo 3 > /proc/sys/vm/drop_caches
14673 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14675 echo "before: $req_before, after: $req_after"
14676 [ $((req_after - req_before)) -ge 300 ] &&
14677 error "open/close requests are not freed"
14680 run_test 209 "read-only open/close requests should be freed promptly"
14684 size=$((size % 8192 + 1))
14685 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
14686 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
14687 rm -f $DIR/f212 $DIR/f212.xyz
14689 run_test 212 "Sendfile test ============================================"
14692 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
14693 cancel_lru_locks osc
14694 lctl set_param fail_loc=0x8000040f
14695 # generate a read lock
14696 cat $DIR/$tfile > /dev/null
14697 # write to the file, it will try to cancel the above read lock.
14698 cat /etc/hosts >> $DIR/$tfile
14700 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
14702 test_214() { # for bug 20133
14703 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
14704 for (( i=0; i < 340; i++ )) ; do
14705 touch $DIR/$tdir/d214c/a$i
14708 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
14709 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
14710 ls $DIR/d214c || error "ls $DIR/d214c failed"
14711 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
14712 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
14714 run_test 214 "hash-indexed directory test - bug 20133"
14716 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
14717 create_lnet_proc_files() {
14718 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
14721 # counterpart of create_lnet_proc_files
14722 remove_lnet_proc_files() {
14723 rm -f $TMP/lnet_$1.sys
14726 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14727 # 3rd arg as regexp for body
14728 check_lnet_proc_stats() {
14729 local l=$(cat "$TMP/lnet_$1" |wc -l)
14730 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
14732 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
14735 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14736 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
14737 # optional and can be regexp for 2nd line (lnet.routes case)
14738 check_lnet_proc_entry() {
14739 local blp=2 # blp stands for 'position of 1st line of body'
14740 [ -z "$5" ] || blp=3 # lnet.routes case
14742 local l=$(cat "$TMP/lnet_$1" |wc -l)
14743 # subtracting one from $blp because the body can be empty
14744 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
14746 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
14747 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
14749 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
14750 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
14752 # bail out if any unexpected line happened
14753 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
14754 [ "$?" != 0 ] || error "$2 misformatted"
14757 test_215() { # for bugs 18102, 21079, 21517
14758 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14760 local N='(0|[1-9][0-9]*)' # non-negative numeric
14761 local P='[1-9][0-9]*' # positive numeric
14762 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
14763 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
14764 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
14765 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
14767 local L1 # regexp for 1st line
14768 local L2 # regexp for 2nd line (optional)
14769 local BR # regexp for the rest (body)
14771 # lnet.stats should look as 11 space-separated non-negative numerics
14772 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
14773 create_lnet_proc_files "stats"
14774 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
14775 remove_lnet_proc_files "stats"
14777 # lnet.routes should look like this:
14778 # Routing disabled/enabled
14779 # net hops priority state router
14780 # where net is a string like tcp0, hops > 0, priority >= 0,
14781 # state is up/down,
14782 # router is a string like 192.168.1.1@tcp2
14783 L1="^Routing (disabled|enabled)$"
14784 L2="^net +hops +priority +state +router$"
14785 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
14786 create_lnet_proc_files "routes"
14787 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
14788 remove_lnet_proc_files "routes"
14790 # lnet.routers should look like this:
14791 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
14792 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
14793 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
14794 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
14795 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
14796 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
14797 create_lnet_proc_files "routers"
14798 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
14799 remove_lnet_proc_files "routers"
14801 # lnet.peers should look like this:
14802 # nid refs state last max rtr min tx min queue
14803 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
14804 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
14805 # numeric (0 or >0 or <0), queue >= 0.
14806 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
14807 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
14808 create_lnet_proc_files "peers"
14809 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
14810 remove_lnet_proc_files "peers"
14812 # lnet.buffers should look like this:
14813 # pages count credits min
14814 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
14815 L1="^pages +count +credits +min$"
14816 BR="^ +$N +$N +$I +$I$"
14817 create_lnet_proc_files "buffers"
14818 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
14819 remove_lnet_proc_files "buffers"
14821 # lnet.nis should look like this:
14822 # nid status alive refs peer rtr max tx min
14823 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
14824 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
14825 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
14826 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
14827 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
14828 create_lnet_proc_files "nis"
14829 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
14830 remove_lnet_proc_files "nis"
14832 # can we successfully write to lnet.stats?
14833 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
14835 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
14837 test_216() { # bug 20317
14838 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14839 remote_ost_nodsh && skip "remote OST with nodsh"
14842 local facets=$(get_facets OST)
14843 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14845 save_lustre_params client "osc.*.contention_seconds" > $p
14846 save_lustre_params $facets \
14847 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
14848 save_lustre_params $facets \
14849 "ldlm.namespaces.filter-*.contended_locks" >> $p
14850 save_lustre_params $facets \
14851 "ldlm.namespaces.filter-*.contention_seconds" >> $p
14852 clear_stats osc.*.osc_stats
14854 # agressive lockless i/o settings
14855 do_nodes $(comma_list $(osts_nodes)) \
14856 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
14857 ldlm.namespaces.filter-*.contended_locks=0 \
14858 ldlm.namespaces.filter-*.contention_seconds=60"
14859 lctl set_param -n osc.*.contention_seconds=60
14861 $DIRECTIO write $DIR/$tfile 0 10 4096
14862 $CHECKSTAT -s 40960 $DIR/$tfile
14864 # disable lockless i/o
14865 do_nodes $(comma_list $(osts_nodes)) \
14866 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
14867 ldlm.namespaces.filter-*.contended_locks=32 \
14868 ldlm.namespaces.filter-*.contention_seconds=0"
14869 lctl set_param -n osc.*.contention_seconds=0
14870 clear_stats osc.*.osc_stats
14872 dd if=/dev/zero of=$DIR/$tfile count=0
14873 $CHECKSTAT -s 0 $DIR/$tfile
14875 restore_lustre_params <$p
14879 run_test 216 "check lockless direct write updates file size and kms correctly"
14881 test_217() { # bug 22430
14882 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14887 for node in $(nodes_list); do
14888 nid=$(host_nids_address $node $NETTYPE)
14889 if [[ $nid = *-* ]] ; then
14890 echo "lctl ping $(h2nettype $nid)"
14891 lctl ping $(h2nettype $nid)
14893 echo "skipping $node (no hyphen detected)"
14897 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
14900 # do directio so as not to populate the page cache
14901 log "creating a 10 Mb file"
14902 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14903 log "starting reads"
14904 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14905 log "truncating the file"
14906 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14908 kill %+ || true # reads might have finished
14909 echo "wait until dd is finished"
14911 log "removing the temporary file"
14912 rm -rf $DIR/$tfile || error "tmp file removal failed"
14914 run_test 218 "parallel read and truncate should not deadlock"
14917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14919 # write one partial page
14920 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
14921 # set no grant so vvp_io_commit_write will do sync write
14922 $LCTL set_param fail_loc=0x411
14923 # write a full page at the end of file
14924 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
14926 $LCTL set_param fail_loc=0
14927 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
14928 $LCTL set_param fail_loc=0x411
14929 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
14932 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
14933 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
14935 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
14937 test_220() { #LU-325
14938 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14939 remote_ost_nodsh && skip "remote OST with nodsh"
14940 remote_mds_nodsh && skip "remote MDS with nodsh"
14941 remote_mgs_nodsh && skip "remote MGS with nodsh"
14945 # create on MDT0000 so the last_id and next_id are correct
14947 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
14951 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
14952 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
14953 osc.$mdtosc_proc1.prealloc_last_id)
14954 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
14955 osc.$mdtosc_proc1.prealloc_next_id)
14959 if ! combined_mgs_mds ; then
14963 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
14964 #define OBD_FAIL_OST_ENOINO 0x229
14965 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
14966 create_pool $FSNAME.$TESTNAME || return 1
14967 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
14969 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
14971 MDSOBJS=$((last_id - next_id))
14972 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
14974 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
14975 echo "OST still has $count kbytes free"
14977 echo "create $MDSOBJS files @next_id..."
14978 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
14980 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14981 osc.$mdtosc_proc1.prealloc_last_id)
14982 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14983 osc.$mdtosc_proc1.prealloc_next_id)
14985 echo "after creation, last_id=$last_id2, next_id=$next_id2"
14990 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
14991 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
14993 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
14994 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
14995 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14996 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
14997 echo "unlink $MDSOBJS files @$next_id..."
14998 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
15000 if ! combined_mgs_mds ; then
15004 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
15007 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15009 dd if=`which date` of=$MOUNT/date oflag=sync
15010 chmod +x $MOUNT/date
15012 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
15013 $LCTL set_param fail_loc=0x80001401
15015 $MOUNT/date > /dev/null
15018 run_test 221 "make sure fault and truncate race to not cause OOM"
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_DELAY 0x31a
15030 $LCTL set_param fail_loc=0x31a
15031 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
15032 $LCTL set_param fail_loc=0
15035 run_test 222a "AGL for ls should not trigger CLIO lock failure"
15038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15041 test_mkdir $DIR/$tdir
15042 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15043 createmany -o $DIR/$tdir/$tfile 10
15044 cancel_lru_locks mdc
15045 cancel_lru_locks osc
15046 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15047 $LCTL set_param fail_loc=0x31a
15048 rm -r $DIR/$tdir || error "AGL for rmdir failed"
15049 $LCTL set_param fail_loc=0
15051 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
15054 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15057 test_mkdir $DIR/$tdir
15058 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15059 createmany -o $DIR/$tdir/$tfile 10
15060 cancel_lru_locks mdc
15061 cancel_lru_locks osc
15062 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
15063 $LCTL set_param fail_loc=0x31b
15064 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
15065 $LCTL set_param fail_loc=0
15068 run_test 223 "osc reenqueue if without AGL lock granted ======================="
15070 test_224a() { # LU-1039, MRP-303
15071 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15073 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
15074 $LCTL set_param fail_loc=0x508
15075 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
15076 $LCTL set_param fail_loc=0
15079 run_test 224a "Don't panic on bulk IO failure"
15081 test_224b() { # LU-1039, MRP-303
15082 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15084 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
15085 cancel_lru_locks osc
15086 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
15087 $LCTL set_param fail_loc=0x515
15088 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
15089 $LCTL set_param fail_loc=0
15092 run_test 224b "Don't panic on bulk IO failure"
15094 test_224c() { # LU-6441
15095 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15096 remote_mds_nodsh && skip "remote MDS with nodsh"
15098 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15099 save_writethrough $p
15100 set_cache writethrough on
15102 local pages_per_rpc=$($LCTL get_param \
15103 osc.*.max_pages_per_rpc)
15104 local at_max=$($LCTL get_param -n at_max)
15105 local timeout=$($LCTL get_param -n timeout)
15106 local test_at="at_max"
15107 local param_at="$FSNAME.sys.at_max"
15108 local test_timeout="timeout"
15109 local param_timeout="$FSNAME.sys.timeout"
15111 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
15113 set_persistent_param_and_check client "$test_at" "$param_at" 0
15114 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
15116 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
15117 do_facet ost1 "$LCTL set_param fail_loc=0x520"
15118 $LFS setstripe -c 1 -i 0 $DIR/$tfile
15119 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
15121 do_facet ost1 "$LCTL set_param fail_loc=0"
15123 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
15124 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
15127 $LCTL set_param -n $pages_per_rpc
15128 restore_lustre_params < $p
15131 run_test 224c "Don't hang if one of md lost during large bulk RPC"
15133 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
15135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15136 if [ -z ${MDSSURVEY} ]; then
15137 skip_env "mds-survey not found"
15139 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15140 skip "Need MDS version at least 2.2.51"
15142 local mds=$(facet_host $SINGLEMDS)
15143 local target=$(do_nodes $mds 'lctl dl' |
15144 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15146 local cmd1="file_count=1000 thrhi=4"
15147 local cmd2="dir_count=2 layer=mdd stripe_count=0"
15148 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15149 local cmd="$cmd1 $cmd2 $cmd3"
15151 rm -f ${TMP}/mds_survey*
15153 eval $cmd || error "mds-survey with zero-stripe failed"
15154 cat ${TMP}/mds_survey*
15155 rm -f ${TMP}/mds_survey*
15157 run_test 225a "Metadata survey sanity with zero-stripe"
15160 if [ -z ${MDSSURVEY} ]; then
15161 skip_env "mds-survey not found"
15163 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15164 skip "Need MDS version at least 2.2.51"
15165 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15166 remote_mds_nodsh && skip "remote MDS with nodsh"
15167 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
15168 skip_env "Need to mount OST to test"
15171 local mds=$(facet_host $SINGLEMDS)
15172 local target=$(do_nodes $mds 'lctl dl' |
15173 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15175 local cmd1="file_count=1000 thrhi=4"
15176 local cmd2="dir_count=2 layer=mdd stripe_count=1"
15177 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15178 local cmd="$cmd1 $cmd2 $cmd3"
15180 rm -f ${TMP}/mds_survey*
15182 eval $cmd || error "mds-survey with stripe_count failed"
15183 cat ${TMP}/mds_survey*
15184 rm -f ${TMP}/mds_survey*
15186 run_test 225b "Metadata survey sanity with stripe_count = 1"
15188 mcreate_path2fid () {
15194 local path=$DIR/$tdir/$name
15199 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
15200 error "cannot create $desc"
15202 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
15204 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
15206 fid_path=$($LFS fid2path $MOUNT $fid)
15208 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
15210 [ "$path" == "$fid_path" ] ||
15211 error "fid2path returned $fid_path, expected $path"
15213 echo "pass with $path and $fid"
15218 mkdir -p $DIR/$tdir
15220 mcreate_path2fid 0010666 0 0 fifo "FIFO"
15221 mcreate_path2fid 0020666 1 3 null "character special file (null)"
15222 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
15223 mcreate_path2fid 0040666 0 0 dir "directory"
15224 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
15225 mcreate_path2fid 0100666 0 0 file "regular file"
15226 mcreate_path2fid 0120666 0 0 link "symbolic link"
15227 mcreate_path2fid 0140666 0 0 sock "socket"
15229 run_test 226a "call path2fid and fid2path on files of all type"
15232 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15237 mkdir -p $DIR/$tdir
15238 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
15239 error "create remote directory failed"
15240 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
15241 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
15242 "character special file (null)"
15243 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
15244 "character special file (no device)"
15245 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
15246 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
15247 "block special file (loop)"
15248 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
15249 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
15250 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
15252 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
15254 # LU-1299 Executing or running ldd on a truncated executable does not
15255 # cause an out-of-memory condition.
15257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15258 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
15260 dd if=$(which date) of=$MOUNT/date bs=1k count=1
15261 chmod +x $MOUNT/date
15263 $MOUNT/date > /dev/null
15264 ldd $MOUNT/date > /dev/null
15267 run_test 227 "running truncated executable does not cause OOM"
15269 # LU-1512 try to reuse idle OI blocks
15271 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15272 remote_mds_nodsh && skip "remote MDS with nodsh"
15273 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15275 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15276 local myDIR=$DIR/$tdir
15279 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15280 $LCTL set_param fail_loc=0x80001002
15281 createmany -o $myDIR/t- 10000
15282 $LCTL set_param fail_loc=0
15283 # The guard is current the largest FID holder
15285 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15287 local IDX=$(($SEQ % 64))
15289 do_facet $SINGLEMDS sync
15290 # Make sure journal flushed.
15292 local blk1=$(do_facet $SINGLEMDS \
15293 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15294 grep Blockcount | awk '{print $4}')
15296 # Remove old files, some OI blocks will become idle.
15297 unlinkmany $myDIR/t- 10000
15298 # Create new files, idle OI blocks should be reused.
15299 createmany -o $myDIR/t- 2000
15300 do_facet $SINGLEMDS sync
15301 # Make sure journal flushed.
15303 local blk2=$(do_facet $SINGLEMDS \
15304 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15305 grep Blockcount | awk '{print $4}')
15307 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15309 run_test 228a "try to reuse idle OI blocks"
15312 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15313 remote_mds_nodsh && skip "remote MDS with nodsh"
15314 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15316 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15317 local myDIR=$DIR/$tdir
15320 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15321 $LCTL set_param fail_loc=0x80001002
15322 createmany -o $myDIR/t- 10000
15323 $LCTL set_param fail_loc=0
15324 # The guard is current the largest FID holder
15326 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15328 local IDX=$(($SEQ % 64))
15330 do_facet $SINGLEMDS sync
15331 # Make sure journal flushed.
15333 local blk1=$(do_facet $SINGLEMDS \
15334 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15335 grep Blockcount | awk '{print $4}')
15337 # Remove old files, some OI blocks will become idle.
15338 unlinkmany $myDIR/t- 10000
15341 stop $SINGLEMDS || error "Fail to stop MDT."
15343 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
15345 df $MOUNT || error "Fail to df."
15346 # Create new files, idle OI blocks should be reused.
15347 createmany -o $myDIR/t- 2000
15348 do_facet $SINGLEMDS sync
15349 # Make sure journal flushed.
15351 local blk2=$(do_facet $SINGLEMDS \
15352 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15353 grep Blockcount | awk '{print $4}')
15355 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15357 run_test 228b "idle OI blocks can be reused after MDT restart"
15361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15362 remote_mds_nodsh && skip "remote MDS with nodsh"
15363 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15365 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15366 local myDIR=$DIR/$tdir
15369 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15370 $LCTL set_param fail_loc=0x80001002
15371 # 20000 files can guarantee there are index nodes in the OI file
15372 createmany -o $myDIR/t- 20000
15373 $LCTL set_param fail_loc=0
15374 # The guard is current the largest FID holder
15376 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15378 local IDX=$(($SEQ % 64))
15380 do_facet $SINGLEMDS sync
15381 # Make sure journal flushed.
15383 local blk1=$(do_facet $SINGLEMDS \
15384 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15385 grep Blockcount | awk '{print $4}')
15387 # Remove old files, some OI blocks will become idle.
15388 unlinkmany $myDIR/t- 20000
15390 # The OI file should become empty now
15392 # Create new files, idle OI blocks should be reused.
15393 createmany -o $myDIR/t- 2000
15394 do_facet $SINGLEMDS sync
15395 # Make sure journal flushed.
15397 local blk2=$(do_facet $SINGLEMDS \
15398 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15399 grep Blockcount | awk '{print $4}')
15401 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15403 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
15405 test_229() { # LU-2482, LU-3448
15406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15407 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
15408 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
15409 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
15413 # Create a file with a released layout and stripe count 2.
15414 $MULTIOP $DIR/$tfile H2c ||
15415 error "failed to create file with released layout"
15417 $LFS getstripe -v $DIR/$tfile
15419 local pattern=$($LFS getstripe -L $DIR/$tfile)
15420 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
15422 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
15424 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
15425 stat $DIR/$tfile || error "failed to stat released file"
15427 chown $RUNAS_ID $DIR/$tfile ||
15428 error "chown $RUNAS_ID $DIR/$tfile failed"
15430 chgrp $RUNAS_ID $DIR/$tfile ||
15431 error "chgrp $RUNAS_ID $DIR/$tfile failed"
15433 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
15434 rm $DIR/$tfile || error "failed to remove released file"
15436 run_test 229 "getstripe/stat/rm/attr changes work on released files"
15439 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15440 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15441 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15442 skip "Need MDS version at least 2.11.52"
15446 test_mkdir $DIR/$tdir
15447 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
15448 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
15449 [ $mdt_idx -ne 0 ] &&
15450 error "create local directory on wrong MDT $mdt_idx"
15452 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
15453 error "create remote directory failed"
15454 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
15455 [ $mdt_idx -ne $MDTIDX ] &&
15456 error "create remote directory on wrong MDT $mdt_idx"
15458 createmany -o $DIR/$tdir/test_230/t- 10 ||
15459 error "create files on remote directory failed"
15460 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
15461 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
15462 rm -r $DIR/$tdir || error "unlink remote directory failed"
15464 run_test 230a "Create remote directory and files under the remote directory"
15467 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15468 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15469 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15470 skip "Need MDS version at least 2.11.52"
15478 local migrate_dir=$DIR/$tdir/migrate_dir
15479 local other_dir=$DIR/$tdir/other_dir
15481 test_mkdir $DIR/$tdir
15482 test_mkdir -i0 -c1 $migrate_dir
15483 test_mkdir -i0 -c1 $other_dir
15484 for ((i=0; i<10; i++)); do
15485 mkdir -p $migrate_dir/dir_${i}
15486 createmany -o $migrate_dir/dir_${i}/f 10 ||
15487 error "create files under remote dir failed $i"
15490 cp /etc/passwd $migrate_dir/$tfile
15491 cp /etc/passwd $other_dir/$tfile
15492 chattr +SAD $migrate_dir
15493 chattr +SAD $migrate_dir/$tfile
15495 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15496 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15497 local old_dir_mode=$(stat -c%f $migrate_dir)
15498 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
15500 mkdir -p $migrate_dir/dir_default_stripe2
15501 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
15502 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
15504 mkdir -p $other_dir
15505 ln $migrate_dir/$tfile $other_dir/luna
15506 ln $migrate_dir/$tfile $migrate_dir/sofia
15507 ln $other_dir/$tfile $migrate_dir/david
15508 ln -s $migrate_dir/$tfile $other_dir/zachary
15509 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
15510 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
15512 $LFS migrate -m $MDTIDX $migrate_dir ||
15513 error "fails on migrating remote dir to MDT1"
15515 echo "migratate to MDT1, then checking.."
15516 for ((i = 0; i < 10; i++)); do
15517 for file in $(find $migrate_dir/dir_${i}); do
15518 mdt_index=$($LFS getstripe -m $file)
15519 [ $mdt_index == $MDTIDX ] ||
15520 error "$file is not on MDT${MDTIDX}"
15524 # the multiple link file should still in MDT0
15525 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
15526 [ $mdt_index == 0 ] ||
15527 error "$file is not on MDT${MDTIDX}"
15529 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15530 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15531 error " expect $old_dir_flag get $new_dir_flag"
15533 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15534 [ "$old_file_flag" = "$new_file_flag" ] ||
15535 error " expect $old_file_flag get $new_file_flag"
15537 local new_dir_mode=$(stat -c%f $migrate_dir)
15538 [ "$old_dir_mode" = "$new_dir_mode" ] ||
15539 error "expect mode $old_dir_mode get $new_dir_mode"
15541 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
15542 [ "$old_file_mode" = "$new_file_mode" ] ||
15543 error "expect mode $old_file_mode get $new_file_mode"
15545 diff /etc/passwd $migrate_dir/$tfile ||
15546 error "$tfile different after migration"
15548 diff /etc/passwd $other_dir/luna ||
15549 error "luna different after migration"
15551 diff /etc/passwd $migrate_dir/sofia ||
15552 error "sofia different after migration"
15554 diff /etc/passwd $migrate_dir/david ||
15555 error "david different after migration"
15557 diff /etc/passwd $other_dir/zachary ||
15558 error "zachary different after migration"
15560 diff /etc/passwd $migrate_dir/${tfile}_ln ||
15561 error "${tfile}_ln different after migration"
15563 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
15564 error "${tfile}_ln_other different after migration"
15566 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
15567 [ $stripe_count = 2 ] ||
15568 error "dir strpe_count $d != 2 after migration."
15570 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
15571 [ $stripe_count = 2 ] ||
15572 error "file strpe_count $d != 2 after migration."
15574 #migrate back to MDT0
15577 $LFS migrate -m $MDTIDX $migrate_dir ||
15578 error "fails on migrating remote dir to MDT0"
15580 echo "migrate back to MDT0, checking.."
15581 for file in $(find $migrate_dir); do
15582 mdt_index=$($LFS getstripe -m $file)
15583 [ $mdt_index == $MDTIDX ] ||
15584 error "$file is not on MDT${MDTIDX}"
15587 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15588 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15589 error " expect $old_dir_flag get $new_dir_flag"
15591 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15592 [ "$old_file_flag" = "$new_file_flag" ] ||
15593 error " expect $old_file_flag get $new_file_flag"
15595 local new_dir_mode=$(stat -c%f $migrate_dir)
15596 [ "$old_dir_mode" = "$new_dir_mode" ] ||
15597 error "expect mode $old_dir_mode get $new_dir_mode"
15599 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
15600 [ "$old_file_mode" = "$new_file_mode" ] ||
15601 error "expect mode $old_file_mode get $new_file_mode"
15603 diff /etc/passwd ${migrate_dir}/$tfile ||
15604 error "$tfile different after migration"
15606 diff /etc/passwd ${other_dir}/luna ||
15607 error "luna different after migration"
15609 diff /etc/passwd ${migrate_dir}/sofia ||
15610 error "sofia different after migration"
15612 diff /etc/passwd ${other_dir}/zachary ||
15613 error "zachary different after migration"
15615 diff /etc/passwd $migrate_dir/${tfile}_ln ||
15616 error "${tfile}_ln different after migration"
15618 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
15619 error "${tfile}_ln_other different after migration"
15621 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
15622 [ $stripe_count = 2 ] ||
15623 error "dir strpe_count $d != 2 after migration."
15625 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
15626 [ $stripe_count = 2 ] ||
15627 error "file strpe_count $d != 2 after migration."
15629 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15631 run_test 230b "migrate directory"
15634 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15635 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15636 remote_mds_nodsh && skip "remote MDS with nodsh"
15637 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15638 skip "Need MDS version at least 2.11.52"
15644 local migrate_dir=$DIR/$tdir/migrate_dir
15646 #If migrating directory fails in the middle, all entries of
15647 #the directory is still accessiable.
15648 test_mkdir $DIR/$tdir
15649 test_mkdir -i0 -c1 $migrate_dir
15650 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
15652 createmany -o $migrate_dir/f $total ||
15653 error "create files under ${migrate_dir} failed"
15655 # fail after migrating top dir, and this will fail only once, so the
15656 # first sub file migration will fail (currently f3), others succeed.
15657 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
15658 do_facet mds1 lctl set_param fail_loc=0x1801
15659 local t=$(ls $migrate_dir | wc -l)
15660 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
15661 error "migrate should fail"
15662 local u=$(ls $migrate_dir | wc -l)
15663 [ "$u" == "$t" ] || error "$u != $t during migration"
15665 # add new dir/file should succeed
15666 mkdir $migrate_dir/dir ||
15667 error "mkdir failed under migrating directory"
15668 touch $migrate_dir/file ||
15669 error "create file failed under migrating directory"
15671 # add file with existing name should fail
15672 for file in $migrate_dir/f*; do
15673 stat $file > /dev/null || error "stat $file failed"
15674 $OPENFILE -f O_CREAT:O_EXCL $file &&
15675 error "open(O_CREAT|O_EXCL) $file should fail"
15676 $MULTIOP $file m && error "create $file should fail"
15677 touch $DIR/$tdir/remote_dir/$tfile ||
15678 error "touch $tfile failed"
15679 ln $DIR/$tdir/remote_dir/$tfile $file &&
15680 error "link $file should fail"
15681 mdt_index=$($LFS getstripe -m $file)
15682 if [ $mdt_index == 0 ]; then
15683 # file failed to migrate is not allowed to rename to
15684 mv $DIR/$tdir/remote_dir/$tfile $file &&
15685 error "rename to $file should fail"
15687 mv $DIR/$tdir/remote_dir/$tfile $file ||
15688 error "rename to $file failed"
15690 echo hello >> $file || error "write $file failed"
15693 # resume migration with different options should fail
15694 $LFS migrate -m 0 $migrate_dir &&
15695 error "migrate -m 0 $migrate_dir should fail"
15697 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
15698 error "migrate -c 2 $migrate_dir should fail"
15700 # resume migration should succeed
15701 $LFS migrate -m $MDTIDX $migrate_dir ||
15702 error "migrate $migrate_dir failed"
15704 echo "Finish migration, then checking.."
15705 for file in $(find $migrate_dir); do
15706 mdt_index=$($LFS getstripe -m $file)
15707 [ $mdt_index == $MDTIDX ] ||
15708 error "$file is not on MDT${MDTIDX}"
15711 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15713 run_test 230c "check directory accessiblity if migration failed"
15716 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15717 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15718 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15719 skip "Need MDS version at least 2.11.52"
15721 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
15723 local migrate_dir=$DIR/$tdir/migrate_dir
15733 old_index=$((RANDOM % MDSCOUNT))
15734 old_count=$((MDSCOUNT - old_index))
15735 new_index=$((RANDOM % MDSCOUNT))
15736 new_count=$((MDSCOUNT - new_index))
15737 new_hash="all_char"
15739 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
15740 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
15742 test_mkdir $DIR/$tdir
15743 test_mkdir -i $old_index -c $old_count $migrate_dir
15745 for ((i=0; i<100; i++)); do
15746 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
15747 createmany -o $migrate_dir/dir_${i}/f 100 ||
15748 error "create files under remote dir failed $i"
15751 echo -n "Migrate from MDT$old_index "
15752 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
15753 echo -n "to MDT$new_index"
15754 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
15757 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
15758 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
15759 error "migrate remote dir error"
15761 echo "Finish migration, then checking.."
15762 for file in $(find $migrate_dir); do
15763 mdt_index=$($LFS getstripe -m $file)
15764 if [ $mdt_index -lt $new_index ] ||
15765 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
15766 error "$file is on MDT$mdt_index"
15770 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15772 run_test 230d "check migrate big directory"
15775 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15776 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15777 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15778 skip "Need MDS version at least 2.11.52"
15785 mkdir -p $DIR/$tdir
15786 mkdir $DIR/$tdir/migrate_dir
15787 mkdir $DIR/$tdir/other_dir
15788 touch $DIR/$tdir/migrate_dir/a
15789 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
15790 ls $DIR/$tdir/other_dir
15792 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15793 error "migrate dir fails"
15795 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15796 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15798 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15799 [ $mdt_index == 0 ] || error "a is not on MDT0"
15801 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
15802 error "migrate dir fails"
15804 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
15805 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
15807 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15808 [ $mdt_index == 1 ] || error "a is not on MDT1"
15810 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
15811 [ $mdt_index == 1 ] || error "b is not on MDT1"
15813 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15814 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
15816 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
15818 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15820 run_test 230e "migrate mulitple local link files"
15823 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15824 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15825 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15826 skip "Need MDS version at least 2.11.52"
15831 mkdir -p $DIR/$tdir
15832 mkdir $DIR/$tdir/migrate_dir
15833 $LFS mkdir -i1 $DIR/$tdir/other_dir
15834 touch $DIR/$tdir/migrate_dir/a
15835 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
15836 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
15837 ls $DIR/$tdir/other_dir
15839 # a should be migrated to MDT1, since no other links on MDT0
15840 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15841 error "#1 migrate dir fails"
15842 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15843 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15844 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15845 [ $mdt_index == 1 ] || error "a is not on MDT1"
15847 # a should stay on MDT1, because it is a mulitple link file
15848 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15849 error "#2 migrate dir fails"
15850 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15851 [ $mdt_index == 1 ] || error "a is not on MDT1"
15853 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15854 error "#3 migrate dir fails"
15856 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15857 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
15858 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
15860 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
15861 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
15863 # a should be migrated to MDT0, since no other links on MDT1
15864 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15865 error "#4 migrate dir fails"
15866 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15867 [ $mdt_index == 0 ] || error "a is not on MDT0"
15869 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15871 run_test 230f "migrate mulitple remote link files"
15874 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15875 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15876 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15877 skip "Need MDS version at least 2.11.52"
15879 mkdir -p $DIR/$tdir/migrate_dir
15881 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
15882 error "migrating dir to non-exist MDT succeeds"
15885 run_test 230g "migrate dir to non-exist MDT"
15888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15889 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15890 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15891 skip "Need MDS version at least 2.11.52"
15895 mkdir -p $DIR/$tdir/migrate_dir
15897 $LFS migrate -m1 $DIR &&
15898 error "migrating mountpoint1 should fail"
15900 $LFS migrate -m1 $DIR/$tdir/.. &&
15901 error "migrating mountpoint2 should fail"
15904 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
15905 error "migrating $tdir/migrate_dir/.. should fail"
15909 run_test 230h "migrate .. and root"
15912 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15913 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15914 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15915 skip "Need MDS version at least 2.11.52"
15917 mkdir -p $DIR/$tdir/migrate_dir
15919 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
15920 error "migration fails with a tailing slash"
15922 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
15923 error "migration fails with two tailing slashes"
15925 run_test 230i "lfs migrate -m tolerates trailing slashes"
15928 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
15929 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15930 skip "Need MDS version at least 2.11.52"
15932 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
15933 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
15934 error "create $tfile failed"
15935 cat /etc/passwd > $DIR/$tdir/$tfile
15937 $LFS migrate -m 1 $DIR/$tdir
15939 cmp /etc/passwd $DIR/$tdir/$tfile ||
15940 error "DoM file mismatch after migration"
15942 run_test 230j "DoM file data not changed after dir migration"
15945 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
15946 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
15947 skip "Need MDS version at least 2.11.56"
15950 local files_on_starting_mdt=0
15952 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
15953 $LFS getdirstripe $DIR/$tdir
15954 for i in $(seq $total); do
15955 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
15956 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
15957 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15960 echo "$files_on_starting_mdt files on MDT0"
15962 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
15963 $LFS getdirstripe $DIR/$tdir
15965 files_on_starting_mdt=0
15966 for i in $(seq $total); do
15967 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
15968 error "file $tfile.$i mismatch after migration"
15969 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
15970 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15973 echo "$files_on_starting_mdt files on MDT1 after migration"
15974 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
15976 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
15977 $LFS getdirstripe $DIR/$tdir
15979 files_on_starting_mdt=0
15980 for i in $(seq $total); do
15981 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
15982 error "file $tfile.$i mismatch after 2nd migration"
15983 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
15984 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15987 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
15988 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
15992 run_test 230k "file data not changed after dir migration"
15995 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
15996 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
15997 skip "Need MDS version at least 2.11.56"
15999 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
16000 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
16001 error "create files under remote dir failed $i"
16002 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
16004 run_test 230l "readdir between MDTs won't crash"
16008 # For simplicity this test assumes that max_pages_per_rpc
16009 # is the same across all OSCs
16010 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
16011 local bulk_size=$((max_pages * PAGE_SIZE))
16012 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
16015 mkdir -p $DIR/$tdir
16016 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
16017 error "failed to set stripe with -S ${brw_size}M option"
16019 # clear the OSC stats
16020 $LCTL set_param osc.*.stats=0 &>/dev/null
16023 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
16024 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
16025 oflag=direct &>/dev/null || error "dd failed"
16027 sync; sleep 1; sync # just to be safe
16028 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
16029 if [ x$nrpcs != "x1" ]; then
16030 $LCTL get_param osc.*.stats
16031 error "found $nrpcs ost_write RPCs, not 1 as expected"
16035 # Drop the OSC cache, otherwise we will read from it
16036 cancel_lru_locks osc
16038 # clear the OSC stats
16039 $LCTL set_param osc.*.stats=0 &>/dev/null
16041 # Client reads $bulk_size.
16042 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
16043 iflag=direct &>/dev/null || error "dd failed"
16045 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
16046 if [ x$nrpcs != "x1" ]; then
16047 $LCTL get_param osc.*.stats
16048 error "found $nrpcs ost_read RPCs, not 1 as expected"
16051 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
16054 mkdir -p $DIR/$tdir
16056 for i in {0..1023}; do
16057 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
16058 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
16059 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
16063 run_test 231b "must not assert on fully utilized OST request buffer"
16066 mkdir -p $DIR/$tdir
16067 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16069 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16070 do_facet ost1 $LCTL set_param fail_loc=0x31c
16072 # ignore dd failure
16073 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
16075 do_facet ost1 $LCTL set_param fail_loc=0
16076 umount_client $MOUNT || error "umount failed"
16077 mount_client $MOUNT || error "mount failed"
16078 stop ost1 || error "cannot stop ost1"
16079 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16081 run_test 232a "failed lock should not block umount"
16084 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
16085 skip "Need MDS version at least 2.10.58"
16087 mkdir -p $DIR/$tdir
16088 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16089 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
16091 cancel_lru_locks osc
16093 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16094 do_facet ost1 $LCTL set_param fail_loc=0x31c
16097 $LFS data_version $DIR/$tdir/$tfile || true
16099 do_facet ost1 $LCTL set_param fail_loc=0
16100 umount_client $MOUNT || error "umount failed"
16101 mount_client $MOUNT || error "mount failed"
16102 stop ost1 || error "cannot stop ost1"
16103 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16105 run_test 232b "failed data version lock should not block umount"
16108 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
16109 skip "Need MDS version at least 2.3.64"
16110 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16112 local fid=$($LFS path2fid $MOUNT)
16114 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16115 error "cannot access $MOUNT using its FID '$fid'"
16117 run_test 233a "checking that OBF of the FS root succeeds"
16120 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
16121 skip "Need MDS version at least 2.5.90"
16122 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16124 local fid=$($LFS path2fid $MOUNT/.lustre)
16126 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16127 error "cannot access $MOUNT/.lustre using its FID '$fid'"
16129 fid=$($LFS path2fid $MOUNT/.lustre/fid)
16130 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16131 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
16133 run_test 233b "checking that OBF of the FS .lustre succeeds"
16136 local p="$TMP/sanityN-$TESTNAME.parameters"
16137 save_lustre_params client "llite.*.xattr_cache" > $p
16138 lctl set_param llite.*.xattr_cache 1 ||
16139 skip_env "xattr cache is not supported"
16141 mkdir -p $DIR/$tdir || error "mkdir failed"
16142 touch $DIR/$tdir/$tfile || error "touch failed"
16143 # OBD_FAIL_LLITE_XATTR_ENOMEM
16144 $LCTL set_param fail_loc=0x1405
16145 getfattr -n user.attr $DIR/$tdir/$tfile &&
16146 error "getfattr should have failed with ENOMEM"
16147 $LCTL set_param fail_loc=0x0
16150 restore_lustre_params < $p
16153 run_test 234 "xattr cache should not crash on ENOMEM"
16156 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
16157 skip "Need MDS version at least 2.4.52"
16159 flock_deadlock $DIR/$tfile
16164 124) error "process hangs on a deadlock"
16166 *) error "error executing flock_deadlock $DIR/$tfile"
16170 run_test 235 "LU-1715: flock deadlock detection does not work properly"
16174 check_swap_layouts_support
16176 local ref1=/etc/passwd
16177 local ref2=/etc/group
16178 local file1=$DIR/$tdir/f1
16179 local file2=$DIR/$tdir/f2
16181 test_mkdir -c1 $DIR/$tdir
16182 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
16183 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
16184 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
16185 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
16186 local fd=$(free_fd)
16187 local cmd="exec $fd<>$file2"
16190 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
16191 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
16194 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
16199 run_test 236 "Layout swap on open unlinked file"
16201 # LU-4659 linkea consistency
16203 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16204 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16205 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16206 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16209 ln $DIR/$tfile $DIR/$tfile.lnk
16210 touch $DIR/$tfile.new
16211 mv $DIR/$tfile.new $DIR/$tfile
16212 local fid1=$($LFS path2fid $DIR/$tfile)
16213 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
16214 local path1=$($LFS fid2path $FSNAME "$fid1")
16215 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
16216 local path2=$($LFS fid2path $FSNAME "$fid2")
16217 [ $tfile.lnk == $path2 ] ||
16218 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
16221 run_test 238 "Verify linkea consistency"
16223 test_239A() { # was test_239
16224 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
16225 skip "Need MDS version at least 2.5.60"
16227 local list=$(comma_list $(mdts_nodes))
16229 mkdir -p $DIR/$tdir
16230 createmany -o $DIR/$tdir/f- 5000
16231 unlinkmany $DIR/$tdir/f- 5000
16232 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
16233 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
16234 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
16235 osp.*MDT*.sync_in_flight" | calc_sum)
16236 [ "$changes" -eq 0 ] || error "$changes not synced"
16238 run_test 239A "osp_sync test"
16240 test_239a() { #LU-5297
16241 remote_mds_nodsh && skip "remote MDS with nodsh"
16244 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
16245 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
16246 chgrp $RUNAS_GID $DIR/$tfile
16247 wait_delete_completed
16249 run_test 239a "process invalid osp sync record correctly"
16251 test_239b() { #LU-5297
16252 remote_mds_nodsh && skip "remote MDS with nodsh"
16255 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
16256 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
16257 chgrp $RUNAS_GID $DIR/$tfile1
16258 wait_delete_completed
16259 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16261 chgrp $RUNAS_GID $DIR/$tfile2
16262 wait_delete_completed
16264 run_test 239b "process osp sync record with ENOMEM error correctly"
16267 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16268 remote_mds_nodsh && skip "remote MDS with nodsh"
16270 mkdir -p $DIR/$tdir
16272 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
16273 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
16274 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
16275 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
16277 umount_client $MOUNT || error "umount failed"
16278 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
16279 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
16280 mount_client $MOUNT || error "failed to mount client"
16282 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
16283 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
16285 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
16291 for LOOP in $(seq $count); do
16292 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
16293 cancel_lru_locks $OSC || true
16301 for LOOP in $(seq $1); do
16302 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
16307 test_241a() { # was test_241
16308 local bsize=$PAGE_SIZE
16310 (( bsize < 40960 )) && bsize=40960
16311 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
16313 cancel_lru_locks $OSC
16314 test_241_bio 1000 $bsize &
16316 test_241_dio 1000 $bsize
16319 run_test 241a "bio vs dio"
16322 local bsize=$PAGE_SIZE
16324 (( bsize < 40960 )) && bsize=40960
16325 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
16327 test_241_dio 1000 $bsize &
16329 test_241_dio 1000 $bsize
16332 run_test 241b "dio vs dio"
16335 remote_mds_nodsh && skip "remote MDS with nodsh"
16337 mkdir -p $DIR/$tdir
16338 touch $DIR/$tdir/$tfile
16340 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
16341 do_facet mds1 lctl set_param fail_loc=0x105
16342 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
16344 do_facet mds1 lctl set_param fail_loc=0
16345 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
16347 run_test 242 "mdt_readpage failure should not cause directory unreadable"
16351 test_mkdir $DIR/$tdir
16352 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
16354 run_test 243 "various group lock tests"
16358 test_mkdir $DIR/$tdir
16359 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
16360 sendfile_grouplock $DIR/$tdir/$tfile || \
16361 error "sendfile+grouplock failed"
16364 run_test 244 "sendfile with group lock tests"
16367 local flagname="multi_mod_rpcs"
16368 local connect_data_name="max_mod_rpcs"
16371 # check if multiple modify RPCs flag is set
16372 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
16373 grep "connect_flags:")
16376 echo "$out" | grep -qw $flagname
16377 if [ $? -ne 0 ]; then
16378 echo "connect flag $flagname is not set"
16382 # check if multiple modify RPCs data is set
16383 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
16386 echo "$out" | grep -qw $connect_data_name ||
16387 error "import should have connect data $connect_data_name"
16389 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
16391 test_246() { # LU-7371
16392 remote_ost_nodsh && skip "remote OST with nodsh"
16393 [ $OST1_VERSION -lt $(version_code 2.7.62) ] &&
16394 skip "Need OST version >= 2.7.62"
16396 do_facet ost1 $LCTL set_param fail_val=4095
16397 #define OBD_FAIL_OST_READ_SIZE 0x234
16398 do_facet ost1 $LCTL set_param fail_loc=0x234
16399 $LFS setstripe $DIR/$tfile -i 0 -c 1
16400 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
16401 cancel_lru_locks $FSNAME-OST0000
16402 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
16404 run_test 246 "Read file of size 4095 should return right length"
16410 umount_client $submount
16415 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16417 skip_env "Fileset feature is not supported"
16419 local submount=${MOUNT}_$tdir
16422 mkdir -p $submount || error "mkdir $submount failed"
16423 FILESET="$FILESET/$tdir" mount_client $submount ||
16424 error "mount $submount failed"
16425 trap "cleanup_247 $submount" EXIT
16426 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
16427 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
16428 error "read $MOUNT/$tdir/$tfile failed"
16429 cleanup_247 $submount
16431 run_test 247a "mount subdir as fileset"
16434 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16435 skip_env "Fileset feature is not supported"
16437 local submount=${MOUNT}_$tdir
16439 rm -rf $MOUNT/$tdir
16440 mkdir -p $submount || error "mkdir $submount failed"
16442 FILESET="$FILESET/$tdir" mount_client $submount &&
16443 error "mount $submount should fail"
16446 run_test 247b "mount subdir that dose not exist"
16449 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16450 skip_env "Fileset feature is not supported"
16452 local submount=${MOUNT}_$tdir
16454 mkdir -p $MOUNT/$tdir/dir1
16455 mkdir -p $submount || error "mkdir $submount failed"
16456 trap "cleanup_247 $submount" EXIT
16457 FILESET="$FILESET/$tdir" mount_client $submount ||
16458 error "mount $submount failed"
16459 local fid=$($LFS path2fid $MOUNT/)
16460 $LFS fid2path $submount $fid && error "fid2path should fail"
16461 cleanup_247 $submount
16463 run_test 247c "running fid2path outside root"
16466 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16467 skip "Fileset feature is not supported"
16469 local submount=${MOUNT}_$tdir
16471 mkdir -p $MOUNT/$tdir/dir1
16472 mkdir -p $submount || error "mkdir $submount failed"
16473 FILESET="$FILESET/$tdir" mount_client $submount ||
16474 error "mount $submount failed"
16475 trap "cleanup_247 $submount" EXIT
16476 local fid=$($LFS path2fid $submount/dir1)
16477 $LFS fid2path $submount $fid || error "fid2path should succeed"
16478 cleanup_247 $submount
16480 run_test 247d "running fid2path inside root"
16484 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16486 skip "Fileset feature is not supported"
16488 local submount=${MOUNT}_$tdir
16491 mkdir -p $submount || error "mkdir $submount failed"
16492 FILESET="$FILESET/.." mount_client $submount &&
16493 error "mount $submount should fail"
16496 run_test 247e "mount .. as fileset"
16499 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
16500 [ -z "$fast_read_sav" ] && skip "no fast read support"
16502 # create a large file for fast read verification
16503 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
16505 # make sure the file is created correctly
16506 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
16507 { rm -f $DIR/$tfile; skip "file creation error"; }
16509 echo "Test 1: verify that fast read is 4 times faster on cache read"
16511 # small read with fast read enabled
16512 $LCTL set_param -n llite.*.fast_read=1
16513 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16514 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16515 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16516 # small read with fast read disabled
16517 $LCTL set_param -n llite.*.fast_read=0
16518 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16519 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16520 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16522 # verify that fast read is 4 times faster for cache read
16523 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
16524 error_not_in_vm "fast read was not 4 times faster: " \
16525 "$t_fast vs $t_slow"
16527 echo "Test 2: verify the performance between big and small read"
16528 $LCTL set_param -n llite.*.fast_read=1
16530 # 1k non-cache read
16531 cancel_lru_locks osc
16532 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16533 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16534 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16536 # 1M non-cache read
16537 cancel_lru_locks osc
16538 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16539 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16540 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16542 # verify that big IO is not 4 times faster than small IO
16543 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
16544 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
16546 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
16549 run_test 248 "fast read verification"
16551 test_249() { # LU-7890
16552 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
16553 skip "Need at least version 2.8.54"
16556 $LFS setstripe -c 1 $DIR/$tfile
16557 # Offset 2T == 4k * 512M
16558 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
16559 error "dd to 2T offset failed"
16561 run_test 249 "Write above 2T file size"
16564 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
16565 && skip "no 16TB file size limit on ZFS"
16567 $LFS setstripe -c 1 $DIR/$tfile
16568 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
16569 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
16570 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
16571 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
16572 conv=notrunc,fsync && error "append succeeded"
16575 run_test 250 "Write above 16T limit"
16578 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
16580 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
16581 #Skip once - writing the first stripe will succeed
16582 $LCTL set_param fail_loc=0xa0001407 fail_val=1
16583 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
16584 error "short write happened"
16586 $LCTL set_param fail_loc=0xa0001407 fail_val=1
16587 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
16588 error "short read happened"
16592 run_test 251 "Handling short read and write correctly"
16595 remote_mds_nodsh && skip "remote MDS with nodsh"
16596 remote_ost_nodsh && skip "remote OST with nodsh"
16597 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
16598 skip_env "ldiskfs only test"
16608 # check lr_reader on OST0000
16610 dev=$(facet_device $tgt)
16611 out=$(do_facet $tgt $LR_READER $dev)
16612 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16614 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
16615 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
16616 error "Invalid uuid returned by $LR_READER on target $tgt"
16617 echo -e "uuid returned by $LR_READER is '$uuid'\n"
16619 # check lr_reader -c on MDT0000
16621 dev=$(facet_device $tgt)
16622 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
16623 skip "$LR_READER does not support additional options"
16625 out=$(do_facet $tgt $LR_READER -c $dev)
16626 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16628 num=$(echo "$out" | grep -c "mdtlov")
16629 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
16630 error "Invalid number of mdtlov clients returned by $LR_READER"
16631 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
16633 # check lr_reader -cr on MDT0000
16634 out=$(do_facet $tgt $LR_READER -cr $dev)
16635 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16637 echo "$out" | grep -q "^reply_data:$" ||
16638 error "$LR_READER should have returned 'reply_data' section"
16639 num=$(echo "$out" | grep -c "client_generation")
16640 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
16642 run_test 252 "check lr_reader tool"
16644 test_253_fill_ost() {
16645 local size_mb #how many MB should we write to pass watermark
16646 local lwm=$3 #low watermark
16647 local free_10mb #10% of free space
16649 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
16650 size_mb=$((free_kb / 1024 - lwm))
16651 free_10mb=$((free_kb / 10240))
16652 #If 10% of free space cross low watermark use it
16653 if (( free_10mb > size_mb )); then
16656 #At least we need to store 1.1 of difference between
16657 #free space and low watermark
16658 size_mb=$((size_mb + size_mb / 10))
16660 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
16661 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
16662 oflag=append conv=notrunc
16667 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
16668 echo "OST still has $((free_kb / 1024)) mbytes free"
16672 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16673 remote_mds_nodsh && skip "remote MDS with nodsh"
16674 remote_mgs_nodsh && skip "remote MGS with nodsh"
16679 local ost_name=$($LFS osts |
16680 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
16682 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
16683 do_facet $SINGLEMDS $LCTL get_param -n \
16684 osp.$mdtosc_proc1.reserved_mb_high ||
16685 skip "remote MDS does not support reserved_mb_high"
16689 wait_delete_completed
16692 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
16693 osp.$mdtosc_proc1.reserved_mb_high)
16694 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
16695 osp.$mdtosc_proc1.reserved_mb_low)
16696 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
16698 if ! combined_mgs_mds ; then
16701 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
16702 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
16703 error "Adding $ost_name to pool failed"
16705 # Wait for client to see a OST at pool
16706 wait_update $HOSTNAME "$LCTL get_param -n
16707 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
16708 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
16709 error "Client can not see the pool"
16710 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
16711 error "Setstripe failed"
16713 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
16714 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
16715 echo "OST still has $((blocks/1024)) mbytes free"
16717 local new_lwm=$((blocks/1024-10))
16718 do_facet $SINGLEMDS $LCTL set_param \
16719 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
16720 do_facet $SINGLEMDS $LCTL set_param \
16721 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
16723 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
16725 #First enospc could execute orphan deletion so repeat.
16726 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
16728 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
16729 osp.$mdtosc_proc1.prealloc_status)
16730 echo "prealloc_status $oa_status"
16732 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
16733 error "File creation should fail"
16734 #object allocation was stopped, but we still able to append files
16735 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
16736 error "Append failed"
16737 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
16739 wait_delete_completed
16743 for i in $(seq 10 12); do
16744 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
16745 error "File creation failed after rm";
16748 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
16749 osp.$mdtosc_proc1.prealloc_status)
16750 echo "prealloc_status $oa_status"
16752 if (( oa_status != 0 )); then
16753 error "Object allocation still disable after rm"
16755 do_facet $SINGLEMDS $LCTL set_param \
16756 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
16757 do_facet $SINGLEMDS $LCTL set_param \
16758 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
16761 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
16762 error "Remove $ost_name from pool failed"
16763 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
16764 error "Pool destroy fialed"
16766 if ! combined_mgs_mds ; then
16770 run_test 253 "Check object allocation limit"
16773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16774 remote_mds_nodsh && skip "remote MDS with nodsh"
16775 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
16776 skip "MDS does not support changelog_size"
16779 local MDT0=$(facet_svc $SINGLEMDS)
16781 changelog_register || error "changelog_register failed"
16783 changelog_clear 0 || error "changelog_clear failed"
16785 local size1=$(do_facet $SINGLEMDS \
16786 $LCTL get_param -n mdd.$MDT0.changelog_size)
16787 echo "Changelog size $size1"
16790 $LFS mkdir -i 0 $DIR/$tdir
16792 mkdir -p $DIR/$tdir/pics/2008/zachy
16793 touch $DIR/$tdir/pics/2008/zachy/timestamp
16794 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
16795 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16796 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16797 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16798 rm $DIR/$tdir/pics/desktop.jpg
16800 local size2=$(do_facet $SINGLEMDS \
16801 $LCTL get_param -n mdd.$MDT0.changelog_size)
16802 echo "Changelog size after work $size2"
16804 (( $size2 > $size1 )) ||
16805 error "new Changelog size=$size2 less than old size=$size1"
16807 run_test 254 "Check changelog size"
16814 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
16815 awk -F: '{print $2}' | grep $type > /dev/null
16816 if [ $? -ne 0 ]; then
16826 lfs ladvise -a willread $file > /dev/null 2>&1
16827 if [ $? -eq 0 ]; then
16831 lfs ladvise -a willread $file 2>&1 |
16832 grep "Inappropriate ioctl for device" > /dev/null
16833 if [ $? -eq 0 ]; then
16840 bc <<<"scale=2; ($1 - $2) * 100 / $2"
16843 # run a random read IO workload
16844 # usage: random_read_iops <filename> <filesize> <iosize>
16845 random_read_iops() {
16848 local iosize=${3:-4096}
16850 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
16851 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
16854 drop_file_oss_cache() {
16858 $LFS ladvise -a dontneed $file 2>/dev/null ||
16859 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
16862 ladvise_willread_performance()
16865 local average_origin=0
16866 local average_cache=0
16867 local average_ladvise=0
16869 for ((i = 1; i <= $repeat; i++)); do
16870 echo "Iter $i/$repeat: reading without willread hint"
16871 cancel_lru_locks osc
16872 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16873 local speed_origin=$(random_read_iops $DIR/$tfile $size)
16874 echo "Iter $i/$repeat: uncached speed: $speed_origin"
16875 average_origin=$(bc <<<"$average_origin + $speed_origin")
16877 cancel_lru_locks osc
16878 local speed_cache=$(random_read_iops $DIR/$tfile $size)
16879 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
16880 average_cache=$(bc <<<"$average_cache + $speed_cache")
16882 cancel_lru_locks osc
16883 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16884 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
16885 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
16886 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
16887 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
16889 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
16890 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
16891 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
16893 speedup_cache=$(percent $average_cache $average_origin)
16894 speedup_ladvise=$(percent $average_ladvise $average_origin)
16896 echo "Average uncached read: $average_origin"
16897 echo "Average speedup with OSS cached read: " \
16898 "$average_cache = +$speedup_cache%"
16899 echo "Average speedup with ladvise willread: " \
16900 "$average_ladvise = +$speedup_ladvise%"
16902 local lowest_speedup=20
16903 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
16904 echo "Speedup with OSS cached read less than $lowest_speedup%," \
16905 "got $average_cache%. Skipping ladvise willread check."
16909 # the test won't work on ZFS until it supports 'ladvise dontneed', but
16910 # it is still good to run until then to exercise 'ladvise willread'
16911 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16912 [ "$ost1_FSTYPE" = "zfs" ] &&
16913 echo "osd-zfs does not support dontneed or drop_caches" &&
16916 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
16917 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
16918 error_not_in_vm "Speedup with willread is less than " \
16919 "$lowest_speedup%, got $average_ladvise%"
16923 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
16924 skip "lustre < 2.8.54 does not support ladvise "
16925 remote_ost_nodsh && skip "remote OST with nodsh"
16927 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
16929 ladvise_no_type willread $DIR/$tfile &&
16930 skip "willread ladvise is not supported"
16932 ladvise_no_ioctl $DIR/$tfile &&
16933 skip "ladvise ioctl is not supported"
16936 local size=$((size_mb * 1048576))
16937 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
16938 error "dd to $DIR/$tfile failed"
16940 lfs ladvise -a willread $DIR/$tfile ||
16941 error "Ladvise failed with no range argument"
16943 lfs ladvise -a willread -s 0 $DIR/$tfile ||
16944 error "Ladvise failed with no -l or -e argument"
16946 lfs ladvise -a willread -e 1 $DIR/$tfile ||
16947 error "Ladvise failed with only -e argument"
16949 lfs ladvise -a willread -l 1 $DIR/$tfile ||
16950 error "Ladvise failed with only -l argument"
16952 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
16953 error "End offset should not be smaller than start offset"
16955 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
16956 error "End offset should not be equal to start offset"
16958 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
16959 error "Ladvise failed with overflowing -s argument"
16961 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
16962 error "Ladvise failed with overflowing -e argument"
16964 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
16965 error "Ladvise failed with overflowing -l argument"
16967 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
16968 error "Ladvise succeeded with conflicting -l and -e arguments"
16970 echo "Synchronous ladvise should wait"
16972 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
16973 do_nodes $(comma_list $(osts_nodes)) \
16974 $LCTL set_param fail_val=$delay fail_loc=0x237
16976 local start_ts=$SECONDS
16977 lfs ladvise -a willread $DIR/$tfile ||
16978 error "Ladvise failed with no range argument"
16979 local end_ts=$SECONDS
16980 local inteval_ts=$((end_ts - start_ts))
16982 if [ $inteval_ts -lt $(($delay - 1)) ]; then
16983 error "Synchronous advice didn't wait reply"
16986 echo "Asynchronous ladvise shouldn't wait"
16987 local start_ts=$SECONDS
16988 lfs ladvise -a willread -b $DIR/$tfile ||
16989 error "Ladvise failed with no range argument"
16990 local end_ts=$SECONDS
16991 local inteval_ts=$((end_ts - start_ts))
16993 if [ $inteval_ts -gt $(($delay / 2)) ]; then
16994 error "Asynchronous advice blocked"
16997 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
16998 ladvise_willread_performance
17000 run_test 255a "check 'lfs ladvise -a willread'"
17006 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
17010 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17011 skip "lustre < 2.8.54 does not support ladvise "
17012 remote_ost_nodsh && skip "remote OST with nodsh"
17014 lfs setstripe -c 1 -i 0 $DIR/$tfile
17016 ladvise_no_type dontneed $DIR/$tfile &&
17017 skip "dontneed ladvise is not supported"
17019 ladvise_no_ioctl $DIR/$tfile &&
17020 skip "ladvise ioctl is not supported"
17022 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17023 [ "$ost1_FSTYPE" = "zfs" ] &&
17024 skip "zfs-osd does not support 'ladvise dontneed'"
17027 local size=$((size_mb * 1048576))
17028 # In order to prevent disturbance of other processes, only check 3/4
17029 # of the memory usage
17030 local kibibytes=$((size_mb * 1024 * 3 / 4))
17032 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17033 error "dd to $DIR/$tfile failed"
17035 #force write to complete before dropping OST cache & checking memory
17038 local total=$(facet_meminfo ost1 MemTotal)
17039 echo "Total memory: $total KiB"
17041 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
17042 local before_read=$(facet_meminfo ost1 Cached)
17043 echo "Cache used before read: $before_read KiB"
17045 lfs ladvise -a willread $DIR/$tfile ||
17046 error "Ladvise willread failed"
17047 local after_read=$(facet_meminfo ost1 Cached)
17048 echo "Cache used after read: $after_read KiB"
17050 lfs ladvise -a dontneed $DIR/$tfile ||
17051 error "Ladvise dontneed again failed"
17052 local no_read=$(facet_meminfo ost1 Cached)
17053 echo "Cache used after dontneed ladvise: $no_read KiB"
17055 if [ $total -lt $((before_read + kibibytes)) ]; then
17056 echo "Memory is too small, abort checking"
17060 if [ $((before_read + kibibytes)) -gt $after_read ]; then
17061 error "Ladvise willread should use more memory" \
17062 "than $kibibytes KiB"
17065 if [ $((no_read + kibibytes)) -gt $after_read ]; then
17066 error "Ladvise dontneed should release more memory" \
17067 "than $kibibytes KiB"
17070 run_test 255b "check 'lfs ladvise -a dontneed'"
17073 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
17074 skip "lustre < 2.10.53 does not support lockahead"
17082 test_mkdir -p $DIR/$tdir
17083 $LFS setstripe -i 0 -c 1 $DIR/$tdir
17085 #test 10 returns only success/failure
17087 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17089 if [ $rc -eq 255 ]; then
17090 error "Ladvise test${i} failed, ${rc}"
17093 #test 11 counts lock enqueue requests, all others count new locks
17095 count=$(do_facet ost1 \
17096 $LCTL get_param -n ost.OSS.ost.stats)
17097 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
17099 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17101 if [ $rc -eq 255 ]; then
17102 error "Ladvise test${i} failed, ${rc}"
17105 new_count=$(do_facet ost1 \
17106 $LCTL get_param -n ost.OSS.ost.stats)
17107 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
17108 awk '{ print $2 }')
17110 difference="$((new_count - count))"
17111 if [ $difference -ne $rc ]; then
17112 error "Ladvise test${i}, bad enqueue count, returned " \
17113 "${rc}, actual ${difference}"
17116 for i in $(seq 12 21); do
17117 # If we do not do this, we run the risk of having too many
17118 # locks and starting lock cancellation while we are checking
17120 cancel_lru_locks osc
17122 count=$($LCTL get_param -n \
17123 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
17125 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17127 if [ $rc -eq 255 ]; then
17128 error "Ladvise test ${i} failed, ${rc}"
17131 new_count=$($LCTL get_param -n \
17132 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
17133 difference="$((new_count - count))"
17135 # Test 15 output is divided by 100 to map down to valid return
17136 if [ $i -eq 15 ]; then
17140 if [ $difference -ne $rc ]; then
17141 error "Ladvise test ${i}, bad lock count, returned " \
17142 "${rc}, actual ${difference}"
17146 #test 22 returns only success/failure
17148 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17150 if [ $rc -eq 255 ]; then
17151 error "Ladvise test${i} failed, ${rc}"
17154 run_test 255c "suite of ladvise lockahead tests"
17157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17158 remote_mds_nodsh && skip "remote MDS with nodsh"
17159 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
17160 changelog_users $SINGLEMDS | grep "^cl" &&
17161 skip "active changelog user"
17167 mdt_dev=$(mdsdevname 1)
17170 changelog_register || error "changelog_register failed"
17173 mkdir -p $DIR/$tdir
17175 changelog_clear 0 || error "changelog_clear failed"
17178 touch $DIR/$tdir/{1..10}
17181 stop $SINGLEMDS || error "Fail to stop MDT"
17185 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
17187 #after mount new plainllog is used
17188 touch $DIR/$tdir/{11..19}
17189 local tmpfile=$(mktemp -u $tfile.XXXXXX)
17190 cat_sl=$(do_facet $SINGLEMDS "sync; \
17191 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
17192 llog_reader $tmpfile | grep -c type=1064553b")
17193 do_facet $SINGLEMDS llog_reader $tmpfile
17195 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
17197 changelog_clear 0 || error "changelog_clear failed"
17199 cat_sl=$(do_facet $SINGLEMDS "sync; \
17200 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
17201 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
17203 if (( cat_sl == 2 )); then
17204 error "Empty plain llog was not deleted from changelog catalog"
17205 elif (( cat_sl != 1 )); then
17206 error "Active plain llog shouldn't be deleted from catalog"
17209 run_test 256 "Check llog delete for empty and not full state"
17212 remote_mds_nodsh && skip "remote MDS with nodsh"
17213 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
17214 skip "Need MDS version at least 2.8.55"
17216 test_mkdir $DIR/$tdir
17218 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
17219 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
17222 #define OBD_FAIL_MDS_XATTR_REP 0x161
17223 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
17224 local facet=mds$((mdtidx + 1))
17225 set_nodes_failloc $(facet_active_host $facet) 0x80000161
17226 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
17228 stop $facet || error "stop MDS failed"
17229 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
17230 error "start MDS fail"
17231 wait_recovery_complete $facet
17233 run_test 257 "xattr locks are not lost"
17235 # Verify we take the i_mutex when security requires it
17237 #define OBD_FAIL_IMUTEX_SEC 0x141c
17238 $LCTL set_param fail_loc=0x141c
17240 chmod u+s $DIR/$tfile
17241 chmod a+rwx $DIR/$tfile
17242 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
17244 if [ $RC -ne 0 ]; then
17245 error "error, failed to take i_mutex, rc=$?"
17249 run_test 258a "verify i_mutex security behavior when suid attributes is set"
17251 # Verify we do NOT take the i_mutex in the normal case
17253 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
17254 $LCTL set_param fail_loc=0x141d
17257 chmod a+rw $DIR/$tfile
17258 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
17260 if [ $RC -ne 0 ]; then
17261 error "error, took i_mutex unnecessarily, rc=$?"
17266 run_test 258b "verify i_mutex security behavior"
17269 local file=$DIR/$tfile
17273 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
17275 stack_trap "rm -f $file" EXIT
17277 wait_delete_completed
17278 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17279 echo "before: $before"
17281 $LFS setstripe -i 0 -c 1 $file
17282 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
17284 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17285 echo "after write: $after"
17287 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
17288 do_facet ost1 $LCTL set_param fail_loc=0x2301
17290 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17291 echo "after truncate: $after"
17294 do_facet ost1 $LCTL set_param fail_loc=0
17295 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
17297 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17298 echo "after restart: $after"
17299 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
17300 error "missing truncate?"
17304 run_test 259 "crash at delayed truncate"
17307 #define OBD_FAIL_MDC_CLOSE 0x806
17308 $LCTL set_param fail_loc=0x80000806
17312 run_test 260 "Check mdc_close fail"
17314 ### Data-on-MDT sanity tests ###
17316 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17317 skip "Need MDS version at least 2.10.55 for DoM"
17320 local dom=$DIR/$tdir/dom_file
17321 local tmp=$DIR/$tdir/tmp_file
17323 mkdir -p $DIR/$tdir
17325 # basic checks for DoM component creation
17326 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
17327 error "Can set MDT layout to non-first entry"
17329 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
17330 error "Can define multiple entries as MDT layout"
17332 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
17334 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
17335 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
17336 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
17338 local mdtidx=$($LFS getstripe -m $dom)
17339 local mdtname=MDT$(printf %04x $mdtidx)
17340 local facet=mds$((mdtidx + 1))
17341 local space_check=1
17343 # Skip free space checks with ZFS
17344 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
17348 local size_tmp=$((65536 * 3))
17349 local mdtfree1=$(do_facet $facet \
17350 lctl get_param -n osd*.*$mdtname.kbytesfree)
17352 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17353 # check also direct IO along write
17354 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
17355 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17357 cmp $tmp $dom || error "file data is different"
17358 [ $(stat -c%s $dom) == $size_tmp ] ||
17359 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17360 if [ $space_check == 1 ]; then
17361 local mdtfree2=$(do_facet $facet \
17362 lctl get_param -n osd*.*$mdtname.kbytesfree)
17364 # increase in usage from by $size_tmp
17365 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17366 error "MDT free space wrong after write: " \
17367 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17371 local size_dom=10000
17373 $TRUNCATE $dom $size_dom
17374 [ $(stat -c%s $dom) == $size_dom ] ||
17375 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
17376 if [ $space_check == 1 ]; then
17377 mdtfree1=$(do_facet $facet \
17378 lctl get_param -n osd*.*$mdtname.kbytesfree)
17379 # decrease in usage from $size_tmp to new $size_dom
17380 [ $(($mdtfree1 - $mdtfree2)) -ge \
17381 $(((size_tmp - size_dom) / 1024)) ] ||
17382 error "MDT free space is wrong after truncate: " \
17383 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
17389 size_dom=$((size_dom + size_tmp))
17390 [ $(stat -c%s $dom) == $size_dom ] ||
17391 error "bad size after append: $(stat -c%s $dom) != $size_dom"
17392 if [ $space_check == 1 ]; then
17393 mdtfree2=$(do_facet $facet \
17394 lctl get_param -n osd*.*$mdtname.kbytesfree)
17395 # increase in usage by $size_tmp from previous
17396 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17397 error "MDT free space is wrong after append: " \
17398 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17403 if [ $space_check == 1 ]; then
17404 mdtfree1=$(do_facet $facet \
17405 lctl get_param -n osd*.*$mdtname.kbytesfree)
17406 # decrease in usage by $size_dom from previous
17407 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
17408 error "MDT free space is wrong after removal: " \
17409 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
17412 # combined striping
17413 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
17414 error "Can't create DoM + OST striping"
17416 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
17417 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17418 # check also direct IO along write
17419 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17421 cmp $tmp $dom || error "file data is different"
17422 [ $(stat -c%s $dom) == $size_tmp ] ||
17423 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17428 run_test 270a "DoM: basic functionality tests"
17431 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17432 skip "Need MDS version at least 2.10.55"
17434 local dom=$DIR/$tdir/dom_file
17435 local max_size=1048576
17437 mkdir -p $DIR/$tdir
17438 $LFS setstripe -E $max_size -L mdt $dom
17440 # truncate over the limit
17441 $TRUNCATE $dom $(($max_size + 1)) &&
17442 error "successful truncate over the maximum size"
17443 # write over the limit
17444 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
17445 error "successful write over the maximum size"
17446 # append over the limit
17447 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
17448 echo "12345" >> $dom && error "successful append over the maximum size"
17453 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
17456 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17457 skip "Need MDS version at least 2.10.55"
17459 mkdir -p $DIR/$tdir
17460 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17462 # check files inherit DoM EA
17463 touch $DIR/$tdir/first
17464 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
17465 error "bad pattern"
17466 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
17467 error "bad stripe count"
17468 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
17469 error "bad stripe size"
17471 # check directory inherits DoM EA and uses it as default
17472 mkdir $DIR/$tdir/subdir
17473 touch $DIR/$tdir/subdir/second
17474 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
17475 error "bad pattern in sub-directory"
17476 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
17477 error "bad stripe count in sub-directory"
17478 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
17479 error "bad stripe size in sub-directory"
17482 run_test 270c "DoM: DoM EA inheritance tests"
17485 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17486 skip "Need MDS version at least 2.10.55"
17488 mkdir -p $DIR/$tdir
17489 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17491 # inherit default DoM striping
17492 mkdir $DIR/$tdir/subdir
17493 touch $DIR/$tdir/subdir/f1
17495 # change default directory striping
17496 $LFS setstripe -c 1 $DIR/$tdir/subdir
17497 touch $DIR/$tdir/subdir/f2
17498 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
17499 error "wrong default striping in file 2"
17500 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
17501 error "bad pattern in file 2"
17504 run_test 270d "DoM: change striping from DoM to RAID0"
17507 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17508 skip "Need MDS version at least 2.10.55"
17510 mkdir -p $DIR/$tdir/dom
17511 mkdir -p $DIR/$tdir/norm
17514 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
17515 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
17517 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
17518 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
17520 # find DoM files by layout
17521 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
17522 [ $NUM -eq $DOMFILES ] ||
17523 error "lfs find -L: found $NUM, expected $DOMFILES"
17524 echo "Test 1: lfs find 20 DOM files by layout: OK"
17526 # there should be 1 dir with default DOM striping
17527 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
17529 error "lfs find -L: found $NUM, expected 1 dir"
17530 echo "Test 2: lfs find 1 DOM dir by layout: OK"
17532 # find DoM files by stripe size
17533 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
17534 [ $NUM -eq $DOMFILES ] ||
17535 error "lfs find -S: found $NUM, expected $DOMFILES"
17536 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
17538 # find files by stripe offset except DoM files
17539 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
17540 [ $NUM -eq $NORMFILES ] ||
17541 error "lfs find -i: found $NUM, expected $NORMFILES"
17542 echo "Test 5: lfs find no DOM files by stripe index: OK"
17545 run_test 270e "DoM: lfs find with DoM files test"
17548 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17549 skip "Need MDS version at least 2.10.55"
17551 local mdtname=${FSNAME}-MDT0000-mdtlov
17552 local dom=$DIR/$tdir/dom_file
17553 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
17554 lod.$mdtname.dom_stripesize)
17555 local dom_limit=131072
17557 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
17558 local dom_current=$(do_facet mds1 $LCTL get_param -n \
17559 lod.$mdtname.dom_stripesize)
17560 [ ${dom_limit} -eq ${dom_current} ] ||
17561 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
17563 $LFS mkdir -i 0 -c 1 $DIR/$tdir
17564 $LFS setstripe -d $DIR/$tdir
17565 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
17566 error "Can't set directory default striping"
17568 # exceed maximum stripe size
17569 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
17570 error "Can't create file with $((dom_limit * 2)) DoM stripe"
17571 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
17572 error "Able to create DoM component size more than LOD limit"
17574 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
17575 dom_current=$(do_facet mds1 $LCTL get_param -n \
17576 lod.$mdtname.dom_stripesize)
17577 [ 0 -eq ${dom_current} ] ||
17578 error "Can't set zero DoM stripe limit"
17581 # attempt to create DoM file on server with disabled DoM should
17582 # remove DoM entry from layout and be succeed
17583 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
17584 error "Can't create DoM file (DoM is disabled)"
17585 [ $($LFS getstripe -L $dom) == "mdt" ] &&
17586 error "File has DoM component while DoM is disabled"
17589 # attempt to create DoM file with only DoM stripe should return error
17590 $LFS setstripe -E $dom_limit -L mdt $dom &&
17591 error "Able to create DoM-only file while DoM is disabled"
17593 # too low values to be aligned with smallest stripe size 64K
17594 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
17595 dom_current=$(do_facet mds1 $LCTL get_param -n \
17596 lod.$mdtname.dom_stripesize)
17597 [ 30000 -eq ${dom_current} ] &&
17598 error "Can set too small DoM stripe limit"
17600 # 64K is a minimal stripe size in Lustre, expect limit of that size
17601 [ 65536 -eq ${dom_current} ] ||
17602 error "Limit is not set to 64K but ${dom_current}"
17604 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
17605 dom_current=$(do_facet mds1 $LCTL get_param -n \
17606 lod.$mdtname.dom_stripesize)
17608 [ 2147483648 -eq ${dom_current} ] &&
17609 error "Can set too large DoM stripe limit"
17611 do_facet mds1 $LCTL set_param -n \
17612 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
17613 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
17614 error "Can't create DoM component size after limit change"
17615 do_facet mds1 $LCTL set_param -n \
17616 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
17617 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
17618 error "Can't create DoM file after limit decrease"
17619 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
17620 error "Can create big DoM component after limit decrease"
17621 touch ${dom}_def ||
17622 error "Can't create file with old default layout"
17624 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
17627 run_test 270f "DoM: maximum DoM stripe size checks"
17630 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17631 skip "Need MDS version at least 2.10.55"
17633 local dom=$DIR/$tdir/dom
17635 mkdir -p $DIR/$tdir
17637 $LFS setstripe -E 1024K -L mdt $dom
17639 lctl set_param -n mdc.*.stats=clear
17640 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
17641 cat $dom > /dev/null
17642 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
17643 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
17647 run_test 271a "DoM: data is cached for read after write"
17650 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17651 skip "Need MDS version at least 2.10.55"
17653 local dom=$DIR/$tdir/dom
17655 mkdir -p $DIR/$tdir
17657 $LFS setstripe -E 1024K -L mdt -E EOF $dom
17659 lctl set_param -n mdc.*.stats=clear
17660 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
17661 cancel_lru_locks mdc
17662 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
17663 # second stat to check size is cached on client
17664 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
17665 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
17666 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
17669 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
17672 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17673 skip "Need MDS version at least 2.10.55"
17675 local dom=$DIR/$tdir/dom
17677 mkdir -p $DIR/$tdir
17679 $LFS setstripe -E 1024K -L mdt -E EOF $dom
17681 lctl set_param -n mdc.*.stats=clear
17682 lctl set_param -n osc.*.stats=clear
17683 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
17684 cancel_lru_locks mdc
17685 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
17686 # second stat to check size is cached on client
17687 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
17688 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
17689 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
17690 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
17691 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
17694 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
17700 local mdt=MDT$(printf %04x $mdtidx)
17702 if [ -z $param ]; then
17703 lctl get_param -n mdc.*$mdt*.stats
17705 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
17710 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17711 skip "Need MDS version at least 2.10.55"
17713 local dom=$DIR/$tdir/dom
17715 mkdir -p $DIR/$tdir
17717 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17719 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
17720 local facet=mds$((mdtidx + 1))
17722 cancel_lru_locks mdc
17723 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
17724 createmany -o $dom 1000
17725 lctl set_param -n mdc.*.stats=clear
17726 smalliomany -w $dom 1000 200
17727 get_mdc_stats $mdtidx
17728 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
17729 # Each file has 1 open, 1 IO enqueues, total 2000
17730 # but now we have also +1 getxattr for security.capability, total 3000
17731 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
17732 unlinkmany $dom 1000
17734 cancel_lru_locks mdc
17735 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
17736 createmany -o $dom 1000
17737 lctl set_param -n mdc.*.stats=clear
17738 smalliomany -w $dom 1000 200
17739 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
17740 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
17741 # for OPEN and IO lock.
17742 [ $((enq - enq_2)) -ge 1000 ] ||
17743 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
17744 unlinkmany $dom 1000
17747 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
17749 cleanup_271def_tests() {
17755 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
17756 skip "Need MDS version at least 2.10.57"
17758 local dom=$DIR/$tdir/dom
17759 local tmp=$TMP/$tfile
17760 trap "cleanup_271def_tests $tmp" EXIT
17762 mkdir -p $DIR/$tdir
17764 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17766 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
17768 cancel_lru_locks mdc
17769 dd if=/dev/urandom of=$tmp bs=1000 count=1
17770 dd if=$tmp of=$dom bs=1000 count=1
17771 cancel_lru_locks mdc
17773 cat /etc/hosts >> $tmp
17774 lctl set_param -n mdc.*.stats=clear
17776 # append data to the same file it should update local page
17777 echo "Append to the same page"
17778 cat /etc/hosts >> $dom
17779 local num=$(get_mdc_stats $mdtidx ost_read)
17780 local ra=$(get_mdc_stats $mdtidx req_active)
17781 local rw=$(get_mdc_stats $mdtidx req_waittime)
17783 [ -z $num ] || error "$num READ RPC occured"
17784 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17788 cmp $tmp $dom || error "file miscompare"
17790 cancel_lru_locks mdc
17791 lctl set_param -n mdc.*.stats=clear
17793 echo "Open and read file"
17794 cat $dom > /dev/null
17795 local num=$(get_mdc_stats $mdtidx ost_read)
17796 local ra=$(get_mdc_stats $mdtidx req_active)
17797 local rw=$(get_mdc_stats $mdtidx req_waittime)
17799 [ -z $num ] || error "$num READ RPC occured"
17800 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17804 cmp $tmp $dom || error "file miscompare"
17808 run_test 271d "DoM: read on open (1K file in reply buffer)"
17811 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
17812 skip "Need MDS version at least 2.10.57"
17814 local dom=$DIR/$tdir/dom
17815 local tmp=$TMP/$tfile
17816 trap "cleanup_271def_tests $tmp" EXIT
17818 mkdir -p $DIR/$tdir
17820 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17822 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
17824 cancel_lru_locks mdc
17825 dd if=/dev/urandom of=$tmp bs=200000 count=1
17826 dd if=$tmp of=$dom bs=200000 count=1
17827 cancel_lru_locks mdc
17828 cat /etc/hosts >> $tmp
17829 lctl set_param -n mdc.*.stats=clear
17831 echo "Append to the same page"
17832 cat /etc/hosts >> $dom
17833 local num=$(get_mdc_stats $mdtidx ost_read)
17834 local ra=$(get_mdc_stats $mdtidx req_active)
17835 local rw=$(get_mdc_stats $mdtidx req_waittime)
17837 [ -z $num ] || error "$num READ RPC occured"
17838 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17842 cmp $tmp $dom || error "file miscompare"
17844 cancel_lru_locks mdc
17845 lctl set_param -n mdc.*.stats=clear
17847 echo "Open and read file"
17848 cat $dom > /dev/null
17849 local num=$(get_mdc_stats $mdtidx ost_read)
17850 local ra=$(get_mdc_stats $mdtidx req_active)
17851 local rw=$(get_mdc_stats $mdtidx req_waittime)
17853 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
17854 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17858 cmp $tmp $dom || error "file miscompare"
17862 run_test 271f "DoM: read on open (200K file and read tail)"
17865 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
17866 skip "Skipping due to old client or server version"
17868 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
17870 $CHECKSTAT -t file $DIR1/$tfile
17872 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
17875 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
17876 $LCTL set_param fail_loc=0x80000314
17877 rm $DIR1/$tfile || error "Unlink fails"
17879 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
17880 [ $RC -eq 0 ] || error "Failed write to stale object"
17882 run_test 271g "Discard DoM data vs client flush race"
17885 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17886 skip "Need MDS version at least 2.11.50"
17888 local dom=$DIR/$tdir/dom
17889 mkdir -p $DIR/$tdir
17891 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
17892 dd if=/dev/urandom of=$dom bs=512K count=1 ||
17893 error "failed to write data into $dom"
17894 local old_md5=$(md5sum $dom)
17896 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
17897 error "failed to migrate to the same DoM component"
17899 local new_md5=$(md5sum $dom)
17901 [ "$old_md5" == "$new_md5" ] ||
17902 error "md5sum differ: $old_md5, $new_md5"
17904 [ $($LFS getstripe -c $dom) -eq 2 ] ||
17905 error "migrate stripe count bad: $(LFS getstripe -c $dom) != 2"
17907 run_test 272a "DoM migration: new layout with the same DOM component"
17910 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17911 skip "Need MDS version at least 2.11.50"
17913 local dom=$DIR/$tdir/dom
17914 mkdir -p $DIR/$tdir
17915 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
17917 local mdtidx=$($LFS getstripe -m $dom)
17918 local mdtname=MDT$(printf %04x $mdtidx)
17919 local facet=mds$((mdtidx + 1))
17921 local mdtfree1=$(do_facet $facet \
17922 lctl get_param -n osd*.*$mdtname.kbytesfree)
17923 dd if=/dev/urandom of=$dom bs=2M count=1 ||
17924 error "failed to write data into $dom"
17925 local old_md5=$(md5sum $dom)
17926 cancel_lru_locks mdc
17927 local mdtfree1=$(do_facet $facet \
17928 lctl get_param -n osd*.*$mdtname.kbytesfree)
17930 $LFS migrate -c2 $dom ||
17931 error "failed to migrate to the new composite layout"
17932 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
17933 error "MDT stripe was not removed"
17935 cancel_lru_locks mdc
17936 local new_md5=$(md5sum $dom)
17937 [ "$old_md5" != "$new_md5" ] &&
17938 error "$old_md5 != $new_md5"
17940 # Skip free space checks with ZFS
17941 if [ "$(facet_fstype $facet)" != "zfs" ]; then
17942 local mdtfree2=$(do_facet $facet \
17943 lctl get_param -n osd*.*$mdtname.kbytesfree)
17944 [ $mdtfree2 -gt $mdtfree1 ] ||
17945 error "MDT space is not freed after migration"
17949 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
17952 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17953 skip "Need MDS version at least 2.11.50"
17955 local dom=$DIR/$tdir/$tfile
17956 mkdir -p $DIR/$tdir
17957 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
17959 local mdtidx=$($LFS getstripe -m $dom)
17960 local mdtname=MDT$(printf %04x $mdtidx)
17961 local facet=mds$((mdtidx + 1))
17963 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
17964 error "failed to write data into $dom"
17965 local old_md5=$(md5sum $dom)
17966 cancel_lru_locks mdc
17967 local mdtfree1=$(do_facet $facet \
17968 lctl get_param -n osd*.*$mdtname.kbytesfree)
17970 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
17971 error "failed to migrate to the new composite layout"
17972 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
17973 error "MDT stripe was not removed"
17975 cancel_lru_locks mdc
17976 local new_md5=$(md5sum $dom)
17977 [ "$old_md5" != "$new_md5" ] &&
17978 error "$old_md5 != $new_md5"
17980 # Skip free space checks with ZFS
17981 if [ "$(facet_fstype $facet)" != "zfs" ]; then
17982 local mdtfree2=$(do_facet $facet \
17983 lctl get_param -n osd*.*$mdtname.kbytesfree)
17984 [ $mdtfree2 -gt $mdtfree1 ] ||
17985 error "MDS space is not freed after migration"
17989 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
17992 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17993 skip "Need MDS version at least 2.11.50"
17995 # Layout swap cannot be done if either file has DOM component,
17996 # this will never be supported, migration should be used instead
17998 local dom=$DIR/$tdir/$tfile
17999 mkdir -p $DIR/$tdir
18001 $LFS setstripe -c2 ${dom}_plain
18002 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
18003 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
18004 error "can swap layout with DoM component"
18005 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
18006 error "can swap layout with DoM component"
18008 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
18009 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
18010 error "can swap layout with DoM component"
18011 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
18012 error "can swap layout with DoM component"
18015 run_test 273a "DoM: layout swapping should fail with DOM"
18018 remote_ost_nodsh && skip "remote OST with nodsh"
18019 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
18020 skip "Need OST version >= 2.10.57"
18022 local file=$DIR/$tfile
18025 oss=$(comma_list $(osts_nodes))
18027 dd if=/dev/urandom of=$file bs=1M count=2 ||
18028 error "failed to create a file"
18029 cancel_lru_locks osc
18032 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18033 error "failed to read a file"
18035 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
18036 $LCTL set_param fail_loc=0x8000031f
18038 cancel_lru_locks osc &
18041 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
18042 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
18043 #IO takes another lock, but matches the PENDING one
18044 #and places it to the IO RPC
18045 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18046 error "failed to read a file with PENDING lock"
18048 run_test 275 "Read on a canceled duplicate lock"
18051 remote_ost_nodsh && skip "remote OST with nodsh"
18054 do_facet ost1 "(while true; do \
18055 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
18056 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
18059 for LOOP in $(seq 20); do
18061 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
18064 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
18065 rm $TMP/sanity_276_pid"
18067 run_test 276 "Race between mount and obd_statfs"
18069 cleanup_test_300() {
18073 test_striped_dir() {
18078 mkdir -p $DIR/$tdir
18080 SAVE_UMASK=$(umask)
18081 trap cleanup_test_300 RETURN EXIT
18083 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
18084 $DIR/$tdir/striped_dir ||
18085 error "set striped dir error"
18087 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
18088 [ "$mode" = "755" ] || error "expect 755 got $mode"
18090 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
18091 error "getdirstripe failed"
18092 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
18093 if [ "$stripe_count" != "2" ]; then
18094 error "1:stripe_count is $stripe_count, expect 2"
18096 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
18097 if [ "$stripe_count" != "2" ]; then
18098 error "2:stripe_count is $stripe_count, expect 2"
18101 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
18102 if [ "$stripe_index" != "$mdt_index" ]; then
18103 error "stripe_index is $stripe_index, expect $mdt_index"
18106 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18107 error "nlink error after create striped dir"
18109 mkdir $DIR/$tdir/striped_dir/a
18110 mkdir $DIR/$tdir/striped_dir/b
18112 stat $DIR/$tdir/striped_dir/a ||
18113 error "create dir under striped dir failed"
18114 stat $DIR/$tdir/striped_dir/b ||
18115 error "create dir under striped dir failed"
18117 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
18118 error "nlink error after mkdir"
18120 rmdir $DIR/$tdir/striped_dir/a
18121 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
18122 error "nlink error after rmdir"
18124 rmdir $DIR/$tdir/striped_dir/b
18125 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18126 error "nlink error after rmdir"
18128 chattr +i $DIR/$tdir/striped_dir
18129 createmany -o $DIR/$tdir/striped_dir/f 10 &&
18130 error "immutable flags not working under striped dir!"
18131 chattr -i $DIR/$tdir/striped_dir
18133 rmdir $DIR/$tdir/striped_dir ||
18134 error "rmdir striped dir error"
18142 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18143 skip "skipped for lustre < 2.7.0"
18144 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18145 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18147 test_striped_dir 0 || error "failed on striped dir on MDT0"
18148 test_striped_dir 1 || error "failed on striped dir on MDT0"
18150 run_test 300a "basic striped dir sanity test"
18153 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18154 skip "skipped for lustre < 2.7.0"
18155 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18156 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18163 test_mkdir $DIR/$tdir || error "mkdir fail"
18164 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18165 error "set striped dir error"
18166 for i in {0..9}; do
18167 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
18169 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
18170 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
18171 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
18173 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
18174 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
18175 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
18179 run_test 300b "check ctime/mtime for striped dir"
18182 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18183 skip "skipped for lustre < 2.7.0"
18184 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18185 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18189 mkdir -p $DIR/$tdir
18190 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
18191 error "set striped dir error"
18193 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
18194 error "chown striped dir failed"
18196 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
18197 error "create 5k files failed"
18199 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
18201 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
18205 run_test 300c "chown && check ls under striped directory"
18208 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18209 skip "skipped for lustre < 2.7.0"
18210 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18211 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18216 mkdir -p $DIR/$tdir
18217 $LFS setstripe -c 2 $DIR/$tdir
18219 #local striped directory
18220 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18221 error "set striped dir error"
18222 createmany -o $DIR/$tdir/striped_dir/f 10 ||
18223 error "create 10 files failed"
18225 #remote striped directory
18226 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
18227 error "set striped dir error"
18228 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
18229 error "create 10 files failed"
18231 for file in $(find $DIR/$tdir); do
18232 stripe_count=$($LFS getstripe -c $file)
18233 [ $stripe_count -eq 2 ] ||
18234 error "wrong stripe $stripe_count for $file"
18239 run_test 300d "check default stripe under striped directory"
18242 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18243 skip "Need MDS version at least 2.7.55"
18244 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18245 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18250 mkdir -p $DIR/$tdir
18252 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18253 error "set striped dir error"
18255 touch $DIR/$tdir/striped_dir/a
18256 touch $DIR/$tdir/striped_dir/b
18257 touch $DIR/$tdir/striped_dir/c
18259 mkdir $DIR/$tdir/striped_dir/dir_a
18260 mkdir $DIR/$tdir/striped_dir/dir_b
18261 mkdir $DIR/$tdir/striped_dir/dir_c
18263 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
18264 error "set striped adir under striped dir error"
18266 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
18267 error "set striped bdir under striped dir error"
18269 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
18270 error "set striped cdir under striped dir error"
18272 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
18273 error "rename dir under striped dir fails"
18275 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
18276 error "rename dir under different stripes fails"
18278 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
18279 error "rename file under striped dir should succeed"
18281 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
18282 error "rename dir under striped dir should succeed"
18286 run_test 300e "check rename under striped directory"
18289 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18290 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18291 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18292 skip "Need MDS version at least 2.7.55"
18298 mkdir -p $DIR/$tdir
18300 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18301 error "set striped dir error"
18303 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
18304 error "set striped dir error"
18306 touch $DIR/$tdir/striped_dir/a
18307 mkdir $DIR/$tdir/striped_dir/dir_a
18308 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
18309 error "create striped dir under striped dir fails"
18311 touch $DIR/$tdir/striped_dir1/b
18312 mkdir $DIR/$tdir/striped_dir1/dir_b
18313 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
18314 error "create striped dir under striped dir fails"
18316 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
18317 error "rename dir under different striped dir should fail"
18319 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
18320 error "rename striped dir under diff striped dir should fail"
18322 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
18323 error "rename file under diff striped dirs fails"
18327 run_test 300f "check rename cross striped directory"
18329 test_300_check_default_striped_dir()
18332 local default_count=$2
18333 local default_index=$3
18336 local dir_stripe_index
18339 echo "checking $dirname $default_count $default_index"
18340 $LFS setdirstripe -D -c $default_count -i $default_index \
18341 -t all_char $DIR/$tdir/$dirname ||
18342 error "set default stripe on striped dir error"
18343 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
18344 [ $stripe_count -eq $default_count ] ||
18345 error "expect $default_count get $stripe_count for $dirname"
18347 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
18348 [ $stripe_index -eq $default_index ] ||
18349 error "expect $default_index get $stripe_index for $dirname"
18351 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
18352 error "create dirs failed"
18354 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
18355 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
18356 for dir in $(find $DIR/$tdir/$dirname/*); do
18357 stripe_count=$($LFS getdirstripe -c $dir)
18358 [ $stripe_count -eq $default_count ] ||
18359 [ $stripe_count -eq 0 ] || [ $default_count -eq 1 ] ||
18360 error "stripe count $default_count != $stripe_count for $dir"
18362 stripe_index=$($LFS getdirstripe -i $dir)
18363 [ $default_index -eq -1 ] ||
18364 [ $stripe_index -eq $default_index ] ||
18365 error "$stripe_index != $default_index for $dir"
18367 #check default stripe
18368 stripe_count=$($LFS getdirstripe -D -c $dir)
18369 [ $stripe_count -eq $default_count ] ||
18370 error "default count $default_count != $stripe_count for $dir"
18372 stripe_index=$($LFS getdirstripe -D -i $dir)
18373 [ $stripe_index -eq $default_index ] ||
18374 error "default index $default_index != $stripe_index for $dir"
18376 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
18380 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18381 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18382 skip "Need MDS version at least 2.7.55"
18389 mkdir $DIR/$tdir/normal_dir
18391 #Checking when client cache stripe index
18392 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
18393 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
18394 error "create striped_dir failed"
18396 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
18397 error "create dir0 fails"
18398 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
18399 [ $stripe_index -eq 0 ] ||
18400 error "dir0 expect index 0 got $stripe_index"
18402 mkdir $DIR/$tdir/striped_dir/dir1 ||
18403 error "create dir1 fails"
18404 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
18405 [ $stripe_index -eq 1 ] ||
18406 error "dir1 expect index 1 got $stripe_index"
18408 #check default stripe count/stripe index
18409 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
18410 test_300_check_default_striped_dir normal_dir 1 0
18411 test_300_check_default_striped_dir normal_dir 2 1
18412 test_300_check_default_striped_dir normal_dir 2 -1
18414 #delete default stripe information
18415 echo "delete default stripeEA"
18416 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
18417 error "set default stripe on striped dir error"
18419 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
18420 for dir in $(find $DIR/$tdir/normal_dir/*); do
18421 stripe_count=$($LFS getdirstripe -c $dir)
18422 [ $stripe_count -eq 0 ] ||
18423 error "expect 1 get $stripe_count for $dir"
18424 stripe_index=$($LFS getdirstripe -i $dir)
18425 [ $stripe_index -eq 0 ] ||
18426 error "expect 0 get $stripe_index for $dir"
18429 run_test 300g "check default striped directory for normal directory"
18432 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18433 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18434 skip "Need MDS version at least 2.7.55"
18440 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18441 error "set striped dir error"
18443 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
18444 test_300_check_default_striped_dir striped_dir 1 0
18445 test_300_check_default_striped_dir striped_dir 2 1
18446 test_300_check_default_striped_dir striped_dir 2 -1
18448 #delete default stripe information
18449 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
18450 error "set default stripe on striped dir error"
18452 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
18453 for dir in $(find $DIR/$tdir/striped_dir/*); do
18454 stripe_count=$($LFS getdirstripe -c $dir)
18455 [ $stripe_count -eq 0 ] ||
18456 error "expect 1 get $stripe_count for $dir"
18459 run_test 300h "check default striped directory for striped directory"
18462 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18463 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18464 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18465 skip "Need MDS version at least 2.7.55"
18472 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18473 error "set striped dir error"
18475 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18476 error "create files under striped dir failed"
18478 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
18479 error "set striped hashdir error"
18481 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
18482 error "create dir0 under hash dir failed"
18483 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
18484 error "create dir1 under hash dir failed"
18486 # unfortunately, we need to umount to clear dir layout cache for now
18487 # once we fully implement dir layout, we can drop this
18488 umount_client $MOUNT || error "umount failed"
18489 mount_client $MOUNT || error "mount failed"
18491 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
18492 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
18493 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
18495 #set the stripe to be unknown hash type
18496 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
18497 $LCTL set_param fail_loc=0x1901
18498 for ((i = 0; i < 10; i++)); do
18499 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
18500 error "stat f-$i failed"
18501 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
18504 touch $DIR/$tdir/striped_dir/f0 &&
18505 error "create under striped dir with unknown hash should fail"
18507 $LCTL set_param fail_loc=0
18509 umount_client $MOUNT || error "umount failed"
18510 mount_client $MOUNT || error "mount failed"
18514 run_test 300i "client handle unknown hash type striped directory"
18517 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18518 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18519 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18520 skip "Need MDS version at least 2.7.55"
18527 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
18528 $LCTL set_param fail_loc=0x1702
18529 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18530 error "set striped dir error"
18532 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18533 error "create files under striped dir failed"
18535 $LCTL set_param fail_loc=0
18537 rm -rf $DIR/$tdir || error "unlink striped dir fails"
18541 run_test 300j "test large update record"
18544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18545 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18546 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18547 skip "Need MDS version at least 2.7.55"
18549 # this test needs a huge transaction
18551 kb=$(do_facet $SINGLEMDS lctl get_param -n osd*.lustre-MDT0000.kbytestotal)
18552 [ $kb -lt $((1024*1024)) ] && skip "too small mds: $kb"
18559 #define OBD_FAIL_LARGE_STRIPE 0x1703
18560 $LCTL set_param fail_loc=0x1703
18561 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
18562 error "set striped dir error"
18563 $LCTL set_param fail_loc=0
18565 $LFS getdirstripe $DIR/$tdir/striped_dir ||
18566 error "getstripeddir fails"
18567 rm -rf $DIR/$tdir/striped_dir ||
18568 error "unlink striped dir fails"
18572 run_test 300k "test large striped directory"
18575 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18576 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18577 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18578 skip "Need MDS version at least 2.7.55"
18582 test_mkdir -p $DIR/$tdir/striped_dir
18583 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
18584 error "chown $RUNAS_ID failed"
18585 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
18586 error "set default striped dir failed"
18588 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
18589 $LCTL set_param fail_loc=0x80000158
18590 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
18592 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
18593 [ $stripe_index -eq 1 ] ||
18594 error "expect 1 get $stripe_index for $dir"
18596 run_test 300l "non-root user to create dir under striped dir with stale layout"
18599 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18600 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
18601 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18602 skip "Need MDS version at least 2.7.55"
18604 mkdir -p $DIR/$tdir/striped_dir
18605 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
18606 error "set default stripes dir error"
18608 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
18610 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
18611 [ $stripe_count -eq 0 ] ||
18612 error "expect 0 get $stripe_count for a"
18614 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
18615 error "set default stripes dir error"
18617 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
18619 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
18620 [ $stripe_count -eq 0 ] ||
18621 error "expect 0 get $stripe_count for b"
18623 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
18624 error "set default stripes dir error"
18626 mkdir $DIR/$tdir/striped_dir/c &&
18627 error "default stripe_index is invalid, mkdir c should fails"
18629 rm -rf $DIR/$tdir || error "rmdir fails"
18631 run_test 300m "setstriped directory on single MDT FS"
18634 local list=$(comma_list $(mdts_nodes))
18637 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18641 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18642 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18643 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18644 skip "Need MDS version at least 2.7.55"
18645 remote_mds_nodsh && skip "remote MDS with nodsh"
18648 local list=$(comma_list $(mdts_nodes))
18650 trap cleanup_300n RETURN EXIT
18651 mkdir -p $DIR/$tdir
18652 chmod 777 $DIR/$tdir
18653 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
18654 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
18655 error "create striped dir succeeds with gid=0"
18657 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
18658 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
18659 error "create striped dir fails with gid=-1"
18661 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18662 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
18663 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
18664 error "set default striped dir succeeds with gid=0"
18667 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
18668 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
18669 error "set default striped dir fails with gid=-1"
18672 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18673 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
18674 error "create test_dir fails"
18675 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
18676 error "create test_dir1 fails"
18677 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
18678 error "create test_dir2 fails"
18681 run_test 300n "non-root user to create dir under striped dir with default EA"
18684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18685 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18686 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18687 skip "Need MDS version at least 2.7.55"
18692 mkdir -p $DIR/$tdir
18694 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
18695 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
18696 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
18697 skip "not enough free inodes $numfree1 $numfree2"
18700 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
18701 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
18702 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
18703 skip "not enough free space $numfree1 $numfree2"
18706 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
18707 error "setdirstripe fails"
18709 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
18710 error "create dirs fails"
18712 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
18713 ls $DIR/$tdir/striped_dir > /dev/null ||
18714 error "ls striped dir fails"
18715 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
18716 error "unlink big striped dir fails"
18718 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
18721 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18722 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18723 remote_mds_nodsh && skip "remote MDS with nodsh"
18725 mkdir -p $DIR/$tdir
18727 #define OBD_FAIL_OUT_ENOSPC 0x1704
18728 do_facet mds2 lctl set_param fail_loc=0x80001704
18729 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
18730 && error "create striped directory should fail"
18732 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
18734 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
18737 run_test 300p "create striped directory without space"
18740 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18741 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18743 local fd=$(free_fd)
18744 local cmd="exec $fd<$tdir"
18746 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
18749 trap "eval $cmd" EXIT
18750 cd $tdir || error "cd $tdir fails"
18751 rmdir ../$tdir || error "rmdir $tdir fails"
18752 mkdir local_dir && error "create dir succeeds"
18753 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
18757 run_test 300q "create remote directory under orphan directory"
18760 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
18761 skip "Need MDS version at least 2.7.55" && return
18762 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
18766 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
18767 error "set striped dir error"
18769 $LFS getdirstripe $DIR/$tdir/striped_dir ||
18770 error "getstripeddir fails"
18773 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
18774 awk '/lmv_stripe_count:/ { print $2 }')
18776 [ $MDSCOUNT -ne $stripe_count ] &&
18777 error "wrong stripe count $stripe_count expected $MDSCOUNT"
18779 rm -rf $DIR/$tdir/striped_dir ||
18780 error "unlink striped dir fails"
18782 run_test 300r "test -1 striped directory"
18784 prepare_remote_file() {
18785 mkdir $DIR/$tdir/src_dir ||
18786 error "create remote source failed"
18788 cp /etc/hosts $DIR/$tdir/src_dir/a ||
18789 error "cp to remote source failed"
18790 touch $DIR/$tdir/src_dir/a
18792 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
18793 error "create remote target dir failed"
18795 touch $DIR/$tdir/tgt_dir/b
18797 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
18798 error "rename dir cross MDT failed!"
18800 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
18801 error "src_child still exists after rename"
18803 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
18804 error "missing file(a) after rename"
18806 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
18807 error "diff after rename"
18811 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
18812 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18814 local remote_file=$DIR/$tdir/tgt_dir/b
18816 mkdir -p $DIR/$tdir
18818 prepare_remote_file || error "prepare remote file failed"
18821 $OPENUNLINK $remote_file $remote_file ||
18822 error "openunlink $remote_file failed"
18823 $CHECKSTAT -a $remote_file || error "$remote_file exists"
18825 run_test 310a "open unlink remote file"
18828 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
18829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18831 local remote_file=$DIR/$tdir/tgt_dir/b
18833 mkdir -p $DIR/$tdir
18835 prepare_remote_file || error "prepare remote file failed"
18837 ln $remote_file $DIR/$tfile || error "link failed for remote file"
18838 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
18839 $CHECKSTAT -t file $remote_file || error "check file failed"
18841 run_test 310b "unlink remote file with multiple links while open"
18844 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18845 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
18847 local remote_file=$DIR/$tdir/tgt_dir/b
18849 mkdir -p $DIR/$tdir
18851 prepare_remote_file || error "prepare remote file failed"
18853 ln $remote_file $DIR/$tfile || error "link failed for remote file"
18854 multiop_bg_pause $remote_file O_uc ||
18855 error "mulitop failed for remote file"
18857 $MULTIOP $DIR/$tfile Ouc
18858 kill -USR1 $MULTIPID
18861 run_test 310c "open-unlink remote file with multiple links"
18865 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18866 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
18867 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
18868 skip "lustre < 2.8.54 does not contain LU-4825 fix"
18869 remote_mds_nodsh && skip "remote MDS with nodsh"
18871 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
18872 local mdts=$(comma_list $(mdts_nodes))
18874 mkdir -p $DIR/$tdir
18875 $LFS setstripe -i 0 -c 1 $DIR/$tdir
18876 createmany -o $DIR/$tdir/$tfile. 1000
18878 # statfs data is not real time, let's just calculate it
18879 old_iused=$((old_iused + 1000))
18881 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
18882 osp.*OST0000*MDT0000.create_count")
18883 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
18884 osp.*OST0000*MDT0000.max_create_count")
18885 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
18887 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
18888 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
18889 [ $index -ne 0 ] || error "$tfile stripe index is 0"
18891 unlinkmany $DIR/$tdir/$tfile. 1000
18893 do_nodes $mdts "$LCTL set_param -n \
18894 osp.*OST0000*.max_create_count=$max_count"
18895 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
18896 do_nodes $mdts "$LCTL set_param -n \
18897 osp.*OST0000*.create_count=$count"
18898 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
18899 grep "=0" && error "create_count is zero"
18902 for i in $(seq 120); do
18903 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
18904 # system may be too busy to destroy all objs in time, use
18905 # a somewhat small value to not fail autotest
18906 [ $((old_iused - new_iused)) -gt 400 ] && break
18910 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
18911 [ $((old_iused - new_iused)) -gt 400 ] ||
18912 error "objs not destroyed after unlink"
18914 run_test 311 "disable OSP precreate, and unlink should destroy objs"
18921 local vdevdir=$(dirname $(facet_vdevice $ost))
18922 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
18923 local zfs_zapid=$(do_facet $ost $cmd |
18924 grep -w "/O/0/d$((objid%32))" -C 5 |
18925 awk '/Object/{getline; print $1}')
18926 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
18927 awk "/$objid = /"'{printf $3}')
18932 zfs_object_blksz() {
18936 local vdevdir=$(dirname $(facet_vdevice $ost))
18937 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
18938 local blksz=$(do_facet $ost $cmd $objid |
18939 awk '/dblk/{getline; printf $4}')
18941 case "${blksz: -1}" in
18942 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
18943 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
18950 test_312() { # LU-4856
18951 remote_ost_nodsh && skip "remote OST with nodsh"
18952 [ "$ost1_FSTYPE" = "zfs" ] ||
18953 skip_env "the test only applies to zfs"
18955 local max_blksz=$(do_facet ost1 \
18956 $ZFS get -p recordsize $(facet_device ost1) |
18957 awk '!/VALUE/{print $3}')
18959 # to make life a little bit easier
18960 $LFS mkdir -c 1 -i 0 $DIR/$tdir
18961 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18963 local tf=$DIR/$tdir/$tfile
18965 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18967 # Get ZFS object id
18968 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18969 # block size change by sequential overwrite
18972 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
18973 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
18975 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
18976 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
18980 # block size change by sequential append write
18981 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
18982 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18983 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18986 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
18987 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
18988 oflag=sync conv=notrunc
18990 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18991 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
18992 error "blksz error, actual $blksz, " \
18993 "expected: 2 * $count * $PAGE_SIZE"
18999 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19000 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19002 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
19003 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19004 [ $blksz -eq $PAGE_SIZE ] ||
19005 error "blksz error: $blksz, expected: $PAGE_SIZE"
19007 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
19008 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19009 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
19011 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
19012 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19013 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
19015 run_test 312 "make sure ZFS adjusts its block size by write pattern"
19018 remote_ost_nodsh && skip "remote OST with nodsh"
19020 local file=$DIR/$tfile
19023 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
19025 # define OBD_FAIL_TGT_RCVD_EIO 0x720
19026 do_facet ost1 "$LCTL set_param fail_loc=0x720"
19027 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
19028 error "write should failed"
19029 do_facet ost1 "$LCTL set_param fail_loc=0"
19032 run_test 313 "io should fail after last_rcvd update fail"
19035 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19037 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
19038 do_facet ost1 "$LCTL set_param fail_loc=0x720"
19040 wait_delete_completed
19041 do_facet ost1 "$LCTL set_param fail_loc=0"
19043 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
19045 test_315() { # LU-618
19046 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
19048 local file=$DIR/$tfile
19051 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
19052 error "multiop file write failed"
19053 $MULTIOP $file oO_RDONLY:r4063232_c &
19058 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
19061 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
19064 run_test 315 "read should be accounted"
19067 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19068 large_xattr_enabled || skip_env "ea_inode feature disabled"
19070 rm -rf $DIR/$tdir/d
19071 mkdir -p $DIR/$tdir/d
19072 chown nobody $DIR/$tdir/d
19073 touch $DIR/$tdir/d/file
19075 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
19077 run_test 316 "lfs mv"
19080 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
19081 skip "Need MDS version at least 2.11.53"
19083 local grant_blk_size
19085 if [ "$(facet_fstype $facet)" == "zfs" ]; then
19086 skip "LU-10370: no implementation for ZFS" && return
19089 stack_trap "rm -f $DIR/$tfile" EXIT
19090 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
19091 awk '/grant_block_size:/ { print $2; exit; }')
19093 # Create File of size 5M. Truncate it to below size's and verify
19096 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
19097 error "Create file : $DIR/$tfile"
19099 for trunc_sz in 2097152 4097 4000 509 0; do
19100 $TRUNCATE $DIR/$tfile $trunc_sz ||
19101 error "truncate $tfile to $trunc_sz failed"
19102 local sz=$(stat --format=%s $DIR/$tfile)
19103 local blk=$(stat --format=%b $DIR/$tfile)
19104 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
19105 grant_blk_size) * 8))
19107 if [[ $blk -ne $trunc_blk ]]; then
19108 $(which stat) $DIR/$tfile
19109 error "Expected Block $trunc_blk got $blk for $tfile"
19112 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
19113 error "Expected Size $trunc_sz got $sz for $tfile"
19118 # Create file with a hole and write actual two blocks. Block count
19121 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
19122 conv=fsync || error "Create file : $DIR/$tfile"
19124 # Calculate the final truncate size.
19125 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
19128 # truncate to size $trunc_sz bytes. Strip the last block
19129 # The block count must drop to 8
19131 $TRUNCATE $DIR/$tfile $trunc_sz ||
19132 error "truncate $tfile to $trunc_sz failed"
19134 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
19135 sz=$(stat --format=%s $DIR/$tfile)
19136 blk=$(stat --format=%b $DIR/$tfile)
19138 if [[ $blk -ne $trunc_bsz ]]; then
19139 $(which stat) $DIR/$tfile
19140 error "Expected Block $trunc_bsz got $blk for $tfile"
19143 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
19144 error "Expected Size $trunc_sz got $sz for $tfile"
19146 run_test 317 "Verify blocks get correctly update after truncate"
19149 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
19151 local before=$(date +%s)
19153 local mdir=$DIR/$tdir
19154 local file=$mdir/xxx
19156 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
19159 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
19160 $LCTL set_param fail_val=5 fail_loc=0x8000032c
19161 $LFS mv -m1 $file &
19164 dd if=$file of=/dev/null
19166 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
19167 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
19169 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
19171 run_test 319 "lost lease lock on migrate error"
19174 local read_write=$1
19175 if [ "$read_write" = "write" ]; then
19176 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
19177 elif [ "$read_write" = "read" ]; then
19178 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
19180 error "argument error"
19183 # turn off debug for performance testing
19184 local saved_debug=$($LCTL get_param -n debug)
19185 $LCTL set_param debug=0
19187 $LFS setstripe -c 1 -i 0 $DIR/$tfile
19189 # get ost1 size - lustre-OST0000
19190 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
19191 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
19192 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
19194 if [ "$read_write" = "read" ]; then
19195 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
19198 local start_time=$(date +%s.%N)
19199 $dd_cmd bs=1M count=$blocks oflag=sync ||
19200 error "real dd $read_write error"
19201 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
19203 if [ "$read_write" = "write" ]; then
19207 # define OBD_FAIL_OST_FAKE_RW 0x238
19208 do_facet ost1 $LCTL set_param fail_loc=0x238
19210 local start_time=$(date +%s.%N)
19211 $dd_cmd bs=1M count=$blocks oflag=sync ||
19212 error "fake dd $read_write error"
19213 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
19215 if [ "$read_write" = "write" ]; then
19217 cancel_lru_locks osc
19218 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
19219 error "$tfile size not $blocks MB"
19221 do_facet ost1 $LCTL set_param fail_loc=0
19223 echo "fake $read_write $duration_fake vs. normal $read_write" \
19224 "$duration in seconds"
19225 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
19226 error_not_in_vm "fake write is slower"
19228 $LCTL set_param -n debug="$saved_debug"
19231 test_399a() { # LU-7655 for OST fake write
19232 remote_ost_nodsh && skip "remote OST with nodsh"
19236 run_test 399a "fake write should not be slower than normal write"
19238 test_399b() { # LU-8726 for OST fake read
19239 remote_ost_nodsh && skip "remote OST with nodsh"
19240 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
19241 skip_env "ldiskfs only test"
19246 run_test 399b "fake read should not be slower than normal read"
19248 test_400a() { # LU-1606, was conf-sanity test_74
19249 if ! which $CC > /dev/null 2>&1; then
19250 skip_env "$CC is not installed"
19253 local extra_flags=''
19254 local out=$TMP/$tfile
19255 local prefix=/usr/include/lustre
19258 if ! [[ -d $prefix ]]; then
19259 # Assume we're running in tree and fixup the include path.
19260 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
19261 extra_flags+=" -L$LUSTRE/utils/.lib"
19264 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
19265 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
19266 error "client api broken"
19270 run_test 400a "Lustre client api program can compile and link"
19272 test_400b() { # LU-1606, LU-5011
19274 local out=$TMP/$tfile
19275 local prefix=/usr/include/linux/lustre
19277 # We use a hard coded prefix so that this test will not fail
19278 # when run in tree. There are headers in lustre/include/lustre/
19279 # that are not packaged (like lustre_idl.h) and have more
19280 # complicated include dependencies (like config.h and lnet/types.h).
19281 # Since this test about correct packaging we just skip them when
19282 # they don't exist (see below) rather than try to fixup cppflags.
19284 if ! which $CC > /dev/null 2>&1; then
19285 skip_env "$CC is not installed"
19288 for header in $prefix/*.h; do
19289 if ! [[ -f "$header" ]]; then
19293 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
19294 continue # lustre_ioctl.h is internal header
19297 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
19298 error "cannot compile '$header'"
19302 run_test 400b "packaged headers can be compiled"
19304 test_401a() { #LU-7437
19305 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
19306 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
19308 #count the number of parameters by "list_param -R"
19309 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
19310 #count the number of parameters by listing proc files
19311 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
19312 echo "proc_dirs='$proc_dirs'"
19313 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
19314 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
19317 [ $params -eq $procs ] ||
19318 error "found $params parameters vs. $procs proc files"
19320 # test the list_param -D option only returns directories
19321 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
19322 #count the number of parameters by listing proc directories
19323 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
19326 [ $params -eq $procs ] ||
19327 error "found $params parameters vs. $procs proc files"
19329 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
19332 local save=$($LCTL get_param -n jobid_var)
19335 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
19336 error "no error returned when setting bad parameters"
19338 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
19339 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
19341 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
19342 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
19343 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
19345 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
19348 local jobid_var_old=$($LCTL get_param -n jobid_var)
19349 local jobid_var_new
19351 $LCTL set_param jobid_var= &&
19352 error "no error returned for 'set_param a='"
19354 jobid_var_new=$($LCTL get_param -n jobid_var)
19355 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
19356 error "jobid_var was changed by setting without value"
19358 $LCTL set_param jobid_var &&
19359 error "no error returned for 'set_param a'"
19361 jobid_var_new=$($LCTL get_param -n jobid_var)
19362 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
19363 error "jobid_var was changed by setting without value"
19365 run_test 401c "Verify 'lctl set_param' without value fails in either format."
19368 local jobid_var_old=$($LCTL get_param -n jobid_var)
19369 local jobid_var_new
19370 local new_value="foo=bar"
19372 $LCTL set_param jobid_var=$new_value ||
19373 error "'set_param a=b' did not accept a value containing '='"
19375 jobid_var_new=$($LCTL get_param -n jobid_var)
19376 [[ "$jobid_var_new" == "$new_value" ]] ||
19377 error "'set_param a=b' failed on a value containing '='"
19379 # Reset the jobid_var to test the other format
19380 $LCTL set_param jobid_var=$jobid_var_old
19381 jobid_var_new=$($LCTL get_param -n jobid_var)
19382 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
19383 error "failed to reset jobid_var"
19385 $LCTL set_param jobid_var $new_value ||
19386 error "'set_param a b' did not accept a value containing '='"
19388 jobid_var_new=$($LCTL get_param -n jobid_var)
19389 [[ "$jobid_var_new" == "$new_value" ]] ||
19390 error "'set_param a b' failed on a value containing '='"
19392 $LCTL set_param jobid_var $jobid_var_old
19393 jobid_var_new=$($LCTL get_param -n jobid_var)
19394 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
19395 error "failed to reset jobid_var"
19397 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
19400 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
19401 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
19402 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
19403 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
19404 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
19405 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
19406 remote_mds_nodsh && skip "remote MDS with nodsh"
19408 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
19409 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
19410 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
19411 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
19412 echo "Touch failed - OK"
19414 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
19417 local file1=$DIR/$tfile.1
19418 local file2=$DIR/$tfile.2
19419 local tfile=$TMP/$tfile
19421 rm -f $file1 $file2 $tfile
19426 # 30 sec OBD_TIMEOUT in ll_getattr()
19427 # right before populating st_nlink
19428 $LCTL set_param fail_loc=0x80001409
19429 stat -c %h $file1 > $tfile &
19431 # create an alias, drop all locks and reclaim the dentry
19433 cancel_lru_locks mdc
19434 cancel_lru_locks osc
19435 sysctl -w vm.drop_caches=2
19439 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
19441 rm -f $tfile $file1 $file2
19443 run_test 403 "i_nlink should not drop to zero due to aliasing"
19445 test_404() { # LU-6601
19446 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
19447 skip "Need server version newer than 2.8.52"
19448 remote_mds_nodsh && skip "remote MDS with nodsh"
19450 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
19451 awk '/osp .*-osc-MDT/ { print $4}')
19454 for osp in $mosps; do
19455 echo "Deactivate: " $osp
19456 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
19457 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19458 awk -vp=$osp '$4 == p { print $2 }')
19459 [ $stat = IN ] || {
19460 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19461 error "deactivate error"
19463 echo "Activate: " $osp
19464 do_facet $SINGLEMDS $LCTL --device %$osp activate
19465 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19466 awk -vp=$osp '$4 == p { print $2 }')
19467 [ $stat = UP ] || {
19468 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19469 error "activate error"
19473 run_test 404 "validate manual {de}activated works properly for OSPs"
19476 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
19477 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
19478 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
19479 skip "Layout swap lock is not supported"
19481 check_swap_layouts_support
19483 test_mkdir $DIR/$tdir
19484 swap_lock_test -d $DIR/$tdir ||
19485 error "One layout swap locked test failed"
19487 run_test 405 "Various layout swap lock tests"
19490 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19491 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
19492 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
19493 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19494 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
19495 skip "Need MDS version at least 2.8.50"
19497 local def_stripe_size=$($LFS getstripe -S $MOUNT)
19498 local test_pool=$TESTNAME
19500 if ! combined_mgs_mds ; then
19503 pool_add $test_pool || error "pool_add failed"
19504 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
19505 error "pool_add_targets failed"
19507 save_layout_restore_at_exit $MOUNT
19509 # parent set default stripe count only, child will stripe from both
19510 # parent and fs default
19511 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
19512 error "setstripe $MOUNT failed"
19513 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
19514 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
19515 for i in $(seq 10); do
19516 local f=$DIR/$tdir/$tfile.$i
19517 touch $f || error "touch failed"
19518 local count=$($LFS getstripe -c $f)
19519 [ $count -eq $OSTCOUNT ] ||
19520 error "$f stripe count $count != $OSTCOUNT"
19521 local offset=$($LFS getstripe -i $f)
19522 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
19523 local size=$($LFS getstripe -S $f)
19524 [ $size -eq $((def_stripe_size * 2)) ] ||
19525 error "$f stripe size $size != $((def_stripe_size * 2))"
19526 local pool=$($LFS getstripe -p $f)
19527 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
19530 # change fs default striping, delete parent default striping, now child
19531 # will stripe from new fs default striping only
19532 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
19533 error "change $MOUNT default stripe failed"
19534 $LFS setstripe -c 0 $DIR/$tdir ||
19535 error "delete $tdir default stripe failed"
19536 for i in $(seq 11 20); do
19537 local f=$DIR/$tdir/$tfile.$i
19538 touch $f || error "touch $f failed"
19539 local count=$($LFS getstripe -c $f)
19540 [ $count -eq 1 ] || error "$f stripe count $count != 1"
19541 local offset=$($LFS getstripe -i $f)
19542 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
19543 local size=$($LFS getstripe -S $f)
19544 [ $size -eq $def_stripe_size ] ||
19545 error "$f stripe size $size != $def_stripe_size"
19546 local pool=$($LFS getstripe -p $f)
19547 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
19550 unlinkmany $DIR/$tdir/$tfile. 1 20
19552 local f=$DIR/$tdir/$tfile
19553 pool_remove_all_targets $test_pool $f
19554 pool_remove $test_pool $f
19556 if ! combined_mgs_mds ; then
19560 run_test 406 "DNE support fs default striping"
19563 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19564 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
19565 skip "Need MDS version at least 2.8.55"
19566 remote_mds_nodsh && skip "remote MDS with nodsh"
19568 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
19569 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
19570 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
19571 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
19572 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
19574 #define OBD_FAIL_DT_TXN_STOP 0x2019
19575 for idx in $(seq $MDSCOUNT); do
19576 do_facet mds$idx "lctl set_param fail_loc=0x2019"
19578 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
19579 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
19580 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
19583 run_test 407 "transaction fail should cause operation fail"
19586 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
19588 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
19589 lctl set_param fail_loc=0x8000040a
19590 # let ll_prepare_partial_page() fail
19591 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
19595 # create at least 100 unused inodes so that
19596 # shrink_icache_memory(0) should not return 0
19597 touch $DIR/$tfile-{0..100}
19598 rm -f $DIR/$tfile-{0..100}
19601 echo 2 > /proc/sys/vm/drop_caches
19603 run_test 408 "drop_caches should not hang due to page leaks"
19607 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19609 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
19610 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
19611 touch $DIR/$tdir/guard || error "(2) Fail to create"
19613 local PREFIX=$(str_repeat 'A' 128)
19614 echo "Create 1K hard links start at $(date)"
19615 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
19616 error "(3) Fail to hard link"
19618 echo "Links count should be right although linkEA overflow"
19619 stat $DIR/$tdir/guard || error "(4) Fail to stat"
19620 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
19621 [ $linkcount -eq 1001 ] ||
19622 error "(5) Unexpected hard links count: $linkcount"
19624 echo "List all links start at $(date)"
19625 ls -l $DIR/$tdir/foo > /dev/null ||
19626 error "(6) Fail to list $DIR/$tdir/foo"
19628 echo "Unlink hard links start at $(date)"
19629 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
19630 error "(7) Fail to unlink"
19631 echo "Unlink hard links finished at $(date)"
19633 run_test 409 "Large amount of cross-MDTs hard links on the same file"
19637 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
19638 skip "Need client version at least 2.9.59"
19640 # Create a file, and stat it from the kernel
19641 local testfile=$DIR/$tfile
19644 local run_id=$RANDOM
19645 local my_ino=$(stat --format "%i" $testfile)
19647 # Try to insert the module. This will always fail as the
19648 # module is designed to not be inserted.
19649 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
19652 # Anything but success is a test failure
19654 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
19655 error "no inode match"
19657 run_test 410 "Test inode number returned from kernel thread"
19659 cleanup_test411_cgroup() {
19665 local cg_basedir=/sys/fs/cgroup/memory
19667 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
19668 skip "no setup for cgroup"
19670 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
19671 error "test file creation failed"
19672 cancel_lru_locks osc
19674 # Create a very small memory cgroup to force a slab allocation error
19675 local cgdir=$cg_basedir/osc_slab_alloc
19676 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
19677 trap "cleanup_test411_cgroup $cgdir" EXIT
19678 echo 2M > $cgdir/memory.kmem.limit_in_bytes
19679 echo 1M > $cgdir/memory.limit_in_bytes
19681 # Should not LBUG, just be killed by oom-killer
19682 # dd will return 0 even allocation failure in some environment.
19683 # So don't check return value
19684 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
19685 cleanup_test411_cgroup $cgdir
19689 run_test 411 "Slab allocation error with cgroup does not LBUG"
19692 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19693 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
19694 skip "Need server version at least 2.10.55"
19697 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
19698 error "mkdir failed"
19699 $LFS getdirstripe $DIR/$tdir
19700 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
19701 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
19702 error "expect $((MDSCOUT - 1)) get $stripe_index"
19703 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
19704 [ $stripe_count -eq 2 ] ||
19705 error "expect 2 get $stripe_count"
19707 run_test 412 "mkdir on specific MDTs"
19710 [ $MDSCOUNT -lt 2 ] &&
19711 skip "We need at least 2 MDTs for this test"
19713 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
19714 skip "Need server version at least 2.10.55"
19717 mkdir $DIR/$tdir || error "mkdir failed"
19719 # find MDT that is the most full
19720 local max=$($LFS df | grep MDT |
19729 END { split(b, c, ":")
19734 for i in $(seq $((MDSCOUNT - 1))); do
19735 $LFS mkdir -c $i $DIR/$tdir/d$i ||
19736 error "mkdir d$i failed"
19737 $LFS getdirstripe $DIR/$tdir/d$i
19738 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
19739 [ $stripe_index -ne $max ] ||
19740 error "don't expect $max"
19743 run_test 413 "mkdir on less full MDTs"
19746 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
19747 $LCTL set_param fail_loc=0x80000521
19748 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
19751 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
19754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19755 [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
19756 skip "Need server version at least 2.11.52"
19766 # this test may be slow on ZFS
19767 [ "$mds1_FSTYPE" == "zfs" ] && total=100
19769 # though this test is designed for striped directory, let's test normal
19770 # directory too since lock is always saved as CoS lock.
19771 test_mkdir $DIR/$tdir || error "mkdir $tdir"
19772 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
19781 start_time=$(date +%s)
19782 for i in $(seq $total); do
19783 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
19786 end_time=$(date +%s)
19787 duration=$((end_time - start_time))
19789 kill -9 $setattr_pid
19791 echo "rename $total files took $duration sec"
19792 [ $duration -lt 100 ] || error "rename took $duration sec"
19794 run_test 415 "lock revoke is not missing"
19797 [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
19798 skip "Need server version at least 2.11.55"
19800 # define OBD_FAIL_OSD_TXN_START 0x19a
19801 do_facet mds1 lctl set_param fail_loc=0x19a
19803 lfs mkdir -c $MDSCOUNT $DIR/$tdir
19807 run_test 416 "transaction start failure won't cause system hung"
19811 do_nodes $(comma_list $(mdts_nodes)) \
19812 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
19813 do_nodes $(comma_list $(mdts_nodes)) \
19814 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
19815 do_nodes $(comma_list $(mdts_nodes)) \
19816 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
19820 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19821 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
19822 skip "Need MDS version at least 2.11.56"
19824 trap cleanup_417 RETURN EXIT
19826 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
19827 do_nodes $(comma_list $(mdts_nodes)) \
19828 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
19829 $LFS migrate -m 0 $DIR/$tdir.1 &&
19830 error "migrate dir $tdir.1 should fail"
19832 do_nodes $(comma_list $(mdts_nodes)) \
19833 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
19834 $LFS mkdir -i 1 $DIR/$tdir.2 &&
19835 error "create remote dir $tdir.2 should fail"
19837 do_nodes $(comma_list $(mdts_nodes)) \
19838 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
19839 $LFS mkdir -c 2 $DIR/$tdir.3 &&
19840 error "create striped dir $tdir.3 should fail"
19843 run_test 417 "disable remote dir, striped dir and dir migration"
19845 # Checks that the outputs of df [-i] and lfs df [-i] match
19847 # usage: check_lfs_df <blocks | inodes> <mountpoint>
19857 [ "$1" == "blocks" ] && inodes= || inodes="-i"
19859 for count in {1..100}; do
19863 # read the lines of interest
19864 df_out=($(df -P $inodes $dir | tail -n +2)) ||
19865 error "df $inodes $dir | tail -n +2 failed"
19866 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
19867 error "lfs df $inodes $dir | grep summary: failed"
19869 # skip first substrings of each output as they are different
19870 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
19871 # compare the two outputs
19873 for i in {1..5}; do
19874 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
19882 lfs df $inodes $dir
19883 error "df and lfs df $1 output mismatch: " \
19884 "df ${inodes}: ${df_out[*]}, " \
19885 "lfs df ${inodes}: ${lfs_df_out[*]}"
19890 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19892 local dir=$DIR/$tdir
19893 local numfiles=$((RANDOM % 4096 + 2))
19894 local numblocks=$((RANDOM % 256 + 1))
19896 wait_delete_completed
19899 # check block output
19900 check_lfs_df blocks $dir
19901 # check inode output
19902 check_lfs_df inodes $dir
19904 # create a single file and retest
19905 echo "Creating a single file and testing"
19906 createmany -o $dir/$tfile- 1 &>/dev/null ||
19907 error "creating 1 file in $dir failed"
19908 check_lfs_df blocks $dir
19909 check_lfs_df inodes $dir
19911 # create a random number of files
19912 echo "Creating $((numfiles - 1)) files and testing"
19913 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
19914 error "creating $((numfiles - 1)) files in $dir failed"
19916 # write a random number of blocks to the first test file
19917 echo "Writing $numblocks 4K blocks and testing"
19918 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
19919 count=$numblocks &>/dev/null ||
19920 error "dd to $dir/${tfile}-0 failed"
19923 check_lfs_df blocks $dir
19924 check_lfs_df inodes $dir
19926 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
19927 error "unlinking $numfiles files in $dir failed"
19929 run_test 418 "df and lfs df outputs match"
19933 local dir=$DIR/$tdir
19938 cancel_lru_locks mdc
19940 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
19941 $LCTL set_param fail_loc=0x1410
19943 $LCTL set_param fail_loc=0
19946 run_test 419 "Verify open file by name doesn't crash kernel"
19950 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
19951 skip "Need MDS version at least 2.12.53"
19953 local SAVE_UMASK=$(umask)
19954 local dir=$DIR/$tdir
19955 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
19959 mkdir -m03777 $dir/testdir
19960 ls -dn $dir/testdir
19961 local dirperms=$(ls -dn $dir/testdir | awk '{print $1}')
19962 [ $dirperms == "drwxrwsrwt" ] ||
19963 error "incorrect perms on $dir/testdir"
19965 $PDSH ${uname}@localhost "PATH=$LUSTRE/tests:\$PATH; \
19966 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
19967 ls -n $dir/testdir/testfile
19968 local fileperms=$(ls -n $dir/testdir/testfile | awk '{print $1}')
19969 [ $fileperms == "-rwxr-xr-x" ] ||
19970 error "incorrect perms on $dir/testdir/testfile"
19974 run_test 420 "clear SGID bit on non-directories for non-members"
19977 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
19978 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
19979 skip "Need server version at least 2.9.55"
19981 start_full_debug_logging
19985 stop_full_debug_logging
19989 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
19990 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
19991 awk '/The barrier for/ { print $7 }')
19994 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
19999 barrier_expired() {
20002 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
20003 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
20004 awk '/will be expired/ { print $7 }')
20006 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
20015 echo "Start barrier_freeze at: $(date)"
20016 #define OBD_FAIL_BARRIER_DELAY 0x2202
20017 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
20018 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
20021 local b_status=$(barrier_stat)
20022 echo "Got barrier status at: $(date)"
20023 [ "$b_status" = "'freezing_p1'" ] ||
20024 error "(1) unexpected barrier status $b_status"
20026 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
20028 b_status=$(barrier_stat)
20029 [ "$b_status" = "'frozen'" ] ||
20030 error "(2) unexpected barrier status $b_status"
20032 local expired=$(barrier_expired)
20033 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
20034 sleep $((expired + 3))
20036 b_status=$(barrier_stat)
20037 [ "$b_status" = "'expired'" ] ||
20038 error "(3) unexpected barrier status $b_status"
20040 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
20041 error "(4) fail to freeze barrier"
20043 b_status=$(barrier_stat)
20044 [ "$b_status" = "'frozen'" ] ||
20045 error "(5) unexpected barrier status $b_status"
20047 echo "Start barrier_thaw at: $(date)"
20048 #define OBD_FAIL_BARRIER_DELAY 0x2202
20049 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
20050 do_facet mgs $LCTL barrier_thaw $FSNAME &
20053 b_status=$(barrier_stat)
20054 echo "Got barrier status at: $(date)"
20055 [ "$b_status" = "'thawing'" ] ||
20056 error "(6) unexpected barrier status $b_status"
20058 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
20060 b_status=$(barrier_stat)
20061 [ "$b_status" = "'thawed'" ] ||
20062 error "(7) unexpected barrier status $b_status"
20064 #define OBD_FAIL_BARRIER_FAILURE 0x2203
20065 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
20066 do_facet mgs $LCTL barrier_freeze $FSNAME
20068 b_status=$(barrier_stat)
20069 [ "$b_status" = "'failed'" ] ||
20070 error "(8) unexpected barrier status $b_status"
20072 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
20073 do_facet mgs $LCTL barrier_thaw $FSNAME
20077 run_test 801a "write barrier user interfaces and stat machine"
20082 mkdir $DIR/$tdir || error "(1) fail to mkdir"
20083 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
20084 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
20085 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
20086 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
20088 cancel_lru_locks mdc
20090 # 180 seconds should be long enough
20091 do_facet mgs $LCTL barrier_freeze $FSNAME 180
20093 local b_status=$(barrier_stat)
20094 [ "$b_status" = "'frozen'" ] ||
20095 error "(6) unexpected barrier status $b_status"
20097 mkdir $DIR/$tdir/d0/d10 &
20100 touch $DIR/$tdir/d1/f13 &
20103 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
20106 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
20109 rm -f $DIR/$tdir/d4/f12 &
20112 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
20114 # To guarantee taht the 'stat' is not blocked
20115 b_status=$(barrier_stat)
20116 [ "$b_status" = "'frozen'" ] ||
20117 error "(8) unexpected barrier status $b_status"
20119 # let above commands to run at background
20122 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
20123 ps -p $touch_pid || error "(10) touch should be blocked"
20124 ps -p $ln_pid || error "(11) link should be blocked"
20125 ps -p $mv_pid || error "(12) rename should be blocked"
20126 ps -p $rm_pid || error "(13) unlink should be blocked"
20128 b_status=$(barrier_stat)
20129 [ "$b_status" = "'frozen'" ] ||
20130 error "(14) unexpected barrier status $b_status"
20132 do_facet mgs $LCTL barrier_thaw $FSNAME
20133 b_status=$(barrier_stat)
20134 [ "$b_status" = "'thawed'" ] ||
20135 error "(15) unexpected barrier status $b_status"
20137 wait $mkdir_pid || error "(16) mkdir should succeed"
20138 wait $touch_pid || error "(17) touch should succeed"
20139 wait $ln_pid || error "(18) link should succeed"
20140 wait $mv_pid || error "(19) rename should succeed"
20141 wait $rm_pid || error "(20) unlink should succeed"
20145 run_test 801b "modification will be blocked by write barrier"
20148 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
20152 stop mds2 || error "(1) Fail to stop mds2"
20154 do_facet mgs $LCTL barrier_freeze $FSNAME 30
20156 local b_status=$(barrier_stat)
20157 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
20158 do_facet mgs $LCTL barrier_thaw $FSNAME
20159 error "(2) unexpected barrier status $b_status"
20162 do_facet mgs $LCTL barrier_rescan $FSNAME ||
20163 error "(3) Fail to rescan barrier bitmap"
20165 do_facet mgs $LCTL barrier_freeze $FSNAME 10
20167 b_status=$(barrier_stat)
20168 [ "$b_status" = "'frozen'" ] ||
20169 error "(4) unexpected barrier status $b_status"
20171 do_facet mgs $LCTL barrier_thaw $FSNAME
20172 b_status=$(barrier_stat)
20173 [ "$b_status" = "'thawed'" ] ||
20174 error "(5) unexpected barrier status $b_status"
20176 local devname=$(mdsdevname 2)
20178 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
20180 do_facet mgs $LCTL barrier_rescan $FSNAME ||
20181 error "(7) Fail to rescan barrier bitmap"
20185 run_test 801c "rescan barrier bitmap"
20187 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
20188 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
20189 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
20195 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
20196 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
20197 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
20203 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
20204 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
20205 skip "Need server version at least 2.9.55"
20207 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
20209 mkdir $DIR/$tdir || error "(1) fail to mkdir"
20211 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
20212 error "(2) Fail to copy"
20214 trap cleanup_802a EXIT
20216 # sync by force before remount as readonly
20217 sync; sync_all_data; sleep 3; sync_all_data
20221 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
20222 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
20223 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
20225 echo "Mount the server as read only"
20226 setupall server_only || error "(3) Fail to start servers"
20228 echo "Mount client without ro should fail"
20229 mount_client $MOUNT &&
20230 error "(4) Mount client without 'ro' should fail"
20232 echo "Mount client with ro should succeed"
20233 mount_client $MOUNT ro ||
20234 error "(5) Mount client with 'ro' should succeed"
20236 echo "Modify should be refused"
20237 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
20239 echo "Read should be allowed"
20240 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
20241 error "(7) Read should succeed under ro mode"
20245 run_test 802a "simulate readonly device"
20248 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20249 remote_mds_nodsh && skip "remote MDS with nodsh"
20251 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
20252 skip "readonly option not available"
20254 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
20256 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
20257 error "(2) Fail to copy"
20259 # write back all cached data before setting MDT to readonly
20263 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
20264 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
20266 echo "Modify should be refused"
20267 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
20269 echo "Read should be allowed"
20270 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
20271 error "(7) Read should succeed under ro mode"
20274 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
20276 run_test 802b "be able to set MDTs to readonly"
20279 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
20280 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
20281 skip "MDS needs to be newer than 2.10.54"
20283 mkdir -p $DIR/$tdir
20284 # Create some objects on all MDTs to trigger related logs objects
20285 for idx in $(seq $MDSCOUNT); do
20286 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
20287 $DIR/$tdir/dir${idx} ||
20288 error "Fail to create $DIR/$tdir/dir${idx}"
20292 wait_delete_completed # ensure old test cleanups are finished
20293 echo "before create:"
20295 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
20297 for i in {1..10}; do
20298 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
20299 error "Fail to create $DIR/$tdir/foo$i"
20303 echo "after create:"
20305 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
20307 # allow for an llog to be cleaned up during the test
20308 [ $after_used -ge $((before_used + 10 - 1)) ] ||
20309 error "before ($before_used) + 10 > after ($after_used)"
20311 for i in {1..10}; do
20312 rm -rf $DIR/$tdir/foo$i ||
20313 error "Fail to remove $DIR/$tdir/foo$i"
20316 sleep 3 # avoid MDT return cached statfs
20317 wait_delete_completed
20318 echo "after unlink:"
20320 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
20322 # allow for an llog to be created during the test
20323 [ $after_used -le $((before_used + 1)) ] ||
20324 error "after ($after_used) > before ($before_used) + 1"
20326 run_test 803 "verify agent object for remote object"
20329 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
20330 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
20331 skip "MDS needs to be newer than 2.10.54"
20332 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
20334 mkdir -p $DIR/$tdir
20335 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
20336 error "Fail to create $DIR/$tdir/dir0"
20338 local fid=$($LFS path2fid $DIR/$tdir/dir0)
20339 local dev=$(mdsdevname 2)
20341 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20342 grep ${fid} || error "NOT found agent entry for dir0"
20344 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
20345 error "Fail to create $DIR/$tdir/dir1"
20347 touch $DIR/$tdir/dir1/foo0 ||
20348 error "Fail to create $DIR/$tdir/dir1/foo0"
20349 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
20352 for idx in $(seq $MDSCOUNT); do
20353 dev=$(mdsdevname $idx)
20354 do_facet mds${idx} \
20355 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20356 grep ${fid} && rc=$idx
20359 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
20360 error "Fail to rename foo0 to foo1"
20361 if [ $rc -eq 0 ]; then
20362 for idx in $(seq $MDSCOUNT); do
20363 dev=$(mdsdevname $idx)
20364 do_facet mds${idx} \
20365 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20366 grep ${fid} && rc=$idx
20370 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
20371 error "Fail to rename foo1 to foo2"
20372 if [ $rc -eq 0 ]; then
20373 for idx in $(seq $MDSCOUNT); do
20374 dev=$(mdsdevname $idx)
20375 do_facet mds${idx} \
20376 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20377 grep ${fid} && rc=$idx
20381 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
20383 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
20384 error "Fail to link to $DIR/$tdir/dir1/foo2"
20385 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
20386 error "Fail to rename foo2 to foo0"
20387 unlink $DIR/$tdir/dir1/foo0 ||
20388 error "Fail to unlink $DIR/$tdir/dir1/foo0"
20389 rm -rf $DIR/$tdir/dir0 ||
20390 error "Fail to rm $DIR/$tdir/dir0"
20392 for idx in $(seq $MDSCOUNT); do
20393 dev=$(mdsdevname $idx)
20397 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
20399 start mds${idx} $dev $MDS_MOUNT_OPTS ||
20400 error "mount mds$idx failed"
20401 df $MOUNT > /dev/null 2>&1
20403 # e2fsck should not return error
20405 error "e2fsck detected error on MDT${idx}: rc=$rc"
20408 run_test 804 "verify agent entry for remote entry"
20411 do_facet $SINGLEMDS zfs set quota=$old $fsset
20412 unlinkmany $DIR/$tdir/f- 1000000
20417 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
20418 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
20419 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
20420 skip "netfree not implemented before 0.7"
20421 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
20422 skip "Need MDS version at least 2.10.57"
20429 local pref="osd-zfs.lustre-MDT0000."
20431 # limit available space on MDS dataset to meet nospace issue
20432 # quickly. then ZFS 0.7.2 can use reserved space if asked
20433 # properly (using netfree flag in osd_declare_destroy()
20434 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
20435 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
20437 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
20438 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
20439 let "usedkb=usedkb-freekb"
20440 let "freekb=freekb/2"
20441 if let "freekb > 5000"; then
20444 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
20445 trap cleanup_805 EXIT
20447 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
20448 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
20449 rm -rf $DIR/$tdir || error "not able to remove"
20450 do_facet $SINGLEMDS zfs set quota=$old $fsset
20453 run_test 805 "ZFS can remove from full fs"
20459 local size=$($LFS getsom -s $file)
20460 local expect=$(stat -c %s $file)
20462 [[ $size == $expect ]] ||
20463 error "$file expected size: $expect, got: $size"
20465 local blocks=$($LFS getsom -b $file)
20466 expect=$(stat -c %b $file)
20467 [[ $blocks == $expect ]] ||
20468 error "$file expected blocks: $expect, got: $blocks"
20473 local size=$($LFS getsom -s $1)
20476 [[ $size == $expect ]] ||
20477 error "$file expected size: $expect, got: $size"
20481 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20482 skip "Need MDS version at least 2.11.52"
20486 touch $DIR/$tfile || error "touch $tfile failed"
20488 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
20489 save_lustre_params client "llite.*.xattr_cache" > $save
20490 lctl set_param llite.*.xattr_cache=0
20491 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
20493 # single-threaded write
20494 echo "Test SOM for single-threaded write"
20495 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
20496 error "write $tfile failed"
20497 check_lsom_size $DIR/$tfile $bs
20500 local size=$(($num * $bs))
20504 echo "Test SOM for single client multi-threaded($num) write"
20505 $TRUNCATE $DIR/$tfile 0
20506 for ((i = 0; i < $num; i++)); do
20507 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20509 offset=$((offset + $bs))
20511 for (( i=0; i < $num; i++ )); do
20514 check_lsom_size $DIR/$tfile $size
20516 $TRUNCATE $DIR/$tfile 0
20517 for ((i = 0; i < $num; i++)); do
20518 offset=$((offset - $bs))
20519 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20522 for (( i=0; i < $num; i++ )); do
20525 check_lsom_size $DIR/$tfile $size
20527 # multi-client wirtes
20528 num=$(get_node_count ${CLIENTS//,/ })
20529 size=$(($num * $bs))
20533 echo "Test SOM for multi-client ($num) writes"
20534 $TRUNCATE $DIR/$tfile 0
20535 for client in ${CLIENTS//,/ }; do
20536 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20539 offset=$((offset + $bs))
20541 for (( i=0; i < $num; i++ )); do
20544 check_lsom_size $DIR/$tfile $offset
20547 $TRUNCATE $DIR/$tfile 0
20548 for client in ${CLIENTS//,/ }; do
20549 offset=$((offset - $bs))
20550 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20554 for (( i=0; i < $num; i++ )); do
20557 check_lsom_size $DIR/$tfile $size
20560 echo "Test SOM for truncate"
20561 $TRUNCATE $DIR/$tfile 1048576
20562 check_lsom_size $DIR/$tfile 1048576
20563 $TRUNCATE $DIR/$tfile 1234
20564 check_lsom_size $DIR/$tfile 1234
20566 # verify SOM blocks count
20567 echo "Verify SOM block count"
20568 $TRUNCATE $DIR/$tfile 0
20569 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
20570 error "failed to write file $tfile"
20571 check_lsom_data $DIR/$tfile
20573 run_test 806 "Verify Lazy Size on MDS"
20576 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
20577 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20578 skip "Need MDS version at least 2.11.52"
20580 # Registration step
20581 changelog_register || error "changelog_register failed"
20582 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
20583 changelog_users $SINGLEMDS | grep -q $cl_user ||
20584 error "User $cl_user not found in changelog_users"
20586 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
20587 save_lustre_params client "llite.*.xattr_cache" > $save
20588 lctl set_param llite.*.xattr_cache=0
20589 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
20591 rm -rf $DIR/$tdir || error "rm $tdir failed"
20592 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
20593 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
20594 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
20595 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
20596 error "truncate $tdir/trunc failed"
20599 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
20600 error "write $tfile failed"
20602 # multi-client wirtes
20603 local num=$(get_node_count ${CLIENTS//,/ })
20607 echo "Test SOM for multi-client ($num) writes"
20608 touch $DIR/$tfile || error "touch $tfile failed"
20609 $TRUNCATE $DIR/$tfile 0
20610 for client in ${CLIENTS//,/ }; do
20611 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20614 offset=$((offset + $bs))
20616 for (( i=0; i < $num; i++ )); do
20621 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
20622 check_lsom_data $DIR/$tdir/trunc
20623 check_lsom_data $DIR/$tdir/single_dd
20624 check_lsom_data $DIR/$tfile
20627 # Deregistration step
20628 changelog_deregister || error "changelog_deregister failed"
20630 run_test 807 "verify LSOM syncing tool"
20632 check_som_nologged()
20634 local lines=$($LFS changelog $FSNAME-MDT0000 |
20635 grep 'x=trusted.som' | wc -l)
20636 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
20640 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
20641 skip "Need MDS version at least 2.11.55"
20643 # Registration step
20644 changelog_register || error "changelog_register failed"
20646 touch $DIR/$tfile || error "touch $tfile failed"
20649 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
20650 error "write $tfile failed"
20653 $TRUNCATE $DIR/$tfile 1234
20656 $TRUNCATE $DIR/$tfile 1048576
20659 # Deregistration step
20660 changelog_deregister || error "changelog_deregister failed"
20662 run_test 808 "Check trusted.som xattr not logged in Changelogs"
20667 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
20671 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20672 skip "Need MDS version at least 2.11.56"
20674 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
20675 error "failed to create DoM-only file $DIR/$tfile"
20676 touch $DIR/$tfile || error "touch $tfile failed"
20677 check_som_nodata $DIR/$tfile
20679 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
20680 error "write $tfile failed"
20681 check_som_nodata $DIR/$tfile
20683 $TRUNCATE $DIR/$tfile 1234
20684 check_som_nodata $DIR/$tfile
20686 $TRUNCATE $DIR/$tfile 4097
20687 check_som_nodata $DIR/$file
20689 run_test 809 "Verify no SOM xattr store for DoM-only files"
20695 # t10 seem to dislike partial pages
20696 lctl set_param osc.*.checksum_type=adler
20697 lctl set_param fail_loc=0x411
20698 dd if=/dev/urandom of=$DIR/$tfile bs=10240 count=2
20699 ORIG=$(md5sum $DIR/$tfile)
20700 lctl set_param ldlm.namespaces.*osc*.lru_size=clear
20701 CSUM=$(md5sum $DIR/$tfile)
20702 set_checksum_type adler
20703 if [ "$ORIG" != "$CSUM" ]; then
20704 error "$ORIG != $CSUM"
20707 run_test 810 "partial page writes on ZFS (LU-11663)"
20710 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
20711 skip "Need MDS version at least 2.11.56"
20713 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
20714 do_facet mds1 $LCTL set_param fail_loc=0x165
20715 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
20718 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
20721 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) -eq 0 ]] ||
20722 error "MDD orphan cleanup thread not quit"
20724 run_test 811 "orphan name stub can be cleaned up in startup"
20727 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
20728 skip "OST < 2.12.51 doesn't support this fail_loc"
20729 [ "$SHARED_KEY" = true ] &&
20730 skip "OSC connections never go IDLE with Shared-Keys enabled"
20732 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20733 # ensure ost1 is connected
20734 stat $DIR/$tfile >/dev/null || error "can't stat"
20735 wait_osc_import_state client ost1 FULL
20736 # no locks, no reqs to let the connection idle
20737 cancel_lru_locks osc
20739 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
20740 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
20741 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
20742 wait_osc_import_state client ost1 CONNECTING
20743 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
20745 stat $DIR/$tfile >/dev/null || error "can't stat file"
20747 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
20750 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
20751 [ -z "$file_heat_sav" ] && skip "no file heat support"
20762 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
20763 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
20765 $LCTL set_param -n llite.*.file_heat=1
20766 echo "Turn on file heat"
20767 echo "Period second: $period_second, Decay percentage: $decay_pct"
20769 echo "QQQQ" > $DIR/$tfile
20770 echo "QQQQ" > $DIR/$tfile
20771 echo "QQQQ" > $DIR/$tfile
20772 cat $DIR/$tfile > /dev/null
20773 cat $DIR/$tfile > /dev/null
20774 cat $DIR/$tfile > /dev/null
20775 cat $DIR/$tfile > /dev/null
20777 local out=$($LFS heat_get $DIR/$tfile)
20779 $LFS heat_get $DIR/$tfile
20780 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20781 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20782 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20783 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20785 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
20786 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
20787 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
20788 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
20790 sleep $((period_second + 3))
20791 echo "Sleep $((period_second + 3)) seconds..."
20792 # The recursion formula to calculate the heat of the file f is as
20794 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
20795 # Where Hi is the heat value in the period between time points i*I and
20796 # (i+1)*I; Ci is the access count in the period; the symbol P refers
20797 # to the weight of Ci.
20798 out=$($LFS heat_get $DIR/$tfile)
20799 $LFS heat_get $DIR/$tfile
20800 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20801 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20802 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20803 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20805 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
20806 error "read sample ($readsample) is wrong"
20807 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
20808 error "write sample ($writesample) is wrong"
20809 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
20810 error "read bytes ($readbyte) is wrong"
20811 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
20812 error "write bytes ($writebyte) is wrong"
20814 echo "QQQQ" > $DIR/$tfile
20815 echo "QQQQ" > $DIR/$tfile
20816 echo "QQQQ" > $DIR/$tfile
20817 cat $DIR/$tfile > /dev/null
20818 cat $DIR/$tfile > /dev/null
20819 cat $DIR/$tfile > /dev/null
20820 cat $DIR/$tfile > /dev/null
20822 sleep $((period_second + 3))
20823 echo "Sleep $((period_second + 3)) seconds..."
20825 out=$($LFS heat_get $DIR/$tfile)
20826 $LFS heat_get $DIR/$tfile
20827 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20828 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20829 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20830 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20832 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
20833 4 * $decay_pct) / 100") -eq 1 ] ||
20834 error "read sample ($readsample1) is wrong"
20835 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
20836 3 * $decay_pct) / 100") -eq 1 ] ||
20837 error "write sample ($writesample1) is wrong"
20838 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
20839 20 * $decay_pct) / 100") -eq 1 ] ||
20840 error "read bytes ($readbyte1) is wrong"
20841 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
20842 15 * $decay_pct) / 100") -eq 1 ] ||
20843 error "write bytes ($writebyte1) is wrong"
20845 echo "Turn off file heat for the file $DIR/$tfile"
20846 $LFS heat_set -o $DIR/$tfile
20848 echo "QQQQ" > $DIR/$tfile
20849 echo "QQQQ" > $DIR/$tfile
20850 echo "QQQQ" > $DIR/$tfile
20851 cat $DIR/$tfile > /dev/null
20852 cat $DIR/$tfile > /dev/null
20853 cat $DIR/$tfile > /dev/null
20854 cat $DIR/$tfile > /dev/null
20856 out=$($LFS heat_get $DIR/$tfile)
20857 $LFS heat_get $DIR/$tfile
20858 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20859 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20860 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20861 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20863 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
20864 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
20865 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
20866 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
20868 echo "Trun on file heat for the file $DIR/$tfile"
20869 $LFS heat_set -O $DIR/$tfile
20871 echo "QQQQ" > $DIR/$tfile
20872 echo "QQQQ" > $DIR/$tfile
20873 echo "QQQQ" > $DIR/$tfile
20874 cat $DIR/$tfile > /dev/null
20875 cat $DIR/$tfile > /dev/null
20876 cat $DIR/$tfile > /dev/null
20877 cat $DIR/$tfile > /dev/null
20879 out=$($LFS heat_get $DIR/$tfile)
20880 $LFS heat_get $DIR/$tfile
20881 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20882 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20883 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20884 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20886 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
20887 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
20888 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
20889 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
20891 $LFS heat_set -c $DIR/$tfile
20892 $LCTL set_param -n llite.*.file_heat=0
20893 echo "Turn off file heat support for the Lustre filesystem"
20895 echo "QQQQ" > $DIR/$tfile
20896 echo "QQQQ" > $DIR/$tfile
20897 echo "QQQQ" > $DIR/$tfile
20898 cat $DIR/$tfile > /dev/null
20899 cat $DIR/$tfile > /dev/null
20900 cat $DIR/$tfile > /dev/null
20901 cat $DIR/$tfile > /dev/null
20903 out=$($LFS heat_get $DIR/$tfile)
20904 $LFS heat_get $DIR/$tfile
20905 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
20906 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
20907 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
20908 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
20910 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
20911 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
20912 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
20913 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
20915 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
20918 run_test 813 "File heat verfication"
20921 # tests that do cleanup/setup should be run at the end
20925 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20928 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
20929 $LCTL set_param fail_loc=0x903
20931 cancel_lru_locks MGC
20933 FAIL_ON_ERROR=true cleanup
20934 FAIL_ON_ERROR=true setup
20936 run_test 900 "umount should not race with any mgc requeue thread"
20939 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
20940 check_and_cleanup_lustre
20941 if [ "$I_MOUNTED" != "yes" ]; then
20942 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true