3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 MUNLINK=${MUNLINK:-munlink}
23 SOCKETSERVER=${SOCKETSERVER:-socketserver}
24 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
25 MEMHOG=${MEMHOG:-memhog}
26 DIRECTIO=${DIRECTIO:-directio}
27 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
31 export PARALLEL=${PARALLEL:-"no"}
34 LUSTRE=${LUSTRE:-$(dirname $0)/..}
35 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
36 . $LUSTRE/tests/test-framework.sh
41 ALWAYS_EXCEPT="$SANITY_EXCEPT "
42 # bug number for skipped test: LU-9693 LU-6493 LU-9693
43 ALWAYS_EXCEPT+=" 42a 42b 42c "
44 # bug number: LU-8411 LU-9054 LU-13314
45 ALWAYS_EXCEPT+=" 407 312 56ob"
48 # bug number: LU-9795 LU-9795 LU-9795 LU-9795
49 ALWAYS_EXCEPT+=" 17n 60a 133g 300f"
52 selinux_status=$(getenforce)
53 if [ "$selinux_status" != "Disabled" ]; then
58 # skip the grant tests for ARM until they are fixed
59 if [[ $(uname -m) = aarch64 ]]; then
60 # bug number: LU-11596
61 ALWAYS_EXCEPT+=" $GRANT_CHECK_LIST"
62 # bug number: LU-11671 LU-11667
63 ALWAYS_EXCEPT+=" 45 317"
66 # skip nfs tests on kernels >= 4.14.0 until they are fixed
67 if [ $LINUX_VERSION_CODE -ge $(version_code 4.14.0) ]; then
68 # bug number: LU-12661
71 # skip cgroup tests on RHEL8.1 kernels until they are fixed
72 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
73 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
74 # bug number: LU-13063
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 135 136 300o"
81 if [ "$mds1_FSTYPE" = "zfs" ]; then
82 # bug number for skipped test:
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
85 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
88 # Get the SLES distro version
90 # Returns a version string that should only be used in comparing
91 # strings returned by version_code()
94 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
96 # All SuSE Linux versions have one decimal. version_code expects two
97 local sles_version=$version.0
98 version_code $sles_version
101 # Check if we are running on Ubuntu or SLES so we can make decisions on
103 if [ -r /etc/SuSE-release ]; then
104 sles_version=$(sles_version_code)
105 [ $sles_version -lt $(version_code 11.4.0) ] &&
106 # bug number for skipped test: LU-4341
107 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
108 [ $sles_version -lt $(version_code 12.0.0) ] &&
109 # bug number for skipped test: LU-3703
110 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
111 elif [ -r /etc/os-release ]; then
112 if grep -qi ubuntu /etc/os-release; then
113 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
114 -e 's/^VERSION=//p' \
118 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
119 # bug number for skipped test:
121 ALWAYS_EXCEPT+=" 103a 410"
131 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
132 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
141 check_swap_layouts_support()
143 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
144 skip "Does not support layout lock."
147 check_and_setup_lustre
151 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
153 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
154 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
155 rm -rf $DIR/[Rdfs][0-9]*
157 # $RUNAS_ID may get set incorrectly somewhere else
158 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
159 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
161 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
163 if [ "${ONLY}" = "MOUNT" ] ; then
164 echo "Lustre is up, please go on"
168 echo "preparing for tests involving mounts"
169 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
171 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
172 echo # add a newline after mke2fs.
176 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
177 lctl set_param debug=-1 2> /dev/null || true
180 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
182 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
184 run_test 0a "touch; rm ====================="
187 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
188 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
190 run_test 0b "chmod 0755 $DIR ============================="
193 $LCTL get_param mdc.*.import | grep "state: FULL" ||
194 error "import not FULL"
195 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
198 run_test 0c "check import proc"
200 test_0d() { # LU-3397
201 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
202 skip "proc exports not supported before 2.10.57"
204 local mgs_exp="mgs.MGS.exports"
205 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
207 local exp_client_version
210 local temp_imp=$DIR/$tfile.import
211 local temp_exp=$DIR/$tfile.export
213 # save mgc import file to $temp_imp
214 $LCTL get_param mgc.*.import | tee $temp_imp
215 # Check if client uuid is found in MGS export
216 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
217 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
221 # save mgs export file to $temp_exp
222 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
224 # Compare the value of field "connect_flags"
225 imp_val=$(grep "connect_flags" $temp_imp)
226 exp_val=$(grep "connect_flags" $temp_exp)
227 [ "$exp_val" == "$imp_val" ] ||
228 error "export flags '$exp_val' != import flags '$imp_val'"
230 # Compare the value of client version
231 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
232 exp_val=$(version_code $exp_client_version)
233 imp_val=$CLIENT_VERSION
234 [ "$exp_val" == "$imp_val" ] ||
235 error "export client version '$exp_val' != '$imp_val'"
237 run_test 0d "check export proc ============================="
240 test_mkdir $DIR/$tdir
241 test_mkdir $DIR/$tdir/d2
242 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
243 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
246 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
248 run_test 1 "mkdir; remkdir; rmdir"
251 test_mkdir $DIR/$tdir
252 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
253 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
255 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
257 run_test 2 "mkdir; touch; rmdir; check file"
260 test_mkdir $DIR/$tdir
261 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
262 touch $DIR/$tdir/$tfile
263 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
265 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
267 run_test 3 "mkdir; touch; rmdir; check dir"
269 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
271 test_mkdir -i 1 $DIR/$tdir
273 touch $DIR/$tdir/$tfile ||
274 error "Create file under remote directory failed"
277 error "Expect error removing in-use dir $DIR/$tdir"
279 test -d $DIR/$tdir || error "Remote directory disappeared"
281 rm -rf $DIR/$tdir || error "remove remote dir error"
283 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
286 test_mkdir $DIR/$tdir
287 test_mkdir $DIR/$tdir/d2
288 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
289 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
290 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
292 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
295 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
296 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
297 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
298 error "$tfile does not have perm 0666 or UID $UID"
299 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
300 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
301 error "$tfile should be 0666 and owned by UID $UID"
303 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
306 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
309 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
310 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
311 error "$tfile should be owned by UID $RUNAS_ID"
312 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
313 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
314 error "$tfile should be owned by UID $RUNAS_ID"
316 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
319 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
322 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
323 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
324 error "$tfile should be owned by GID $UID"
325 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
326 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
327 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
329 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
332 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
334 test_mkdir $DIR/$tdir
335 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
336 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
337 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
338 test_mkdir $DIR/$tdir/d/subdir
339 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
340 error "$tdir/d/subdir should be GID $RUNAS_GID"
341 if [[ $MDSCOUNT -gt 1 ]]; then
342 # check remote dir sgid inherite
343 $LFS mkdir -i 0 $DIR/$tdir.local ||
344 error "mkdir $tdir.local failed"
345 chmod g+s $DIR/$tdir.local ||
346 error "chmod $tdir.local failed"
347 chgrp $RUNAS_GID $DIR/$tdir.local ||
348 error "chgrp $tdir.local failed"
349 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
350 error "mkdir $tdir.remote failed"
351 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
352 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
353 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
354 error "$tdir.remote should be mode 02755"
357 run_test 6g "verify new dir in sgid dir inherits group"
359 test_6h() { # bug 7331
360 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
362 touch $DIR/$tfile || error "touch failed"
363 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
364 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
365 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
366 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
367 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
369 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
372 test_mkdir $DIR/$tdir
373 $MCREATE $DIR/$tdir/$tfile
374 chmod 0666 $DIR/$tdir/$tfile
375 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
376 error "$tdir/$tfile should be mode 0666"
378 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
381 if [ ! -d $DIR/$tdir ]; then
382 test_mkdir $DIR/$tdir
384 $MCREATE $DIR/$tdir/$tfile
385 echo -n foo > $DIR/$tdir/$tfile
386 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
387 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
389 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
392 test_mkdir $DIR/$tdir
393 touch $DIR/$tdir/$tfile
394 chmod 0666 $DIR/$tdir/$tfile
395 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
396 error "$tfile mode not 0666"
398 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
401 test_mkdir $DIR/$tdir
402 test_mkdir $DIR/$tdir/d2
403 test_mkdir $DIR/$tdir/d2/d3
404 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
406 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
409 test_mkdir $DIR/$tdir
410 test_mkdir $DIR/$tdir/d2
411 touch $DIR/$tdir/d2/$tfile
412 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
413 error "$tdir/d2/$tfile not a file"
415 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
418 test_mkdir $DIR/$tdir
419 test_mkdir $DIR/$tdir/d2
420 chmod 0666 $DIR/$tdir/d2
421 chmod 0705 $DIR/$tdir/d2
422 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
423 error "$tdir/d2 mode not 0705"
425 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
428 test_mkdir $DIR/$tdir
429 touch $DIR/$tdir/$tfile
430 chmod 0666 $DIR/$tdir/$tfile
431 chmod 0654 $DIR/$tdir/$tfile
432 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
433 error "$tdir/d2 mode not 0654"
435 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
438 test_mkdir $DIR/$tdir
439 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
441 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
442 error "$tdir/$tfile size not 0 after truncate"
444 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
447 test_mkdir $DIR/$tdir
448 touch $DIR/$tdir/$tfile
450 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
452 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
455 test_mkdir $DIR/$tdir
456 touch $DIR/$tdir/$tfile
457 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
458 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
459 error "$tdir/${tfile_2} not a file after rename"
460 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
462 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
465 test_mkdir $DIR/$tdir
466 touch $DIR/$tdir/$tfile
467 rm -rf $DIR/$tdir/$tfile
468 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
470 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
473 test_mkdir $DIR/$tdir
474 touch $DIR/$tdir/$tfile
475 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
477 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
478 error "$tdir/l-exist not a symlink"
479 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
480 error "$tdir/l-exist not referencing a file"
481 rm -f $DIR/$tdir/l-exist
482 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
484 run_test 17a "symlinks: create, remove (real)"
487 test_mkdir $DIR/$tdir
488 ln -s no-such-file $DIR/$tdir/l-dangle
490 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
491 error "$tdir/l-dangle not referencing no-such-file"
492 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
493 error "$tdir/l-dangle not referencing non-existent file"
494 rm -f $DIR/$tdir/l-dangle
495 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
497 run_test 17b "symlinks: create, remove (dangling)"
499 test_17c() { # bug 3440 - don't save failed open RPC for replay
500 test_mkdir $DIR/$tdir
501 ln -s foo $DIR/$tdir/$tfile
502 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
504 run_test 17c "symlinks: open dangling (should return error)"
507 test_mkdir $DIR/$tdir
508 ln -s foo $DIR/$tdir/$tfile
509 touch $DIR/$tdir/$tfile || error "creating to new symlink"
511 run_test 17d "symlinks: create dangling"
514 test_mkdir $DIR/$tdir
515 local foo=$DIR/$tdir/$tfile
516 ln -s $foo $foo || error "create symlink failed"
517 ls -l $foo || error "ls -l failed"
518 ls $foo && error "ls not failed" || true
520 run_test 17e "symlinks: create recursive symlink (should return error)"
523 test_mkdir $DIR/$tdir
524 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
525 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
526 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
527 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
528 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
529 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
532 run_test 17f "symlinks: long and very long symlink name"
534 # str_repeat(S, N) generate a string that is string S repeated N times
539 while [ $((n -= 1)) -ge 0 ]; do
545 # Long symlinks and LU-2241
547 test_mkdir $DIR/$tdir
548 local TESTS="59 60 61 4094 4095"
550 # Fix for inode size boundary in 2.1.4
551 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
554 # Patch not applied to 2.2 or 2.3 branches
555 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
556 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
560 local SYMNAME=$(str_repeat 'x' $i)
561 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
562 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
565 run_test 17g "symlinks: really long symlink name and inode boundaries"
567 test_17h() { #bug 17378
568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
569 remote_mds_nodsh && skip "remote MDS with nodsh"
573 test_mkdir $DIR/$tdir
574 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
575 $LFS setstripe -c -1 $DIR/$tdir
576 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
577 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
578 touch $DIR/$tdir/$tfile || true
580 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
582 test_17i() { #bug 20018
583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
584 remote_mds_nodsh && skip "remote MDS with nodsh"
586 local foo=$DIR/$tdir/$tfile
589 test_mkdir -c1 $DIR/$tdir
590 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
591 ln -s $foo $foo || error "create symlink failed"
592 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
593 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
594 ls -l $foo && error "error not detected"
597 run_test 17i "don't panic on short symlink (should return error)"
599 test_17k() { #bug 22301
600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
601 [[ -z "$(which rsync 2>/dev/null)" ]] &&
602 skip "no rsync command"
603 rsync --help | grep -q xattr ||
604 skip_env "$(rsync --version | head -n1) does not support xattrs"
605 test_mkdir $DIR/$tdir
606 test_mkdir $DIR/$tdir.new
607 touch $DIR/$tdir/$tfile
608 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
609 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
610 error "rsync failed with xattrs enabled"
612 run_test 17k "symlinks: rsync with xattrs enabled"
614 test_17l() { # LU-279
615 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
616 skip "no getfattr command"
618 test_mkdir $DIR/$tdir
619 touch $DIR/$tdir/$tfile
620 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
621 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
622 # -h to not follow symlinks. -m '' to list all the xattrs.
623 # grep to remove first line: '# file: $path'.
624 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
626 lgetxattr_size_check $path $xattr ||
627 error "lgetxattr_size_check $path $xattr failed"
631 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
636 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
637 remote_mds_nodsh && skip "remote MDS with nodsh"
638 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
639 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
640 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
642 local short_sym="0123456789"
643 local wdir=$DIR/$tdir
648 # create a long symlink file
649 for ((i = 0; i < 4; ++i)); do
650 long_sym=${long_sym}${long_sym}
653 echo "create 512 short and long symlink files under $wdir"
654 for ((i = 0; i < 256; ++i)); do
655 ln -sf ${long_sym}"a5a5" $wdir/long-$i
656 ln -sf ${short_sym}"a5a5" $wdir/short-$i
662 wait_delete_completed
664 echo "recreate the 512 symlink files with a shorter string"
665 for ((i = 0; i < 512; ++i)); do
666 # rewrite the symlink file with a shorter string
667 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
668 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
671 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
672 local devname=$(mdsdevname $mds_index)
674 echo "stop and checking mds${mds_index}:"
675 # e2fsck should not return error
677 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
680 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
681 error "start mds${mds_index} failed"
682 df $MOUNT > /dev/null 2>&1
684 error "e2fsck detected error for short/long symlink: rc=$rc"
687 run_test 17m "run e2fsck against MDT which contains short/long symlink"
689 check_fs_consistency_17n() {
693 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
694 # so it only check MDT1/MDT2 instead of all of MDTs.
695 for mdt_index in 1 2; do
696 local devname=$(mdsdevname $mdt_index)
697 # e2fsck should not return error
699 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
702 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
703 error "mount mds$mdt_index failed"
704 df $MOUNT > /dev/null 2>&1
710 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
711 [ $PARALLEL == "yes" ] && skip "skip parallel run"
712 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
713 remote_mds_nodsh && skip "remote MDS with nodsh"
714 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
715 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
716 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
720 test_mkdir $DIR/$tdir
721 for ((i=0; i<10; i++)); do
722 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
723 error "create remote dir error $i"
724 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
725 error "create files under remote dir failed $i"
728 check_fs_consistency_17n ||
729 error "e2fsck report error after create files under remote dir"
731 for ((i = 0; i < 10; i++)); do
732 rm -rf $DIR/$tdir/remote_dir_${i} ||
733 error "destroy remote dir error $i"
736 check_fs_consistency_17n ||
737 error "e2fsck report error after unlink files under remote dir"
739 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
740 skip "lustre < 2.4.50 does not support migrate mv"
742 for ((i = 0; i < 10; i++)); do
743 mkdir -p $DIR/$tdir/remote_dir_${i}
744 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
745 error "create files under remote dir failed $i"
746 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
747 error "migrate remote dir error $i"
749 check_fs_consistency_17n || error "e2fsck report error after migration"
751 for ((i = 0; i < 10; i++)); do
752 rm -rf $DIR/$tdir/remote_dir_${i} ||
753 error "destroy remote dir error $i"
756 check_fs_consistency_17n || error "e2fsck report error after unlink"
758 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
761 remote_mds_nodsh && skip "remote MDS with nodsh"
762 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
763 skip "Need MDS version at least 2.3.64"
765 local wdir=$DIR/${tdir}o
771 mdt_index=$($LFS getstripe -m $wdir/$tfile)
772 mdt_index=$((mdt_index + 1))
775 #fail mds will wait the failover finish then set
776 #following fail_loc to avoid interfer the recovery process.
779 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
780 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
781 ls -l $wdir/$tfile && rc=1
782 do_facet mds${mdt_index} lctl set_param fail_loc=0
783 [[ $rc -eq 0 ]] || error "stat file should fail"
785 run_test 17o "stat file with incompat LMA feature"
788 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
789 ls $DIR || error "Failed to ls $DIR: $?"
791 run_test 18 "touch .../f ; ls ... =============================="
797 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
799 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
802 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
804 run_test 19b "ls -l .../f19 (should return error) =============="
807 [ $RUNAS_ID -eq $UID ] &&
808 skip_env "RUNAS_ID = UID = $UID -- skipping"
810 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
812 run_test 19c "$RUNAS touch .../f19 (should return error) =="
815 cat $DIR/f19 && error || true
817 run_test 19d "cat .../f19 (should return error) =============="
826 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
828 run_test 20 "touch .../f ; ls -l ..."
831 test_mkdir $DIR/$tdir
832 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
833 ln -s dangle $DIR/$tdir/link
834 echo foo >> $DIR/$tdir/link
835 cat $DIR/$tdir/dangle
836 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
837 $CHECKSTAT -f -t file $DIR/$tdir/link ||
838 error "$tdir/link not linked to a file"
840 run_test 21 "write to dangling link"
843 local wdir=$DIR/$tdir
845 chown $RUNAS_ID:$RUNAS_GID $wdir
846 (cd $wdir || error "cd $wdir failed";
847 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
849 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
850 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
851 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
852 error "checkstat -u failed"
854 run_test 22 "unpack tar archive as non-root user"
858 test_mkdir $DIR/$tdir
859 local file=$DIR/$tdir/$tfile
861 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
862 openfile -f O_CREAT:O_EXCL $file &&
863 error "$file recreate succeeded" || true
865 run_test 23a "O_CREAT|O_EXCL in subdir"
867 test_23b() { # bug 18988
868 test_mkdir $DIR/$tdir
869 local file=$DIR/$tdir/$tfile
872 echo foo > $file || error "write filed"
873 echo bar >> $file || error "append filed"
874 $CHECKSTAT -s 8 $file || error "wrong size"
877 run_test 23b "O_APPEND check"
879 # LU-9409, size with O_APPEND and tiny writes
881 local file=$DIR/$tfile
884 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
885 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
889 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
890 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
892 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
895 #racing tiny & normal writes
896 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
897 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
899 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
902 #racing tiny & normal writes 2, ugly numbers
903 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
904 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
906 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
909 run_test 23c "O_APPEND size checks for tiny writes"
911 # LU-11069 file offset is correct after appending writes
913 local file=$DIR/$tfile
916 echo CentaurHauls > $file
917 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
918 if ((offset != 26)); then
919 error "wrong offset, expected 26, got '$offset'"
922 run_test 23d "file offset is correct after appending writes"
926 echo '-- same directory rename'
927 test_mkdir $DIR/$tdir
928 touch $DIR/$tdir/$tfile.1
929 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
930 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
932 run_test 24a "rename file to non-existent target"
935 test_mkdir $DIR/$tdir
936 touch $DIR/$tdir/$tfile.{1,2}
937 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
938 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
939 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
941 run_test 24b "rename file to existing target"
944 test_mkdir $DIR/$tdir
945 test_mkdir $DIR/$tdir/d$testnum.1
946 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
947 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
948 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
950 run_test 24c "rename directory to non-existent target"
953 test_mkdir -c1 $DIR/$tdir
954 test_mkdir -c1 $DIR/$tdir/d$testnum.1
955 test_mkdir -c1 $DIR/$tdir/d$testnum.2
956 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
957 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
958 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
960 run_test 24d "rename directory to existing target"
963 echo '-- cross directory renames --'
967 mv $DIR/R5a/f $DIR/R5b/g
968 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
969 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
971 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
976 touch $DIR/R6a/f $DIR/R6b/g
977 mv $DIR/R6a/f $DIR/R6b/g
978 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
979 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
981 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
986 test_mkdir $DIR/R7a/d
987 mv $DIR/R7a/d $DIR/R7b/e
988 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
989 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
991 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
994 test_mkdir -c1 $DIR/R8a
995 test_mkdir -c1 $DIR/R8b
996 test_mkdir -c1 $DIR/R8a/d
997 test_mkdir -c1 $DIR/R8b/e
998 mrename $DIR/R8a/d $DIR/R8b/e
999 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1000 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1002 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1005 echo "-- rename error cases"
1007 test_mkdir $DIR/R9/a
1009 mrename $DIR/R9/f $DIR/R9/a
1010 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1011 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1012 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1014 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1018 mrename $DIR/R10/f $DIR/R10/g
1019 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1020 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1021 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1023 run_test 24j "source does not exist ============================"
1026 test_mkdir $DIR/R11a
1027 test_mkdir $DIR/R11a/d
1029 mv $DIR/R11a/f $DIR/R11a/d
1030 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1031 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1033 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1035 # bug 2429 - rename foo foo foo creates invalid file
1038 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1040 run_test 24l "Renaming a file to itself ========================"
1044 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1045 # on ext3 this does not remove either the source or target files
1046 # though the "expected" operation would be to remove the source
1047 $CHECKSTAT -t file ${f} || error "${f} missing"
1048 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1050 run_test 24m "Renaming a file to a hard link to itself ========="
1054 # this stats the old file after it was renamed, so it should fail
1056 $CHECKSTAT ${f} || error "${f} missing"
1058 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1059 $CHECKSTAT -a ${f} || error "${f} exists"
1061 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1064 test_mkdir $DIR/$tdir
1065 rename_many -s random -v -n 10 $DIR/$tdir
1067 run_test 24o "rename of files during htree split"
1070 test_mkdir $DIR/R12a
1071 test_mkdir $DIR/R12b
1072 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1073 mrename $DIR/R12a $DIR/R12b
1074 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1075 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1076 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1077 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1079 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1081 cleanup_multiop_pause() {
1083 kill -USR1 $MULTIPID
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1089 test_mkdir $DIR/R13a
1090 test_mkdir $DIR/R13b
1091 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1092 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1095 trap cleanup_multiop_pause EXIT
1096 mrename $DIR/R13a $DIR/R13b
1097 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1098 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1099 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1100 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1101 cleanup_multiop_pause
1102 wait $MULTIPID || error "multiop close failed"
1104 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1106 test_24r() { #bug 3789
1107 test_mkdir $DIR/R14a
1108 test_mkdir $DIR/R14a/b
1109 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1110 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1111 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1113 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1116 test_mkdir $DIR/R15a
1117 test_mkdir $DIR/R15a/b
1118 test_mkdir $DIR/R15a/b/c
1119 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1120 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1121 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1123 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1125 test_mkdir $DIR/R16a
1126 test_mkdir $DIR/R16a/b
1127 test_mkdir $DIR/R16a/b/c
1128 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1129 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1130 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1132 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1134 test_24u() { # bug12192
1135 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1136 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1138 run_test 24u "create stripe file"
1140 simple_cleanup_common() {
1143 [ -z "$DIR" ] || [ -z "$tdir" ] && return 0
1145 local start=$SECONDS
1148 wait_delete_completed
1149 echo "cleanup time $((SECONDS - start))"
1153 max_pages_per_rpc() {
1154 local mdtname="$(printf "MDT%04x" ${1:-0})"
1155 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1161 local nrfiles=${COUNT:-100000}
1162 local fname="$DIR/$tdir/$tfile"
1164 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1165 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1167 test_mkdir "$(dirname $fname)"
1168 # assume MDT0000 has the fewest inodes
1169 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1170 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1171 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1173 trap simple_cleanup_common EXIT
1175 createmany -m "$fname" $nrfiles
1177 cancel_lru_locks mdc
1178 lctl set_param mdc.*.stats clear
1180 # was previously test_24D: LU-6101
1181 # readdir() returns correct number of entries after cursor reload
1182 local num_ls=$(ls $DIR/$tdir | wc -l)
1183 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1184 local num_all=$(ls -a $DIR/$tdir | wc -l)
1185 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1186 [ $num_all -ne $((nrfiles + 2)) ]; then
1187 error "Expected $nrfiles files, got $num_ls " \
1188 "($num_uniq unique $num_all .&..)"
1190 # LU-5 large readdir
1191 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1192 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1193 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1194 # take into account of overhead in lu_dirpage header and end mark in
1195 # each page, plus one in rpc_num calculation.
1196 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1197 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1198 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1199 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1200 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1201 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1202 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1203 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1204 error "large readdir doesn't take effect: " \
1205 "$mds_readpage should be about $rpc_max"
1207 simple_cleanup_common
1209 run_test 24v "list large directory (test hash collision, b=17560)"
1211 test_24w() { # bug21506
1213 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1214 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1215 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1216 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1217 [[ "$SZ1" -eq "$SZ2" ]] ||
1218 error "Error reading at the end of the file $tfile"
1220 run_test 24w "Reading a file larger than 4Gb"
1223 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1225 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1226 skip "Need MDS version at least 2.7.56"
1229 local remote_dir=$DIR/$tdir/remote_dir
1231 test_mkdir $DIR/$tdir
1232 $LFS mkdir -i $MDTIDX $remote_dir ||
1233 error "create remote directory failed"
1235 test_mkdir $DIR/$tdir/src_dir
1236 touch $DIR/$tdir/src_file
1237 test_mkdir $remote_dir/tgt_dir
1238 touch $remote_dir/tgt_file
1240 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1241 error "rename dir cross MDT failed!"
1243 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1244 error "rename file cross MDT failed!"
1246 touch $DIR/$tdir/ln_file
1247 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1248 error "ln file cross MDT failed"
1250 rm -rf $DIR/$tdir || error "Can not delete directories"
1252 run_test 24x "cross MDT rename/link"
1255 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1258 local remote_dir=$DIR/$tdir/remote_dir
1261 test_mkdir $DIR/$tdir
1262 $LFS mkdir -i $mdtidx $remote_dir ||
1263 error "create remote directory failed"
1265 test_mkdir $remote_dir/src_dir
1266 touch $remote_dir/src_file
1267 test_mkdir $remote_dir/tgt_dir
1268 touch $remote_dir/tgt_file
1270 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1271 error "rename subdir in the same remote dir failed!"
1273 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1274 error "rename files in the same remote dir failed!"
1276 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1277 error "link files in the same remote dir failed!"
1279 rm -rf $DIR/$tdir || error "Can not delete directories"
1281 run_test 24y "rename/link on the same dir should succeed"
1284 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1285 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1286 skip "Need MDS version at least 2.12.51"
1290 for index in 0 1; do
1291 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1292 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1295 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1297 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1298 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1300 local mdts=$(comma_list $(mdts_nodes))
1302 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1303 stack_trap "do_nodes $mdts $LCTL \
1304 set_param mdt.*.enable_remote_rename=1" EXIT
1306 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1308 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1309 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1311 run_test 24z "cross-MDT rename is done as cp"
1313 test_24A() { # LU-3182
1317 test_mkdir $DIR/$tdir
1318 trap simple_cleanup_common EXIT
1319 createmany -m $DIR/$tdir/$tfile $NFILES
1320 local t=$(ls $DIR/$tdir | wc -l)
1321 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1322 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1323 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1324 [ $v -ne $((NFILES + 2)) ] ; then
1325 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1328 simple_cleanup_common || error "Can not delete directories"
1330 run_test 24A "readdir() returns correct number of entries."
1332 test_24B() { # LU-4805
1333 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1337 test_mkdir $DIR/$tdir
1338 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1339 error "create striped dir failed"
1341 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1342 [ $count -eq 2 ] || error "Expected 2, got $count"
1344 touch $DIR/$tdir/striped_dir/a
1346 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1347 [ $count -eq 3 ] || error "Expected 3, got $count"
1349 touch $DIR/$tdir/striped_dir/.f
1351 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1352 [ $count -eq 4 ] || error "Expected 4, got $count"
1354 rm -rf $DIR/$tdir || error "Can not delete directories"
1356 run_test 24B "readdir for striped dir return correct number of entries"
1359 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1365 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1366 error "create striped dir failed"
1368 cd $DIR/$tdir/d0/striped_dir
1370 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1371 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1372 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1374 [ "$d0_ino" = "$parent_ino" ] ||
1375 error ".. wrong, expect $d0_ino, get $parent_ino"
1377 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1378 error "mv striped dir failed"
1380 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1382 [ "$d1_ino" = "$parent_ino" ] ||
1383 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1385 run_test 24C "check .. in striped dir"
1388 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1389 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1392 mkdir $DIR/$tdir/src_dir
1393 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1394 error "create remote source failed"
1396 touch $DIR/$tdir/src_dir/src_child/a
1398 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1399 error "create remote target dir failed"
1401 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1402 error "create remote target child failed"
1404 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1405 error "rename dir cross MDT failed!"
1409 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1410 error "src_child still exists after rename"
1412 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1413 error "missing file(a) after rename"
1415 rm -rf $DIR/$tdir || error "Can not delete directories"
1417 run_test 24E "cross MDT rename/link"
1420 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1423 [ "$SLOW" = "no" ] && repeats=100
1427 echo "$repeats repeats"
1428 for ((i = 0; i < repeats; i++)); do
1429 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1430 touch $DIR/$tdir/test/a || error "touch fails"
1431 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1432 rm -rf $DIR/$tdir/test || error "rmdir fails"
1437 run_test 24F "hash order vs readdir (LU-11330)"
1440 echo '== symlink sanity ============================================='
1444 touch $DIR/s25/foo ||
1445 error "File creation in symlinked directory failed"
1447 run_test 25a "create file in symlinked directory ==============="
1450 [ ! -d $DIR/d25 ] && test_25a
1451 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1453 run_test 25b "lookup file in symlinked directory ==============="
1457 test_mkdir $DIR/d26/d26-2
1458 ln -s d26/d26-2 $DIR/s26
1459 touch $DIR/s26/foo || error "File creation failed"
1461 run_test 26a "multiple component symlink ======================="
1464 test_mkdir -p $DIR/$tdir/d26-2
1465 ln -s $tdir/d26-2/foo $DIR/s26-2
1466 touch $DIR/s26-2 || error "File creation failed"
1468 run_test 26b "multiple component symlink at end of lookup ======"
1471 test_mkdir $DIR/d26.2
1472 touch $DIR/d26.2/foo
1473 ln -s d26.2 $DIR/s26.2-1
1474 ln -s s26.2-1 $DIR/s26.2-2
1475 ln -s s26.2-2 $DIR/s26.2-3
1476 chmod 0666 $DIR/s26.2-3/foo
1478 run_test 26c "chain of symlinks"
1480 # recursive symlinks (bug 439)
1482 ln -s d26-3/foo $DIR/d26-3
1484 run_test 26d "create multiple component recursive symlink"
1487 [ ! -h $DIR/d26-3 ] && test_26d
1490 run_test 26e "unlink multiple component recursive symlink"
1492 # recursive symlinks (bug 7022)
1494 test_mkdir $DIR/$tdir
1495 test_mkdir $DIR/$tdir/$tfile
1496 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1497 test_mkdir -p lndir/bar1
1498 test_mkdir $DIR/$tdir/$tfile/$tfile
1499 cd $tfile || error "cd $tfile failed"
1500 ln -s .. dotdot || error "ln dotdot failed"
1501 ln -s dotdot/lndir lndir || error "ln lndir failed"
1502 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1503 output=`ls $tfile/$tfile/lndir/bar1`
1504 [ "$output" = bar1 ] && error "unexpected output"
1505 rm -r $tfile || error "rm $tfile failed"
1506 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1508 run_test 26f "rm -r of a directory which has recursive symlink"
1511 test_mkdir $DIR/$tdir
1512 $LFS getstripe $DIR/$tdir
1513 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1514 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1515 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1517 run_test 27a "one stripe file"
1520 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1522 test_mkdir $DIR/$tdir
1523 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1524 $LFS getstripe -c $DIR/$tdir/$tfile
1525 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1526 error "two-stripe file doesn't have two stripes"
1528 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1530 run_test 27b "create and write to two stripe file"
1532 # 27c family tests specific striping, setstripe -o
1534 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1535 test_mkdir -p $DIR/$tdir
1538 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1539 $LFS getstripe -i $DIR/$tdir/$tfile
1540 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1541 error "stripe not on specified OST"
1543 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1545 run_test 27ca "one stripe on specified OST"
1548 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1549 test_mkdir -p $DIR/$tdir
1551 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1552 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1555 # Strip getstripe output to a space separated list of OSTs
1556 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1557 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1558 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1559 error "stripes not on specified OSTs"
1561 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1563 run_test 27cb "two stripes on specified OSTs"
1566 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1567 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1568 skip "server does not support overstriping"
1570 test_mkdir -p $DIR/$tdir
1572 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1573 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1576 # Strip getstripe output to a space separated list of OSTs
1577 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1578 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1579 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1580 error "stripes not on specified OSTs"
1582 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1584 run_test 27cc "two stripes on the same OST"
1587 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1588 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1589 skip "server does not support overstriping"
1590 test_mkdir -p $DIR/$tdir
1591 local osts="0,1,1,0"
1592 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1593 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1596 # Strip getstripe output to a space separated list of OSTs
1597 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1598 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1599 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1600 error "stripes not on specified OSTs"
1602 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1604 run_test 27cd "four stripes on two OSTs"
1607 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1608 skip_env "too many osts, skipping"
1609 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1610 skip "server does not support overstriping"
1611 # We do one more stripe than we have OSTs
1612 [ $OSTCOUNT -ge 159 ] || large_xattr_enabled ||
1613 skip_env "ea_inode feature disabled"
1615 test_mkdir -p $DIR/$tdir
1617 for i in $(seq 0 $OSTCOUNT);
1620 if [ $i -ne $OSTCOUNT ]; then
1624 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1625 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1628 # Strip getstripe output to a space separated list of OSTs
1629 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1630 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1631 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1632 error "stripes not on specified OSTs"
1634 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1636 run_test 27ce "more stripes than OSTs with -o"
1639 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1642 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1643 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1644 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1645 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1646 error "failed to set $osp_proc=0"
1648 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1651 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1652 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1653 error "failed to set $osp_proc=1"
1656 error "should return error due to $osp_proc=0"
1658 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1661 test_mkdir $DIR/$tdir
1662 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1663 error "setstripe failed"
1664 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1665 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1667 run_test 27d "create file with default settings"
1670 # LU-5839 adds check for existed layout before setting it
1671 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1672 skip "Need MDS version at least 2.7.56"
1674 test_mkdir $DIR/$tdir
1675 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1676 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1677 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1679 run_test 27e "setstripe existing file (should return error)"
1682 test_mkdir $DIR/$tdir
1683 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1684 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1685 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1686 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1687 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1688 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1690 run_test 27f "setstripe with bad stripe size (should return error)"
1693 test_mkdir $DIR/$tdir
1694 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1695 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1696 error "$DIR/$tdir/$tfile has object"
1698 run_test 27g "$LFS getstripe with no objects"
1701 test_mkdir $DIR/$tdir
1702 touch $DIR/$tdir/$tfile || error "touch failed"
1703 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1704 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1706 (( rc == 2 )) || error "getstripe did not return ENOENT"
1708 run_test 27ga "$LFS getstripe with missing file (should return error)"
1711 test_mkdir $DIR/$tdir
1712 touch $DIR/$tdir/$tfile || error "touch failed"
1713 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1714 error "missing objects"
1716 run_test 27i "$LFS getstripe with some objects"
1719 test_mkdir $DIR/$tdir
1720 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1721 error "setstripe failed" || true
1723 run_test 27j "setstripe with bad stripe offset (should return error)"
1725 test_27k() { # bug 2844
1726 test_mkdir $DIR/$tdir
1727 local file=$DIR/$tdir/$tfile
1728 local ll_max_blksize=$((4 * 1024 * 1024))
1729 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1730 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1731 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1732 dd if=/dev/zero of=$file bs=4k count=1
1733 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1734 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1736 run_test 27k "limit i_blksize for broken user apps"
1739 mcreate $DIR/$tfile || error "creating file"
1740 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1741 error "setstripe should have failed" || true
1743 run_test 27l "check setstripe permissions (should return error)"
1746 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1748 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1749 skip_env "multiple clients -- skipping"
1751 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1753 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1754 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1756 trap simple_cleanup_common EXIT
1757 test_mkdir $DIR/$tdir
1758 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1759 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1760 error "dd should fill OST0"
1762 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1764 [ $i -gt 256 ] && break
1767 touch $DIR/$tdir/$tfile.$i
1768 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1769 awk '{print $1}'| grep -w "0") ] &&
1770 error "OST0 was full but new created file still use it"
1772 touch $DIR/$tdir/$tfile.$i
1773 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1774 awk '{print $1}'| grep -w "0") ] &&
1775 error "OST0 was full but new created file still use it"
1776 simple_cleanup_common
1778 run_test 27m "create file while OST0 was full"
1780 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1781 # if the OST isn't full anymore.
1783 local OSTIDX=${1:-""}
1785 local list=$(comma_list $(osts_nodes))
1786 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1788 do_nodes $list lctl set_param fail_loc=0
1789 sync # initiate all OST_DESTROYs from MDS to OST
1793 exhaust_precreations() {
1796 local FAILIDX=${3:-$OSTIDX}
1797 local ofacet=ost$((OSTIDX + 1))
1799 test_mkdir -p -c1 $DIR/$tdir
1800 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1801 local mfacet=mds$((mdtidx + 1))
1802 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1804 local OST=$(ostname_from_index $OSTIDX)
1807 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1808 local last_id=$(do_facet $mfacet lctl get_param -n \
1809 osp.$mdtosc_proc1.prealloc_last_id)
1810 local next_id=$(do_facet $mfacet lctl get_param -n \
1811 osp.$mdtosc_proc1.prealloc_next_id)
1813 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1814 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1816 test_mkdir -p $DIR/$tdir/${OST}
1817 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1818 #define OBD_FAIL_OST_ENOSPC 0x215
1819 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1820 echo "Creating to objid $last_id on ost $OST..."
1821 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1822 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1823 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1827 exhaust_all_precreations() {
1829 for (( i=0; i < OSTCOUNT; i++ )) ; do
1830 exhaust_precreations $i $1 -1
1835 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1836 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1837 remote_mds_nodsh && skip "remote MDS with nodsh"
1838 remote_ost_nodsh && skip "remote OST with nodsh"
1841 rm -f $DIR/$tdir/$tfile
1842 exhaust_precreations 0 0x80000215
1843 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1844 touch $DIR/$tdir/$tfile || error "touch failed"
1845 $LFS getstripe $DIR/$tdir/$tfile
1848 run_test 27n "create file with some full OSTs"
1851 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1852 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1853 remote_mds_nodsh && skip "remote MDS with nodsh"
1854 remote_ost_nodsh && skip "remote OST with nodsh"
1857 rm -f $DIR/$tdir/$tfile
1858 exhaust_all_precreations 0x215
1860 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1865 run_test 27o "create file with all full OSTs (should error)"
1868 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1870 remote_mds_nodsh && skip "remote MDS with nodsh"
1871 remote_ost_nodsh && skip "remote OST with nodsh"
1874 rm -f $DIR/$tdir/$tfile
1875 test_mkdir $DIR/$tdir
1877 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1878 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1879 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1881 exhaust_precreations 0 0x80000215
1882 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1883 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1884 $LFS getstripe $DIR/$tdir/$tfile
1888 run_test 27p "append to a truncated file with some full OSTs"
1891 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1892 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1893 remote_mds_nodsh && skip "remote MDS with nodsh"
1894 remote_ost_nodsh && skip "remote OST with nodsh"
1897 rm -f $DIR/$tdir/$tfile
1899 test_mkdir $DIR/$tdir
1900 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1901 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1902 error "truncate $DIR/$tdir/$tfile failed"
1903 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1905 exhaust_all_precreations 0x215
1907 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1908 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1912 run_test 27q "append to truncated file with all OSTs full (should error)"
1915 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1916 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1917 remote_mds_nodsh && skip "remote MDS with nodsh"
1918 remote_ost_nodsh && skip "remote OST with nodsh"
1921 rm -f $DIR/$tdir/$tfile
1922 exhaust_precreations 0 0x80000215
1924 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1928 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1930 test_27s() { # bug 10725
1931 test_mkdir $DIR/$tdir
1932 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1933 local stripe_count=0
1934 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1935 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1936 error "stripe width >= 2^32 succeeded" || true
1939 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1941 test_27t() { # bug 10864
1946 $WLFS getstripe $tfile
1949 run_test 27t "check that utils parse path correctly"
1951 test_27u() { # bug 4900
1952 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1953 remote_mds_nodsh && skip "remote MDS with nodsh"
1956 local list=$(comma_list $(mdts_nodes))
1958 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1959 do_nodes $list $LCTL set_param fail_loc=0x139
1960 test_mkdir -p $DIR/$tdir
1961 trap simple_cleanup_common EXIT
1962 createmany -o $DIR/$tdir/t- 1000
1963 do_nodes $list $LCTL set_param fail_loc=0
1965 TLOG=$TMP/$tfile.getstripe
1966 $LFS getstripe $DIR/$tdir > $TLOG
1967 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1968 unlinkmany $DIR/$tdir/t- 1000
1970 [[ $OBJS -gt 0 ]] &&
1971 error "$OBJS objects created on OST-0. See $TLOG" ||
1974 run_test 27u "skip object creation on OSC w/o objects"
1976 test_27v() { # bug 4900
1977 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1978 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1979 remote_mds_nodsh && skip "remote MDS with nodsh"
1980 remote_ost_nodsh && skip "remote OST with nodsh"
1982 exhaust_all_precreations 0x215
1985 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1987 touch $DIR/$tdir/$tfile
1988 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1990 for (( i=1; i < OSTCOUNT; i++ )); do
1991 do_facet ost$i lctl set_param fail_loc=0x705
1993 local START=`date +%s`
1994 createmany -o $DIR/$tdir/$tfile 32
1996 local FINISH=`date +%s`
1997 local TIMEOUT=`lctl get_param -n timeout`
1998 local PROCESS=$((FINISH - START))
1999 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2000 error "$FINISH - $START >= $TIMEOUT / 2"
2001 sleep $((TIMEOUT / 2 - PROCESS))
2004 run_test 27v "skip object creation on slow OST"
2006 test_27w() { # bug 10997
2007 test_mkdir $DIR/$tdir
2008 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2009 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2010 error "stripe size $size != 65536" || true
2011 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2012 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2014 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2017 [[ $OSTCOUNT -lt 2 ]] &&
2018 skip_env "skipping multiple stripe count/offset test"
2020 test_mkdir $DIR/$tdir
2021 for i in $(seq 1 $OSTCOUNT); do
2023 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2024 error "setstripe -c $i -i $offset failed"
2025 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2026 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2027 [ $count -ne $i ] && error "stripe count $count != $i" || true
2028 [ $index -ne $offset ] &&
2029 error "stripe offset $index != $offset" || true
2032 run_test 27wa "check $LFS setstripe -c -i options"
2035 remote_ost_nodsh && skip "remote OST with nodsh"
2036 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2037 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2039 OFFSET=$(($OSTCOUNT - 1))
2041 local OST=$(ostname_from_index $OSTIDX)
2043 test_mkdir $DIR/$tdir
2044 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2045 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2047 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2048 for i in $(seq 0 $OFFSET); do
2049 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2050 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2051 error "OST0 was degraded but new created file still use it"
2053 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2055 run_test 27x "create files while OST0 is degraded"
2058 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2059 remote_mds_nodsh && skip "remote MDS with nodsh"
2060 remote_ost_nodsh && skip "remote OST with nodsh"
2061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2063 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2064 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2065 osp.$mdtosc.prealloc_last_id)
2066 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2067 osp.$mdtosc.prealloc_next_id)
2068 local fcount=$((last_id - next_id))
2069 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2070 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2072 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2073 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2074 local OST_DEACTIVE_IDX=-1
2079 for OSC in $MDS_OSCS; do
2080 OST=$(osc_to_ost $OSC)
2081 OSTIDX=$(index_from_ostuuid $OST)
2082 if [ $OST_DEACTIVE_IDX == -1 ]; then
2083 OST_DEACTIVE_IDX=$OSTIDX
2085 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2086 echo $OSC "is Deactivated:"
2087 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2091 OSTIDX=$(index_from_ostuuid $OST)
2092 test_mkdir $DIR/$tdir
2093 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2095 for OSC in $MDS_OSCS; do
2096 OST=$(osc_to_ost $OSC)
2097 OSTIDX=$(index_from_ostuuid $OST)
2098 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2099 echo $OST "is degraded:"
2100 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2101 obdfilter.$OST.degraded=1
2106 createmany -o $DIR/$tdir/$tfile $fcount
2108 for OSC in $MDS_OSCS; do
2109 OST=$(osc_to_ost $OSC)
2110 OSTIDX=$(index_from_ostuuid $OST)
2111 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2112 echo $OST "is recovered from degraded:"
2113 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2114 obdfilter.$OST.degraded=0
2116 do_facet $SINGLEMDS lctl --device %$OSC activate
2120 # all osp devices get activated, hence -1 stripe count restored
2121 local stripe_count=0
2123 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2124 # devices get activated.
2126 $LFS setstripe -c -1 $DIR/$tfile
2127 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2129 [ $stripe_count -ne $OSTCOUNT ] &&
2130 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2133 run_test 27y "create files while OST0 is degraded and the rest inactive"
2139 lmm_count=$($LFS getstripe -c $1)
2140 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2141 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2143 local old_ifs="$IFS"
2145 fid=($($LFS path2fid $1))
2148 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2149 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2151 # compare lmm_seq and lu_fid->f_seq
2152 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2153 # compare lmm_object_id and lu_fid->oid
2154 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2156 # check the trusted.fid attribute of the OST objects of the file
2157 local have_obdidx=false
2159 $LFS getstripe $1 | while read obdidx oid hex seq; do
2160 # skip lines up to and including "obdidx"
2161 [ -z "$obdidx" ] && break
2162 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2163 $have_obdidx || continue
2165 local ost=$((obdidx + 1))
2166 local dev=$(ostdevname $ost)
2169 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2171 seq=$(echo $seq | sed -e "s/^0x//g")
2172 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2173 oid_hex=$(echo $oid)
2175 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2177 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2181 # Don't unmount/remount the OSTs if we don't need to do that.
2182 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2183 # update too, until that use mount/ll_decode_filter_fid/mount.
2184 # Re-enable when debugfs will understand new filter_fid.
2186 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2187 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2188 $dev 2>/dev/null" | grep "parent=")
2190 if [ -z "$ff" ]; then
2192 mount_fstype ost$ost
2193 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2194 $(facet_mntpt ost$ost)/$obj_file)
2195 unmount_fstype ost$ost
2196 start ost$ost $dev $OST_MOUNT_OPTS
2200 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2202 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2204 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2205 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2207 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2208 # stripe_size=1048576 component_id=1 component_start=0 \
2209 # component_end=33554432
2210 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2211 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2212 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2214 if grep -q 'stripe=' <<<$ff; then
2215 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2217 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2218 # into f_ver in this case. See comment on ff_parent.
2219 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2222 # compare lmm_seq and filter_fid->ff_parent.f_seq
2223 [ $ff_pseq = $lmm_seq ] ||
2224 error "FF parent SEQ $ff_pseq != $lmm_seq"
2225 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2226 [ $ff_poid = $lmm_oid ] ||
2227 error "FF parent OID $ff_poid != $lmm_oid"
2228 (($ff_pstripe == $stripe_nr)) ||
2229 error "FF stripe $ff_pstripe != $stripe_nr"
2231 stripe_nr=$((stripe_nr + 1))
2232 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2234 if grep -q 'stripe_count=' <<<$ff; then
2235 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2236 -e 's/ .*//' <<<$ff)
2237 [ $lmm_count = $ff_scnt ] ||
2238 error "FF stripe count $lmm_count != $ff_scnt"
2244 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2245 remote_ost_nodsh && skip "remote OST with nodsh"
2247 test_mkdir $DIR/$tdir
2248 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2249 { error "setstripe -c -1 failed"; return 1; }
2250 # We need to send a write to every object to get parent FID info set.
2251 # This _should_ also work for setattr, but does not currently.
2252 # touch $DIR/$tdir/$tfile-1 ||
2253 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2254 { error "dd $tfile-1 failed"; return 2; }
2255 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2256 { error "setstripe -c -1 failed"; return 3; }
2257 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2258 { error "dd $tfile-2 failed"; return 4; }
2260 # make sure write RPCs have been sent to OSTs
2263 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2264 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2266 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2268 test_27A() { # b=19102
2269 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2271 save_layout_restore_at_exit $MOUNT
2272 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2273 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2274 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2275 local default_size=$($LFS getstripe -S $MOUNT)
2276 local default_offset=$($LFS getstripe -i $MOUNT)
2277 local dsize=$(do_facet $SINGLEMDS \
2278 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2279 [ $default_size -eq $dsize ] ||
2280 error "stripe size $default_size != $dsize"
2281 [ $default_offset -eq -1 ] ||
2282 error "stripe offset $default_offset != -1"
2284 run_test 27A "check filesystem-wide default LOV EA values"
2286 test_27B() { # LU-2523
2287 test_mkdir $DIR/$tdir
2288 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2290 # open f1 with O_LOV_DELAY_CREATE
2292 # call setstripe ioctl on open file descriptor for f1
2294 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2298 # open f1 with O_LOV_DELAY_CREATE
2300 # call setstripe ioctl on open file descriptor for f1
2302 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2304 # Allow multiop to fail in imitation of NFS's busted semantics.
2307 run_test 27B "call setstripe on open unlinked file/rename victim"
2309 # 27C family tests full striping and overstriping
2310 test_27Ca() { #LU-2871
2311 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2319 test_mkdir $DIR/$tdir
2321 for i in $(seq 0 $((OSTCOUNT - 1))); do
2322 # set stripe across all OSTs starting from OST$i
2323 $LFS setstripe -i $i -c -1 $tfile$i
2324 # get striping information
2325 ost_idx=($($LFS getstripe $tfile$i |
2326 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2330 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2331 error "${#ost_idx[@]} != $OSTCOUNT"
2333 for index in $(seq 0 $((OSTCOUNT - 1))); do
2335 for j in $(echo ${ost_idx[@]}); do
2336 if [ $index -eq $j ]; then
2342 error "Can not find $index in ${ost_idx[@]}"
2346 run_test 27Ca "check full striping across all OSTs"
2349 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2350 skip "server does not support overstriping"
2351 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2352 skip_env "too many osts, skipping"
2354 test_mkdir -p $DIR/$tdir
2355 local setcount=$(($OSTCOUNT * 2))
2356 [ $setcount -ge 160 ] || large_xattr_enabled ||
2357 skip_env "ea_inode feature disabled"
2359 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2360 error "setstripe failed"
2362 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2363 [ $count -eq $setcount ] ||
2364 error "stripe count $count, should be $setcount"
2366 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2367 error "overstriped should be set in pattern"
2369 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2372 run_test 27Cb "more stripes than OSTs with -C"
2375 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2376 skip "server does not support overstriping"
2377 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2379 test_mkdir -p $DIR/$tdir
2380 local setcount=$(($OSTCOUNT - 1))
2382 [ $setcount -ge 160 ] || large_xattr_enabled ||
2383 skip_env "ea_inode feature disabled"
2385 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2386 error "setstripe failed"
2388 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2389 [ $count -eq $setcount ] ||
2390 error "stripe count $count, should be $setcount"
2392 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2393 error "overstriped should not be set in pattern"
2395 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2398 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2401 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2402 skip "server does not support overstriping"
2403 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2404 large_xattr_enabled || skip_env "ea_inode feature disabled"
2406 test_mkdir -p $DIR/$tdir
2407 local setcount=$LOV_MAX_STRIPE_COUNT
2409 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2410 error "setstripe failed"
2412 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2413 [ $count -eq $setcount ] ||
2414 error "stripe count $count, should be $setcount"
2416 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2417 error "overstriped should be set in pattern"
2419 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2422 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2424 run_test 27Cd "test maximum stripe count"
2427 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2428 skip "server does not support overstriping"
2429 test_mkdir -p $DIR/$tdir
2431 pool_add $TESTNAME || error "Pool creation failed"
2432 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2436 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2437 error "setstripe failed"
2439 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2440 [ $count -eq $setcount ] ||
2441 error "stripe count $count, should be $setcount"
2443 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2444 error "overstriped should be set in pattern"
2446 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2449 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2451 run_test 27Ce "test pool with overstriping"
2454 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2455 skip "server does not support overstriping"
2456 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2457 skip_env "too many osts, skipping"
2459 test_mkdir -p $DIR/$tdir
2461 local setcount=$(($OSTCOUNT * 2))
2462 [ $setcount -ge 160 ] || large_xattr_enabled ||
2463 skip_env "ea_inode feature disabled"
2465 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2466 error "setstripe failed"
2468 echo 1 > $DIR/$tdir/$tfile
2470 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2471 [ $count -eq $setcount ] ||
2472 error "stripe count $count, should be $setcount"
2474 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2475 error "overstriped should be set in pattern"
2477 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2480 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2482 run_test 27Cf "test default inheritance with overstriping"
2485 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2486 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2487 remote_mds_nodsh && skip "remote MDS with nodsh"
2489 local POOL=${POOL:-testpool}
2491 local last_ost=$(($OSTCOUNT - 1))
2493 local ost_list=$(seq $first_ost $ost_step $last_ost)
2494 local ost_range="$first_ost $last_ost $ost_step"
2496 test_mkdir $DIR/$tdir
2497 pool_add $POOL || error "pool_add failed"
2498 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2501 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2503 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2504 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2505 skip27D+=" -s 30,31"
2506 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2507 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2508 skip27D+=" -s 32,33"
2509 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2511 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2512 error "llapi_layout_test failed"
2514 destroy_test_pools || error "destroy test pools failed"
2516 run_test 27D "validate llapi_layout API"
2518 # Verify that default_easize is increased from its initial value after
2519 # accessing a widely striped file.
2521 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2522 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2523 skip "client does not have LU-3338 fix"
2525 # 72 bytes is the minimum space required to store striping
2526 # information for a file striped across one OST:
2527 # (sizeof(struct lov_user_md_v3) +
2528 # sizeof(struct lov_user_ost_data_v1))
2530 $LCTL set_param -n llite.*.default_easize $min_easize ||
2531 error "lctl set_param failed"
2532 local easize=$($LCTL get_param -n llite.*.default_easize)
2534 [ $easize -eq $min_easize ] ||
2535 error "failed to set default_easize"
2537 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2538 error "setstripe failed"
2539 # In order to ensure stat() call actually talks to MDS we need to
2540 # do something drastic to this file to shake off all lock, e.g.
2541 # rename it (kills lookup lock forcing cache cleaning)
2542 mv $DIR/$tfile $DIR/${tfile}-1
2543 ls -l $DIR/${tfile}-1
2546 easize=$($LCTL get_param -n llite.*.default_easize)
2548 [ $easize -gt $min_easize ] ||
2549 error "default_easize not updated"
2551 run_test 27E "check that default extended attribute size properly increases"
2553 test_27F() { # LU-5346/LU-7975
2554 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2555 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2556 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2557 skip "Need MDS version at least 2.8.51"
2558 remote_ost_nodsh && skip "remote OST with nodsh"
2560 test_mkdir $DIR/$tdir
2562 $LFS setstripe -c 2 $DIR/$tdir
2564 # stop all OSTs to reproduce situation for LU-7975 ticket
2565 for num in $(seq $OSTCOUNT); do
2569 # open/create f0 with O_LOV_DELAY_CREATE
2570 # truncate f0 to a non-0 size
2572 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2574 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2575 # open/write it again to force delayed layout creation
2576 cat /etc/hosts > $DIR/$tdir/f0 &
2580 for num in $(seq $OSTCOUNT); do
2581 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2582 error "ost$num failed to start"
2585 wait $catpid || error "cat failed"
2587 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2588 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2589 error "wrong stripecount"
2592 run_test 27F "Client resend delayed layout creation with non-zero size"
2594 test_27G() { #LU-10629
2595 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2596 skip "Need MDS version at least 2.11.51"
2597 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2598 remote_mds_nodsh && skip "remote MDS with nodsh"
2599 local POOL=${POOL:-testpool}
2600 local ostrange="0 0 1"
2602 test_mkdir $DIR/$tdir
2603 pool_add $POOL || error "pool_add failed"
2604 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2605 $LFS setstripe -p $POOL $DIR/$tdir
2607 local pool=$($LFS getstripe -p $DIR/$tdir)
2609 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2611 $LFS setstripe -d $DIR/$tdir
2613 pool=$($LFS getstripe -p $DIR/$tdir)
2617 [ -z "$pool" ] || error "'$pool' is not empty"
2619 run_test 27G "Clear OST pool from stripe"
2622 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2623 skip "Need MDS version newer than 2.11.54"
2624 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2625 test_mkdir $DIR/$tdir
2626 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2627 touch $DIR/$tdir/$tfile
2628 $LFS getstripe -c $DIR/$tdir/$tfile
2629 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2630 error "two-stripe file doesn't have two stripes"
2632 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2633 $LFS getstripe -y $DIR/$tdir/$tfile
2634 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2635 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2636 error "expected l_ost_idx: [02]$ not matched"
2638 # make sure ost list has been cleared
2639 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2640 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2641 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2643 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2645 run_test 27H "Set specific OSTs stripe"
2648 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2649 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2650 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2651 skip "Need MDS version newer than 2.12.52"
2652 local pool=$TESTNAME
2653 local ostrange="1 1 1"
2655 save_layout_restore_at_exit $MOUNT
2656 $LFS setstripe -c 2 -i 0 $MOUNT
2657 pool_add $pool || error "pool_add failed"
2658 pool_add_targets $pool $ostrange || "pool_add_targets failed"
2659 test_mkdir $DIR/$tdir
2660 $LFS setstripe -p $pool $DIR/$tdir
2661 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2662 $LFS getstripe $DIR/$tdir/$tfile
2664 run_test 27I "check that root dir striping does not break parent dir one"
2667 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2668 skip "Need MDS version newer than 2.12.51"
2670 test_mkdir $DIR/$tdir
2671 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2672 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2674 # create foreign file (raw way)
2675 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2676 -t 1 -F 0xda08 || error "create_foreign_file failed"
2678 # verify foreign file (raw way)
2679 parse_foreign_file -f $DIR/$tdir/$tfile |
2680 grep "lov_foreign_magic: 0x0BD70BD0" ||
2681 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2682 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2683 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2684 parse_foreign_file -f $DIR/$tdir/$tfile |
2685 grep "lov_foreign_size: 73" ||
2686 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2687 parse_foreign_file -f $DIR/$tdir/$tfile |
2688 grep "lov_foreign_type: 1" ||
2689 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2690 parse_foreign_file -f $DIR/$tdir/$tfile |
2691 grep "lov_foreign_flags: 0x0000DA08" ||
2692 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2693 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2694 grep "lov_foreign_value: 0x" |
2695 sed -e 's/lov_foreign_value: 0x//')
2696 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2697 [[ $lov = ${lov2// /} ]] ||
2698 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2700 # create foreign file (lfs + API)
2701 $LFS setstripe --foreign=daos --flags 0xda08 \
2702 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2703 error "$DIR/$tdir/${tfile}2: create failed"
2705 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2706 grep "lfm_magic:.*0x0BD70BD0" ||
2707 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2708 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2709 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2710 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2711 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
2712 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2713 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2714 grep "lfm_flags:.*0x0000DA08" ||
2715 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2716 $LFS getstripe $DIR/$tdir/${tfile}2 |
2717 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2718 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2720 # modify striping should fail
2721 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2722 error "$DIR/$tdir/$tfile: setstripe should fail"
2723 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2724 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2727 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2728 cat $DIR/$tdir/${tfile}2 &&
2729 error "$DIR/$tdir/${tfile}2: read should fail"
2730 cat /etc/passwd > $DIR/$tdir/$tfile &&
2731 error "$DIR/$tdir/$tfile: write should fail"
2732 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2733 error "$DIR/$tdir/${tfile}2: write should fail"
2736 chmod 222 $DIR/$tdir/$tfile ||
2737 error "$DIR/$tdir/$tfile: chmod failed"
2738 chmod 222 $DIR/$tdir/${tfile}2 ||
2739 error "$DIR/$tdir/${tfile}2: chmod failed"
2742 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2743 error "$DIR/$tdir/$tfile: chown failed"
2744 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2745 error "$DIR/$tdir/${tfile}2: chown failed"
2747 # rename should work
2748 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2749 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2750 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2751 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2753 #remove foreign file
2754 rm $DIR/$tdir/${tfile}.new ||
2755 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2756 rm $DIR/$tdir/${tfile}2.new ||
2757 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2759 run_test 27J "basic ops on file with foreign LOV"
2762 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2763 skip "Need MDS version newer than 2.12.49"
2765 test_mkdir $DIR/$tdir
2766 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2767 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2769 # create foreign dir (raw way)
2770 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2771 error "create_foreign_dir FAILED"
2773 # verify foreign dir (raw way)
2774 parse_foreign_dir -d $DIR/$tdir/$tdir |
2775 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2776 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2777 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2778 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2779 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2780 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2781 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
2782 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2783 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2784 grep "lmv_foreign_value: 0x" |
2785 sed 's/lmv_foreign_value: 0x//')
2786 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2788 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2790 # create foreign dir (lfs + API)
2791 $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2792 $DIR/$tdir/${tdir}2 ||
2793 error "$DIR/$tdir/${tdir}2: create failed"
2795 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2796 grep "lfm_magic:.*0x0CD50CD0" ||
2797 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2798 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2799 # - sizeof(lfm_type) - sizeof(lfm_flags)
2800 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2801 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2802 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
2803 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2804 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2805 grep "lfm_flags:.*0x0000DA05" ||
2806 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2807 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2808 grep "lfm_value.*${uuid1}@${uuid2}" ||
2809 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2811 # file create in dir should fail
2812 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2813 touch $DIR/$tdir/${tdir}2/$tfile &&
2814 "$DIR/${tdir}2: file create should fail"
2817 chmod 777 $DIR/$tdir/$tdir ||
2818 error "$DIR/$tdir: chmod failed"
2819 chmod 777 $DIR/$tdir/${tdir}2 ||
2820 error "$DIR/${tdir}2: chmod failed"
2823 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2824 error "$DIR/$tdir: chown failed"
2825 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2826 error "$DIR/${tdir}2: chown failed"
2828 # rename should work
2829 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2830 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2831 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2832 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2835 rmdir $DIR/$tdir/${tdir}.new ||
2836 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2837 rmdir $DIR/$tdir/${tdir}2.new ||
2838 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2840 run_test 27K "basic ops on dir with foreign LMV"
2843 remote_mds_nodsh && skip "remote MDS with nodsh"
2845 local POOL=${POOL:-$TESTNAME}
2847 pool_add $POOL || error "pool_add failed"
2849 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2850 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2851 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2853 run_test 27L "lfs pool_list gives correct pool name"
2856 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2857 skip "Need MDS version >= than 2.12.57"
2858 remote_mds_nodsh && skip "remote MDS with nodsh"
2859 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2861 test_mkdir $DIR/$tdir
2863 # Set default striping on directory
2864 $LFS setstripe -C 4 $DIR/$tdir
2866 echo 1 > $DIR/$tdir/${tfile}.1
2867 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2869 [ $count -eq $setcount ] ||
2870 error "(1) stripe count $count, should be $setcount"
2872 # Capture existing append_stripe_count setting for restore
2873 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2874 local mdts=$(comma_list $(mdts_nodes))
2875 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2877 local appendcount=$orig_count
2878 echo 1 >> $DIR/$tdir/${tfile}.2_append
2879 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2880 [ $count -eq $appendcount ] ||
2881 error "(2)stripe count $count, should be $appendcount for append"
2883 # Disable O_APPEND striping, verify it works
2884 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2886 # Should now get the default striping, which is 4
2888 echo 1 >> $DIR/$tdir/${tfile}.3_append
2889 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2890 [ $count -eq $setcount ] ||
2891 error "(3) stripe count $count, should be $setcount"
2893 # Try changing the stripe count for append files
2894 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2896 # Append striping is now 2 (directory default is still 4)
2898 echo 1 >> $DIR/$tdir/${tfile}.4_append
2899 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2900 [ $count -eq $appendcount ] ||
2901 error "(4) stripe count $count, should be $appendcount for append"
2903 # Test append stripe count of -1
2904 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2905 appendcount=$OSTCOUNT
2906 echo 1 >> $DIR/$tdir/${tfile}.5
2907 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2908 [ $count -eq $appendcount ] ||
2909 error "(5) stripe count $count, should be $appendcount for append"
2911 # Set append striping back to default of 1
2912 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2914 # Try a new default striping, PFL + DOM
2915 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2917 # Create normal DOM file, DOM returns stripe count == 0
2919 touch $DIR/$tdir/${tfile}.6
2920 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2921 [ $count -eq $setcount ] ||
2922 error "(6) stripe count $count, should be $setcount"
2926 echo 1 >> $DIR/$tdir/${tfile}.7_append
2927 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2928 [ $count -eq $appendcount ] ||
2929 error "(7) stripe count $count, should be $appendcount for append"
2931 # Clean up DOM layout
2932 $LFS setstripe -d $DIR/$tdir
2934 # Now test that append striping works when layout is from root
2935 $LFS setstripe -c 2 $MOUNT
2936 # Make a special directory for this
2937 mkdir $DIR/${tdir}/${tdir}.2
2938 stack_trap "$LFS setstripe -d $MOUNT" EXIT
2940 # Verify for normal file
2942 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2943 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2944 [ $count -eq $setcount ] ||
2945 error "(8) stripe count $count, should be $setcount"
2948 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2949 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2950 [ $count -eq $appendcount ] ||
2951 error "(9) stripe count $count, should be $appendcount for append"
2953 # Now test O_APPEND striping with pools
2954 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2955 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
2958 pool_add $TESTNAME || error "pool creation failed"
2959 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2961 echo 1 >> $DIR/$tdir/${tfile}.10_append
2963 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
2964 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
2966 # Check that count is still correct
2968 echo 1 >> $DIR/$tdir/${tfile}.11_append
2969 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
2970 [ $count -eq $appendcount ] ||
2971 error "(11) stripe count $count, should be $appendcount for append"
2973 # Disable O_APPEND stripe count, verify pool works separately
2974 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2976 echo 1 >> $DIR/$tdir/${tfile}.12_append
2978 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
2979 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
2981 # Remove pool setting, verify it's not applied
2982 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
2984 echo 1 >> $DIR/$tdir/${tfile}.13_append
2986 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
2987 [ "$pool" = "" ] || error "(13) pool found: $pool"
2989 run_test 27M "test O_APPEND striping"
2992 combined_mgs_mds && skip "needs separate MGS/MDT"
2994 pool_add $TESTNAME || error "pool_add failed"
2995 do_facet mgs "$LCTL pool_list $FSNAME" |
2996 grep -Fx "${FSNAME}.${TESTNAME}" ||
2997 error "lctl pool_list on MGS failed"
2999 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3001 # createtest also checks that device nodes are created and
3002 # then visible correctly (#2091)
3003 test_28() { # bug 2091
3005 $CREATETEST $DIR/d28/ct || error "createtest failed"
3007 run_test 28 "create/mknod/mkdir with bad file types ============"
3010 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3012 sync; sleep 1; sync # flush out any dirty pages from previous tests
3019 declare -i LOCKCOUNTORIG=0
3020 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3021 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3023 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3025 declare -i LOCKUNUSEDCOUNTORIG=0
3026 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3027 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3034 declare -i LOCKCOUNTCURRENT=0
3035 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3036 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3039 declare -i LOCKUNUSEDCOUNTCURRENT=0
3040 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3041 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3044 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3045 $LCTL set_param -n ldlm.dump_namespaces ""
3046 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3047 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3048 log "dumped log to $TMP/test_29.dk (bug 5793)"
3051 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3052 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3053 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3054 log "dumped log to $TMP/test_29.dk (bug 5793)"
3058 run_test 29 "IT_GETATTR regression ============================"
3060 test_30a() { # was test_30
3061 cp $(which ls) $DIR || cp /bin/ls $DIR
3062 $DIR/ls / || error "Can't execute binary from lustre"
3065 run_test 30a "execute binary from Lustre (execve) =============="
3068 cp `which ls` $DIR || cp /bin/ls $DIR
3070 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3073 run_test 30b "execute binary from Lustre as non-root ==========="
3075 test_30c() { # b=22376
3076 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3078 cp $(which ls) $DIR || cp /bin/ls $DIR
3080 cancel_lru_locks mdc
3081 cancel_lru_locks osc
3082 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3085 run_test 30c "execute binary from Lustre without read perms ===="
3088 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3090 for i in {1..10}; do
3091 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3094 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3095 wait $PID || error "executing dd from Lustre failed"
3101 run_test 30d "execute binary from Lustre while clear locks"
3104 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3105 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3107 run_test 31a "open-unlink file =================================="
3110 touch $DIR/f31 || error "touch $DIR/f31 failed"
3111 ln $DIR/f31 $DIR/f31b || error "ln failed"
3112 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3113 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3115 run_test 31b "unlink file with multiple links while open ======="
3118 touch $DIR/f31 || error "touch $DIR/f31 failed"
3119 ln $DIR/f31 $DIR/f31c || error "ln failed"
3120 multiop_bg_pause $DIR/f31 O_uc ||
3121 error "multiop_bg_pause for $DIR/f31 failed"
3123 $MULTIOP $DIR/f31c Ouc
3124 kill -USR1 $MULTIPID
3127 run_test 31c "open-unlink file with multiple links ============="
3130 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3131 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3133 run_test 31d "remove of open directory ========================="
3135 test_31e() { # bug 2904
3136 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3138 run_test 31e "remove of open non-empty directory ==============="
3140 test_31f() { # bug 4554
3141 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3144 test_mkdir $DIR/d31f
3145 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3146 cp /etc/hosts $DIR/d31f
3148 $LFS getstripe $DIR/d31f/hosts
3149 multiop_bg_pause $DIR/d31f D_c || return 1
3152 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3153 test_mkdir $DIR/d31f
3154 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3155 cp /etc/hosts $DIR/d31f
3157 $LFS getstripe $DIR/d31f/hosts
3158 multiop_bg_pause $DIR/d31f D_c || return 1
3161 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3162 wait $MULTIPID || error "first opendir $MULTIPID failed"
3166 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3167 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3170 run_test 31f "remove of open directory with open-unlink file ==="
3173 echo "-- cross directory link --"
3174 test_mkdir -c1 $DIR/${tdir}ga
3175 test_mkdir -c1 $DIR/${tdir}gb
3176 touch $DIR/${tdir}ga/f
3177 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3178 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3179 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3180 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3181 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3183 run_test 31g "cross directory link==============="
3186 echo "-- cross directory link --"
3187 test_mkdir -c1 $DIR/${tdir}
3188 test_mkdir -c1 $DIR/${tdir}/dir
3189 touch $DIR/${tdir}/f
3190 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3191 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3192 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3193 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3194 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3196 run_test 31h "cross directory link under child==============="
3199 echo "-- cross directory link --"
3200 test_mkdir -c1 $DIR/$tdir
3201 test_mkdir -c1 $DIR/$tdir/dir
3202 touch $DIR/$tdir/dir/f
3203 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3204 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3205 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3206 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3207 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3209 run_test 31i "cross directory link under parent==============="
3212 test_mkdir -c1 -p $DIR/$tdir
3213 test_mkdir -c1 -p $DIR/$tdir/dir1
3214 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3215 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3216 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3217 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3220 run_test 31j "link for directory==============="
3223 test_mkdir -c1 -p $DIR/$tdir
3225 touch $DIR/$tdir/exist
3226 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3227 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3228 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3229 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3230 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3231 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3232 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3235 run_test 31k "link to file: the same, non-existing, dir==============="
3241 touch $DIR/d31m2/exist
3242 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3243 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3244 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3245 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3246 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3247 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3250 run_test 31m "link to file: the same, non-existing, dir==============="
3253 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3254 nlink=$(stat --format=%h $DIR/$tfile)
3255 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3257 local cmd="exec $fd<$DIR/$tfile"
3260 trap "eval $cmd" EXIT
3261 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3262 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3263 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3264 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3265 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3268 run_test 31n "check link count of unlinked file"
3271 local tempfile=$(mktemp $1_XXXXXX)
3272 mlink $tempfile $1 2> /dev/null &&
3273 echo "$BASHPID: link $tempfile to $1 succeeded"
3277 test_31o() { # LU-2901
3278 test_mkdir $DIR/$tdir
3279 for LOOP in $(seq 100); do
3280 rm -f $DIR/$tdir/$tfile*
3281 for THREAD in $(seq 8); do
3282 link_one $DIR/$tdir/$tfile.$LOOP &
3285 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3286 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3287 error "$LINKS duplicate links to $tfile.$LOOP" &&
3291 run_test 31o "duplicate hard links with same filename"
3294 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3296 test_mkdir $DIR/$tdir
3297 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3298 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3300 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3301 error "open unlink test1 failed"
3302 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3303 error "open unlink test2 failed"
3305 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3306 error "test1 still exists"
3307 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3308 error "test2 still exists"
3310 run_test 31p "remove of open striped directory"
3312 cleanup_test32_mount() {
3315 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3316 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3317 losetup -d $loopdev || true
3323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3325 echo "== more mountpoints and symlinks ================="
3326 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3327 trap cleanup_test32_mount EXIT
3328 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3329 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3330 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3331 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3332 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3333 cleanup_test32_mount
3335 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3338 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3340 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3341 trap cleanup_test32_mount EXIT
3342 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3343 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3344 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3345 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3346 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3347 cleanup_test32_mount
3349 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3352 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3354 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3355 trap cleanup_test32_mount EXIT
3356 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3357 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3358 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3359 test_mkdir -p $DIR/$tdir/d2/test_dir
3360 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3361 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3362 cleanup_test32_mount
3364 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3367 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3369 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3370 trap cleanup_test32_mount EXIT
3371 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3372 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3373 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3374 test_mkdir -p $DIR/$tdir/d2/test_dir
3375 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3376 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3377 cleanup_test32_mount
3379 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3383 test_mkdir -p $DIR/$tdir/tmp
3384 local tmp_dir=$DIR/$tdir/tmp
3385 ln -s $DIR/$tdir $tmp_dir/symlink11
3386 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3387 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3388 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3390 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3394 test_mkdir -p $DIR/$tdir/tmp
3395 local tmp_dir=$DIR/$tdir/tmp
3396 ln -s $DIR/$tdir $tmp_dir/symlink11
3397 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3398 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3399 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3401 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3404 local tmp_dir=$DIR/$tdir/tmp
3405 test_mkdir -p $tmp_dir
3406 test_mkdir $DIR/${tdir}2
3407 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3408 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3409 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3410 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3411 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3412 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3414 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3417 rm -fr $DIR/$tdir $DIR/${tdir}2
3418 tmp_dir=$DIR/$tdir/tmp
3419 test_mkdir -p $tmp_dir
3420 test_mkdir $DIR/${tdir}2
3421 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3422 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3423 ls $tmp_dir/symlink12 || error "listing symlink12"
3424 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3426 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3429 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3431 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3432 trap cleanup_test32_mount EXIT
3433 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3434 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3435 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3436 touch $DIR/$tdir/test_file
3437 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3438 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3439 cleanup_test32_mount
3441 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3446 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3447 trap cleanup_test32_mount EXIT
3448 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3449 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3450 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3451 touch $DIR/$tdir/test_file
3452 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3453 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3454 cleanup_test32_mount
3456 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3459 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3462 trap cleanup_test32_mount EXIT
3463 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3464 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3465 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3466 test_mkdir -p $DIR/$tdir/d2
3467 touch $DIR/$tdir/d2/test_file || error "touch failed"
3468 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3469 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3470 cleanup_test32_mount
3472 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3478 trap cleanup_test32_mount EXIT
3479 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3480 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3481 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3482 test_mkdir -p $DIR/$tdir/d2
3483 touch $DIR/$tdir/d2/test_file || error "touch failed"
3484 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3485 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3486 cleanup_test32_mount
3488 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3492 test_mkdir -p $DIR/d32m/tmp
3493 TMP_DIR=$DIR/d32m/tmp
3494 ln -s $DIR $TMP_DIR/symlink11
3495 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3496 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3497 error "symlink11 not a link"
3498 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3499 error "symlink01 not a link"
3501 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3505 test_mkdir -p $DIR/d32n/tmp
3506 TMP_DIR=$DIR/d32n/tmp
3507 ln -s $DIR $TMP_DIR/symlink11
3508 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3509 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3510 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3512 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3516 test_mkdir -p $DIR/d32o/tmp
3517 TMP_DIR=$DIR/d32o/tmp
3518 ln -s $DIR/$tfile $TMP_DIR/symlink12
3519 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3520 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3521 error "symlink12 not a link"
3522 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3523 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3524 error "$DIR/d32o/tmp/symlink12 not file type"
3525 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3526 error "$DIR/d32o/symlink02 not file type"
3528 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3538 test_mkdir -p $DIR/d32p/tmp
3540 TMP_DIR=$DIR/d32p/tmp
3542 ln -s $DIR/$tfile $TMP_DIR/symlink12
3544 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3546 cat $DIR/d32p/tmp/symlink12 ||
3547 error "Can't open $DIR/d32p/tmp/symlink12"
3549 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3552 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3555 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3557 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3558 trap cleanup_test32_mount EXIT
3559 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3560 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3561 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3562 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3563 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3564 cleanup_test32_mount
3566 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3569 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3571 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3572 trap cleanup_test32_mount EXIT
3573 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3574 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3575 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3576 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3577 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3578 cleanup_test32_mount
3580 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3585 chmod 444 $DIR/$tfile
3586 chown $RUNAS_ID $DIR/$tfile
3588 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3591 run_test 33aa "write file with mode 444 (should return error)"
3595 test_mkdir $DIR/$tdir
3596 chown $RUNAS_ID $DIR/$tdir
3597 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3598 error "$RUNAS create $tdir/$tfile failed"
3599 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3600 error "open RDWR" || true
3602 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3606 test_mkdir $DIR/$tdir
3607 chown $RUNAS_ID $DIR/$tdir
3608 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3610 run_test 33b "test open file with malformed flags (No panic)"
3613 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3614 remote_ost_nodsh && skip "remote OST with nodsh"
3623 test_mkdir $DIR/$tdir
3624 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3627 for ostnum in $(seq $OSTCOUNT); do
3628 # test-framework's OST numbering is one-based, while Lustre's
3630 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3631 # Parsing llobdstat's output sucks; we could grep the /proc
3632 # path, but that's likely to not be as portable as using the
3633 # llobdstat utility. So we parse lctl output instead.
3634 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3635 obdfilter/$ostname/stats |
3636 awk '/^write_bytes/ {print $7}' )
3637 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3638 if (( ${write_bytes:-0} > 0 ))
3645 $all_zeros || return 0
3648 echo foo > $DIR/$tdir/bar
3652 # Total up write_bytes after writing. We'd better find non-zeros.
3653 for ostnum in $(seq $OSTCOUNT); do
3654 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3655 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3656 obdfilter/$ostname/stats |
3657 awk '/^write_bytes/ {print $7}' )
3658 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3659 if (( ${write_bytes:-0} > 0 ))
3668 for ostnum in $(seq $OSTCOUNT); do
3669 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3670 echo "Check that write_bytes is present in obdfilter/*/stats:"
3671 do_facet ost$ostnum lctl get_param -n \
3672 obdfilter/$ostname/stats
3674 error "OST not keeping write_bytes stats (b22312)"
3677 run_test 33c "test llobdstat and write_bytes"
3680 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3684 local remote_dir=$DIR/$tdir/remote_dir
3686 test_mkdir $DIR/$tdir
3687 $LFS mkdir -i $MDTIDX $remote_dir ||
3688 error "create remote directory failed"
3690 touch $remote_dir/$tfile
3691 chmod 444 $remote_dir/$tfile
3692 chown $RUNAS_ID $remote_dir/$tfile
3694 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3696 chown $RUNAS_ID $remote_dir
3697 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3698 error "create" || true
3699 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3700 error "open RDWR" || true
3701 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3703 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3706 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3710 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3711 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3712 mkdir $DIR/$tdir/local_dir
3714 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3715 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3716 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3718 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3719 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3721 rmdir $DIR/$tdir/* || error "rmdir failed"
3724 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3725 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3726 mkdir $DIR/$tdir/local_dir
3728 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3729 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3730 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3732 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3733 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3735 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3738 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3739 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3740 mkdir $DIR/$tdir/local_dir
3742 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3743 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3744 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3746 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3747 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3749 run_test 33e "mkdir and striped directory should have same mode"
3753 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3757 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3758 remote_mds_nodsh && skip "remote MDS with nodsh"
3761 chmod go+rwx $DIR/$tdir
3762 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3763 trap cleanup_33f EXIT
3765 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3766 error "cannot create striped directory"
3768 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3769 error "cannot create files in striped directory"
3771 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3772 error "cannot remove files in striped directory"
3774 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3775 error "cannot remove striped directory"
3779 run_test 33f "nonroot user can create, access, and remove a striped directory"
3782 mkdir -p $DIR/$tdir/dir2
3784 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3786 [[ $err =~ "exists" ]] || error "Not exists error"
3788 run_test 33g "nonroot user create already existing root created file"
3791 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3792 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
3793 skip "Need MDS version at least 2.13.50"
3795 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir ||
3796 error "mkdir $tdir failed"
3797 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
3799 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
3802 for fname in $DIR/$tdir/$tfile.bak \
3803 $DIR/$tdir/$tfile.SAV \
3804 $DIR/$tdir/$tfile.orig \
3805 $DIR/$tdir/$tfile~; do
3806 touch $fname || error "touch $fname failed"
3807 index2=$($LFS getstripe -m $fname)
3808 [ $index -eq $index2 ] ||
3809 error "$fname MDT index mismatch $index != $index2"
3813 for i in {1..50}; do
3814 for fname in $(mktemp -u $DIR/$tdir/.$tfile.XXXXXX) \
3815 $(mktemp $DIR/$tdir/$tfile.XXXXXXXX); do
3816 touch $fname || error "touch $fname failed"
3817 index2=$($LFS getstripe -m $fname)
3818 if [[ $index != $index2 ]]; then
3819 failed=$((failed + 1))
3820 echo "$fname MDT index mismatch $index != $index2"
3824 echo "$failed MDT index mismatches"
3825 (( failed < 4 )) || error "MDT index mismatch $failed times"
3828 run_test 33h "temp file is located on the same MDT as target"
3830 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3833 $MCREATE $DIR/f34 || error "mcreate failed"
3834 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3835 error "getstripe failed"
3836 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3837 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3838 error "getstripe failed"
3839 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3840 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3842 run_test 34a "truncate file that has not been opened ==========="
3845 [ ! -f $DIR/f34 ] && test_34a
3846 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3847 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3848 $OPENFILE -f O_RDONLY $DIR/f34
3849 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3850 error "getstripe failed"
3851 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3852 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3854 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3857 [ ! -f $DIR/f34 ] && test_34a
3858 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3859 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3860 $OPENFILE -f O_RDWR $DIR/f34
3861 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3862 error "$LFS getstripe failed"
3863 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3864 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3866 run_test 34c "O_RDWR opening file-with-size works =============="
3869 [ ! -f $DIR/f34 ] && test_34a
3870 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3872 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3873 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3876 run_test 34d "write to sparse file ============================="
3880 $MCREATE $DIR/f34e || error "mcreate failed"
3881 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3882 $CHECKSTAT -s 1000 $DIR/f34e ||
3883 error "Size of $DIR/f34e not equal to 1000 bytes"
3884 $OPENFILE -f O_RDWR $DIR/f34e
3885 $CHECKSTAT -s 1000 $DIR/f34e ||
3886 error "Size of $DIR/f34e not equal to 1000 bytes"
3888 run_test 34e "create objects, some with size and some without =="
3890 test_34f() { # bug 6242, 6243
3891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3895 $MCREATE $DIR/f34f || error "mcreate failed"
3896 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3897 dd if=$DIR/f34f of=$TMP/f34f
3898 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3899 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3900 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3901 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3902 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3904 run_test 34f "read from a file with no objects until EOF ======="
3907 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3909 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3911 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3912 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3913 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3914 cancel_lru_locks osc
3915 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3916 error "wrong size after lock cancel"
3918 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3919 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3920 error "expanding truncate failed"
3921 cancel_lru_locks osc
3922 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3923 error "wrong expanded size after lock cancel"
3925 run_test 34g "truncate long file ==============================="
3928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3933 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3934 sync # Flush the cache so that multiop below does not block on cache
3935 # flush when getting the group lock
3936 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3939 # Since just timed wait is not good enough, let's do a sync write
3940 # that way we are sure enough time for a roundtrip + processing
3941 # passed + 2 seconds of extra margin.
3942 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3946 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3947 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3951 local nsz=`stat -c %s $DIR/$tfile`
3952 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3954 run_test 34h "ftruncate file under grouplock should not block"
3957 cp /bin/sh $DIR/f35a
3959 chown $RUNAS_ID $DIR/f35a
3960 $RUNAS $DIR/f35a && error || true
3963 run_test 35a "exec file with mode 444 (should return and not leak)"
3967 utime $DIR/f36 || error "utime failed for MDS"
3969 run_test 36a "MDS utime check (mknod, utime)"
3973 utime $DIR/f36 || error "utime failed for OST"
3975 run_test 36b "OST utime check (open, utime)"
3980 chown $RUNAS_ID $DIR/d36
3981 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3983 run_test 36c "non-root MDS utime check (mknod, utime)"
3986 [ ! -d $DIR/d36 ] && test_36c
3987 echo "" > $DIR/d36/f36
3988 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3990 run_test 36d "non-root OST utime check (open, utime)"
3993 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3995 test_mkdir $DIR/$tdir
3996 touch $DIR/$tdir/$tfile
3997 $RUNAS utime $DIR/$tdir/$tfile &&
3998 error "utime worked, expected failure" || true
4000 run_test 36e "utime on non-owned file (should return error)"
4004 local LANG_SAVE=$LANG
4005 local LC_LANG_SAVE=$LC_LANG
4006 export LANG=C LC_LANG=C # for date language
4008 DATESTR="Dec 20 2000"
4009 test_mkdir $DIR/$tdir
4010 lctl set_param fail_loc=$fl
4012 cp /etc/hosts $DIR/$tdir/$tfile
4013 sync & # write RPC generated with "current" inode timestamp, but delayed
4015 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4016 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4017 cancel_lru_locks $OSC
4018 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4020 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4021 echo "BEFORE: $LS_BEFORE" && \
4022 echo "AFTER : $LS_AFTER" && \
4023 echo "WANT : $DATESTR" && \
4024 error "$DIR/$tdir/$tfile timestamps changed" || true
4026 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4030 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4032 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4033 subr_36fh "0x80000214"
4035 run_test 36f "utime on file racing with OST BRW write =========="
4038 remote_ost_nodsh && skip "remote OST with nodsh"
4039 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4040 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4041 skip "Need MDS version at least 2.12.51"
4046 local tgt="obdfilter"
4048 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4050 test_mkdir $DIR/$tdir
4051 fmd_max_age=$(do_facet $facet \
4052 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4055 echo "FMD max age: ${fmd_max_age}s"
4056 touch $DIR/$tdir/$tfile
4057 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4058 gawk '{cnt=cnt+$1} END{print cnt}')
4059 echo "FMD before: $fmd"
4061 error "FMD wasn't create by touch"
4062 sleep $((fmd_max_age + 12))
4063 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4064 gawk '{cnt=cnt+$1} END{print cnt}')
4065 echo "FMD after: $fmd"
4067 error "FMD wasn't expired by ping"
4069 run_test 36g "FMD cache expiry ====================="
4072 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4074 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4075 subr_36fh "0x80000227"
4077 run_test 36h "utime on file racing with OST BRW write =========="
4080 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4082 test_mkdir $DIR/$tdir
4083 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4085 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4086 local new_mtime=$((mtime + 200))
4088 #change Modify time of striped dir
4089 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4090 error "change mtime failed"
4092 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4094 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4096 run_test 36i "change mtime on striped directory"
4098 # test_37 - duplicate with tests 32q 32r
4101 local file=$DIR/$tfile
4103 openfile -f O_DIRECTORY $file
4106 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4107 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4109 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4111 test_39a() { # was test_39
4113 touch $DIR/${tfile}2
4114 # ls -l $DIR/$tfile $DIR/${tfile}2
4115 # ls -lu $DIR/$tfile $DIR/${tfile}2
4116 # ls -lc $DIR/$tfile $DIR/${tfile}2
4118 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4119 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4121 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4123 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4125 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4126 error "O_TRUNC didn't change timestamps"
4129 run_test 39a "mtime changed on create"
4132 test_mkdir -c1 $DIR/$tdir
4133 cp -p /etc/passwd $DIR/$tdir/fopen
4134 cp -p /etc/passwd $DIR/$tdir/flink
4135 cp -p /etc/passwd $DIR/$tdir/funlink
4136 cp -p /etc/passwd $DIR/$tdir/frename
4137 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4140 echo "aaaaaa" >> $DIR/$tdir/fopen
4141 echo "aaaaaa" >> $DIR/$tdir/flink
4142 echo "aaaaaa" >> $DIR/$tdir/funlink
4143 echo "aaaaaa" >> $DIR/$tdir/frename
4145 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4146 local link_new=`stat -c %Y $DIR/$tdir/flink`
4147 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4148 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4150 cat $DIR/$tdir/fopen > /dev/null
4151 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4152 rm -f $DIR/$tdir/funlink2
4153 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4155 for (( i=0; i < 2; i++ )) ; do
4156 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4157 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4158 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4159 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4161 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4162 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4163 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4164 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4166 cancel_lru_locks $OSC
4167 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4170 run_test 39b "mtime change on open, link, unlink, rename ======"
4172 # this should be set to past
4173 TEST_39_MTIME=`date -d "1 year ago" +%s`
4179 local mtime0=`stat -c %Y $DIR1/$tfile`
4181 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4182 local mtime1=`stat -c %Y $DIR1/$tfile`
4183 [ "$mtime1" = $TEST_39_MTIME ] || \
4184 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4187 echo hello >> $DIR1/$tfile
4189 local mtime2=`stat -c %Y $DIR1/$tfile`
4190 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4191 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4193 mv $DIR1/$tfile $DIR1/$tfile-1
4195 for (( i=0; i < 2; i++ )) ; do
4196 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4197 [ "$mtime2" = "$mtime3" ] || \
4198 error "mtime ($mtime2) changed (to $mtime3) on rename"
4200 cancel_lru_locks $OSC
4201 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4204 run_test 39c "mtime change on rename ==========================="
4208 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4211 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4213 for (( i=0; i < 2; i++ )) ; do
4214 local mtime=`stat -c %Y $DIR1/$tfile`
4215 [ $mtime = $TEST_39_MTIME ] || \
4216 error "mtime($mtime) is not set to $TEST_39_MTIME"
4218 cancel_lru_locks $OSC
4219 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4222 run_test 39d "create, utime, stat =============================="
4226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4229 local mtime1=`stat -c %Y $DIR1/$tfile`
4231 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4233 for (( i=0; i < 2; i++ )) ; do
4234 local mtime2=`stat -c %Y $DIR1/$tfile`
4235 [ $mtime2 = $TEST_39_MTIME ] || \
4236 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4238 cancel_lru_locks $OSC
4239 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4242 run_test 39e "create, stat, utime, stat ========================"
4246 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4249 mtime1=`stat -c %Y $DIR1/$tfile`
4252 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4254 for (( i=0; i < 2; i++ )) ; do
4255 local mtime2=`stat -c %Y $DIR1/$tfile`
4256 [ $mtime2 = $TEST_39_MTIME ] || \
4257 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4259 cancel_lru_locks $OSC
4260 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4263 run_test 39f "create, stat, sleep, utime, stat ================="
4267 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4269 echo hello >> $DIR1/$tfile
4270 local mtime1=`stat -c %Y $DIR1/$tfile`
4273 chmod o+r $DIR1/$tfile
4275 for (( i=0; i < 2; i++ )) ; do
4276 local mtime2=`stat -c %Y $DIR1/$tfile`
4277 [ "$mtime1" = "$mtime2" ] || \
4278 error "lost mtime: $mtime2, should be $mtime1"
4280 cancel_lru_locks $OSC
4281 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4284 run_test 39g "write, chmod, stat ==============================="
4288 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4294 echo hello >> $DIR1/$tfile
4295 local mtime1=`stat -c %Y $DIR1/$tfile`
4297 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4299 if [ "$d1" != "$d2" ]; then
4300 echo "write and touch not within one second"
4302 for (( i=0; i < 2; i++ )) ; do
4303 local mtime2=`stat -c %Y $DIR1/$tfile`
4304 [ "$mtime2" = $TEST_39_MTIME ] || \
4305 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4307 cancel_lru_locks $OSC
4308 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4312 run_test 39h "write, utime within one second, stat ============="
4315 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4320 echo hello >> $DIR1/$tfile
4321 local mtime1=`stat -c %Y $DIR1/$tfile`
4323 mv $DIR1/$tfile $DIR1/$tfile-1
4325 for (( i=0; i < 2; i++ )) ; do
4326 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4328 [ "$mtime1" = "$mtime2" ] || \
4329 error "lost mtime: $mtime2, should be $mtime1"
4331 cancel_lru_locks $OSC
4332 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4335 run_test 39i "write, rename, stat =============================="
4338 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4340 start_full_debug_logging
4344 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4345 lctl set_param fail_loc=0x80000412
4346 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4347 error "multiop failed"
4349 local mtime1=`stat -c %Y $DIR1/$tfile`
4351 mv $DIR1/$tfile $DIR1/$tfile-1
4353 kill -USR1 $multipid
4354 wait $multipid || error "multiop close failed"
4356 for (( i=0; i < 2; i++ )) ; do
4357 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4358 [ "$mtime1" = "$mtime2" ] ||
4359 error "mtime is lost on close: $mtime2, " \
4363 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4365 lctl set_param fail_loc=0
4366 stop_full_debug_logging
4368 run_test 39j "write, rename, close, stat ======================="
4371 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4376 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4378 local mtime1=`stat -c %Y $DIR1/$tfile`
4380 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4382 kill -USR1 $multipid
4383 wait $multipid || error "multiop close failed"
4385 for (( i=0; i < 2; i++ )) ; do
4386 local mtime2=`stat -c %Y $DIR1/$tfile`
4388 [ "$mtime2" = $TEST_39_MTIME ] || \
4389 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4392 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4395 run_test 39k "write, utime, close, stat ========================"
4397 # this should be set to future
4398 TEST_39_ATIME=`date -d "1 year" +%s`
4401 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4402 remote_mds_nodsh && skip "remote MDS with nodsh"
4404 local atime_diff=$(do_facet $SINGLEMDS \
4405 lctl get_param -n mdd.*MDT0000*.atime_diff)
4409 # test setting directory atime to future
4410 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4411 local atime=$(stat -c %X $DIR/$tdir)
4412 [ "$atime" = $TEST_39_ATIME ] ||
4413 error "atime is not set to future: $atime, $TEST_39_ATIME"
4415 # test setting directory atime from future to now
4416 local now=$(date +%s)
4417 touch -a -d @$now $DIR/$tdir
4419 atime=$(stat -c %X $DIR/$tdir)
4420 [ "$atime" -eq "$now" ] ||
4421 error "atime is not updated from future: $atime, $now"
4423 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4426 # test setting directory atime when now > dir atime + atime_diff
4427 local d1=$(date +%s)
4429 local d2=$(date +%s)
4430 cancel_lru_locks mdc
4431 atime=$(stat -c %X $DIR/$tdir)
4432 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4433 error "atime is not updated : $atime, should be $d2"
4435 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4438 # test not setting directory atime when now < dir atime + atime_diff
4440 cancel_lru_locks mdc
4441 atime=$(stat -c %X $DIR/$tdir)
4442 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4443 error "atime is updated to $atime, should remain $d1<atime<$d2"
4445 do_facet $SINGLEMDS \
4446 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4448 run_test 39l "directory atime update ==========================="
4451 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4455 local far_past_mtime=$(date -d "May 29 1953" +%s)
4456 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4458 touch -m -d @$far_past_mtime $DIR1/$tfile
4459 touch -a -d @$far_past_atime $DIR1/$tfile
4461 for (( i=0; i < 2; i++ )) ; do
4462 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4463 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4464 error "atime or mtime set incorrectly"
4466 cancel_lru_locks $OSC
4467 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4470 run_test 39m "test atime and mtime before 1970"
4472 test_39n() { # LU-3832
4473 remote_mds_nodsh && skip "remote MDS with nodsh"
4475 local atime_diff=$(do_facet $SINGLEMDS \
4476 lctl get_param -n mdd.*MDT0000*.atime_diff)
4481 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4484 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4485 atime0=$(stat -c %X $DIR/$tfile)
4488 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4489 atime1=$(stat -c %X $DIR/$tfile)
4492 cancel_lru_locks mdc
4493 cancel_lru_locks osc
4494 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4495 atime2=$(stat -c %X $DIR/$tfile)
4497 do_facet $SINGLEMDS \
4498 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4500 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4501 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4503 run_test 39n "check that O_NOATIME is honored"
4506 TESTDIR=$DIR/$tdir/$tfile
4507 [ -e $TESTDIR ] && rm -rf $TESTDIR
4514 links2=$(stat -c %h .)
4515 [ $(($links1 + 2)) != $links2 ] &&
4516 error "wrong links count $(($links1 + 2)) != $links2"
4518 links3=$(stat -c %h .)
4519 [ $(($links1 + 1)) != $links3 ] &&
4520 error "wrong links count $links1 != $links3"
4523 run_test 39o "directory cached attributes updated after create"
4526 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4529 TESTDIR=$DIR/$tdir/$tdir
4530 [ -e $TESTDIR ] && rm -rf $TESTDIR
4531 test_mkdir -p $TESTDIR
4535 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4536 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4538 links2=$(stat -c %h .)
4539 [ $(($links1 + 2)) != $links2 ] &&
4540 error "wrong links count $(($links1 + 2)) != $links2"
4542 links3=$(stat -c %h .)
4543 [ $(($links1 + 1)) != $links3 ] &&
4544 error "wrong links count $links1 != $links3"
4547 run_test 39p "remote directory cached attributes updated after create ========"
4550 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
4551 skip "no atime update on old OST"
4552 if [ "$ost1_FSTYPE" != ldiskfs ]; then
4553 skip_env "ldiskfs only test"
4557 saved_adiff=$(do_facet ost1 \
4558 lctl get_param -n obdfilter.*OST0000.atime_diff)
4559 stack_trap "do_facet ost1 \
4560 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
4562 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
4564 $LFS setstripe -i 0 $DIR/$tfile
4565 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
4566 error "can't write initial file"
4567 cancel_lru_locks osc
4569 # exceed atime_diff and access file
4571 dd if=$DIR/$tfile of=/dev/null || error "can't udpate atime"
4573 local atime_cli=$(stat -c %X $DIR/$tfile)
4574 echo "client atime: $atime_cli"
4575 # allow atime update to be written to device
4576 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
4579 local ostdev=$(ostdevname 1)
4580 local fid=($(lfs getstripe -y $DIR/$tfile |
4581 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
4582 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
4583 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
4585 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
4586 local atime_ost=$(do_facet ost1 "$cmd" |&
4587 awk -F'[: ]' '/atime:/ { print $4 }')
4588 (( atime_cli == atime_ost )) ||
4589 error "atime on client $atime_cli != ost $atime_ost"
4591 run_test 39r "lazy atime update on OST"
4593 test_39q() { # LU-8041
4594 local testdir=$DIR/$tdir
4596 multiop_bg_pause $testdir D_c || error "multiop failed"
4598 cancel_lru_locks mdc
4599 kill -USR1 $multipid
4600 local atime=$(stat -c %X $testdir)
4601 [ "$atime" -ne 0 ] || error "atime is zero"
4603 run_test 39q "close won't zero out atime"
4606 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4607 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4608 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4609 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4610 error "$tfile is not 4096 bytes in size"
4612 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4616 small_write $DIR/f41 18
4618 run_test 41 "test small file write + fstat ====================="
4620 count_ost_writes() {
4621 lctl get_param -n ${OSC}.*.stats |
4622 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4623 END { printf("%0.0f", writes) }'
4630 BG_DIRTY_RATIO_SAVE=10
4631 MAX_BG_DIRTY_RATIO=25
4635 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4636 # dirty_ratio, dirty_background_ratio
4637 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4638 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4639 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4640 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4642 # if file not here, we are a 2.4 kernel
4643 kill -CONT `pidof kupdated`
4648 # setup the trap first, so someone cannot exit the test at the
4649 # exact wrong time and mess up a machine
4650 trap start_writeback EXIT
4651 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4652 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4653 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4654 sysctl -w vm.dirty_writeback_centisecs=0
4655 sysctl -w vm.dirty_writeback_centisecs=0
4656 # save and increase /proc/sys/vm/dirty_ratio
4657 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4658 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4659 # save and increase /proc/sys/vm/dirty_background_ratio
4660 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4661 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4663 # if file not here, we are a 2.4 kernel
4664 kill -STOP `pidof kupdated`
4668 # ensure that all stripes have some grant before we test client-side cache
4670 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4671 dd if=/dev/zero of=$i bs=4k count=1
4676 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4677 # file truncation, and file removal.
4679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4682 cancel_lru_locks $OSC
4684 sync; sleep 1; sync # just to be safe
4685 BEFOREWRITES=`count_ost_writes`
4686 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4687 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4688 AFTERWRITES=`count_ost_writes`
4689 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4690 error "$BEFOREWRITES < $AFTERWRITES"
4693 run_test 42a "ensure that we don't flush on close"
4696 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4699 cancel_lru_locks $OSC
4702 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4703 BEFOREWRITES=$(count_ost_writes)
4704 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4705 AFTERWRITES=$(count_ost_writes)
4706 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4707 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4709 BEFOREWRITES=$(count_ost_writes)
4710 sync || error "sync: $?"
4711 AFTERWRITES=$(count_ost_writes)
4712 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4713 error "$BEFOREWRITES < $AFTERWRITES on sync"
4715 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4719 run_test 42b "test destroy of file with cached dirty data ======"
4721 # if these tests just want to test the effect of truncation,
4722 # they have to be very careful. consider:
4723 # - the first open gets a {0,EOF}PR lock
4724 # - the first write conflicts and gets a {0, count-1}PW
4725 # - the rest of the writes are under {count,EOF}PW
4726 # - the open for truncate tries to match a {0,EOF}PR
4727 # for the filesize and cancels the PWs.
4728 # any number of fixes (don't get {0,EOF} on open, match
4729 # composite locks, do smarter file size management) fix
4730 # this, but for now we want these tests to verify that
4731 # the cancellation with truncate intent works, so we
4732 # start the file with a full-file pw lock to match against
4733 # until the truncate.
4738 cancel_lru_locks $OSC
4740 # prime the file with 0,EOF PW to match
4744 # now the real test..
4745 dd if=/dev/zero of=$file bs=1024 count=100
4746 BEFOREWRITES=`count_ost_writes`
4747 $TRUNCATE $file $offset
4748 cancel_lru_locks $OSC
4749 AFTERWRITES=`count_ost_writes`
4754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4757 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4758 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4761 run_test 42c "test partial truncate of file with cached dirty data"
4764 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4767 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4768 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4771 run_test 42d "test complete truncate of file with cached dirty data"
4773 test_42e() { # bug22074
4774 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4776 local TDIR=$DIR/${tdir}e
4777 local pages=16 # hardcoded 16 pages, don't change it.
4778 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4779 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4783 test_mkdir $DIR/${tdir}e
4784 $LFS setstripe -c 1 $TDIR
4785 createmany -o $TDIR/f $files
4787 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4789 # we assume that with $OSTCOUNT files, at least one of them will
4790 # be allocated on OST0.
4791 warmup_files=$((OSTCOUNT * max_dirty_mb))
4792 createmany -o $TDIR/w $warmup_files
4794 # write a large amount of data into one file and sync, to get good
4795 # avail_grant number from OST.
4796 for ((i=0; i<$warmup_files; i++)); do
4797 idx=$($LFS getstripe -i $TDIR/w$i)
4798 [ $idx -ne 0 ] && continue
4799 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4802 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4804 $LCTL get_param $proc_osc0/cur_dirty_bytes
4805 $LCTL get_param $proc_osc0/cur_grant_bytes
4807 # create as much dirty pages as we can while not to trigger the actual
4808 # RPCs directly. but depends on the env, VFS may trigger flush during this
4809 # period, hopefully we are good.
4810 for ((i=0; i<$warmup_files; i++)); do
4811 idx=$($LFS getstripe -i $TDIR/w$i)
4812 [ $idx -ne 0 ] && continue
4813 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4815 $LCTL get_param $proc_osc0/cur_dirty_bytes
4816 $LCTL get_param $proc_osc0/cur_grant_bytes
4818 # perform the real test
4819 $LCTL set_param $proc_osc0/rpc_stats 0
4820 for ((;i<$files; i++)); do
4821 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
4822 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4825 $LCTL get_param $proc_osc0/rpc_stats
4828 local have_ppr=false
4829 $LCTL get_param $proc_osc0/rpc_stats |
4830 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4831 # skip lines until we are at the RPC histogram data
4832 [ "$PPR" == "pages" ] && have_ppr=true && continue
4833 $have_ppr || continue
4835 # we only want the percent stat for < 16 pages
4836 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4838 percent=$((percent + WPCT))
4839 if [[ $percent -gt 15 ]]; then
4840 error "less than 16-pages write RPCs" \
4847 run_test 42e "verify sub-RPC writes are not done synchronously"
4849 test_43A() { # was test_43
4850 test_mkdir $DIR/$tdir
4851 cp -p /bin/ls $DIR/$tdir/$tfile
4852 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4854 # give multiop a chance to open
4857 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4860 run_test 43A "execution of file opened for write should return -ETXTBSY"
4863 test_mkdir $DIR/$tdir
4864 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4865 $DIR/$tdir/sleep 60 &
4867 # Make sure exec of $tdir/sleep wins race with truncate
4869 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4872 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4875 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4877 test_mkdir $DIR/$tdir
4878 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4879 $DIR/$tdir/sleep 60 &
4881 # Make sure exec of $tdir/sleep wins race with truncate
4883 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4886 run_test 43b "truncate of file being executed should return -ETXTBSY"
4889 local testdir="$DIR/$tdir"
4892 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4893 ( cd $testdir && md5sum -c )
4895 run_test 43c "md5sum of copy into lustre"
4897 test_44A() { # was test_44
4898 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4900 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4901 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4903 run_test 44A "zero length read from a sparse stripe"
4906 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4908 [ -z "$nstripe" ] && skip "can't get stripe info"
4909 [[ $nstripe -gt $OSTCOUNT ]] &&
4910 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4912 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4914 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4915 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4919 OFFSETS="0 $((stride/2)) $((stride-1))"
4920 for offset in $OFFSETS; do
4921 for i in $(seq 0 $((nstripe-1))); do
4922 local GLOBALOFFSETS=""
4924 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4925 local myfn=$DIR/d44a-$size
4926 echo "--------writing $myfn at $size"
4927 ll_sparseness_write $myfn $size ||
4928 error "ll_sparseness_write"
4929 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4930 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4931 error "ll_sparseness_verify $GLOBALOFFSETS"
4933 for j in $(seq 0 $((nstripe-1))); do
4935 size=$((((j + $nstripe )*$stride + $offset)))
4936 ll_sparseness_write $myfn $size ||
4937 error "ll_sparseness_write"
4938 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4940 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4941 error "ll_sparseness_verify $GLOBALOFFSETS"
4946 run_test 44a "test sparse pwrite ==============================="
4950 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4956 before=`dirty_osc_total`
4957 echo executing "\"$*\""
4959 after=`dirty_osc_total`
4960 echo before $before, after $after
4963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4966 # Obtain grants from OST if it supports it
4967 echo blah > ${f}_grant
4970 do_dirty_record "echo blah > $f"
4971 [[ $before -eq $after ]] && error "write wasn't cached"
4972 do_dirty_record "> $f"
4973 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4974 do_dirty_record "echo blah > $f"
4975 [[ $before -eq $after ]] && error "write wasn't cached"
4976 do_dirty_record "sync"
4977 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4978 do_dirty_record "echo blah > $f"
4979 [[ $before -eq $after ]] && error "write wasn't cached"
4980 do_dirty_record "cancel_lru_locks osc"
4981 [[ $before -gt $after ]] ||
4982 error "lock cancellation didn't lower dirty count"
4985 run_test 45 "osc io page accounting ============================"
4987 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4988 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4989 # objects offset and an assert hit when an rpc was built with 1023's mapped
4990 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4992 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4997 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4999 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5000 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5004 run_test 46 "dirtying a previously written page ================"
5006 # test_47 is removed "Device nodes check" is moved to test_28
5008 test_48a() { # bug 2399
5009 [ "$mds1_FSTYPE" = "zfs" ] &&
5010 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5011 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5013 test_mkdir $DIR/$tdir
5015 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5016 test_mkdir $DIR/$tdir
5017 touch foo || error "'touch foo' failed after recreating cwd"
5019 touch .foo || error "'touch .foo' failed after recreating cwd"
5021 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5022 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5023 cd . || error "'cd .' failed after recreating cwd"
5024 mkdir . && error "'mkdir .' worked after recreating cwd"
5025 rmdir . && error "'rmdir .' worked after recreating cwd"
5026 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5027 cd .. || error "'cd ..' failed after recreating cwd"
5029 run_test 48a "Access renamed working dir (should return errors)="
5031 test_48b() { # bug 2399
5033 test_mkdir $DIR/$tdir
5035 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5036 touch foo && error "'touch foo' worked after removing cwd"
5037 mkdir foo && error "'mkdir foo' worked after removing cwd"
5038 touch .foo && error "'touch .foo' worked after removing cwd"
5039 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5040 ls . > /dev/null && error "'ls .' worked after removing cwd"
5041 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5042 mkdir . && error "'mkdir .' worked after removing cwd"
5043 rmdir . && error "'rmdir .' worked after removing cwd"
5044 ln -s . foo && error "'ln -s .' worked after removing cwd"
5045 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5047 run_test 48b "Access removed working dir (should return errors)="
5049 test_48c() { # bug 2350
5050 #lctl set_param debug=-1
5053 test_mkdir -p $DIR/$tdir/dir
5055 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5056 $TRACE touch foo && error "touch foo worked after removing cwd"
5057 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5058 touch .foo && error "touch .foo worked after removing cwd"
5059 mkdir .foo && error "mkdir .foo worked after removing cwd"
5060 $TRACE ls . && error "'ls .' worked after removing cwd"
5061 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5062 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5063 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5064 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5065 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5067 run_test 48c "Access removed working subdir (should return errors)"
5069 test_48d() { # bug 2350
5070 #lctl set_param debug=-1
5073 test_mkdir -p $DIR/$tdir/dir
5075 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5076 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5077 $TRACE touch foo && error "'touch foo' worked after removing parent"
5078 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5079 touch .foo && error "'touch .foo' worked after removing parent"
5080 mkdir .foo && error "mkdir .foo worked after removing parent"
5081 $TRACE ls . && error "'ls .' worked after removing parent"
5082 $TRACE ls .. && error "'ls ..' worked after removing parent"
5083 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5084 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5085 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5088 run_test 48d "Access removed parent subdir (should return errors)"
5090 test_48e() { # bug 4134
5091 #lctl set_param debug=-1
5094 test_mkdir -p $DIR/$tdir/dir
5096 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5097 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5098 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5099 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5100 # On a buggy kernel addition of "touch foo" after cd .. will
5101 # produce kernel oops in lookup_hash_it
5102 touch ../foo && error "'cd ..' worked after recreate parent"
5104 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5106 run_test 48e "Access to recreated parent subdir (should return errors)"
5108 test_49() { # LU-1030
5109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5110 remote_ost_nodsh && skip "remote OST with nodsh"
5112 # get ost1 size - $FSNAME-OST0000
5113 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5115 # write 800M at maximum
5116 [[ $ost1_size -lt 2 ]] && ost1_size=2
5117 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5119 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5120 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5123 # change max_pages_per_rpc while writing the file
5124 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5125 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5126 # loop until dd process exits
5127 while ps ax -opid | grep -wq $dd_pid; do
5128 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5129 sleep $((RANDOM % 5 + 1))
5131 # restore original max_pages_per_rpc
5132 $LCTL set_param $osc1_mppc=$orig_mppc
5133 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5135 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5139 test_mkdir $DIR/$tdir
5141 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5143 run_test 50 "special situations: /proc symlinks ==============="
5145 test_51a() { # was test_51
5146 # bug 1516 - create an empty entry right after ".." then split dir
5147 test_mkdir -c1 $DIR/$tdir
5148 touch $DIR/$tdir/foo
5149 $MCREATE $DIR/$tdir/bar
5151 createmany -m $DIR/$tdir/longfile 201
5153 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5154 $MCREATE $DIR/$tdir/longfile$FNUM
5159 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5161 run_test 51a "special situations: split htree with empty entry =="
5163 cleanup_print_lfs_df () {
5170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5172 local dir=$DIR/$tdir
5173 local nrdirs=$((65536 + 100))
5175 # cleanup the directory
5182 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5183 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5184 [[ $numfree -lt $nrdirs ]] &&
5185 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5187 # need to check free space for the directories as well
5188 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5189 numfree=$(( blkfree / $(fs_inode_ksize) ))
5190 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5192 trap cleanup_print_lfs_df EXIT
5195 createmany -d $dir/d $nrdirs || {
5196 unlinkmany $dir/d $nrdirs
5197 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5201 nrdirs=$(ls -U $dir | wc -l)
5203 # unlink all but 100 subdirectories, then check it still works
5205 local delete=$((nrdirs - left))
5210 # for ldiskfs the nlink count should be 1, but this is OSD specific
5211 # and so this is listed for informational purposes only
5212 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5213 unlinkmany -d $dir/d $delete ||
5214 error "unlink of first $delete subdirs failed"
5216 echo "nlink between: $(stat -c %h $dir)"
5217 local found=$(ls -U $dir | wc -l)
5218 [ $found -ne $left ] &&
5219 error "can't find subdirs: found only $found, expected $left"
5221 unlinkmany -d $dir/d $delete $left ||
5222 error "unlink of second $left subdirs failed"
5223 # regardless of whether the backing filesystem tracks nlink accurately
5224 # or not, the nlink count shouldn't be more than "." and ".." here
5225 local after=$(stat -c %h $dir)
5226 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5227 echo "nlink after: $after"
5229 cleanup_print_lfs_df
5231 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5235 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5237 test_mkdir $DIR/$tdir
5238 createmany -o $DIR/$tdir/t- 1000
5239 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5240 for N in $(seq 0 $((OSTCOUNT - 1))); do
5241 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
5242 END { printf("%0.0f", objs) }' $TMP/$tfile)
5243 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5244 '($1 == '$N') { objs += 1 } \
5245 END { printf("%0.0f", objs) }')
5246 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
5248 unlinkmany $DIR/$tdir/t- 1000
5251 for N in $(seq 1 $((OSTCOUNT - 1))); do
5252 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
5253 error "OST $N has less objects vs OST $NLAST" \
5254 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5255 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
5256 error "OST $N has less objects vs OST $NLAST" \
5257 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5259 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
5260 error "OST $N has less #0 objects vs OST $NLAST" \
5261 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5262 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
5263 error "OST $N has less #0 objects vs OST $NLAST" \
5264 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5269 run_test 51d "check object distribution"
5272 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5273 skip_env "ldiskfs only test"
5276 test_mkdir -c1 $DIR/$tdir
5277 test_mkdir -c1 $DIR/$tdir/d0
5279 touch $DIR/$tdir/d0/foo
5280 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5281 error "file exceed 65000 nlink limit!"
5282 unlinkmany $DIR/$tdir/d0/f- 65001
5285 run_test 51e "check file nlink limit"
5288 test_mkdir $DIR/$tdir
5291 local ulimit_old=$(ulimit -n)
5292 local spare=20 # number of spare fd's for scripts/libraries, etc.
5293 local mdt=$($LFS getstripe -m $DIR/$tdir)
5294 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5296 echo "MDT$mdt numfree=$numfree, max=$max"
5297 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5298 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5299 while ! ulimit -n $((numfree + spare)); do
5300 numfree=$((numfree * 3 / 4))
5302 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5304 echo "left ulimit at $ulimit_old"
5307 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5308 unlinkmany $DIR/$tdir/f $numfree
5309 error "create+open $numfree files in $DIR/$tdir failed"
5311 ulimit -n $ulimit_old
5313 # if createmany exits at 120s there will be fewer than $numfree files
5314 unlinkmany $DIR/$tdir/f $numfree || true
5316 run_test 51f "check many open files limit"
5319 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5320 test_mkdir $DIR/$tdir
5321 touch $DIR/$tdir/foo
5322 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5323 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5324 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5325 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5326 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5328 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5329 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5330 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5332 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5333 cp -r $DIR/$tdir $TMP/
5334 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5336 run_test 52a "append-only flag test (should return errors)"
5339 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5340 test_mkdir $DIR/$tdir
5341 touch $DIR/$tdir/foo
5342 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5343 cat test > $DIR/$tdir/foo && error "cat test worked"
5344 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5345 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5346 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5348 echo foo >> $DIR/$tdir/foo && error "echo worked"
5349 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5350 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5351 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5352 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5354 chattr -i $DIR/$tdir/foo || error "chattr failed"
5356 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5358 run_test 52b "immutable flag test (should return errors) ======="
5361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5362 remote_mds_nodsh && skip "remote MDS with nodsh"
5363 remote_ost_nodsh && skip "remote OST with nodsh"
5376 local support_last_seq=true
5378 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5379 support_last_seq=false
5382 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5384 for value in $(do_facet $SINGLEMDS \
5385 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5386 param=$(echo ${value[0]} | cut -d "=" -f1)
5387 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5389 if $support_last_seq; then
5390 param_seq=$(echo $param |
5391 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5392 mds_last_seq=$(do_facet $SINGLEMDS \
5393 $LCTL get_param -n $param_seq)
5395 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5397 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5398 node=$(facet_active_host ost$((ostnum+1)))
5399 param="obdfilter.$ostname.last_id"
5400 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5401 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5402 ost_last_id=$ost_last
5404 if $support_last_seq; then
5405 ost_last_id=$(echo $ost_last |
5406 awk -F':' '{print $2}' |
5408 ost_last_seq=$(echo $ost_last |
5409 awk -F':' '{print $1}')
5410 [[ $ost_last_seq = $mds_last_seq ]] || continue
5413 if [[ $ost_last_id != $mds_last ]]; then
5414 error "$ost_last_id != $mds_last"
5421 $found || error "can not match last_seq/last_id for $mdtosc"
5424 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5427 perl -MSocket -e ';' || skip "no Socket perl module installed"
5429 $SOCKETSERVER $DIR/socket ||
5430 error "$SOCKETSERVER $DIR/socket failed: $?"
5431 $SOCKETCLIENT $DIR/socket ||
5432 error "$SOCKETCLIENT $DIR/socket failed: $?"
5433 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5435 run_test 54a "unix domain socket test =========================="
5441 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5443 run_test 54b "char device works in lustre ======================"
5446 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5447 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5448 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5450 for i in $(seq 3 7); do
5451 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5460 loopdev="$DIR/loop54c"
5463 $UMOUNT $DIR/$tdir || rc=$?
5464 losetup -d $loopdev || true
5465 losetup -d $LOOPDEV || true
5466 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5471 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5473 loopdev="$DIR/loop54c"
5476 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5477 trap cleanup_54c EXIT
5478 mknod $loopdev b 7 $LOOPNUM
5479 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5480 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5481 losetup $loopdev $DIR/$tfile ||
5482 error "can't set up $loopdev for $DIR/$tfile"
5483 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5484 test_mkdir $DIR/$tdir
5485 mount -t ext2 $loopdev $DIR/$tdir ||
5486 error "error mounting $loopdev on $DIR/$tdir"
5487 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
5490 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
5494 run_test 54c "block device works in lustre ====================="
5500 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
5502 run_test 54d "fifo device works in lustre ======================"
5507 cp -aL /dev/console $f
5508 echo $string > $f || error "echo $string to $f failed"
5510 run_test 54e "console/tty device works in lustre ======================"
5514 local dir=$DIR/$tdir
5517 test_mkdir -p $dir/dir
5518 for i in $(seq $numfiles); do
5520 touch $dir/dir/file$i
5523 local numcomp=$($LFS getstripe --component-count $dir)
5525 [[ $numcomp == 0 ]] && numcomp=1
5527 # test lfs getstripe with --recursive
5528 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5530 [[ $filenum -eq $((numfiles * 2)) ]] ||
5531 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5532 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5533 [[ $filenum -eq $numfiles ]] ||
5534 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5535 echo "$LFS getstripe showed obdidx or l_ost_idx"
5537 # test lfs getstripe with file instead of dir
5538 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5539 [[ $filenum -eq 1 ]] ||
5540 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5541 echo "$LFS getstripe file1 passed"
5543 #test lfs getstripe with --verbose
5544 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5545 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5546 error "$LFS getstripe --verbose $dir: "\
5547 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5548 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5549 error "$LFS getstripe $dir: showed lmm_magic"
5551 #test lfs getstripe with -v prints lmm_fid
5552 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5553 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5554 error "$LFS getstripe -v $dir: "\
5555 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5556 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5557 error "$LFS getstripe $dir: showed lmm_fid by default"
5558 echo "$LFS getstripe --verbose passed"
5560 #check for FID information
5561 local fid1=$($LFS getstripe --fid $dir/file1)
5562 local fid2=$($LFS getstripe --verbose $dir/file1 |
5563 awk '/lmm_fid: / { print $2; exit; }')
5564 local fid3=$($LFS path2fid $dir/file1)
5566 [ "$fid1" != "$fid2" ] &&
5567 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5568 [ "$fid1" != "$fid3" ] &&
5569 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5570 echo "$LFS getstripe --fid passed"
5572 #test lfs getstripe with --obd
5573 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5574 error "$LFS getstripe --obd wrong_uuid: should return error"
5576 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5579 local obduuid=$(ostuuid_from_index $ostidx)
5580 local found=$($LFS getstripe -r --obd $obduuid $dir |
5581 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5583 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5584 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5586 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5589 [[ $found -eq $filenum ]] ||
5590 error "$LFS getstripe --obd: found $found expect $filenum"
5591 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5592 sed '/^[ ]*'${ostidx}'[ ]/d' |
5593 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5594 error "$LFS getstripe --obd: should not show file on other obd"
5595 echo "$LFS getstripe --obd passed"
5597 run_test 56a "check $LFS getstripe"
5600 local dir=$DIR/$tdir
5604 for i in $(seq $numdirs); do
5605 test_mkdir $dir/dir$i
5608 # test lfs getdirstripe default mode is non-recursion, which is
5609 # different from lfs getstripe
5610 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5612 [[ $dircnt -eq 1 ]] ||
5613 error "$LFS getdirstripe: found $dircnt, not 1"
5614 dircnt=$($LFS getdirstripe --recursive $dir |
5615 grep -c lmv_stripe_count)
5616 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5617 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5619 run_test 56b "check $LFS getdirstripe"
5622 remote_ost_nodsh && skip "remote OST with nodsh"
5625 local ost_name=$(ostname_from_index $ost_idx)
5626 local old_status=$(ost_dev_status $ost_idx)
5627 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
5629 [[ -z "$old_status" ]] ||
5630 skip_env "OST $ost_name is in $old_status status"
5632 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5633 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
5634 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
5635 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
5636 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
5637 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
5640 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
5641 error "$LFS df -v showing inactive devices"
5644 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
5646 [[ "$new_status" =~ "D" ]] ||
5647 error "$ost_name status is '$new_status', missing 'D'"
5648 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
5649 [[ "$new_status" =~ "N" ]] ||
5650 error "$ost_name status is '$new_status', missing 'N'"
5652 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
5653 [[ "$new_status" =~ "f" ]] ||
5654 error "$ost_name status is '$new_status', missing 'f'"
5657 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5658 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
5659 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
5660 [[ -z "$p" ]] && restore_lustre_params < $p || true
5663 new_status=$(ost_dev_status $ost_idx)
5664 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
5665 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
5666 # can't check 'f' as devices may actually be on flash
5668 run_test 56c "check 'lfs df' showing device status"
5671 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
5672 local osts=$($LFS df -v $MOUNT | grep -c OST)
5676 (( mdts == MDSCOUNT )) ||
5677 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
5678 (( osts == OSTCOUNT )) ||
5679 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
5681 run_test 56d "'lfs df -v' prints only configured devices"
5686 local local_tdir="$1"
5687 local local_numfiles="$2"
5688 local local_numdirs="$3"
5689 local dir_params="$4"
5690 local dir_stripe_params="$5"
5692 if [ ! -d "$local_tdir" ] ; then
5693 test_mkdir -p $dir_stripe_params $local_tdir
5694 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5695 for i in $(seq $local_numfiles) ; do
5696 touch $local_tdir/file$i
5698 for i in $(seq $local_numdirs) ; do
5699 test_mkdir $dir_stripe_params $local_tdir/dir$i
5700 for j in $(seq $local_numfiles) ; do
5701 touch $local_tdir/dir$i/file$j
5707 setup_56_special() {
5709 local local_numfiles=$2
5710 local local_numdirs=$3
5712 setup_56 $local_tdir $local_numfiles $local_numdirs
5714 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5715 for i in $(seq $local_numfiles) ; do
5716 mknod $local_tdir/loop${i}b b 7 $i
5717 mknod $local_tdir/null${i}c c 1 3
5718 ln -s $local_tdir/file1 $local_tdir/link${i}
5720 for i in $(seq $local_numdirs) ; do
5721 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5722 mknod $local_tdir/dir$i/null${i}c c 1 3
5723 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5729 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5730 local expected=$(($NUMDIRS + 2))
5732 setup_56 $dir $NUMFILES $NUMDIRS
5734 # test lfs find with -name
5735 for i in $(seq $NUMFILES) ; do
5736 local nums=$($LFS find -name "*$i" $dir | wc -l)
5738 [ $nums -eq $expected ] ||
5739 error "lfs find -name '*$i' $dir wrong: "\
5740 "found $nums, expected $expected"
5743 run_test 56g "check lfs find -name"
5746 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5747 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5749 setup_56 $dir $NUMFILES $NUMDIRS
5751 # test lfs find with ! -name
5752 for i in $(seq $NUMFILES) ; do
5753 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5755 [ $nums -eq $expected ] ||
5756 error "lfs find ! -name '*$i' $dir wrong: "\
5757 "found $nums, expected $expected"
5760 run_test 56h "check lfs find ! -name"
5763 local dir=$DIR/$tdir
5767 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5770 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5772 run_test 56i "check 'lfs find -ost UUID' skips directories"
5775 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5777 setup_56_special $dir $NUMFILES $NUMDIRS
5779 local expected=$((NUMDIRS + 1))
5780 local cmd="$LFS find -type d $dir"
5781 local nums=$($cmd | wc -l)
5783 [ $nums -eq $expected ] ||
5784 error "'$cmd' wrong: found $nums, expected $expected"
5786 run_test 56j "check lfs find -type d"
5789 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5791 setup_56_special $dir $NUMFILES $NUMDIRS
5793 local expected=$(((NUMDIRS + 1) * NUMFILES))
5794 local cmd="$LFS find -type f $dir"
5795 local nums=$($cmd | wc -l)
5797 [ $nums -eq $expected ] ||
5798 error "'$cmd' wrong: found $nums, expected $expected"
5800 run_test 56k "check lfs find -type f"
5803 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5805 setup_56_special $dir $NUMFILES $NUMDIRS
5807 local expected=$((NUMDIRS + NUMFILES))
5808 local cmd="$LFS find -type b $dir"
5809 local nums=$($cmd | wc -l)
5811 [ $nums -eq $expected ] ||
5812 error "'$cmd' wrong: found $nums, expected $expected"
5814 run_test 56l "check lfs find -type b"
5817 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5819 setup_56_special $dir $NUMFILES $NUMDIRS
5821 local expected=$((NUMDIRS + NUMFILES))
5822 local cmd="$LFS find -type c $dir"
5823 local nums=$($cmd | wc -l)
5824 [ $nums -eq $expected ] ||
5825 error "'$cmd' wrong: found $nums, expected $expected"
5827 run_test 56m "check lfs find -type c"
5830 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5831 setup_56_special $dir $NUMFILES $NUMDIRS
5833 local expected=$((NUMDIRS + NUMFILES))
5834 local cmd="$LFS find -type l $dir"
5835 local nums=$($cmd | wc -l)
5837 [ $nums -eq $expected ] ||
5838 error "'$cmd' wrong: found $nums, expected $expected"
5840 run_test 56n "check lfs find -type l"
5843 local dir=$DIR/$tdir
5845 setup_56 $dir $NUMFILES $NUMDIRS
5846 utime $dir/file1 > /dev/null || error "utime (1)"
5847 utime $dir/file2 > /dev/null || error "utime (2)"
5848 utime $dir/dir1 > /dev/null || error "utime (3)"
5849 utime $dir/dir2 > /dev/null || error "utime (4)"
5850 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5851 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5854 local nums=$($LFS find -mtime +0 $dir | wc -l)
5856 [ $nums -eq $expected ] ||
5857 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5860 cmd="$LFS find -mtime 0 $dir"
5861 nums=$($cmd | wc -l)
5862 [ $nums -eq $expected ] ||
5863 error "'$cmd' wrong: found $nums, expected $expected"
5865 run_test 56o "check lfs find -mtime for old files"
5868 local dir=$DIR/$tdir
5872 # just to make sure there is something that won't be found
5874 touch $dir/$tfile.now
5876 for age in year week day hour min; do
5877 count=$((count + 1))
5879 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
5880 touch --date="$count $age ago" -a $dir/$tfile-a.$age
5881 touch --date="$count $age ago" -m $dir/$tfile-m.$age
5883 local cmd="$LFS find $dir -mtime $count${age:0:1}"
5884 local nums=$($cmd | wc -l)
5885 [ $nums -eq $expected ] ||
5886 error "'$cmd' wrong: found $nums, expected $expected"
5888 cmd="$LFS find $dir -atime $count${age:0:1}"
5889 nums=$($cmd | wc -l)
5890 [ $nums -eq $expected ] ||
5891 error "'$cmd' wrong: found $nums, expected $expected"
5895 cmd="$LFS find $dir -ctime +1s -type f"
5896 nums=$($cmd | wc -l)
5897 (( $nums == $count * 2 + 1)) ||
5898 error "'$cmd' wrong: found $nums, expected $((expected*2+1))"
5900 run_test 56ob "check lfs find -atime -mtime -ctime with units"
5902 test_newerXY_base() {
5905 local dir=$DIR/$tdir
5909 if [ $y == "t" ]; then
5910 if [ $x == "b" ]; then
5911 ref="\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\""
5913 ref="\"$(date +"%Y-%m-%d %H:%M:%S")\""
5916 ref=$DIR/$tfile.newer.$x$y
5917 touch $ref || error "touch $ref failed"
5920 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
5922 if [ $y == "t" ]; then
5923 if [ $x == "b" ]; then
5924 negref="\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\""
5926 negref="\"$(date +"%Y-%m-%d %H:%M:%S")\""
5929 negref=$DIR/$tfile.negnewer.$x$y
5930 touch $negref || error "touch $negref failed"
5933 local cmd="$LFS find $dir -newer$x$y $ref"
5934 local nums=$(eval $cmd | wc -l)
5935 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
5937 [ $nums -eq $expected ] ||
5938 error "'$cmd' wrong: found $nums, expected $expected"
5940 cmd="$LFS find $dir ! -newer$x$y $negref"
5941 nums=$(eval $cmd | wc -l)
5942 [ $nums -eq $expected ] ||
5943 error "'$cmd' wrong: found $nums, expected $expected"
5945 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
5946 nums=$(eval $cmd | wc -l)
5947 [ $nums -eq $expected ] ||
5948 error "'$cmd' wrong: found $nums, expected $expected"
5954 test_newerXY_base "b" "t"
5955 test_newerXY_base "a" "a"
5956 test_newerXY_base "a" "m"
5957 test_newerXY_base "a" "c"
5958 test_newerXY_base "m" "a"
5959 test_newerXY_base "m" "m"
5960 test_newerXY_base "m" "c"
5961 test_newerXY_base "c" "a"
5962 test_newerXY_base "c" "m"
5963 test_newerXY_base "c" "c"
5964 test_newerXY_base "b" "b"
5965 test_newerXY_base "a" "t"
5966 test_newerXY_base "m" "t"
5967 test_newerXY_base "c" "t"
5968 test_newerXY_base "b" "t"
5970 run_test 56oc "check lfs find -newerXY work"
5973 local dir=$DIR/$tdir
5978 $LFS find $dir -btime -1d -type f
5985 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
5986 ! btime_supported && skip "btime unsupported on MDS"
5988 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
5989 ! btime_supported && skip "btime unsupported on clients"
5991 local dir=$DIR/$tdir
5992 local ref=$DIR/$tfile.ref
5993 local negref=$DIR/$tfile.negref
5995 mkdir $dir || error "mkdir $dir failed"
5996 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
5997 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
5998 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
5999 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6000 touch $ref || error "touch $ref failed"
6001 # sleep 3 seconds at least
6004 local before=$(do_facet mds1 date +%s)
6005 local skew=$(($(date +%s) - before + 1))
6007 if (( skew < 0 && skew > -5 )); then
6008 sleep $((0 - skew + 1))
6012 # Set the dir stripe params to limit files all on MDT0,
6013 # otherwise we need to calc the max clock skew between
6014 # the client and MDTs.
6015 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6017 touch $negref || error "touch $negref failed"
6019 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6020 local nums=$($cmd | wc -l)
6021 local expected=$(((NUMFILES + 1) * NUMDIRS))
6023 [ $nums -eq $expected ] ||
6024 error "'$cmd' wrong: found $nums, expected $expected"
6026 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6027 nums=$($cmd | wc -l)
6028 expected=$((NUMFILES + 1))
6029 [ $nums -eq $expected ] ||
6030 error "'$cmd' wrong: found $nums, expected $expected"
6032 [ $skew -lt 0 ] && return
6034 local after=$(do_facet mds1 date +%s)
6035 local age=$((after - before + 1 + skew))
6037 cmd="$LFS find $dir -btime -${age}s -type f"
6038 nums=$($cmd | wc -l)
6039 expected=$(((NUMFILES + 1) * NUMDIRS))
6041 echo "Clock skew between client and server: $skew, age:$age"
6042 [ $nums -eq $expected ] ||
6043 error "'$cmd' wrong: found $nums, expected $expected"
6045 expected=$(($NUMDIRS + 1))
6046 cmd="$LFS find $dir -btime -${age}s -type d"
6047 nums=$($cmd | wc -l)
6048 [ $nums -eq $expected ] ||
6049 error "'$cmd' wrong: found $nums, expected $expected"
6050 rm -f $ref $negref || error "Failed to remove $ref $negref"
6052 run_test 56od "check lfs find -btime with units"
6055 [ $RUNAS_ID -eq $UID ] &&
6056 skip_env "RUNAS_ID = UID = $UID -- skipping"
6058 local dir=$DIR/$tdir
6060 setup_56 $dir $NUMFILES $NUMDIRS
6061 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6063 local expected=$NUMFILES
6064 local cmd="$LFS find -uid $RUNAS_ID $dir"
6065 local nums=$($cmd | wc -l)
6067 [ $nums -eq $expected ] ||
6068 error "'$cmd' wrong: found $nums, expected $expected"
6070 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6071 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6072 nums=$($cmd | wc -l)
6073 [ $nums -eq $expected ] ||
6074 error "'$cmd' wrong: found $nums, expected $expected"
6076 run_test 56p "check lfs find -uid and ! -uid"
6079 [ $RUNAS_ID -eq $UID ] &&
6080 skip_env "RUNAS_ID = UID = $UID -- skipping"
6082 local dir=$DIR/$tdir
6084 setup_56 $dir $NUMFILES $NUMDIRS
6085 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6087 local expected=$NUMFILES
6088 local cmd="$LFS find -gid $RUNAS_GID $dir"
6089 local nums=$($cmd | wc -l)
6091 [ $nums -eq $expected ] ||
6092 error "'$cmd' wrong: found $nums, expected $expected"
6094 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6095 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6096 nums=$($cmd | wc -l)
6097 [ $nums -eq $expected ] ||
6098 error "'$cmd' wrong: found $nums, expected $expected"
6100 run_test 56q "check lfs find -gid and ! -gid"
6103 local dir=$DIR/$tdir
6105 setup_56 $dir $NUMFILES $NUMDIRS
6108 local cmd="$LFS find -size 0 -type f -lazy $dir"
6109 local nums=$($cmd | wc -l)
6111 [ $nums -eq $expected ] ||
6112 error "'$cmd' wrong: found $nums, expected $expected"
6113 cmd="$LFS find -size 0 -type f $dir"
6114 nums=$($cmd | wc -l)
6115 [ $nums -eq $expected ] ||
6116 error "'$cmd' wrong: found $nums, expected $expected"
6119 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6120 nums=$($cmd | wc -l)
6121 [ $nums -eq $expected ] ||
6122 error "'$cmd' wrong: found $nums, expected $expected"
6123 cmd="$LFS find ! -size 0 -type f $dir"
6124 nums=$($cmd | wc -l)
6125 [ $nums -eq $expected ] ||
6126 error "'$cmd' wrong: found $nums, expected $expected"
6128 echo "test" > $dir/$tfile
6129 echo "test2" > $dir/$tfile.2 && sync
6131 cmd="$LFS find -size 5 -type f -lazy $dir"
6132 nums=$($cmd | wc -l)
6133 [ $nums -eq $expected ] ||
6134 error "'$cmd' wrong: found $nums, expected $expected"
6135 cmd="$LFS find -size 5 -type f $dir"
6136 nums=$($cmd | wc -l)
6137 [ $nums -eq $expected ] ||
6138 error "'$cmd' wrong: found $nums, expected $expected"
6141 cmd="$LFS find -size +5 -type f -lazy $dir"
6142 nums=$($cmd | wc -l)
6143 [ $nums -eq $expected ] ||
6144 error "'$cmd' wrong: found $nums, expected $expected"
6145 cmd="$LFS find -size +5 -type f $dir"
6146 nums=$($cmd | wc -l)
6147 [ $nums -eq $expected ] ||
6148 error "'$cmd' wrong: found $nums, expected $expected"
6151 cmd="$LFS find -size +0 -type f -lazy $dir"
6152 nums=$($cmd | wc -l)
6153 [ $nums -eq $expected ] ||
6154 error "'$cmd' wrong: found $nums, expected $expected"
6155 cmd="$LFS find -size +0 -type f $dir"
6156 nums=$($cmd | wc -l)
6157 [ $nums -eq $expected ] ||
6158 error "'$cmd' wrong: found $nums, expected $expected"
6161 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6162 nums=$($cmd | wc -l)
6163 [ $nums -eq $expected ] ||
6164 error "'$cmd' wrong: found $nums, expected $expected"
6165 cmd="$LFS find ! -size -5 -type f $dir"
6166 nums=$($cmd | wc -l)
6167 [ $nums -eq $expected ] ||
6168 error "'$cmd' wrong: found $nums, expected $expected"
6171 cmd="$LFS find -size -5 -type f -lazy $dir"
6172 nums=$($cmd | wc -l)
6173 [ $nums -eq $expected ] ||
6174 error "'$cmd' wrong: found $nums, expected $expected"
6175 cmd="$LFS find -size -5 -type f $dir"
6176 nums=$($cmd | wc -l)
6177 [ $nums -eq $expected ] ||
6178 error "'$cmd' wrong: found $nums, expected $expected"
6180 run_test 56r "check lfs find -size works"
6183 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6184 skip "MDS < 2.12.58 doesn't return LSOM data"
6185 local dir=$DIR/$tdir
6187 [[ $OSC == "mdc" ]] && skip "DoM files" && return
6189 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6191 cancel_lru_locks $OSC
6193 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6195 local cmd="$LFS find -size 0 -type f -lazy $dir"
6196 local nums=$($cmd | wc -l)
6198 [ $nums -eq $expected ] ||
6199 error "'$cmd' wrong: found $nums, expected $expected"
6201 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6202 [ $rpcs_before -eq $rpcs_after ] ||
6203 error "'$cmd' should not send glimpse RPCs to OST"
6204 cmd="$LFS find -size 0 -type f $dir"
6205 nums=$($cmd | wc -l)
6206 [ $nums -eq $expected ] ||
6207 error "'$cmd' wrong: found $nums, expected $expected"
6208 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6209 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6210 $LCTL get_param osc.*.stats
6211 [ $rpcs_after -eq $((rpcs_before + 12)) ] ||
6212 error "'$cmd' should send 12 glimpse RPCs to OST"
6214 cancel_lru_locks $OSC
6215 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6217 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6218 nums=$($cmd | wc -l)
6219 [ $nums -eq $expected ] ||
6220 error "'$cmd' wrong: found $nums, expected $expected"
6221 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6222 $LCTL get_param mdc.*.stats
6223 [ $rpcs_before -eq $rpcs_after ] ||
6224 error "'$cmd' should not send glimpse RPCs to OST"
6225 cmd="$LFS find ! -size 0 -type f $dir"
6226 nums=$($cmd | wc -l)
6227 [ $nums -eq $expected ] ||
6228 error "'$cmd' wrong: found $nums, expected $expected"
6229 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6230 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6231 [ $rpcs_after -eq $((rpcs_before + 12)) ] ||
6232 error "'$cmd' should send 12 glimpse RPCs to OST"
6234 echo "test" > $dir/$tfile
6235 echo "test2" > $dir/$tfile.2 && sync
6236 cancel_lru_locks $OSC
6237 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6239 cmd="$LFS find -size 5 -type f -lazy $dir"
6240 nums=$($cmd | wc -l)
6241 [ $nums -eq $expected ] ||
6242 error "'$cmd' wrong: found $nums, expected $expected"
6243 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6244 [ $rpcs_before -eq $rpcs_after ] ||
6245 error "'$cmd' should not send glimpse RPCs to OST"
6246 cmd="$LFS find -size 5 -type f $dir"
6247 nums=$($cmd | wc -l)
6248 [ $nums -eq $expected ] ||
6249 error "'$cmd' wrong: found $nums, expected $expected"
6250 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6251 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6252 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6253 error "'$cmd' should send 14 glimpse RPCs to OST"
6255 cancel_lru_locks $OSC
6256 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6258 cmd="$LFS find -size +5 -type f -lazy $dir"
6259 nums=$($cmd | wc -l)
6260 [ $nums -eq $expected ] ||
6261 error "'$cmd' wrong: found $nums, expected $expected"
6262 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6263 [ $rpcs_before -eq $rpcs_after ] ||
6264 error "'$cmd' should not send glimpse RPCs to OST"
6265 cmd="$LFS find -size +5 -type f $dir"
6266 nums=$($cmd | wc -l)
6267 [ $nums -eq $expected ] ||
6268 error "'$cmd' wrong: found $nums, expected $expected"
6269 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6270 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6271 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6272 error "'$cmd' should send 14 glimpse RPCs to OST"
6274 cancel_lru_locks $OSC
6275 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6277 cmd="$LFS find -size +0 -type f -lazy $dir"
6278 nums=$($cmd | wc -l)
6279 [ $nums -eq $expected ] ||
6280 error "'$cmd' wrong: found $nums, expected $expected"
6281 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6282 [ $rpcs_before -eq $rpcs_after ] ||
6283 error "'$cmd' should not send glimpse RPCs to OST"
6284 cmd="$LFS find -size +0 -type f $dir"
6285 nums=$($cmd | wc -l)
6286 [ $nums -eq $expected ] ||
6287 error "'$cmd' wrong: found $nums, expected $expected"
6288 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6289 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6290 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6291 error "'$cmd' should send 14 glimpse RPCs to OST"
6293 cancel_lru_locks $OSC
6294 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6296 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6297 nums=$($cmd | wc -l)
6298 [ $nums -eq $expected ] ||
6299 error "'$cmd' wrong: found $nums, expected $expected"
6300 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6301 [ $rpcs_before -eq $rpcs_after ] ||
6302 error "'$cmd' should not send glimpse RPCs to OST"
6303 cmd="$LFS find ! -size -5 -type f $dir"
6304 nums=$($cmd | wc -l)
6305 [ $nums -eq $expected ] ||
6306 error "'$cmd' wrong: found $nums, expected $expected"
6307 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6308 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6309 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6310 error "'$cmd' should send 14 glimpse RPCs to OST"
6312 cancel_lru_locks $OSC
6313 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6315 cmd="$LFS find -size -5 -type f -lazy $dir"
6316 nums=$($cmd | wc -l)
6317 [ $nums -eq $expected ] ||
6318 error "'$cmd' wrong: found $nums, expected $expected"
6319 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6320 [ $rpcs_before -eq $rpcs_after ] ||
6321 error "'$cmd' should not send glimpse RPCs to OST"
6322 cmd="$LFS find -size -5 -type f $dir"
6323 nums=$($cmd | wc -l)
6324 [ $nums -eq $expected ] ||
6325 error "'$cmd' wrong: found $nums, expected $expected"
6326 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6327 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6328 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6329 error "'$cmd' should send 14 glimpse RPCs to OST"
6331 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6334 local dir=$DIR/$tdir
6335 local tmp=$TMP/$tfile.log
6338 test_mkdir -p $dir || error "failed to mkdir $dir"
6339 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6340 error "failed to setstripe $dir/$tfile"
6341 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6343 stack_trap "rm -f $tmp" EXIT
6344 $LFS find --size +100K --ost 0 $dir 2>&1 | tee $tmp
6345 [ -z "$(cat $tmp | grep "obd_uuid: ")" ] ||
6346 error "failed to find --size +100K --ost 0 $dir"
6347 $LFS find --size +100K --mdt $mdt_idx $dir 2>&1 | tee $tmp
6348 [ -z "$(cat $tmp | grep "obd_uuid: ")" ] ||
6349 error "failed to find --size +100K --mdt $mdt_idx $dir"
6351 run_test 56rb "check lfs find --size --ost/--mdt works"
6353 test_56s() { # LU-611 #LU-9369
6354 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
6356 local dir=$DIR/$tdir
6357 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
6359 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6360 for i in $(seq $NUMDIRS); do
6361 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
6364 local expected=$NUMDIRS
6365 local cmd="$LFS find -c $OSTCOUNT $dir"
6366 local nums=$($cmd | wc -l)
6368 [ $nums -eq $expected ] || {
6369 $LFS getstripe -R $dir
6370 error "'$cmd' wrong: found $nums, expected $expected"
6373 expected=$((NUMDIRS + onestripe))
6374 cmd="$LFS find -stripe-count +0 -type f $dir"
6375 nums=$($cmd | wc -l)
6376 [ $nums -eq $expected ] || {
6377 $LFS getstripe -R $dir
6378 error "'$cmd' wrong: found $nums, expected $expected"
6382 cmd="$LFS find -stripe-count 1 -type f $dir"
6383 nums=$($cmd | wc -l)
6384 [ $nums -eq $expected ] || {
6385 $LFS getstripe -R $dir
6386 error "'$cmd' wrong: found $nums, expected $expected"
6389 cmd="$LFS find -stripe-count -2 -type f $dir"
6390 nums=$($cmd | wc -l)
6391 [ $nums -eq $expected ] || {
6392 $LFS getstripe -R $dir
6393 error "'$cmd' wrong: found $nums, expected $expected"
6397 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
6398 nums=$($cmd | wc -l)
6399 [ $nums -eq $expected ] || {
6400 $LFS getstripe -R $dir
6401 error "'$cmd' wrong: found $nums, expected $expected"
6404 run_test 56s "check lfs find -stripe-count works"
6406 test_56t() { # LU-611 #LU-9369
6407 local dir=$DIR/$tdir
6409 setup_56 $dir 0 $NUMDIRS
6410 for i in $(seq $NUMDIRS); do
6411 $LFS setstripe -S 8M $dir/dir$i/$tfile
6414 local expected=$NUMDIRS
6415 local cmd="$LFS find -S 8M $dir"
6416 local nums=$($cmd | wc -l)
6418 [ $nums -eq $expected ] || {
6419 $LFS getstripe -R $dir
6420 error "'$cmd' wrong: found $nums, expected $expected"
6424 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
6426 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
6428 expected=$(((NUMDIRS + 1) * NUMFILES))
6429 cmd="$LFS find -stripe-size 512k -type f $dir"
6430 nums=$($cmd | wc -l)
6431 [ $nums -eq $expected ] ||
6432 error "'$cmd' wrong: found $nums, expected $expected"
6434 cmd="$LFS find -stripe-size +320k -type f $dir"
6435 nums=$($cmd | wc -l)
6436 [ $nums -eq $expected ] ||
6437 error "'$cmd' wrong: found $nums, expected $expected"
6439 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
6440 cmd="$LFS find -stripe-size +200k -type f $dir"
6441 nums=$($cmd | wc -l)
6442 [ $nums -eq $expected ] ||
6443 error "'$cmd' wrong: found $nums, expected $expected"
6445 cmd="$LFS find -stripe-size -640k -type f $dir"
6446 nums=$($cmd | wc -l)
6447 [ $nums -eq $expected ] ||
6448 error "'$cmd' wrong: found $nums, expected $expected"
6451 cmd="$LFS find -stripe-size 256k -type f $dir"
6452 nums=$($cmd | wc -l)
6453 [ $nums -eq $expected ] ||
6454 error "'$cmd' wrong: found $nums, expected $expected"
6456 cmd="$LFS find -stripe-size -320k -type f $dir"
6457 nums=$($cmd | wc -l)
6458 [ $nums -eq $expected ] ||
6459 error "'$cmd' wrong: found $nums, expected $expected"
6462 cmd="$LFS find -stripe-size 1024k -type f $dir"
6463 nums=$($cmd | wc -l)
6464 [ $nums -eq $expected ] ||
6465 error "'$cmd' wrong: found $nums, expected $expected"
6467 run_test 56t "check lfs find -stripe-size works"
6469 test_56u() { # LU-611
6470 local dir=$DIR/$tdir
6472 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
6474 if [[ $OSTCOUNT -gt 1 ]]; then
6475 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
6481 local expected=$(((NUMDIRS + 1) * NUMFILES))
6482 local cmd="$LFS find -stripe-index 0 -type f $dir"
6483 local nums=$($cmd | wc -l)
6485 [ $nums -eq $expected ] ||
6486 error "'$cmd' wrong: found $nums, expected $expected"
6489 cmd="$LFS find -stripe-index 1 -type f $dir"
6490 nums=$($cmd | wc -l)
6491 [ $nums -eq $expected ] ||
6492 error "'$cmd' wrong: found $nums, expected $expected"
6494 cmd="$LFS find ! -stripe-index 0 -type f $dir"
6495 nums=$($cmd | wc -l)
6496 [ $nums -eq $expected ] ||
6497 error "'$cmd' wrong: found $nums, expected $expected"
6500 # This should produce an error and not return any files
6501 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
6502 nums=$($cmd 2>/dev/null | wc -l)
6503 [ $nums -eq $expected ] ||
6504 error "'$cmd' wrong: found $nums, expected $expected"
6506 if [[ $OSTCOUNT -gt 1 ]]; then
6507 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
6508 cmd="$LFS find -stripe-index 0,1 -type f $dir"
6509 nums=$($cmd | wc -l)
6510 [ $nums -eq $expected ] ||
6511 error "'$cmd' wrong: found $nums, expected $expected"
6514 run_test 56u "check lfs find -stripe-index works"
6518 local dir=$DIR/$tdir
6520 setup_56 $dir $NUMFILES $NUMDIRS
6522 UUID=$(mdtuuid_from_index $mdt_idx $dir)
6523 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
6525 for file in $($LFS find -m $UUID $dir); do
6526 file_midx=$($LFS getstripe -m $file)
6527 [ $file_midx -eq $mdt_idx ] ||
6528 error "lfs find -m $UUID != getstripe -m $file_midx"
6531 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
6534 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6535 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6537 local dir=$DIR/$tdir
6539 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
6541 local stripe_size=$($LFS getstripe -S -d $dir) ||
6542 error "$LFS getstripe -S -d $dir failed"
6543 stripe_size=${stripe_size%% *}
6545 local file_size=$((stripe_size * OSTCOUNT))
6546 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
6547 local required_space=$((file_num * file_size))
6548 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
6550 [[ $free_space -le $((required_space / 1024)) ]] &&
6551 skip_env "need $required_space, have $free_space kbytes"
6554 local dd_count=$((file_size / dd_bs))
6556 # write data into the files
6561 for i in $(seq $NUMFILES); do
6563 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6564 error "write data into $file failed"
6566 for i in $(seq $NUMDIRS); do
6567 for j in $(seq $NUMFILES); do
6568 file=$dir/dir$i/file$j
6569 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6570 error "write data into $file failed"
6574 # $LFS_MIGRATE will fail if hard link migration is unsupported
6575 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
6576 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
6577 error "creating links to $dir/dir1/file1 failed"
6582 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
6585 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
6588 eval $cmd || error "$cmd failed"
6590 check_stripe_count $dir/file1 $expected
6592 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
6594 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
6595 # OST 1 if it is on OST 0. This file is small enough to
6596 # be on only one stripe.
6597 file=$dir/migr_1_ost
6598 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
6599 error "write data into $file failed"
6600 local obdidx=$($LFS getstripe -i $file)
6601 local oldmd5=$(md5sum $file)
6604 [[ $obdidx -eq 0 ]] && newobdidx=1
6605 cmd="$LFS migrate -i $newobdidx $file"
6607 eval $cmd || error "$cmd failed"
6609 local realobdix=$($LFS getstripe -i $file)
6610 local newmd5=$(md5sum $file)
6612 [[ $newobdidx -ne $realobdix ]] &&
6613 error "new OST is different (was=$obdidx, "\
6614 "wanted=$newobdidx, got=$realobdix)"
6615 [[ "$oldmd5" != "$newmd5" ]] &&
6616 error "md5sum differ: $oldmd5, $newmd5"
6620 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
6622 eval $cmd || error "$cmd failed"
6624 for j in $(seq $NUMFILES); do
6625 check_stripe_count $dir/dir1/file$j $expected
6628 # lfs_migrate works with lfs find
6629 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
6630 $LFS_MIGRATE -y -c $expected"
6632 eval $cmd || error "$cmd failed"
6634 for i in $(seq 2 $NUMFILES); do
6635 check_stripe_count $dir/file$i $expected
6637 for i in $(seq 2 $NUMDIRS); do
6638 for j in $(seq $NUMFILES); do
6639 check_stripe_count $dir/dir$i/file$j $expected
6643 run_test 56w "check lfs_migrate -c stripe_count works"
6646 local file1=$DIR/$tdir/file1
6647 local create_pool=false
6648 local initial_pool=$($LFS getstripe -p $DIR)
6652 echo -n "Creating test dir..."
6653 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6656 echo -n "Creating test file..."
6657 touch $file1 || error "cannot create file"
6660 echo -n "Detecting existing pools..."
6661 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
6663 if [ ${#pool_list[@]} -gt 0 ]; then
6664 echo "${pool_list[@]}"
6665 for thispool in "${pool_list[@]}"; do
6666 if [[ -z "$initial_pool" ||
6667 "$initial_pool" != "$thispool" ]]; then
6669 echo "Using existing pool '$pool'"
6674 echo "none detected."
6676 if [ -z "$pool" ]; then
6677 pool=${POOL:-testpool}
6678 [ "$initial_pool" = "$pool" ] && pool="testpool2"
6679 echo -n "Creating pool '$pool'..."
6681 pool_add $pool &> /dev/null ||
6682 error "pool_add failed"
6685 echo -n "Adding target to pool..."
6686 pool_add_targets $pool 0 0 1 &> /dev/null ||
6687 error "pool_add_targets failed"
6691 echo -n "Setting pool using -p option..."
6692 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
6693 error "migrate failed rc = $?"
6696 echo -n "Verifying test file is in pool after migrating..."
6697 [ "$($LFS getstripe -p $file1)" = $pool ] ||
6698 error "file was not migrated to pool $pool"
6701 echo -n "Removing test file from pool '$pool'..."
6702 # "lfs migrate $file" won't remove the file from the pool
6703 # until some striping information is changed.
6704 $LFS migrate -c 1 $file1 &> /dev/null ||
6705 error "cannot remove from pool"
6706 [ "$($LFS getstripe -p $file1)" ] &&
6707 error "pool still set"
6710 echo -n "Setting pool using --pool option..."
6711 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
6712 error "migrate failed rc = $?"
6717 if $create_pool; then
6718 destroy_test_pools 2> /dev/null ||
6719 error "destroy test pools failed"
6722 run_test 56wb "check lfs_migrate pool support"
6725 local file1="$DIR/$tdir/file1"
6732 echo -n "Creating test dir..."
6733 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6734 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
6735 error "cannot set stripe by '-S 1M -c 1'"
6738 echo -n "Setting initial stripe for test file..."
6739 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
6740 error "cannot set stripe"
6741 cur_ssize=$($LFS getstripe -S "$file1")
6742 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
6745 # File currently set to -S 512K -c 1
6747 # Ensure -c and -S options are rejected when -R is set
6748 echo -n "Verifying incompatible options are detected..."
6749 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
6750 error "incompatible -c and -R options not detected"
6751 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
6752 error "incompatible -S and -R options not detected"
6755 # Ensure unrecognized options are passed through to 'lfs migrate'
6756 echo -n "Verifying -S option is passed through to lfs migrate..."
6757 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
6758 error "migration failed"
6759 cur_ssize=$($LFS getstripe -S "$file1")
6760 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
6763 # File currently set to -S 1M -c 1
6765 # Ensure long options are supported
6766 echo -n "Verifying long options supported..."
6767 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
6768 error "long option without argument not supported"
6769 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
6770 error "long option with argument not supported"
6771 cur_ssize=$($LFS getstripe -S "$file1")
6772 [ $cur_ssize -eq 524288 ] ||
6773 error "migrate --stripe-size $cur_ssize != 524288"
6776 # File currently set to -S 512K -c 1
6778 if [ "$OSTCOUNT" -gt 1 ]; then
6779 echo -n "Verifying explicit stripe count can be set..."
6780 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
6781 error "migrate failed"
6782 cur_scount=$($LFS getstripe -c "$file1")
6783 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
6787 # File currently set to -S 512K -c 1 or -S 512K -c 2
6789 # Ensure parent striping is used if -R is set, and no stripe
6790 # count or size is specified
6791 echo -n "Setting stripe for parent directory..."
6792 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6793 error "cannot set stripe '-S 2M -c 1'"
6796 echo -n "Verifying restripe option uses parent stripe settings..."
6797 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
6798 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
6799 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
6800 error "migrate failed"
6801 cur_ssize=$($LFS getstripe -S "$file1")
6802 [ $cur_ssize -eq $parent_ssize ] ||
6803 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
6804 cur_scount=$($LFS getstripe -c "$file1")
6805 [ $cur_scount -eq $parent_scount ] ||
6806 error "migrate -R stripe_count $cur_scount != $parent_scount"
6809 # File currently set to -S 1M -c 1
6811 # Ensure striping is preserved if -R is not set, and no stripe
6812 # count or size is specified
6813 echo -n "Verifying striping size preserved when not specified..."
6814 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
6815 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6816 error "cannot set stripe on parent directory"
6817 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6818 error "migrate failed"
6819 cur_ssize=$($LFS getstripe -S "$file1")
6820 [ $cur_ssize -eq $orig_ssize ] ||
6821 error "migrate by default $cur_ssize != $orig_ssize"
6824 # Ensure file name properly detected when final option has no argument
6825 echo -n "Verifying file name properly detected..."
6826 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6827 error "file name interpreted as option argument"
6833 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
6836 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6838 local file1=$DIR/$tdir/file1
6840 echo -n "Creating test dir..."
6841 test_mkdir $DIR/$tdir || error "cannot create dir"
6844 echo -n "Creating test file..."
6848 # Ensure 'lfs migrate' will fail by using a non-existent option,
6849 # and make sure rsync is not called to recover
6850 echo -n "Make sure --no-rsync option works..."
6851 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
6852 grep -q 'refusing to fall back to rsync' ||
6853 error "rsync was called with --no-rsync set"
6856 # Ensure rsync is called without trying 'lfs migrate' first
6857 echo -n "Make sure --rsync option works..."
6858 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
6859 grep -q 'falling back to rsync' &&
6860 error "lfs migrate was called with --rsync set"
6863 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
6864 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
6865 grep -q 'at the same time' ||
6866 error "--rsync and --no-rsync accepted concurrently"
6872 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
6875 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6876 check_swap_layouts_support
6878 local dir=$DIR/$tdir
6879 local ref1=/etc/passwd
6880 local file1=$dir/file1
6882 test_mkdir $dir || error "creating dir $dir"
6883 $LFS setstripe -c 2 $file1
6885 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
6886 stripe=$($LFS getstripe -c $file1)
6887 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6888 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6893 run_test 56x "lfs migration support"
6896 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6897 check_swap_layouts_support
6899 local dir=$DIR/$tdir/$testnum
6903 local ref1=/etc/passwd
6904 local file1=$dir/file1
6906 $LFS setstripe -c 2 $file1
6908 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6910 local stripe=$($LFS getstripe -c $file1)
6912 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6913 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6918 run_test 56xa "lfs migration --block support"
6920 check_migrate_links() {
6922 local file1="$dir/file1"
6926 local total_count=$(($begin + $count - 1))
6927 local symlink_count=10
6930 if [ ! -f "$file1" ]; then
6931 echo -n "creating initial file..."
6932 $LFS setstripe -c 1 -S "512k" "$file1" ||
6933 error "cannot setstripe initial file"
6936 echo -n "creating symlinks..."
6937 for s in $(seq 1 $symlink_count); do
6938 ln -s "$file1" "$dir/slink$s" ||
6939 error "cannot create symlinks"
6943 echo -n "creating nonlinked files..."
6944 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6945 error "cannot create nonlinked files"
6950 if [ ! -f "$dir/file$total_count" ]; then
6951 echo -n "creating hard links $begin:$total_count..."
6952 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6953 /dev/null || error "cannot create hard links"
6957 echo -n "checking number of hard links listed in xattrs..."
6958 local fid=$($LFS getstripe -F "$file1")
6959 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6962 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6963 skip "hard link list has unexpected size, skipping test"
6965 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6966 error "link names should exceed xattrs size"
6969 echo -n "migrating files..."
6970 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
6972 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6975 # make sure all links have been properly migrated
6976 echo -n "verifying files..."
6977 fid=$($LFS getstripe -F "$file1") ||
6978 error "cannot get fid for file $file1"
6979 for i in $(seq 2 $total_count); do
6980 local fid2=$($LFS getstripe -F $dir/file$i)
6982 [ "$fid2" == "$fid" ] ||
6983 error "migrated hard link has mismatched FID"
6986 # make sure hard links were properly detected, and migration was
6987 # performed only once for the entire link set; nonlinked files should
6989 local actual=$(grep -c 'done' <<< "$migrate_out")
6990 local expected=$(($uniq_count + 1))
6992 [ "$actual" -eq "$expected" ] ||
6993 error "hard links individually migrated ($actual != $expected)"
6995 # make sure the correct number of hard links are present
6996 local hardlinks=$(stat -c '%h' "$file1")
6998 [ $hardlinks -eq $total_count ] ||
6999 error "num hard links $hardlinks != $total_count"
7006 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
7007 skip "Need MDS version at least 2.10.55"
7009 local dir="$DIR/$tdir"
7011 test_mkdir "$dir" || error "cannot create dir $dir"
7013 echo "testing lfs migrate mode when all links fit within xattrs"
7014 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
7016 echo "testing rsync mode when all links fit within xattrs"
7017 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
7019 echo "testing lfs migrate mode when all links do not fit within xattrs"
7020 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
7022 echo "testing rsync mode when all links do not fit within xattrs"
7023 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
7025 chown -R $RUNAS_ID $dir
7026 echo "testing non-root lfs migrate mode when not all links are in xattr"
7027 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
7032 run_test 56xb "lfs migration hard link support"
7035 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7037 local dir="$DIR/$tdir"
7039 test_mkdir "$dir" || error "cannot create dir $dir"
7041 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
7042 echo -n "Setting initial stripe for 20MB test file..."
7043 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
7044 error "cannot setstripe 20MB file"
7046 echo -n "Sizing 20MB test file..."
7047 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
7049 echo -n "Verifying small file autostripe count is 1..."
7050 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
7051 error "cannot migrate 20MB file"
7052 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7053 error "cannot get stripe for $dir/20mb"
7054 [ $stripe_count -eq 1 ] ||
7055 error "unexpected stripe count $stripe_count for 20MB file"
7059 # Test 2: File is small enough to fit within the available space on
7060 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7061 # have at least an additional 1KB for each desired stripe for test 3
7062 echo -n "Setting stripe for 1GB test file..."
7063 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7065 echo -n "Sizing 1GB test file..."
7066 # File size is 1GB + 3KB
7067 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7070 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7071 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7072 if (( avail > 524288 * OSTCOUNT )); then
7073 echo -n "Migrating 1GB file..."
7074 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7075 error "cannot migrate 1GB file"
7077 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7078 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7079 error "cannot getstripe for 1GB file"
7080 [ $stripe_count -eq 2 ] ||
7081 error "unexpected stripe count $stripe_count != 2"
7085 # Test 3: File is too large to fit within the available space on
7086 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7087 if [ $OSTCOUNT -ge 3 ]; then
7088 # The required available space is calculated as
7089 # file size (1GB + 3KB) / OST count (3).
7090 local kb_per_ost=349526
7092 echo -n "Migrating 1GB file with limit..."
7093 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7094 error "cannot migrate 1GB file with limit"
7097 stripe_count=$($LFS getstripe -c "$dir/1gb")
7098 echo -n "Verifying 1GB autostripe count with limited space..."
7099 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7100 error "unexpected stripe count $stripe_count (min 3)"
7107 run_test 56xc "lfs migration autostripe"
7110 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7112 local dir=$DIR/$tdir
7113 local f_mgrt=$dir/$tfile.mgrt
7114 local f_yaml=$dir/$tfile.yaml
7115 local f_copy=$dir/$tfile.copy
7116 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7117 local layout_copy="-c 2 -S 2M -i 1"
7118 local yamlfile=$dir/yamlfile
7119 local layout_before;
7122 test_mkdir "$dir" || error "cannot create dir $dir"
7123 $LFS setstripe $layout_yaml $f_yaml ||
7124 error "cannot setstripe $f_yaml with layout $layout_yaml"
7125 $LFS getstripe --yaml $f_yaml > $yamlfile
7126 $LFS setstripe $layout_copy $f_copy ||
7127 error "cannot setstripe $f_copy with layout $layout_copy"
7129 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7131 # 1. test option --yaml
7132 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7133 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7134 layout_before=$(get_layout_param $f_yaml)
7135 layout_after=$(get_layout_param $f_mgrt)
7136 [ "$layout_after" == "$layout_before" ] ||
7137 error "lfs_migrate --yaml: $layout_after != $layout_before"
7139 # 2. test option --copy
7140 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7141 error "cannot migrate $f_mgrt with --copy $f_copy"
7142 layout_before=$(get_layout_param $f_copy)
7143 layout_after=$(get_layout_param $f_mgrt)
7144 [ "$layout_after" == "$layout_before" ] ||
7145 error "lfs_migrate --copy: $layout_after != $layout_before"
7147 run_test 56xd "check lfs_migrate --yaml and --copy support"
7150 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7152 local dir=$DIR/$tdir
7153 local f_comp=$dir/$tfile
7154 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7155 local layout_before=""
7156 local layout_after=""
7158 test_mkdir "$dir" || error "cannot create dir $dir"
7159 $LFS setstripe $layout $f_comp ||
7160 error "cannot setstripe $f_comp with layout $layout"
7161 layout_before=$(get_layout_param $f_comp)
7162 dd if=/dev/zero of=$f_comp bs=1M count=4
7164 # 1. migrate a comp layout file by lfs_migrate
7165 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7166 layout_after=$(get_layout_param $f_comp)
7167 [ "$layout_before" == "$layout_after" ] ||
7168 error "lfs_migrate: $layout_before != $layout_after"
7170 # 2. migrate a comp layout file by lfs migrate
7171 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7172 layout_after=$(get_layout_param $f_comp)
7173 [ "$layout_before" == "$layout_after" ] ||
7174 error "lfs migrate: $layout_before != $layout_after"
7176 run_test 56xe "migrate a composite layout file"
7179 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7181 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7182 skip "Need server version at least 2.13.53"
7184 local dir=$DIR/$tdir
7185 local f_comp=$dir/$tfile
7186 local layout="-E 1M -c1 -E -1 -c2"
7190 test_mkdir "$dir" || error "cannot create dir $dir"
7191 $LFS setstripe $layout $f_comp ||
7192 error "cannot setstripe $f_comp with layout $layout"
7193 fid_before=$($LFS getstripe --fid $f_comp)
7194 dd if=/dev/zero of=$f_comp bs=1M count=4
7196 # 1. migrate a comp layout file to a comp layout
7197 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7198 fid_after=$($LFS getstripe --fid $f_comp)
7199 [ "$fid_before" == "$fid_after" ] ||
7200 error "comp-to-comp migrate: $fid_before != $fid_after"
7202 # 2. migrate a comp layout file to a plain layout
7203 $LFS migrate -c2 $f_comp ||
7204 error "cannot migrate $f_comp by lfs migrate"
7205 fid_after=$($LFS getstripe --fid $f_comp)
7206 [ "$fid_before" == "$fid_after" ] ||
7207 error "comp-to-plain migrate: $fid_before != $fid_after"
7209 # 3. migrate a plain layout file to a comp layout
7210 $LFS migrate $layout $f_comp ||
7211 error "cannot migrate $f_comp by lfs migrate"
7212 fid_after=$($LFS getstripe --fid $f_comp)
7213 [ "$fid_before" == "$fid_after" ] ||
7214 error "plain-to-comp migrate: $fid_before != $fid_after"
7216 run_test 56xf "FID is not lost during migration of a composite layout file"
7219 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
7220 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
7223 local dir=$DIR/$tdir
7227 test_mkdir -p $dir || error "creating dir $dir"
7228 touch $f1 || error "creating std file $f1"
7229 $MULTIOP $f2 H2c || error "creating released file $f2"
7231 # a directory can be raid0, so ask only for files
7232 res=$($LFS find $dir -L raid0 -type f | wc -l)
7233 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
7235 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
7236 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
7238 # only files can be released, so no need to force file search
7239 res=$($LFS find $dir -L released)
7240 [[ $res == $f2 ]] || error "search released: found $res != $f2"
7242 res=$($LFS find $dir -type f \! -L released)
7243 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
7245 run_test 56y "lfs find -L raid0|released"
7247 test_56z() { # LU-4824
7248 # This checks to make sure 'lfs find' continues after errors
7249 # There are two classes of errors that should be caught:
7250 # - If multiple paths are provided, all should be searched even if one
7252 # - If errors are encountered during the search, it should not terminate
7254 local dir=$DIR/$tdir
7258 for i in d{0..9}; do
7260 touch $dir/$i/$tfile
7262 $LFS find $DIR/non_existent_dir $dir &&
7263 error "$LFS find did not return an error"
7264 # Make a directory unsearchable. This should NOT be the last entry in
7265 # directory order. Arbitrarily pick the 6th entry
7266 chmod 700 $($LFS find $dir -type d | sed '6!d')
7268 $RUNAS $LFS find $DIR/non_existent $dir
7269 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
7271 # The user should be able to see 10 directories and 9 files
7272 (( count == 19 )) ||
7273 error "$LFS find found $count != 19 entries after error"
7275 run_test 56z "lfs find should continue after an error"
7277 test_56aa() { # LU-5937
7278 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
7280 local dir=$DIR/$tdir
7283 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
7285 createmany -o $dir/striped_dir/${tfile}- 1024
7286 local dirs=$($LFS find --size +8k $dir/)
7288 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
7290 run_test 56aa "lfs find --size under striped dir"
7292 test_56ab() { # LU-10705
7293 test_mkdir $DIR/$tdir
7294 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
7295 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
7296 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
7297 # Flush writes to ensure valid blocks. Need to be more thorough for
7298 # ZFS, since blocks are not allocated/returned to client immediately.
7300 wait_zfs_commit ost1 2
7301 cancel_lru_locks osc
7304 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
7306 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
7308 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
7309 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
7311 rm -f $DIR/$tdir/$tfile.[123]
7313 run_test 56ab "lfs find --blocks"
7316 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
7317 skip "Need MDS version at least 2.10.50"
7319 # Create composite files with one component
7320 local dir=$DIR/$tdir
7322 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
7323 # Create composite files with three components
7324 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
7325 # Create non-composite files
7326 createmany -o $dir/${tfile}- 10
7328 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
7330 [[ $nfiles == 10 ]] ||
7331 error "lfs find -E 1M found $nfiles != 10 files"
7333 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
7334 [[ $nfiles == 25 ]] ||
7335 error "lfs find ! -E 1M found $nfiles != 25 files"
7337 # All files have a component that starts at 0
7338 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
7339 [[ $nfiles == 35 ]] ||
7340 error "lfs find --component-start 0 - $nfiles != 35 files"
7342 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
7343 [[ $nfiles == 15 ]] ||
7344 error "lfs find --component-start 2M - $nfiles != 15 files"
7346 # All files created here have a componenet that does not starts at 2M
7347 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
7348 [[ $nfiles == 35 ]] ||
7349 error "lfs find ! --component-start 2M - $nfiles != 35 files"
7351 # Find files with a specified number of components
7352 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
7353 [[ $nfiles == 15 ]] ||
7354 error "lfs find --component-count 3 - $nfiles != 15 files"
7356 # Remember non-composite files have a component count of zero
7357 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
7358 [[ $nfiles == 10 ]] ||
7359 error "lfs find --component-count 0 - $nfiles != 10 files"
7361 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
7362 [[ $nfiles == 20 ]] ||
7363 error "lfs find ! --component-count 3 - $nfiles != 20 files"
7365 # All files have a flag called "init"
7366 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
7367 [[ $nfiles == 35 ]] ||
7368 error "lfs find --component-flags init - $nfiles != 35 files"
7370 # Multi-component files will have a component not initialized
7371 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
7372 [[ $nfiles == 15 ]] ||
7373 error "lfs find !--component-flags init - $nfiles != 15 files"
7378 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
7381 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
7382 skip "Need MDS version at least 2.10.57"
7392 # create mirrored directories and mirrored files
7393 mkdir $td || error "mkdir $td failed"
7394 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
7395 createmany -o $tf- 10 || error "create $tf- failed"
7397 for i in $(seq 2); do
7399 mkdir $dir || error "mkdir $dir failed"
7400 $LFS mirror create -N$((3 + i)) $dir ||
7401 error "create mirrored dir $dir failed"
7402 createmany -o $dir/$tfile- 10 ||
7403 error "create $dir/$tfile- failed"
7406 # change the states of some mirrored files
7408 for i in $(seq 2); do
7410 for j in $(seq 4 9); do
7411 echo foo > $dir/$tfile-$j
7415 # find mirrored files with specific mirror count
7416 cmd="$LFS find --mirror-count 3 --type f $td"
7417 nfiles=$($cmd | wc -l)
7418 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
7420 cmd="$LFS find ! --mirror-count 3 --type f $td"
7421 nfiles=$($cmd | wc -l)
7422 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
7424 cmd="$LFS find --mirror-count +2 --type f $td"
7425 nfiles=$($cmd | wc -l)
7426 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7428 cmd="$LFS find --mirror-count -6 --type f $td"
7429 nfiles=$($cmd | wc -l)
7430 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7432 # find mirrored files with specific file state
7433 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
7434 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
7436 cmd="$LFS find --mirror-state=ro --type f $td"
7437 nfiles=$($cmd | wc -l)
7438 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
7440 cmd="$LFS find ! --mirror-state=ro --type f $td"
7441 nfiles=$($cmd | wc -l)
7442 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7444 cmd="$LFS find --mirror-state=wp --type f $td"
7445 nfiles=$($cmd | wc -l)
7446 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7448 cmd="$LFS find ! --mirror-state=sp --type f $td"
7449 nfiles=$($cmd | wc -l)
7450 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7452 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
7455 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7456 # note test will not do anything if MDS is not local
7457 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7458 skip_env "ldiskfs only test"
7460 remote_mds_nodsh && skip "remote MDS with nodsh"
7462 local MNTDEV="osd*.*MDT*.mntdev"
7463 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
7464 [ -z "$DEV" ] && error "can't access $MNTDEV"
7465 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
7466 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
7467 error "can't access $DEV"
7468 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
7469 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
7473 run_test 57a "verify MDS filesystem created with large inodes =="
7476 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7477 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7478 skip_env "ldiskfs only test"
7480 remote_mds_nodsh && skip "remote MDS with nodsh"
7482 local dir=$DIR/$tdir
7485 local fileN=$dir/f$filecount
7487 rm -rf $dir || error "removing $dir"
7489 local mdtidx=$($LFS getstripe -m $dir)
7490 local mdtname=MDT$(printf %04x $mdtidx)
7491 local facet=mds$((mdtidx + 1))
7493 echo "mcreating $filecount files"
7494 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
7496 # verify that files do not have EAs yet
7497 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
7498 error "$file1 has an EA"
7499 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
7500 error "$fileN has an EA"
7504 df $dir #make sure we get new statfs data
7505 local mdsfree=$(do_facet $facet \
7506 lctl get_param -n osd*.*$mdtname.kbytesfree)
7507 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7510 echo "opening files to create objects/EAs"
7511 for file in $(seq -f $dir/f%g 1 $filecount); do
7512 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
7513 error "opening $file"
7516 # verify that files have EAs now
7517 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
7518 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
7520 sleep 1 #make sure we get new statfs data
7522 local mdsfree2=$(do_facet $facet \
7523 lctl get_param -n osd*.*$mdtname.kbytesfree)
7524 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7526 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
7527 if [ "$mdsfree" != "$mdsfree2" ]; then
7528 error "MDC before $mdcfree != after $mdcfree2"
7530 echo "MDC before $mdcfree != after $mdcfree2"
7531 echo "unable to confirm if MDS has large inodes"
7536 run_test 57b "default LOV EAs are stored inside large inodes ==="
7539 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7540 [ -z "$(which wiretest 2>/dev/null)" ] &&
7541 skip_env "could not find wiretest"
7545 run_test 58 "verify cross-platform wire constants =============="
7548 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7550 echo "touch 130 files"
7551 createmany -o $DIR/f59- 130
7553 unlinkmany $DIR/f59- 130
7555 # wait for commitment of removal
7556 wait_delete_completed
7558 run_test 59 "verify cancellation of llog records async ========="
7560 TEST60_HEAD="test_60 run $RANDOM"
7562 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7563 remote_mgs_nodsh && skip "remote MGS with nodsh"
7564 do_facet mgs "! which run-llog.sh &> /dev/null" &&
7565 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
7566 skip_env "missing subtest run-llog.sh"
7568 log "$TEST60_HEAD - from kernel mode"
7569 do_facet mgs "$LCTL dk > /dev/null"
7570 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
7571 do_facet mgs $LCTL dk > $TMP/$tfile
7573 # LU-6388: test llog_reader
7574 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
7575 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
7576 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
7577 skip_env "missing llog_reader"
7578 local fstype=$(facet_fstype mgs)
7579 [ $fstype != ldiskfs -a $fstype != zfs ] &&
7580 skip_env "Only for ldiskfs or zfs type mgs"
7582 local mntpt=$(facet_mntpt mgs)
7583 local mgsdev=$(mgsdevname 1)
7595 #get fid and record list
7596 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
7598 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
7600 #remount mgs as ldiskfs or zfs type
7601 stop mgs || error "stop mgs failed"
7602 mount_fstype mgs || error "remount mgs failed"
7603 for ((i = 0; i < ${#fid_list[@]}; i++)); do
7606 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
7607 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
7612 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
7614 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
7616 echo "obj_file is $obj_file"
7617 do_facet mgs $llog_reader $obj_file
7619 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
7620 awk '{ print $3 }' | sed -e "s/^type=//g")
7621 if [ $rec_type != $rec ]; then
7622 echo "FAILED test_60a wrong record type $rec_type," \
7628 #check obj path if record type is LLOG_LOGID_MAGIC
7629 if [ "$rec" == "1064553b" ]; then
7630 path=$(do_facet mgs $llog_reader $obj_file |
7631 grep "path=" | awk '{ print $NF }' |
7632 sed -e "s/^path=//g")
7633 if [ $obj_file != $mntpt/$path ]; then
7634 echo "FAILED test_60a wrong obj path" \
7635 "$montpt/$path, should be $obj_file"
7642 #restart mgs before "error", otherwise it will block the next test
7643 stop mgs || error "stop mgs failed"
7644 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
7645 $pass || error "test failed, see FAILED test_60a messages for specifics"
7647 run_test 60a "llog_test run from kernel module and test llog_reader"
7649 test_60b() { # bug 6411
7650 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7653 LLOG_COUNT=$(do_facet mgs dmesg |
7654 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
7655 /llog_[a-z]*.c:[0-9]/ {
7667 [[ $LLOG_COUNT -gt 120 ]] &&
7668 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
7670 run_test 60b "limit repeated messages from CERROR/CWARN"
7673 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7675 echo "create 5000 files"
7676 createmany -o $DIR/f60c- 5000
7677 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
7678 lctl set_param fail_loc=0x80000137
7679 unlinkmany $DIR/f60c- 5000
7680 lctl set_param fail_loc=0
7682 run_test 60c "unlink file when mds full"
7685 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7687 SAVEPRINTK=$(lctl get_param -n printk)
7688 # verify "lctl mark" is even working"
7689 MESSAGE="test message ID $RANDOM $$"
7690 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7691 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
7693 lctl set_param printk=0 || error "set lnet.printk failed"
7694 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
7695 MESSAGE="new test message ID $RANDOM $$"
7696 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
7697 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7698 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
7700 lctl set_param -n printk="$SAVEPRINTK"
7702 run_test 60d "test printk console message masking"
7705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7706 remote_mds_nodsh && skip "remote MDS with nodsh"
7709 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
7710 do_facet mds1 lctl set_param fail_loc=0x15b
7713 run_test 60e "no space while new llog is being created"
7719 test_mkdir -c $MDSCOUNT $DIR/$tdir
7724 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
7725 -c $MDSCOUNT $DIR/$tdir/subdir$index \
7727 mkdir $DIR/$tdir/subdir$index 2>/dev/null
7728 rmdir $DIR/$tdir/subdir$index 2>/dev/null
7729 index=$((index + 1))
7735 for i in {0..100}; do
7736 # define OBD_FAIL_OSD_TXN_START 0x19a
7737 local index=$((i % MDSCOUNT + 1))
7739 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
7746 for i in $(seq $MDSCOUNT); do
7747 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
7750 mkdir $DIR/$tdir/new || error "mkdir failed"
7751 rmdir $DIR/$tdir/new || error "rmdir failed"
7753 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
7755 for i in $(seq $MDSCOUNT); do
7756 wait_update_facet mds$i "$LCTL get_param -n \
7757 mdd.$(facet_svc mds$i).lfsck_namespace |
7758 awk '/^status/ { print \\\$2 }'" "completed"
7761 ls -R $DIR/$tdir || error "ls failed"
7762 rm -rf $DIR/$tdir || error "rmdir failed"
7764 run_test 60g "transaction abort won't cause MDT hung"
7767 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
7768 skip "Need MDS version at least 2.12.52"
7769 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
7773 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
7774 #define OBD_FAIL_MDS_STRIPE_FID 0x189
7775 for fail_loc in 0x80000188 0x80000189; do
7776 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
7777 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
7778 error "mkdir $dir-$fail_loc failed"
7779 for i in {0..10}; do
7780 # create may fail on missing stripe
7781 echo $i > $DIR/$tdir-$fail_loc/$i
7783 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7784 error "getdirstripe $tdir-$fail_loc failed"
7785 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
7786 error "migrate $tdir-$fail_loc failed"
7787 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7788 error "getdirstripe $tdir-$fail_loc failed"
7789 pushd $DIR/$tdir-$fail_loc
7791 echo $f | cmp $f - || error "$f data mismatch"
7794 rm -rf $DIR/$tdir-$fail_loc
7797 run_test 60h "striped directory with missing stripes can be accessed"
7800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7803 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
7804 cancel_lru_locks osc
7805 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
7808 run_test 61a "mmap() writes don't make sync hang ================"
7811 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
7813 run_test 61b "mmap() of unstriped file is successful"
7815 # bug 2330 - insufficient obd_match error checking causes LBUG
7817 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7821 cancel_lru_locks osc
7822 lctl set_param fail_loc=0x405
7823 cat $f && error "cat succeeded, expect -EIO"
7824 lctl set_param fail_loc=0
7826 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
7827 # match every page all of the time.
7828 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
7830 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
7831 # Though this test is irrelevant anymore, it helped to reveal some
7832 # other grant bugs (LU-4482), let's keep it.
7833 test_63a() { # was test_63
7834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7836 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
7838 for i in `seq 10` ; do
7839 dd if=/dev/zero of=$DIR/f63 bs=8k &
7845 rm -f $DIR/f63 || true
7847 run_test 63a "Verify oig_wait interruption does not crash ======="
7849 # bug 2248 - async write errors didn't return to application on sync
7850 # bug 3677 - async write errors left page locked
7852 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7855 lctl set_param debug=-1
7857 # ensure we have a grant to do async writes
7858 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
7861 sync # sync lest earlier test intercept the fail_loc
7863 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7864 lctl set_param fail_loc=0x80000406
7865 $MULTIOP $DIR/$tfile Owy && \
7866 error "sync didn't return ENOMEM"
7867 sync; sleep 2; sync # do a real sync this time to flush page
7868 lctl get_param -n llite.*.dump_page_cache | grep locked && \
7869 error "locked page left in cache after async error" || true
7872 run_test 63b "async write errors should be returned to fsync ==="
7875 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7878 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
7880 run_test 64a "verify filter grant calculations (in kernel) ====="
7883 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7885 sh oos.sh $MOUNT || error "oos.sh failed: $?"
7887 run_test 64b "check out-of-space detection on client"
7890 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
7892 run_test 64c "verify grant shrink"
7894 # this does exactly what osc_request.c:osc_announce_cached() does in
7895 # order to calculate max amount of grants to ask from server
7899 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
7900 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
7902 ((rpc_in_flight ++));
7903 nrpages=$((nrpages * rpc_in_flight))
7905 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
7907 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
7909 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
7910 local undirty=$((nrpages * PAGE_SIZE))
7912 local max_extent_pages
7913 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
7914 grep grant_max_extent_size | awk '{print $2}')
7915 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
7916 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
7917 local grant_extent_tax
7918 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7919 grep grant_extent_tax | awk '{print $2}')
7921 undirty=$((undirty + nrextents * grant_extent_tax))
7926 # this is size of unit for grant allocation. It should be equal to
7927 # what tgt_grant.c:tgt_grant_chunk() calculates
7931 local grant_extent_tax
7933 max_brw_size=$($LCTL get_param osc.${tgt}.import |
7934 grep max_brw_size | awk '{print $2}')
7936 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7937 grep grant_extent_tax | awk '{print $2}')
7939 echo $(((max_brw_size + grant_extent_tax) * 2))
7943 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
7944 skip "OST < 2.10.55 doesn't limit grants enough"
7946 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
7947 local file=$DIR/$tfile
7949 [[ $($LCTL get_param osc.${tgt}.import |
7950 grep "connect_flags:.*grant_param") ]] ||
7951 skip "no grant_param connect flag"
7953 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
7955 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
7957 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
7958 stack_trap "rm -f $file" EXIT
7960 $LFS setstripe $file -i 0 -c 1
7961 dd if=/dev/zero of=$file bs=1M count=1000 &
7966 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
7967 if [[ $cur_grant -gt $max_cur_granted ]]
7970 error "cur_grant $cur_grant > $max_cur_granted"
7973 [[ $? -ne 0 ]] && break;
7978 wait_delete_completed
7979 $LCTL set_param debug="$olddebug" 2> /dev/null || true
7981 run_test 64d "check grant limit exceed"
7983 # bug 1414 - set/get directories' stripe info
7985 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7987 test_mkdir $DIR/$tdir
7989 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7991 run_test 65a "directory with no stripe info"
7994 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7996 test_mkdir $DIR/$tdir
7997 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7999 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8002 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
8004 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
8007 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8008 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
8010 test_mkdir $DIR/$tdir
8011 local stripesize=$($LFS getstripe -S $DIR/$tdir)
8013 $LFS setstripe -S $((stripesize * 4)) -i 1 \
8014 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
8016 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
8018 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
8021 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8023 test_mkdir $DIR/$tdir
8024 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
8025 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8027 if [[ $STRIPECOUNT -le 0 ]]; then
8029 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
8030 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
8031 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
8033 sc=$(($STRIPECOUNT - 1))
8035 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
8036 touch $DIR/$tdir/f4 $DIR/$tdir/f5
8037 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
8038 error "lverify failed"
8040 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
8043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8045 test_mkdir $DIR/$tdir
8047 $LFS setstripe $DIR/$tdir || error "setstripe"
8048 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
8049 error "no stripe info failed"
8051 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
8053 run_test 65e "directory setstripe defaults"
8056 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8058 test_mkdir $DIR/${tdir}f
8059 $RUNAS $LFS setstripe $DIR/${tdir}f &&
8060 error "setstripe succeeded" || true
8062 run_test 65f "dir setstripe permission (should return error) ==="
8065 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8067 test_mkdir $DIR/$tdir
8068 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8070 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8071 error "setstripe -S failed"
8072 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
8073 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
8074 error "delete default stripe failed"
8076 run_test 65g "directory setstripe -d"
8079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8081 test_mkdir $DIR/$tdir
8082 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8084 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8085 error "setstripe -S failed"
8086 test_mkdir $DIR/$tdir/dd1
8087 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
8088 error "stripe info inherit failed"
8090 run_test 65h "directory stripe info inherit ===================="
8093 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8095 save_layout_restore_at_exit $MOUNT
8097 # bug6367: set non-default striping on root directory
8098 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
8100 # bug12836: getstripe on -1 default directory striping
8101 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
8103 # bug12836: getstripe -v on -1 default directory striping
8104 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
8106 # bug12836: new find on -1 default directory striping
8107 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
8109 run_test 65i "various tests to set root directory striping"
8111 test_65j() { # bug6367
8112 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8116 # if we aren't already remounting for each test, do so for this test
8117 if [ "$I_MOUNTED" = "yes" ]; then
8118 cleanup || error "failed to unmount"
8122 save_layout_restore_at_exit $MOUNT
8124 $LFS setstripe -d $MOUNT || error "setstripe failed"
8126 run_test 65j "set default striping on root directory (bug 6367)="
8130 wait_delete_completed
8131 do_facet $SINGLEMDS "lctl set_param -n \
8132 osp.$ost*MDT0000.max_create_count=$max_count"
8133 do_facet $SINGLEMDS "lctl set_param -n \
8134 osp.$ost*MDT0000.create_count=$count"
8135 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
8136 echo $INACTIVE_OSC "is Activate"
8138 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
8141 test_65k() { # bug11679
8142 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8143 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8144 remote_mds_nodsh && skip "remote MDS with nodsh"
8146 local disable_precreate=true
8147 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
8148 disable_precreate=false
8150 echo "Check OST status: "
8151 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
8152 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
8154 for OSC in $MDS_OSCS; do
8155 echo $OSC "is active"
8156 do_facet $SINGLEMDS lctl --device %$OSC activate
8159 for INACTIVE_OSC in $MDS_OSCS; do
8160 local ost=$(osc_to_ost $INACTIVE_OSC)
8161 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
8162 lov.*md*.target_obd |
8163 awk -F: /$ost/'{ print $1 }' | head -n 1)
8166 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
8167 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
8169 echo "Deactivate: " $INACTIVE_OSC
8170 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
8172 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
8173 osp.$ost*MDT0000.create_count")
8174 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
8175 osp.$ost*MDT0000.max_create_count")
8176 $disable_precreate &&
8177 do_facet $SINGLEMDS "lctl set_param -n \
8178 osp.$ost*MDT0000.max_create_count=0"
8180 for idx in $(seq 0 $((OSTCOUNT - 1))); do
8181 [ -f $DIR/$tdir/$idx ] && continue
8182 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
8183 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
8185 error "setstripe $idx should succeed"; }
8186 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
8188 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
8191 do_facet $SINGLEMDS "lctl set_param -n \
8192 osp.$ost*MDT0000.max_create_count=$max_count"
8193 do_facet $SINGLEMDS "lctl set_param -n \
8194 osp.$ost*MDT0000.create_count=$count"
8195 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
8196 echo $INACTIVE_OSC "is Activate"
8198 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
8201 run_test 65k "validate manual striping works properly with deactivated OSCs"
8203 test_65l() { # bug 12836
8204 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8206 test_mkdir -p $DIR/$tdir/test_dir
8207 $LFS setstripe -c -1 $DIR/$tdir/test_dir
8208 $LFS find -mtime -1 $DIR/$tdir >/dev/null
8210 run_test 65l "lfs find on -1 stripe dir ========================"
8213 local layout=$(save_layout $MOUNT)
8214 $RUNAS $LFS setstripe -c 2 $MOUNT && {
8215 restore_layout $MOUNT $layout
8216 error "setstripe should fail by non-root users"
8220 run_test 65m "normal user can't set filesystem default stripe"
8223 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
8224 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
8225 skip "Need MDS version at least 2.12.50"
8226 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
8228 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
8229 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
8230 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
8232 local root_layout=$(save_layout $MOUNT)
8233 stack_trap "restore_layout $MOUNT $root_layout" EXIT
8235 # new subdirectory under root directory should not inherit
8236 # the default layout from root
8237 local dir1=$MOUNT/$tdir-1
8238 mkdir $dir1 || error "mkdir $dir1 failed"
8239 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
8240 error "$dir1 shouldn't have LOV EA"
8242 # delete the default layout on root directory
8243 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
8245 local dir2=$MOUNT/$tdir-2
8246 mkdir $dir2 || error "mkdir $dir2 failed"
8247 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
8248 error "$dir2 shouldn't have LOV EA"
8250 # set a new striping pattern on root directory
8251 local def_stripe_size=$($LFS getstripe -S $MOUNT)
8252 local new_def_stripe_size=$((def_stripe_size * 2))
8253 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
8254 error "set stripe size on $MOUNT failed"
8256 # new file created in $dir2 should inherit the new stripe size from
8257 # the filesystem default
8258 local file2=$dir2/$tfile-2
8259 touch $file2 || error "touch $file2 failed"
8261 local file2_stripe_size=$($LFS getstripe -S $file2)
8262 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
8263 error "$file2 didn't inherit stripe size $new_def_stripe_size"
8265 local dir3=$MOUNT/$tdir-3
8266 mkdir $dir3 || error "mkdir $dir3 failed"
8267 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
8268 # the root layout, which is the actual default layout that will be used
8269 # when new files are created in $dir3.
8270 local dir3_layout=$(get_layout_param $dir3)
8271 local root_dir_layout=$(get_layout_param $MOUNT)
8272 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
8273 error "$dir3 should show the default layout from $MOUNT"
8275 # set OST pool on root directory
8276 local pool=$TESTNAME
8277 pool_add $pool || error "add $pool failed"
8278 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8279 error "add targets to $pool failed"
8281 $LFS setstripe -p $pool $MOUNT ||
8282 error "set OST pool on $MOUNT failed"
8284 # new file created in $dir3 should inherit the pool from
8285 # the filesystem default
8286 local file3=$dir3/$tfile-3
8287 touch $file3 || error "touch $file3 failed"
8289 local file3_pool=$($LFS getstripe -p $file3)
8290 [[ "$file3_pool" = "$pool" ]] ||
8291 error "$file3 didn't inherit OST pool $pool"
8293 local dir4=$MOUNT/$tdir-4
8294 mkdir $dir4 || error "mkdir $dir4 failed"
8295 local dir4_layout=$(get_layout_param $dir4)
8296 root_dir_layout=$(get_layout_param $MOUNT)
8297 echo "$LFS getstripe -d $dir4"
8298 $LFS getstripe -d $dir4
8299 echo "$LFS getstripe -d $MOUNT"
8300 $LFS getstripe -d $MOUNT
8301 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
8302 error "$dir4 should show the default layout from $MOUNT"
8304 # new file created in $dir4 should inherit the pool from
8305 # the filesystem default
8306 local file4=$dir4/$tfile-4
8307 touch $file4 || error "touch $file4 failed"
8309 local file4_pool=$($LFS getstripe -p $file4)
8310 [[ "$file4_pool" = "$pool" ]] ||
8311 error "$file4 didn't inherit OST pool $pool"
8313 # new subdirectory under non-root directory should inherit
8314 # the default layout from its parent directory
8315 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
8316 error "set directory layout on $dir4 failed"
8318 local dir5=$dir4/$tdir-5
8319 mkdir $dir5 || error "mkdir $dir5 failed"
8321 dir4_layout=$(get_layout_param $dir4)
8322 local dir5_layout=$(get_layout_param $dir5)
8323 [[ "$dir4_layout" = "$dir5_layout" ]] ||
8324 error "$dir5 should inherit the default layout from $dir4"
8326 # though subdir under ROOT doesn't inherit default layout, but
8327 # its sub dir/file should be created with default layout.
8328 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
8329 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
8330 skip "Need MDS version at least 2.12.59"
8332 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
8333 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
8334 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
8336 if [ $default_lmv_hash == "none" ]; then
8337 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
8339 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
8340 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
8343 $LFS setdirstripe -D -c 2 $MOUNT ||
8344 error "setdirstripe -D -c 2 failed"
8345 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
8346 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
8347 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
8349 run_test 65n "don't inherit default layout from root for new subdirectories"
8351 # bug 2543 - update blocks count on client
8353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8356 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
8357 sync; sync_all_data; sync; sync_all_data
8358 cancel_lru_locks osc
8359 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
8360 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
8362 run_test 66 "update inode blocks count on client ==============="
8365 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
8369 swapon -s | awk '($1 == "'$1'") { print $4 }'
8372 # bug5265, obdfilter oa2dentry return -ENOENT
8373 # #define OBD_FAIL_SRV_ENOENT 0x217
8375 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8376 remote_ost_nodsh && skip "remote OST with nodsh"
8379 $LFS setstripe -c 1 -i 0 $f
8381 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
8383 do_facet ost1 lctl set_param fail_loc=0x217
8384 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
8385 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
8387 do_facet ost1 lctl set_param fail_loc=0
8388 $DIRECTIO write $f 0 2 || error "write error"
8390 cancel_lru_locks osc
8391 $DIRECTIO read $f 0 1 || error "read error"
8393 do_facet ost1 lctl set_param fail_loc=0x217
8394 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
8396 do_facet ost1 lctl set_param fail_loc=0
8399 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
8402 test_mkdir $DIR/$tdir
8403 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
8404 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
8406 run_test 71 "Running dbench on lustre (don't segment fault) ===="
8408 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
8409 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8410 [ "$RUNAS_ID" = "$UID" ] &&
8411 skip_env "RUNAS_ID = UID = $UID -- skipping"
8412 # Check that testing environment is properly set up. Skip if not
8413 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
8414 skip_env "User $RUNAS_ID does not exist - skipping"
8417 chmod 777 $DIR/$tfile
8418 chmod ug+s $DIR/$tfile
8419 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
8420 error "$RUNAS dd $DIR/$tfile failed"
8421 # See if we are still setuid/sgid
8422 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
8423 error "S/gid is not dropped on write"
8424 # Now test that MDS is updated too
8425 cancel_lru_locks mdc
8426 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
8427 error "S/gid is not dropped on MDS"
8430 run_test 72a "Test that remove suid works properly (bug5695) ===="
8432 test_72b() { # bug 24226 -- keep mode setting when size is not changing
8435 [ "$RUNAS_ID" = "$UID" ] &&
8436 skip_env "RUNAS_ID = UID = $UID -- skipping"
8437 [ "$RUNAS_ID" -eq 0 ] &&
8438 skip_env "RUNAS_ID = 0 -- skipping"
8439 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8440 # Check that testing environment is properly set up. Skip if not
8441 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
8442 skip_env "User $RUNAS_ID does not exist - skipping"
8444 touch $DIR/${tfile}-f{g,u}
8445 test_mkdir $DIR/${tfile}-dg
8446 test_mkdir $DIR/${tfile}-du
8447 chmod 770 $DIR/${tfile}-{f,d}{g,u}
8448 chmod g+s $DIR/${tfile}-{f,d}g
8449 chmod u+s $DIR/${tfile}-{f,d}u
8450 for perm in 777 2777 4777; do
8451 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
8452 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
8453 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
8454 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
8458 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
8460 # bug 3462 - multiple simultaneous MDC requests
8462 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8464 test_mkdir $DIR/d73-1
8465 test_mkdir $DIR/d73-2
8466 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
8469 lctl set_param fail_loc=0x80000129
8470 $MULTIOP $DIR/d73-1/f73-2 Oc &
8472 lctl set_param fail_loc=0
8474 $MULTIOP $DIR/d73-2/f73-3 Oc &
8478 wait $pid1 || return 1
8482 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
8483 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
8484 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
8488 run_test 73 "multiple MDC requests (should not deadlock)"
8490 test_74a() { # bug 6149, 6184
8491 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8494 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8496 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8497 # will spin in a tight reconnection loop
8498 $LCTL set_param fail_loc=0x8000030e
8499 # get any lock that won't be difficult - lookup works.
8501 $LCTL set_param fail_loc=0
8505 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
8507 test_74b() { # bug 13310
8508 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8510 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8512 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8513 # will spin in a tight reconnection loop
8514 $LCTL set_param fail_loc=0x8000030e
8515 # get a "difficult" lock
8517 $LCTL set_param fail_loc=0
8521 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
8524 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8526 #define OBD_FAIL_LDLM_NEW_LOCK
8527 $LCTL set_param fail_loc=0x319
8528 touch $DIR/$tfile && error "touch successful"
8529 $LCTL set_param fail_loc=0
8532 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
8535 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
8538 test_76() { # Now for bug 20433, added originally in bug 1443
8539 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8541 cancel_lru_locks osc
8542 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
8543 local before=$(num_inodes)
8544 local count=$((512 * cpus))
8545 [ "$SLOW" = "no" ] && count=$((64 * cpus))
8547 echo "before inodes: $before"
8548 for i in $(seq $count); do
8552 cancel_lru_locks osc
8553 local after=$(num_inodes)
8554 echo "after inodes: $after"
8555 while (( after > before + 8 * ${cpus:-1} )); do
8559 (( wait % 5 == 0 )) && echo "wait $wait seconds inodes: $after"
8560 if (( wait > 30 )); then
8561 error "inode slab grew from $before to $after"
8565 run_test 76 "confirm clients recycle inodes properly ===="
8571 # Note: in sptlrpc modes which enable its own bulk checksum, the
8572 # original crc32_le bulk checksum will be automatically disabled,
8573 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
8574 # will be checked by sptlrpc code against sptlrpc bulk checksum.
8575 # In this case set_checksums() will not be no-op, because sptlrpc
8576 # bulk checksum will be enabled all through the test.
8578 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
8579 lctl set_param -n osc.*.checksums $1
8583 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8584 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
8585 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8586 tr -d [] | head -n1)}
8589 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
8591 log "set checksum type to $1, rc = $rc"
8595 get_osc_checksum_type()
8597 # arugment 1: OST name, like OST0000
8599 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
8600 sed 's/.*\[\(.*\)\].*/\1/g')
8602 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
8606 F77_TMP=$TMP/f77-temp
8609 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
8610 error "error writing to $F77_TMP"
8613 test_77a() { # bug 10889
8614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8615 $GSS && skip_env "could not run with gss"
8617 [ ! -f $F77_TMP ] && setup_f77
8619 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
8623 run_test 77a "normal checksum read/write operation"
8625 test_77b() { # bug 10889
8626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8627 $GSS && skip_env "could not run with gss"
8629 [ ! -f $F77_TMP ] && setup_f77
8630 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8631 $LCTL set_param fail_loc=0x80000409
8634 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8635 error "dd error: $?"
8636 $LCTL set_param fail_loc=0
8638 for algo in $CKSUM_TYPES; do
8639 cancel_lru_locks osc
8640 set_checksum_type $algo
8641 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8642 $LCTL set_param fail_loc=0x80000408
8643 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
8644 $LCTL set_param fail_loc=0
8647 set_checksum_type $ORIG_CSUM_TYPE
8650 run_test 77b "checksum error on client write, read"
8655 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
8657 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
8658 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
8659 $check_ost && [ -n "$ost_file_prefix" ] &&
8660 do_facet ost1 rm -f ${ost_file_prefix}\*
8664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8665 $GSS && skip_env "could not run with gss"
8666 remote_ost_nodsh && skip "remote OST with nodsh"
8669 local osc_file_prefix
8671 local check_ost=false
8672 local ost_file_prefix
8678 # ensure corruption will occur on first OSS/OST
8679 $LFS setstripe -i 0 $DIR/$tfile
8681 [ ! -f $F77_TMP ] && setup_f77
8682 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8683 error "dd write error: $?"
8684 fid=$($LFS path2fid $DIR/$tfile)
8686 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
8689 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
8690 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
8692 echo "OSS do not support bulk pages dump upon error"
8695 osc_file_prefix=$($LCTL get_param -n debug_path)
8696 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
8698 trap cleanup_77c EXIT
8701 # enable bulk pages dump upon error on Client
8702 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
8703 # enable bulk pages dump upon error on OSS
8705 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
8707 # flush Client cache to allow next read to reach OSS
8708 cancel_lru_locks osc
8710 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8711 $LCTL set_param fail_loc=0x80000408
8712 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
8713 $LCTL set_param fail_loc=0
8717 # check cksum dump on Client
8718 osc_file=$(ls ${osc_file_prefix}*)
8719 [ -n "$osc_file" ] || error "no checksum dump file on Client"
8720 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
8721 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
8722 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
8723 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
8725 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
8726 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8727 error "dump content does not match on Client"
8729 $check_ost || skip "No need to check cksum dump on OSS"
8731 # check cksum dump on OSS
8732 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
8733 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
8734 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
8735 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
8736 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8737 error "dump content does not match on OSS"
8741 run_test 77c "checksum error on client read with debug"
8743 test_77d() { # bug 10889
8744 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8745 $GSS && skip_env "could not run with gss"
8747 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8748 $LCTL set_param fail_loc=0x80000409
8750 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8751 error "direct write: rc=$?"
8752 $LCTL set_param fail_loc=0
8755 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8756 $LCTL set_param fail_loc=0x80000408
8758 cancel_lru_locks osc
8759 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8760 error "direct read: rc=$?"
8761 $LCTL set_param fail_loc=0
8764 run_test 77d "checksum error on OST direct write, read"
8766 test_77f() { # bug 10889
8767 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8768 $GSS && skip_env "could not run with gss"
8771 for algo in $CKSUM_TYPES; do
8772 cancel_lru_locks osc
8773 set_checksum_type $algo
8774 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8775 $LCTL set_param fail_loc=0x409
8776 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
8777 error "direct write succeeded"
8778 $LCTL set_param fail_loc=0
8780 set_checksum_type $ORIG_CSUM_TYPE
8783 run_test 77f "repeat checksum error on write (expect error)"
8785 test_77g() { # bug 10889
8786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8787 $GSS && skip_env "could not run with gss"
8788 remote_ost_nodsh && skip "remote OST with nodsh"
8790 [ ! -f $F77_TMP ] && setup_f77
8792 local file=$DIR/$tfile
8793 stack_trap "rm -f $file" EXIT
8795 $LFS setstripe -c 1 -i 0 $file
8796 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
8797 do_facet ost1 lctl set_param fail_loc=0x8000021a
8799 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
8800 error "write error: rc=$?"
8801 do_facet ost1 lctl set_param fail_loc=0
8804 cancel_lru_locks osc
8805 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
8806 do_facet ost1 lctl set_param fail_loc=0x8000021b
8808 cmp $F77_TMP $file || error "file compare failed"
8809 do_facet ost1 lctl set_param fail_loc=0
8812 run_test 77g "checksum error on OST write, read"
8814 test_77k() { # LU-10906
8815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8816 $GSS && skip_env "could not run with gss"
8818 local cksum_param="osc.$FSNAME*.checksums"
8819 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
8823 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
8824 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
8825 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
8829 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
8830 error "failed to set checksum=$i on MGS"
8831 wait_update $HOSTNAME "$get_checksum" $i
8833 echo "remount client, checksum should be $i"
8834 remount_client $MOUNT || error "failed to remount client"
8835 checksum=$(eval $get_checksum)
8836 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8838 # remove persistent param to avoid races with checksum mountopt below
8839 do_facet mgs $LCTL set_param -P -d $cksum_param ||
8840 error "failed to delete checksum on MGS"
8842 for opt in "checksum" "nochecksum"; do
8843 #remount with mount option
8844 echo "remount client with option $opt, checksum should be $i"
8845 umount_client $MOUNT || error "failed to umount client"
8846 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
8847 error "failed to mount client with option '$opt'"
8848 checksum=$(eval $get_checksum)
8849 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8853 remount_client $MOUNT || error "failed to remount client"
8855 run_test 77k "enable/disable checksum correctly"
8858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8859 $GSS && skip_env "could not run with gss"
8862 stack_trap "set_checksums $ORIG_CSUM" EXIT
8863 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
8865 set_checksum_type invalid && error "unexpected success of invalid checksum type"
8867 $LFS setstripe -c 1 -i 0 $DIR/$tfile
8868 for algo in $CKSUM_TYPES; do
8869 set_checksum_type $algo || error "fail to set checksum type $algo"
8870 osc_algo=$(get_osc_checksum_type OST0000)
8871 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
8873 # no locks, no reqs to let the connection idle
8874 cancel_lru_locks osc
8875 lru_resize_disable osc
8876 wait_osc_import_state client ost1 IDLE
8878 # ensure ost1 is connected
8879 stat $DIR/$tfile >/dev/null || error "can't stat"
8880 wait_osc_import_state client ost1 FULL
8882 osc_algo=$(get_osc_checksum_type OST0000)
8883 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
8887 run_test 77l "preferred checksum type is remembered after reconnected"
8889 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
8898 test_78() { # bug 10901
8899 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8900 remote_ost || skip_env "local OST"
8903 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
8904 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
8905 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
8906 echo "MemTotal: $MEMTOTAL"
8908 # reserve 256MB of memory for the kernel and other running processes,
8909 # and then take 1/2 of the remaining memory for the read/write buffers.
8910 if [ $MEMTOTAL -gt 512 ] ;then
8911 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
8913 # for those poor memory-starved high-end clusters...
8914 MEMTOTAL=$((MEMTOTAL / 2))
8916 echo "Mem to use for directio: $MEMTOTAL"
8918 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
8919 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
8920 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
8921 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
8923 echo "Smallest OST: $SMALLESTOST"
8924 [[ $SMALLESTOST -lt 10240 ]] &&
8925 skip "too small OSTSIZE, useless to run large O_DIRECT test"
8927 trap cleanup_test_78 EXIT
8929 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
8930 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
8932 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
8933 echo "File size: $F78SIZE"
8934 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
8935 for i in $(seq 1 $NSEQ); do
8936 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
8937 echo directIO rdwr round $i of $NSEQ
8938 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
8943 run_test 78 "handle large O_DIRECT writes correctly ============"
8945 test_79() { # bug 12743
8946 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8948 wait_delete_completed
8950 BKTOTAL=$(calc_osc_kbytes kbytestotal)
8951 BKFREE=$(calc_osc_kbytes kbytesfree)
8952 BKAVAIL=$(calc_osc_kbytes kbytesavail)
8954 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
8955 DFTOTAL=`echo $STRING | cut -d, -f1`
8956 DFUSED=`echo $STRING | cut -d, -f2`
8957 DFAVAIL=`echo $STRING | cut -d, -f3`
8958 DFFREE=$(($DFTOTAL - $DFUSED))
8960 ALLOWANCE=$((64 * $OSTCOUNT))
8962 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
8963 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
8964 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
8966 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
8967 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
8968 error "df free($DFFREE) mismatch OST free($BKFREE)"
8970 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
8971 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
8972 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
8975 run_test 79 "df report consistency check ======================="
8977 test_80() { # bug 10718
8978 remote_ost_nodsh && skip "remote OST with nodsh"
8979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8981 # relax strong synchronous semantics for slow backends like ZFS
8982 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
8983 local soc="obdfilter.*.sync_lock_cancel"
8984 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8986 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
8987 if [ -z "$save" ]; then
8988 soc="obdfilter.*.sync_on_lock_cancel"
8989 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8992 if [ "$save" != "never" ]; then
8993 local hosts=$(comma_list $(osts_nodes))
8995 do_nodes $hosts $LCTL set_param $soc=never
8996 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
9000 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
9002 local before=$(date +%s)
9003 cancel_lru_locks osc
9004 local after=$(date +%s)
9005 local diff=$((after - before))
9006 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
9010 run_test 80 "Page eviction is equally fast at high offsets too"
9012 test_81a() { # LU-456
9013 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9014 remote_ost_nodsh && skip "remote OST with nodsh"
9016 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
9017 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
9018 do_facet ost1 lctl set_param fail_loc=0x80000228
9020 # write should trigger a retry and success
9021 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9022 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9024 if [ $RC -ne 0 ] ; then
9025 error "write should success, but failed for $RC"
9028 run_test 81a "OST should retry write when get -ENOSPC ==============="
9030 test_81b() { # LU-456
9031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9032 remote_ost_nodsh && skip "remote OST with nodsh"
9034 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
9035 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
9036 do_facet ost1 lctl set_param fail_loc=0x228
9038 # write should retry several times and return -ENOSPC finally
9039 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9040 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9043 if [ $RC -ne $ENOSPC ] ; then
9044 error "dd should fail for -ENOSPC, but succeed."
9047 run_test 81b "OST should return -ENOSPC when retry still fails ======="
9049 test_82() { # LU-1031
9050 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
9054 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
9056 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
9058 kill -USR1 $MULTIPID2
9060 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
9061 error "First grouplock does not block second one"
9063 echo "Second grouplock blocks first one"
9065 kill -USR1 $MULTIPID1
9069 run_test 82 "Basic grouplock test"
9072 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
9074 test_mkdir $DIR/$tdir.cvsroot
9075 chown $RUNAS_ID $DIR/$tdir.cvsroot
9078 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
9081 # some versions of cvs import exit(1) when asked to import links or
9082 # files they can't read. ignore those files.
9083 local toignore=$(find . -type l -printf '-I %f\n' -o \
9084 ! -perm /4 -printf '-I %f\n')
9085 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
9086 $tdir.reposname vtag rtag
9089 test_mkdir $DIR/$tdir.reposname
9090 chown $RUNAS_ID $DIR/$tdir.reposname
9091 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
9093 cd $DIR/$tdir.reposname
9095 $RUNAS cvs add -m 'addmsg' foo99
9097 $RUNAS cvs commit -m 'nomsg' foo99
9098 rm -fr $DIR/$tdir.cvsroot
9100 run_test 99 "cvs strange file/directory operations"
9103 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9104 [[ "$NETTYPE" =~ tcp ]] ||
9105 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
9106 remote_ost_nodsh && skip "remote OST with nodsh"
9107 remote_mds_nodsh && skip "remote MDS with nodsh"
9109 skip "useless for local single node setup"
9111 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
9112 [ "$PROT" != "tcp" ] && continue
9113 RPORT=$(echo $REMOTE | cut -d: -f2)
9114 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
9117 LPORT=`echo $LOCAL | cut -d: -f2`
9118 if [ $LPORT -ge 1024 ]; then
9119 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
9121 error_exit "local: $LPORT > 1024, remote: $RPORT"
9124 [ "$rc" = 0 ] || error_exit "privileged port not found" )
9126 run_test 100 "check local port using privileged port ==========="
9128 function get_named_value()
9137 echo $line | sed "s/^$tag[ ]*//"
9144 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
9145 awk '/^max_cached_mb/ { print $2 }')
9148 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
9153 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9158 local cache_limit=32
9160 $LCTL set_param -n osc.*-osc*.rpc_stats 0
9161 trap cleanup_101a EXIT
9162 $LCTL set_param -n llite.*.read_ahead_stats 0
9163 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
9166 # randomly read 10000 of 64K chunks from file 3x 32MB in size
9168 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
9169 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
9172 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
9173 get_named_value 'read but discarded' | cut -d" " -f1); do
9174 discard=$(($discard + $s))
9178 $LCTL get_param osc.*-osc*.rpc_stats
9179 $LCTL get_param llite.*.read_ahead_stats
9181 # Discard is generally zero, but sometimes a few random reads line up
9182 # and trigger larger readahead, which is wasted & leads to discards.
9183 if [[ $(($discard)) -gt $nreads ]]; then
9184 error "too many ($discard) discarded pages"
9186 rm -f $DIR/$tfile || true
9188 run_test 101a "check read-ahead for random reads"
9191 test_mkdir $DIR/$tdir
9193 local FILE_LENGTH=$2
9196 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
9198 local list=$(comma_list $(osts_nodes))
9199 set_osd_param $list '' read_cache_enable 0
9200 set_osd_param $list '' writethrough_cache_enable 0
9202 trap cleanup_test101bc EXIT
9203 # prepare the read-ahead file
9204 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
9206 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
9207 count=$FILE_SIZE_MB 2> /dev/null
9211 cleanup_test101bc() {
9216 local list=$(comma_list $(osts_nodes))
9217 set_osd_param $list '' read_cache_enable 1
9218 set_osd_param $list '' writethrough_cache_enable 1
9222 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
9227 local STRIPE_SIZE=$2
9228 local FILE_LENGTH=$3
9229 local RA_INC=1048576
9230 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
9231 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
9232 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
9233 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
9234 get_named_value 'read but discarded' |
9235 cut -d" " -f1 | calc_total)
9236 if [[ $DISCARD -gt $discard_limit ]]; then
9237 $LCTL get_param llite.*.read_ahead_stats
9238 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
9240 echo "Read-ahead success for size ${READ_SIZE}"
9245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9246 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9248 local STRIPE_SIZE=1048576
9249 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
9251 if [ $SLOW == "yes" ]; then
9252 local FILE_LENGTH=$((STRIDE_SIZE * 64))
9254 local FILE_LENGTH=$((STRIDE_SIZE * 8))
9257 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
9259 # prepare the read-ahead file
9260 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
9261 cancel_lru_locks osc
9262 for BIDX in 2 4 8 16 32 64 128 256
9264 local BSIZE=$((BIDX*4096))
9265 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
9266 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
9267 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
9268 $LCTL set_param -n llite.*.read_ahead_stats 0
9269 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
9270 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
9271 cancel_lru_locks osc
9272 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
9277 run_test 101b "check stride-io mode read-ahead ================="
9280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9282 local STRIPE_SIZE=1048576
9283 local FILE_LENGTH=$((STRIPE_SIZE*100))
9288 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
9290 cancel_lru_locks osc
9291 $LCTL set_param osc.*.rpc_stats 0
9292 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
9293 $LCTL get_param osc.*.rpc_stats
9294 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
9295 local stats=$($LCTL get_param -n $osc_rpc_stats)
9296 local lines=$(echo "$stats" | awk 'END {print NR;}')
9299 if [ $lines -le 20 ]; then
9300 echo "continue debug"
9303 for size in 1 2 4 8; do
9304 local rpc=$(echo "$stats" |
9305 awk '($1 == "'$size':") {print $2; exit; }')
9306 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
9307 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
9309 echo "$osc_rpc_stats check passed!"
9314 run_test 101c "check stripe_size aligned read-ahead ================="
9317 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9319 local file=$DIR/$tfile
9320 local sz_MB=${FILESIZE_101d:-80}
9321 local ra_MB=${READAHEAD_MB:-40}
9323 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
9324 [ $free_MB -lt $sz_MB ] &&
9325 skip "Need free space ${sz_MB}M, have ${free_MB}M"
9327 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
9328 $LFS setstripe -c -1 $file || error "setstripe failed"
9330 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
9331 echo Cancel LRU locks on lustre client to flush the client cache
9332 cancel_lru_locks osc
9334 echo Disable read-ahead
9335 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
9336 $LCTL set_param -n llite.*.max_read_ahead_mb=0
9337 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_RA" EXIT
9338 $LCTL get_param -n llite.*.max_read_ahead_mb
9340 echo "Reading the test file $file with read-ahead disabled"
9341 local sz_KB=$((sz_MB * 1024 / 4))
9342 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
9343 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
9344 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
9345 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
9347 echo "Cancel LRU locks on lustre client to flush the client cache"
9348 cancel_lru_locks osc
9349 echo Enable read-ahead with ${ra_MB}MB
9350 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
9352 echo "Reading the test file $file with read-ahead enabled"
9353 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
9354 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
9356 echo "read-ahead disabled time read $raOFF"
9357 echo "read-ahead enabled time read $raON"
9360 wait_delete_completed
9362 # use awk for this check instead of bash because it handles decimals
9363 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
9364 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
9366 run_test 101d "file read with and without read-ahead enabled"
9369 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9371 local file=$DIR/$tfile
9372 local size_KB=500 #KB
9376 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
9377 local need_KB=$((count * size_KB))
9378 [[ $free_KB -le $need_KB ]] &&
9379 skip_env "Need free space $need_KB, have $free_KB"
9381 echo "Creating $count ${size_KB}K test files"
9382 for ((i = 0; i < $count; i++)); do
9383 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
9386 echo "Cancel LRU locks on lustre client to flush the client cache"
9387 cancel_lru_locks $OSC
9389 echo "Reset readahead stats"
9390 $LCTL set_param -n llite.*.read_ahead_stats 0
9392 for ((i = 0; i < $count; i++)); do
9393 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
9396 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9397 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9399 for ((i = 0; i < $count; i++)); do
9400 rm -rf $file.$i 2>/dev/null
9403 #10000 means 20% reads are missing in readahead
9404 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
9406 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
9409 which iozone || skip_env "no iozone installed"
9411 local old_debug=$($LCTL get_param debug)
9412 old_debug=${old_debug#*=}
9413 $LCTL set_param debug="reada mmap"
9415 # create a test file
9416 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
9418 echo Cancel LRU locks on lustre client to flush the client cache
9419 cancel_lru_locks osc
9421 echo Reset readahead stats
9422 $LCTL set_param -n llite.*.read_ahead_stats 0
9424 echo mmap read the file with small block size
9425 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
9428 echo checking missing pages
9429 $LCTL get_param llite.*.read_ahead_stats
9430 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9431 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9433 $LCTL set_param debug="$old_debug"
9434 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
9437 run_test 101f "check mmap read performance"
9439 test_101g_brw_size_test() {
9441 local pages=$((mb * 1048576 / PAGE_SIZE))
9442 local file=$DIR/$tfile
9444 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
9445 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
9446 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
9447 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
9451 stack_trap "rm -f $file" EXIT
9452 $LCTL set_param -n osc.*.rpc_stats=0
9454 # 10 RPCs should be enough for the test
9456 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
9457 { error "dd write ${mb} MB blocks failed"; return 3; }
9458 cancel_lru_locks osc
9459 dd of=/dev/null if=$file bs=${mb}M count=$count ||
9460 { error "dd write ${mb} MB blocks failed"; return 4; }
9462 # calculate number of full-sized read and write RPCs
9463 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
9464 sed -n '/pages per rpc/,/^$/p' |
9465 awk '/'$pages':/ { reads += $2; writes += $6 }; \
9466 END { print reads,writes }'))
9467 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
9469 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
9476 remote_ost_nodsh && skip "remote OST with nodsh"
9479 local osts=$(get_facets OST)
9480 local list=$(comma_list $(osts_nodes))
9481 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9482 local brw_size="obdfilter.*.brw_size"
9484 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9486 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
9488 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
9489 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
9490 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
9491 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
9492 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
9493 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
9495 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
9498 if [[ $orig_mb -lt 16 ]]; then
9499 save_lustre_params $osts "$brw_size" > $p
9500 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
9501 error "set 16MB RPC size failed"
9503 echo "remount client to enable new RPC size"
9504 remount_client $MOUNT || error "remount_client failed"
9507 test_101g_brw_size_test 16 || error "16MB RPC test failed"
9508 # should be able to set brw_size=12, but no rpc_stats for that
9509 test_101g_brw_size_test 8 || error "8MB RPC test failed"
9512 test_101g_brw_size_test 4 || error "4MB RPC test failed"
9514 if [[ $orig_mb -lt 16 ]]; then
9515 restore_lustre_params < $p
9516 remount_client $MOUNT || error "remount_client restore failed"
9519 rm -f $p $DIR/$tfile
9521 run_test 101g "Big bulk(4/16 MiB) readahead"
9524 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9526 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
9527 error "dd 70M file failed"
9528 echo Cancel LRU locks on lustre client to flush the client cache
9529 cancel_lru_locks osc
9531 echo "Reset readahead stats"
9532 $LCTL set_param -n llite.*.read_ahead_stats 0
9534 echo "Read 10M of data but cross 64M bundary"
9535 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
9536 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9537 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9538 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
9539 rm -f $p $DIR/$tfile
9541 run_test 101h "Readahead should cover current read window"
9544 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
9545 error "dd 10M file failed"
9547 local max_per_file_mb=$($LCTL get_param -n \
9548 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
9549 cancel_lru_locks osc
9550 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
9551 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
9552 error "set max_read_ahead_per_file_mb to 1 failed"
9554 echo "Reset readahead stats"
9555 $LCTL set_param llite.*.read_ahead_stats=0
9557 dd if=$DIR/$tfile of=/dev/null bs=2M
9559 $LCTL get_param llite.*.read_ahead_stats
9560 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9561 awk '/misses/ { print $2 }')
9562 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
9565 run_test 101i "allow current readahead to exceed reservation"
9568 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
9569 error "setstripe $DIR/$tfile failed"
9570 local file_size=$((1048576 * 16))
9571 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
9572 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
9574 echo Disable read-ahead
9575 $LCTL set_param -n llite.*.max_read_ahead_mb=0
9577 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
9578 for blk in $PAGE_SIZE 1048576 $file_size; do
9579 cancel_lru_locks osc
9580 echo "Reset readahead stats"
9581 $LCTL set_param -n llite.*.read_ahead_stats=0
9582 local count=$(($file_size / $blk))
9583 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
9584 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9585 get_named_value 'failed to fast read' |
9586 cut -d" " -f1 | calc_total)
9587 $LCTL get_param -n llite.*.read_ahead_stats
9588 [ $miss -eq $count ] || error "expected $count got $miss"
9591 rm -f $p $DIR/$tfile
9593 run_test 101j "A complete read block should be submitted when no RA"
9596 test_mkdir $DIR/$tdir
9597 chown $RUNAS_ID $DIR/$tdir
9600 STRIPE_COUNT=$OSTCOUNT
9601 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
9603 trap cleanup_test102 EXIT
9605 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
9607 for num in 1 2 3 4; do
9608 for count in $(seq 1 $STRIPE_COUNT); do
9609 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
9610 local size=`expr $STRIPE_SIZE \* $num`
9611 local file=file"$num-$idx-$count"
9612 $1 $LFS setstripe -S $size -i $idx -c $count $file
9618 $1 tar cf $TMP/f102.tar $tdir --xattrs
9624 rm -rf $DIR/d0.sanity/d102
9628 [ "$UID" != 0 ] && skip "must run as root"
9629 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
9630 skip_env "must have user_xattr"
9632 [ -z "$(which setfattr 2>/dev/null)" ] &&
9633 skip_env "could not find setfattr"
9635 local testfile=$DIR/$tfile
9638 echo "set/get xattr..."
9639 setfattr -n trusted.name1 -v value1 $testfile ||
9640 error "setfattr -n trusted.name1=value1 $testfile failed"
9641 getfattr -n trusted.name1 $testfile 2> /dev/null |
9642 grep "trusted.name1=.value1" ||
9643 error "$testfile missing trusted.name1=value1"
9645 setfattr -n user.author1 -v author1 $testfile ||
9646 error "setfattr -n user.author1=author1 $testfile failed"
9647 getfattr -n user.author1 $testfile 2> /dev/null |
9648 grep "user.author1=.author1" ||
9649 error "$testfile missing trusted.author1=author1"
9652 setfattr -n trusted.name2 -v value2 $testfile ||
9653 error "$testfile unable to set trusted.name2"
9654 setfattr -n trusted.name3 -v value3 $testfile ||
9655 error "$testfile unable to set trusted.name3"
9656 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
9657 grep "trusted.name" | wc -l) -eq 3 ] ||
9658 error "$testfile missing 3 trusted.name xattrs"
9660 setfattr -n user.author2 -v author2 $testfile ||
9661 error "$testfile unable to set user.author2"
9662 setfattr -n user.author3 -v author3 $testfile ||
9663 error "$testfile unable to set user.author3"
9664 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
9665 grep "user.author" | wc -l) -eq 3 ] ||
9666 error "$testfile missing 3 user.author xattrs"
9668 echo "remove xattr..."
9669 setfattr -x trusted.name1 $testfile ||
9670 error "$testfile error deleting trusted.name1"
9671 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
9672 error "$testfile did not delete trusted.name1 xattr"
9674 setfattr -x user.author1 $testfile ||
9675 error "$testfile error deleting user.author1"
9676 echo "set lustre special xattr ..."
9677 $LFS setstripe -c1 $testfile
9678 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
9679 awk -F "=" '/trusted.lov/ { print $2 }' )
9680 setfattr -n "trusted.lov" -v $lovea $testfile ||
9681 error "$testfile doesn't ignore setting trusted.lov again"
9682 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
9683 error "$testfile allow setting invalid trusted.lov"
9686 run_test 102a "user xattr test =================================="
9688 check_102b_layout() {
9690 local testfile=$DIR/$tfile
9692 echo "test layout '$layout'"
9693 $LFS setstripe $layout $testfile || error "setstripe failed"
9694 $LFS getstripe -y $testfile
9696 echo "get/set/list trusted.lov xattr ..." # b=10930
9697 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
9698 [[ "$value" =~ "trusted.lov" ]] ||
9699 error "can't get trusted.lov from $testfile"
9700 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
9701 error "getstripe failed"
9703 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
9705 value=$(cut -d= -f2 <<<$value)
9706 # LU-13168: truncated xattr should fail if short lov_user_md header
9707 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
9708 lens="${#value}" || lens="$(seq 4 2 ${#value})"
9709 for len in $lens; do
9710 echo "setfattr $len $testfile.2"
9711 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
9712 [ $len -lt 66 ] && error "short xattr len=$len worked"
9714 local stripe_size=$($LFS getstripe -S $testfile.2)
9715 local stripe_count=$($LFS getstripe -c $testfile.2)
9716 [[ $stripe_size -eq 65536 ]] ||
9717 error "stripe size $stripe_size != 65536"
9718 [[ $stripe_count -eq $stripe_count_orig ]] ||
9719 error "stripe count $stripe_count != $stripe_count_orig"
9720 rm $testfile $testfile.2
9724 [ -z "$(which setfattr 2>/dev/null)" ] &&
9725 skip_env "could not find setfattr"
9726 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9728 # check plain layout
9729 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
9731 # and also check composite layout
9732 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
9735 run_test 102b "getfattr/setfattr for trusted.lov EAs"
9738 [ -z "$(which setfattr 2>/dev/null)" ] &&
9739 skip_env "could not find setfattr"
9740 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9742 # b10930: get/set/list lustre.lov xattr
9743 echo "get/set/list lustre.lov xattr ..."
9744 test_mkdir $DIR/$tdir
9745 chown $RUNAS_ID $DIR/$tdir
9746 local testfile=$DIR/$tdir/$tfile
9747 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
9748 error "setstripe failed"
9749 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
9750 error "getstripe failed"
9751 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
9752 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
9754 local testfile2=${testfile}2
9755 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
9756 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
9758 $RUNAS $MCREATE $testfile2
9759 $RUNAS setfattr -n lustre.lov -v $value $testfile2
9760 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
9761 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
9762 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
9763 [ $stripe_count -eq $STRIPECOUNT ] ||
9764 error "stripe count $stripe_count != $STRIPECOUNT"
9766 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
9768 compare_stripe_info1() {
9769 local stripe_index_all_zero=true
9771 for num in 1 2 3 4; do
9772 for count in $(seq 1 $STRIPE_COUNT); do
9773 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
9774 local size=$((STRIPE_SIZE * num))
9775 local file=file"$num-$offset-$count"
9776 stripe_size=$($LFS getstripe -S $PWD/$file)
9777 [[ $stripe_size -ne $size ]] &&
9778 error "$file: size $stripe_size != $size"
9779 stripe_count=$($LFS getstripe -c $PWD/$file)
9780 # allow fewer stripes to be created, ORI-601
9781 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
9782 error "$file: count $stripe_count != $count"
9783 stripe_index=$($LFS getstripe -i $PWD/$file)
9784 [[ $stripe_index -ne 0 ]] &&
9785 stripe_index_all_zero=false
9789 $stripe_index_all_zero &&
9790 error "all files are being extracted starting from OST index 0"
9794 have_xattrs_include() {
9795 tar --help | grep -q xattrs-include &&
9796 echo --xattrs-include="lustre.*"
9800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9801 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9803 XINC=$(have_xattrs_include)
9805 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9807 compare_stripe_info1
9809 run_test 102d "tar restore stripe info from tarfile,not keep osts"
9812 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9813 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9815 XINC=$(have_xattrs_include)
9817 test_mkdir $DIR/$tdir.restore
9819 tar cf - --xattrs $tdir | tar xf - \
9820 -C $DIR/$tdir.restore --xattrs $XINC
9821 cd $DIR/$tdir.restore/$tdir
9822 compare_stripe_info1
9824 run_test 102f "tar copy files, not keep osts"
9827 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
9828 skip "must have user_xattr"
9829 [ -z "$(which setfattr 2>/dev/null)" ] &&
9830 skip_env "could not find setfattr"
9831 [ -z "$(which getfattr 2>/dev/null)" ] &&
9832 skip_env "could not find getfattr"
9834 local xsize=${1:-1024} # in bytes
9835 local file=$DIR/$tfile
9836 local value="$(generate_string $xsize)"
9837 local xbig=trusted.big
9841 log "save $xbig on $file"
9844 setfattr -n $xbig -v $value $file ||
9845 error "saving $xbig on $file failed"
9847 setfattr -n $xbig -v $value $file &&
9848 error "saving $xbig on $file succeeded"
9852 local orig=$(get_xattr_value $xbig $file)
9853 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
9855 local xsml=trusted.sml
9856 log "save $xsml on $file"
9857 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
9859 local new=$(get_xattr_value $xbig $file)
9860 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
9862 log "grow $xsml on $file"
9863 setfattr -n $xsml -v "$value" $file ||
9864 error "growing $xsml on $file failed"
9866 new=$(get_xattr_value $xbig $file)
9867 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
9868 log "$xbig still valid after growing $xsml"
9873 test_102h() { # bug 15777
9876 run_test 102h "grow xattr from inside inode to external block"
9879 large_xattr_enabled || skip_env "ea_inode feature disabled"
9881 echo "setting xattr of max xattr size: $(max_xattr_size)"
9882 grow_xattr $(max_xattr_size)
9884 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
9885 echo "This should fail:"
9886 grow_xattr $(($(max_xattr_size) + 10)) 1
9888 run_test 102ha "grow xattr from inside inode to external inode"
9890 test_102i() { # bug 17038
9891 [ -z "$(which getfattr 2>/dev/null)" ] &&
9892 skip "could not find getfattr"
9895 ln -s $DIR/$tfile $DIR/${tfile}link
9896 getfattr -n trusted.lov $DIR/$tfile ||
9897 error "lgetxattr on $DIR/$tfile failed"
9898 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
9899 grep -i "no such attr" ||
9900 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
9901 rm -f $DIR/$tfile $DIR/${tfile}link
9903 run_test 102i "lgetxattr test on symbolic link ============"
9906 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9907 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9909 XINC=$(have_xattrs_include)
9910 setup_test102 "$RUNAS"
9911 chown $RUNAS_ID $DIR/$tdir
9912 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9914 compare_stripe_info1 "$RUNAS"
9916 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
9919 [ -z "$(which setfattr 2>/dev/null)" ] &&
9920 skip "could not find setfattr"
9923 # b22187 just check that does not crash for regular file.
9924 setfattr -n trusted.lov $DIR/$tfile
9925 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
9926 local test_kdir=$DIR/$tdir
9927 test_mkdir $test_kdir
9928 local default_size=$($LFS getstripe -S $test_kdir)
9929 local default_count=$($LFS getstripe -c $test_kdir)
9930 local default_offset=$($LFS getstripe -i $test_kdir)
9931 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
9932 error 'dir setstripe failed'
9933 setfattr -n trusted.lov $test_kdir
9934 local stripe_size=$($LFS getstripe -S $test_kdir)
9935 local stripe_count=$($LFS getstripe -c $test_kdir)
9936 local stripe_offset=$($LFS getstripe -i $test_kdir)
9937 [ $stripe_size -eq $default_size ] ||
9938 error "stripe size $stripe_size != $default_size"
9939 [ $stripe_count -eq $default_count ] ||
9940 error "stripe count $stripe_count != $default_count"
9941 [ $stripe_offset -eq $default_offset ] ||
9942 error "stripe offset $stripe_offset != $default_offset"
9943 rm -rf $DIR/$tfile $test_kdir
9945 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
9948 [ -z "$(which getfattr 2>/dev/null)" ] &&
9949 skip "could not find getfattr"
9951 # LU-532 trusted. xattr is invisible to non-root
9952 local testfile=$DIR/$tfile
9956 echo "listxattr as user..."
9957 chown $RUNAS_ID $testfile
9958 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
9959 grep -q "trusted" &&
9960 error "$testfile trusted xattrs are user visible"
9964 run_test 102l "listxattr size test =================================="
9966 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
9967 local path=$DIR/$tfile
9970 listxattr_size_check $path || error "listattr_size_check $path failed"
9972 run_test 102m "Ensure listxattr fails on small bufffer ========"
9976 getxattr() { # getxattr path name
9977 # Return the base64 encoding of the value of xattr name on path.
9981 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
9983 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9985 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9987 getfattr --absolute-names --encoding=base64 --name=$name $path |
9988 awk -F= -v name=$name '$1 == name {
9989 print substr($0, index($0, "=") + 1);
9993 test_102n() { # LU-4101 mdt: protect internal xattrs
9994 [ -z "$(which setfattr 2>/dev/null)" ] &&
9995 skip "could not find setfattr"
9996 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
9998 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
10001 local file0=$DIR/$tfile.0
10002 local file1=$DIR/$tfile.1
10003 local xattr0=$TMP/$tfile.0
10004 local xattr1=$TMP/$tfile.1
10005 local namelist="lov lma lmv link fid version som hsm"
10009 rm -rf $file0 $file1 $xattr0 $xattr1
10010 touch $file0 $file1
10012 # Get 'before' xattrs of $file1.
10013 getfattr --absolute-names --dump --match=- $file1 > $xattr0
10015 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
10016 namelist+=" lfsck_namespace"
10017 for name in $namelist; do
10018 # Try to copy xattr from $file0 to $file1.
10019 value=$(getxattr $file0 trusted.$name 2> /dev/null)
10021 setfattr --name=trusted.$name --value="$value" $file1 ||
10022 error "setxattr 'trusted.$name' failed"
10024 # Try to set a garbage xattr.
10025 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
10027 if [[ x$name == "xlov" ]]; then
10028 setfattr --name=trusted.lov --value="$value" $file1 &&
10029 error "setxattr invalid 'trusted.lov' success"
10031 setfattr --name=trusted.$name --value="$value" $file1 ||
10032 error "setxattr invalid 'trusted.$name' failed"
10035 # Try to remove the xattr from $file1. We don't care if this
10036 # appears to succeed or fail, we just don't want there to be
10037 # any changes or crashes.
10038 setfattr --remove=$trusted.$name $file1 2> /dev/null
10041 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
10044 # Try to copy xattr from $file0 to $file1.
10045 value=$(getxattr $file0 trusted.$name 2> /dev/null)
10047 setfattr --name=trusted.$name --value="$value" $file1 ||
10048 error "setxattr 'trusted.$name' failed"
10050 # Try to set a garbage xattr.
10051 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
10053 setfattr --name=trusted.$name --value="$value" $file1 ||
10054 error "setxattr 'trusted.$name' failed"
10056 # Try to remove the xattr from $file1. We don't care if this
10057 # appears to succeed or fail, we just don't want there to be
10058 # any changes or crashes.
10059 setfattr --remove=$trusted.$name $file1 2> /dev/null
10062 # Get 'after' xattrs of file1.
10063 getfattr --absolute-names --dump --match=- $file1 > $xattr1
10065 if ! diff $xattr0 $xattr1; then
10066 error "before and after xattrs of '$file1' differ"
10069 rm -rf $file0 $file1 $xattr0 $xattr1
10073 run_test 102n "silently ignore setxattr on internal trusted xattrs"
10075 test_102p() { # LU-4703 setxattr did not check ownership
10076 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
10077 skip "MDS needs to be at least 2.5.56"
10079 local testfile=$DIR/$tfile
10083 echo "setfacl as user..."
10084 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
10085 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
10087 echo "setfattr as user..."
10088 setfacl -m "u:$RUNAS_ID:---" $testfile
10089 $RUNAS setfattr -x system.posix_acl_access $testfile
10090 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
10092 run_test 102p "check setxattr(2) correctly fails without permission"
10095 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
10096 skip "MDS needs to be at least 2.6.92"
10098 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
10100 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
10103 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
10104 skip "MDS needs to be at least 2.6.93"
10106 touch $DIR/$tfile || error "touch"
10107 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
10108 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
10109 rm $DIR/$tfile || error "rm"
10112 mkdir -p $DIR/$tdir || error "mkdir"
10113 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
10114 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
10115 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
10116 error "$testfile error deleting user.author1"
10117 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
10118 grep "user.$(basename $tdir)" &&
10119 error "$tdir did not delete user.$(basename $tdir)"
10120 rmdir $DIR/$tdir || error "rmdir"
10123 test_mkdir $DIR/$tdir
10124 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
10125 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
10126 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
10127 error "$testfile error deleting user.author1"
10128 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
10129 grep "user.$(basename $tdir)" &&
10130 error "$tdir did not delete user.$(basename $tdir)"
10131 rmdir $DIR/$tdir || error "rm striped dir"
10133 run_test 102r "set EAs with empty values"
10136 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
10137 skip "MDS needs to be at least 2.11.52"
10139 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10141 save_lustre_params client "llite.*.xattr_cache" > $save
10143 for cache in 0 1; do
10144 lctl set_param llite.*.xattr_cache=$cache
10147 touch $DIR/$tfile || error "touch"
10148 for prefix in lustre security system trusted user; do
10149 # Note getxattr() may fail with 'Operation not
10150 # supported' or 'No such attribute' depending
10151 # on prefix and cache.
10152 getfattr -n $prefix.n102s $DIR/$tfile &&
10153 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
10157 restore_lustre_params < $save
10159 run_test 102s "getting nonexistent xattrs should fail"
10162 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
10163 skip "MDS needs to be at least 2.11.52"
10165 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10167 save_lustre_params client "llite.*.xattr_cache" > $save
10169 for cache in 0 1; do
10170 lctl set_param llite.*.xattr_cache=$cache
10172 for buf_size in 0 256; do
10174 touch $DIR/$tfile || error "touch"
10175 setfattr -n user.multiop $DIR/$tfile
10176 $MULTIOP $DIR/$tfile oa$buf_size ||
10177 error "cannot get zero length xattr value (buf_size = $buf_size)"
10181 restore_lustre_params < $save
10183 run_test 102t "zero length xattr values handled correctly"
10187 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
10192 [ "$UID" != 0 ] && skip "must run as root"
10193 $GSS && skip_env "could not run under gss"
10194 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
10195 skip_env "must have acl enabled"
10196 [ -z "$(which setfacl 2>/dev/null)" ] &&
10197 skip_env "could not find setfacl"
10198 remote_mds_nodsh && skip "remote MDS with nodsh"
10200 gpasswd -a daemon bin # LU-5641
10201 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
10203 declare -a identity_old
10205 for num in $(seq $MDSCOUNT); do
10206 switch_identity $num true || identity_old[$num]=$?
10209 SAVE_UMASK=$(umask)
10211 mkdir -p $DIR/$tdir
10214 echo "performing cp ..."
10215 run_acl_subtest cp || error "run_acl_subtest cp failed"
10216 echo "performing getfacl-noacl..."
10217 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
10218 echo "performing misc..."
10219 run_acl_subtest misc || error "misc test failed"
10220 echo "performing permissions..."
10221 run_acl_subtest permissions || error "permissions failed"
10222 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
10223 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
10224 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
10225 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
10227 echo "performing permissions xattr..."
10228 run_acl_subtest permissions_xattr ||
10229 error "permissions_xattr failed"
10231 echo "performing setfacl..."
10232 run_acl_subtest setfacl || error "setfacl test failed"
10234 # inheritance test got from HP
10235 echo "performing inheritance..."
10236 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
10237 chmod +x make-tree || error "chmod +x failed"
10238 run_acl_subtest inheritance || error "inheritance test failed"
10241 echo "LU-974 ignore umask when acl is enabled..."
10242 run_acl_subtest 974 || error "LU-974 umask test failed"
10243 if [ $MDSCOUNT -ge 2 ]; then
10244 run_acl_subtest 974_remote ||
10245 error "LU-974 umask test failed under remote dir"
10248 echo "LU-2561 newly created file is same size as directory..."
10249 if [ "$mds1_FSTYPE" != "zfs" ]; then
10250 run_acl_subtest 2561 || error "LU-2561 test failed"
10252 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
10255 run_acl_subtest 4924 || error "LU-4924 test failed"
10260 for num in $(seq $MDSCOUNT); do
10261 if [ "${identity_old[$num]}" = 1 ]; then
10262 switch_identity $num false || identity_old[$num]=$?
10266 run_test 103a "acl test"
10272 for U in {0..511}; do
10274 local O=$(printf "%04o" $U)
10276 umask $(printf "%04o" $((511 ^ $O)))
10277 $LFS setstripe -c 1 $DIR/$tfile.s$O
10278 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
10280 (( $S == ($O & 0666) )) ||
10281 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
10283 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
10284 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
10285 (( $S == ($O & 0666) )) ||
10286 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
10288 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
10289 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
10290 (( $S == ($O & 0666) )) ||
10291 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
10292 rm -f $DIR/$tfile.[smp]$0
10296 # limit the concurrently running threads to 64. LU-11878
10297 local idx=$((U % 64))
10298 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
10303 run_test 103b "umask lfs setstripe"
10306 mkdir -p $DIR/$tdir
10307 cp -rp $DIR/$tdir $DIR/$tdir.bak
10309 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
10310 error "$DIR/$tdir shouldn't contain default ACL"
10311 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
10312 error "$DIR/$tdir.bak shouldn't contain default ACL"
10315 run_test 103c "'cp -rp' won't set empty acl"
10318 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10321 lfs df || error "lfs df failed"
10322 lfs df -ih || error "lfs df -ih failed"
10323 lfs df -h $DIR || error "lfs df -h $DIR failed"
10324 lfs df -i $DIR || error "lfs df -i $DIR failed"
10325 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
10326 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
10328 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
10329 lctl --device %$OSC deactivate
10330 lfs df || error "lfs df with deactivated OSC failed"
10331 lctl --device %$OSC activate
10332 # wait the osc back to normal
10333 wait_osc_import_ready client ost
10335 lfs df || error "lfs df with reactivated OSC failed"
10338 run_test 104a "lfs df [-ih] [path] test ========================="
10341 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10342 [ $RUNAS_ID -eq $UID ] &&
10343 skip_env "RUNAS_ID = UID = $UID -- skipping"
10345 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
10346 grep "Permission denied" | wc -l)))
10347 if [ $denied_cnt -ne 0 ]; then
10348 error "lfs check servers test failed"
10351 run_test 104b "$RUNAS lfs check servers test ===================="
10354 # doesn't work on 2.4 kernels
10356 if $(flock_is_enabled); then
10357 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
10359 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
10363 run_test 105a "flock when mounted without -o flock test ========"
10367 if $(flock_is_enabled); then
10368 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
10370 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
10374 run_test 105b "fcntl when mounted without -o flock test ========"
10378 if $(flock_is_enabled); then
10379 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
10381 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
10385 run_test 105c "lockf when mounted without -o flock test"
10387 test_105d() { # bug 15924
10388 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10390 test_mkdir $DIR/$tdir
10391 flock_is_enabled || skip_env "mount w/o flock enabled"
10392 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
10393 $LCTL set_param fail_loc=0x80000315
10394 flocks_test 2 $DIR/$tdir
10396 run_test 105d "flock race (should not freeze) ========"
10398 test_105e() { # bug 22660 && 22040
10399 flock_is_enabled || skip_env "mount w/o flock enabled"
10402 flocks_test 3 $DIR/$tfile
10404 run_test 105e "Two conflicting flocks from same process"
10406 test_106() { #bug 10921
10407 test_mkdir $DIR/$tdir
10408 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
10409 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
10411 run_test 106 "attempt exec of dir followed by chown of that dir"
10414 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10422 local save_pattern=$(sysctl -n kernel.core_pattern)
10423 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
10424 sysctl -w kernel.core_pattern=$file
10425 sysctl -w kernel.core_uses_pid=0
10427 ulimit -c unlimited
10433 kill -s 11 $SLEEPPID
10435 if [ -e $file ]; then
10436 size=`stat -c%s $file`
10437 [ $size -eq 0 ] && error "Fail to create core file $file"
10439 error "Fail to create core file $file"
10442 sysctl -w kernel.core_pattern=$save_pattern
10443 sysctl -w kernel.core_uses_pid=$save_uses_pid
10446 run_test 107 "Coredump on SIG"
10449 test_mkdir $DIR/$tdir
10450 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
10451 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
10452 error "mkdir with 256 char should fail, but did not"
10453 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
10454 error "create with 255 char failed"
10455 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
10456 error "create with 256 char should fail, but did not"
10461 run_test 110 "filename length checking"
10464 # Purpose: To verify dynamic thread (OSS) creation.
10467 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10468 remote_ost_nodsh && skip "remote OST with nodsh"
10470 # Lustre does not stop service threads once they are started.
10471 # Reset number of running threads to default.
10476 local save_params="$TMP/sanity-$TESTNAME.parameters"
10478 # Get ll_ost_io count before I/O
10479 OSTIO_pre=$(do_facet ost1 \
10480 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
10481 # Exit if lustre is not running (ll_ost_io not running).
10482 [ -z "$OSTIO_pre" ] && error "no OSS threads"
10484 echo "Starting with $OSTIO_pre threads"
10485 local thread_max=$((OSTIO_pre * 2))
10486 local rpc_in_flight=$((thread_max * 2))
10487 # Number of I/O Process proposed to be started.
10489 local facets=$(get_facets OST)
10491 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
10492 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
10494 # Set in_flight to $rpc_in_flight
10495 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
10496 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
10497 nfiles=${rpc_in_flight}
10498 # Set ost thread_max to $thread_max
10499 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
10501 # 5 Minutes should be sufficient for max number of OSS
10502 # threads(thread_max) to be created.
10506 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
10507 test_mkdir $DIR/$tdir
10508 for i in $(seq $nfiles); do
10509 local file=$DIR/$tdir/${tfile}-$i
10510 $LFS setstripe -c -1 -i 0 $file
10511 ($WTL $file $timeout)&
10514 # I/O Started - Wait for thread_started to reach thread_max or report
10515 # error if thread_started is more than thread_max.
10516 echo "Waiting for thread_started to reach thread_max"
10517 local thread_started=0
10518 local end_time=$((SECONDS + timeout))
10520 while [ $SECONDS -le $end_time ] ; do
10522 # Get ost i/o thread_started count.
10523 thread_started=$(do_facet ost1 \
10525 ost.OSS.ost_io.threads_started | cut -d= -f2")
10526 # Break out if thread_started is equal/greater than thread_max
10527 if [[ $thread_started -ge $thread_max ]]; then
10528 echo ll_ost_io thread_started $thread_started, \
10529 equal/greater than thread_max $thread_max
10535 # Cleanup - We have the numbers, Kill i/o jobs if running.
10536 jobcount=($(jobs -p))
10537 for i in $(seq 0 $((${#jobcount[@]}-1)))
10539 kill -9 ${jobcount[$i]}
10540 if [ $? -ne 0 ] ; then
10542 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
10546 # Cleanup files left by WTL binary.
10547 for i in $(seq $nfiles); do
10548 local file=$DIR/$tdir/${tfile}-$i
10550 if [ $? -ne 0 ] ; then
10551 echo "Warning: Failed to delete file $file"
10555 restore_lustre_params <$save_params
10556 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
10558 # Error out if no new thread has started or Thread started is greater
10560 if [[ $thread_started -le $OSTIO_pre ||
10561 $thread_started -gt $thread_max ]]; then
10562 error "ll_ost_io: thread_started $thread_started" \
10563 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
10564 "No new thread started or thread started greater " \
10568 run_test 115 "verify dynamic thread creation===================="
10571 wait_delete_completed
10572 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
10573 echo "OST kbytes available: ${AVAIL[@]}"
10578 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
10579 #echo OST $i: ${AVAIL[i]}kb
10580 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
10584 if [[ ${AVAIL[i]} -lt $MINV ]]; then
10589 echo "Min free space: OST $MINI: $MINV"
10590 echo "Max free space: OST $MAXI: $MAXV"
10593 test_116a() { # was previously test_116()
10594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10595 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10596 remote_mds_nodsh && skip "remote MDS with nodsh"
10598 echo -n "Free space priority "
10599 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
10604 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
10605 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
10606 trap simple_cleanup_common EXIT
10608 # Check if we need to generate uneven OSTs
10609 test_mkdir -p $DIR/$tdir/OST${MINI}
10610 local FILL=$((MINV / 4))
10611 local DIFF=$((MAXV - MINV))
10612 local DIFF2=$((DIFF * 100 / MINV))
10614 local threshold=$(do_facet $SINGLEMDS \
10615 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
10616 threshold=${threshold%%%}
10617 echo -n "Check for uneven OSTs: "
10618 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
10620 if [[ $DIFF2 -gt $threshold ]]; then
10622 echo "Don't need to fill OST$MINI"
10624 # generate uneven OSTs. Write 2% over the QOS threshold value
10626 DIFF=$((threshold - DIFF2 + 2))
10627 DIFF2=$((MINV * DIFF / 100))
10628 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
10629 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
10630 error "setstripe failed"
10631 DIFF=$((DIFF2 / 2048))
10633 while [ $i -lt $DIFF ]; do
10635 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
10636 bs=2M count=1 2>/dev/null
10645 DIFF=$((MAXV - MINV))
10646 DIFF2=$((DIFF * 100 / MINV))
10647 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
10648 if [ $DIFF2 -gt $threshold ]; then
10651 echo "failed - QOS mode won't be used"
10652 simple_cleanup_common
10653 skip "QOS imbalance criteria not met"
10661 # now fill using QOS
10662 $LFS setstripe -c 1 $DIR/$tdir
10663 FILL=$((FILL / 200))
10664 if [ $FILL -gt 600 ]; then
10667 echo "writing $FILL files to QOS-assigned OSTs"
10669 while [ $i -lt $FILL ]; do
10671 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
10672 count=1 2>/dev/null
10675 echo "wrote $i 200k files"
10679 echo "Note: free space may not be updated, so measurements might be off"
10681 DIFF2=$((MAXV - MINV))
10682 echo "free space delta: orig $DIFF final $DIFF2"
10683 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
10684 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
10685 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
10686 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
10687 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
10688 if [[ $DIFF -gt 0 ]]; then
10689 FILL=$((DIFF2 * 100 / DIFF - 100))
10690 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
10693 # Figure out which files were written where
10694 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10695 awk '/'$MINI1': / {print $2; exit}')
10697 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10698 echo "$MINC files created on smaller OST $MINI1"
10699 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10700 awk '/'$MAXI1': / {print $2; exit}')
10702 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10703 echo "$MAXC files created on larger OST $MAXI1"
10704 if [[ $MINC -gt 0 ]]; then
10705 FILL=$((MAXC * 100 / MINC - 100))
10706 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
10708 [[ $MAXC -gt $MINC ]] ||
10709 error_ignore LU-9 "stripe QOS didn't balance free space"
10710 simple_cleanup_common
10712 run_test 116a "stripe QOS: free space balance ==================="
10714 test_116b() { # LU-2093
10715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10716 remote_mds_nodsh && skip "remote MDS with nodsh"
10718 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
10719 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
10720 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
10721 [ -z "$old_rr" ] && skip "no QOS"
10722 do_facet $SINGLEMDS lctl set_param \
10723 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
10724 mkdir -p $DIR/$tdir
10725 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
10726 createmany -o $DIR/$tdir/f- 20 || error "can't create"
10727 do_facet $SINGLEMDS lctl set_param fail_loc=0
10729 do_facet $SINGLEMDS lctl set_param \
10730 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
10732 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
10734 test_117() # bug 10891
10736 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10738 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
10739 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
10740 lctl set_param fail_loc=0x21e
10741 > $DIR/$tfile || error "truncate failed"
10742 lctl set_param fail_loc=0
10743 echo "Truncate succeeded."
10746 run_test 117 "verify osd extend =========="
10748 NO_SLOW_RESENDCOUNT=4
10749 export OLD_RESENDCOUNT=""
10750 set_resend_count () {
10751 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
10752 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
10753 lctl set_param -n $PROC_RESENDCOUNT $1
10754 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
10757 # for reduce test_118* time (b=14842)
10758 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10760 # Reset async IO behavior after error case
10762 FILE=$DIR/reset_async
10764 # Ensure all OSCs are cleared
10765 $LFS setstripe -c -1 $FILE
10766 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
10771 test_118a() #bug 11710
10773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10777 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10778 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10779 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10781 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10782 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10787 run_test 118a "verify O_SYNC works =========="
10791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10792 remote_ost_nodsh && skip "remote OST with nodsh"
10796 #define OBD_FAIL_SRV_ENOENT 0x217
10797 set_nodes_failloc "$(osts_nodes)" 0x217
10798 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10800 set_nodes_failloc "$(osts_nodes)" 0
10801 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10802 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10805 if [[ $RC -eq 0 ]]; then
10806 error "Must return error due to dropped pages, rc=$RC"
10810 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10811 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10815 echo "Dirty pages not leaked on ENOENT"
10817 # Due to the above error the OSC will issue all RPCs syncronously
10818 # until a subsequent RPC completes successfully without error.
10819 $MULTIOP $DIR/$tfile Ow4096yc
10824 run_test 118b "Reclaim dirty pages on fatal error =========="
10828 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10830 # for 118c, restore the original resend count, LU-1940
10831 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
10832 set_resend_count $OLD_RESENDCOUNT
10833 remote_ost_nodsh && skip "remote OST with nodsh"
10837 #define OBD_FAIL_OST_EROFS 0x216
10838 set_nodes_failloc "$(osts_nodes)" 0x216
10840 # multiop should block due to fsync until pages are written
10841 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10845 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10846 error "Multiop failed to block on fsync, pid=$MULTIPID"
10849 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10851 if [[ $WRITEBACK -eq 0 ]]; then
10852 error "No page in writeback, writeback=$WRITEBACK"
10855 set_nodes_failloc "$(osts_nodes)" 0
10858 if [[ $RC -ne 0 ]]; then
10859 error "Multiop fsync failed, rc=$RC"
10862 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10863 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10865 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10866 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10870 echo "Dirty pages flushed via fsync on EROFS"
10873 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
10875 # continue to use small resend count to reduce test_118* time (b=14842)
10876 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10880 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10881 remote_ost_nodsh && skip "remote OST with nodsh"
10885 #define OBD_FAIL_OST_BRW_PAUSE_BULK
10886 set_nodes_failloc "$(osts_nodes)" 0x214
10887 # multiop should block due to fsync until pages are written
10888 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10892 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10893 error "Multiop failed to block on fsync, pid=$MULTIPID"
10896 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10898 if [[ $WRITEBACK -eq 0 ]]; then
10899 error "No page in writeback, writeback=$WRITEBACK"
10902 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
10903 set_nodes_failloc "$(osts_nodes)" 0
10905 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10906 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10908 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10909 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10913 echo "Dirty pages gaurenteed flushed via fsync"
10916 run_test 118d "Fsync validation inject a delay of the bulk =========="
10919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10923 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
10924 lctl set_param fail_loc=0x8000040a
10926 # Should simulate EINVAL error which is fatal
10927 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10929 if [[ $RC -eq 0 ]]; then
10930 error "Must return error due to dropped pages, rc=$RC"
10933 lctl set_param fail_loc=0x0
10935 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10936 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10937 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10939 if [[ $LOCKED -ne 0 ]]; then
10940 error "Locked pages remain in cache, locked=$LOCKED"
10943 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10944 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10948 echo "No pages locked after fsync"
10953 run_test 118f "Simulate unrecoverable OSC side error =========="
10956 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10960 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
10961 lctl set_param fail_loc=0x406
10963 # simulate local -ENOMEM
10964 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10967 lctl set_param fail_loc=0
10968 if [[ $RC -eq 0 ]]; then
10969 error "Must return error due to dropped pages, rc=$RC"
10972 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10973 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10974 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10976 if [[ $LOCKED -ne 0 ]]; then
10977 error "Locked pages remain in cache, locked=$LOCKED"
10980 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10981 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10985 echo "No pages locked after fsync"
10990 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
10993 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10994 remote_ost_nodsh && skip "remote OST with nodsh"
10998 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10999 set_nodes_failloc "$(osts_nodes)" 0x20e
11000 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
11001 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11004 set_nodes_failloc "$(osts_nodes)" 0
11005 if [[ $RC -eq 0 ]]; then
11006 error "Must return error due to dropped pages, rc=$RC"
11009 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11010 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11011 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
11013 if [[ $LOCKED -ne 0 ]]; then
11014 error "Locked pages remain in cache, locked=$LOCKED"
11017 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11018 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11022 echo "No pages locked after fsync"
11026 run_test 118h "Verify timeout in handling recoverables errors =========="
11028 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
11031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11032 remote_ost_nodsh && skip "remote OST with nodsh"
11036 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
11037 set_nodes_failloc "$(osts_nodes)" 0x20e
11039 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
11040 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
11043 set_nodes_failloc "$(osts_nodes)" 0
11047 if [[ $RC -ne 0 ]]; then
11048 error "got error, but should be not, rc=$RC"
11051 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11052 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11053 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
11054 if [[ $LOCKED -ne 0 ]]; then
11055 error "Locked pages remain in cache, locked=$LOCKED"
11058 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11059 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11063 echo "No pages locked after fsync"
11067 run_test 118i "Fix error before timeout in recoverable error =========="
11069 [ "$SLOW" = "no" ] && set_resend_count 4
11072 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11073 remote_ost_nodsh && skip "remote OST with nodsh"
11077 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
11078 set_nodes_failloc "$(osts_nodes)" 0x220
11080 # return -EIO from OST
11081 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11083 set_nodes_failloc "$(osts_nodes)" 0x0
11084 if [[ $RC -eq 0 ]]; then
11085 error "Must return error due to dropped pages, rc=$RC"
11088 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11089 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11090 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
11091 if [[ $LOCKED -ne 0 ]]; then
11092 error "Locked pages remain in cache, locked=$LOCKED"
11095 # in recoverable error on OST we want resend and stay until it finished
11096 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11097 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11101 echo "No pages locked after fsync"
11105 run_test 118j "Simulate unrecoverable OST side error =========="
11109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11110 remote_ost_nodsh && skip "remote OSTs with nodsh"
11112 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
11113 set_nodes_failloc "$(osts_nodes)" 0x20e
11114 test_mkdir $DIR/$tdir
11116 for ((i=0;i<10;i++)); do
11117 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
11118 error "dd to $DIR/$tdir/$tfile-$i failed" )&
11125 set_nodes_failloc "$(osts_nodes)" 0
11128 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
11130 test_118l() # LU-646
11132 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11134 test_mkdir $DIR/$tdir
11135 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
11138 run_test 118l "fsync dir"
11140 test_118m() # LU-3066
11142 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11144 test_mkdir $DIR/$tdir
11145 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
11148 run_test 118m "fdatasync dir ========="
11150 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
11157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11158 remote_ost_nodsh && skip "remote OSTs with nodsh"
11160 # Sleep to avoid a cached response.
11161 #define OBD_STATFS_CACHE_SECONDS 1
11164 # Inject a 10 second delay in the OST_STATFS handler.
11165 #define OBD_FAIL_OST_STATFS_DELAY 0x242
11166 set_nodes_failloc "$(osts_nodes)" 0x242
11169 stat --file-system $MOUNT > /dev/null
11172 set_nodes_failloc "$(osts_nodes)" 0
11174 if ((end - begin > 20)); then
11175 error "statfs took $((end - begin)) seconds, expected 10"
11178 run_test 118n "statfs() sends OST_STATFS requests in parallel"
11180 test_119a() # bug 11737
11182 BSIZE=$((512 * 1024))
11183 directio write $DIR/$tfile 0 1 $BSIZE
11184 # We ask to read two blocks, which is more than a file size.
11185 # directio will indicate an error when requested and actual
11186 # sizes aren't equeal (a normal situation in this case) and
11187 # print actual read amount.
11188 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
11189 if [ "$NOB" != "$BSIZE" ]; then
11190 error "read $NOB bytes instead of $BSIZE"
11194 run_test 119a "Short directIO read must return actual read amount"
11196 test_119b() # bug 11737
11198 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11200 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
11201 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
11203 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
11204 error "direct read failed"
11207 run_test 119b "Sparse directIO read must return actual read amount"
11209 test_119c() # bug 13099
11212 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
11213 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
11216 run_test 119c "Testing for direct read hitting hole"
11218 test_119d() # bug 15950
11220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11222 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
11223 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
11225 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
11226 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
11227 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
11228 lctl set_param fail_loc=0x40d
11229 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
11232 cat $DIR/$tfile > /dev/null &
11233 lctl set_param fail_loc=0
11236 log "the DIO writes have completed, now wait for the reads (should not block very long)"
11238 [ -n "`ps h -p $pid_reads -o comm`" ] && \
11239 error "the read rpcs have not completed in 2s"
11241 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
11243 run_test 119d "The DIO path should try to send a new rpc once one is completed"
11246 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11247 remote_mds_nodsh && skip "remote MDS with nodsh"
11248 test_mkdir -i0 -c1 $DIR/$tdir
11249 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11250 skip_env "no early lock cancel on server"
11252 lru_resize_disable mdc
11253 lru_resize_disable osc
11254 cancel_lru_locks mdc
11255 # asynchronous object destroy at MDT could cause bl ast to client
11256 cancel_lru_locks osc
11258 stat $DIR/$tdir > /dev/null
11259 can1=$(do_facet mds1 \
11260 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11261 awk '/ldlm_cancel/ {print $2}')
11262 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11263 awk '/ldlm_bl_callback/ {print $2}')
11264 test_mkdir -i0 -c1 $DIR/$tdir/d1
11265 can2=$(do_facet mds1 \
11266 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11267 awk '/ldlm_cancel/ {print $2}')
11268 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11269 awk '/ldlm_bl_callback/ {print $2}')
11270 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11271 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11272 lru_resize_enable mdc
11273 lru_resize_enable osc
11275 run_test 120a "Early Lock Cancel: mkdir test"
11278 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11279 remote_mds_nodsh && skip "remote MDS with nodsh"
11280 test_mkdir $DIR/$tdir
11281 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11282 skip_env "no early lock cancel on server"
11284 lru_resize_disable mdc
11285 lru_resize_disable osc
11286 cancel_lru_locks mdc
11287 stat $DIR/$tdir > /dev/null
11288 can1=$(do_facet $SINGLEMDS \
11289 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11290 awk '/ldlm_cancel/ {print $2}')
11291 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11292 awk '/ldlm_bl_callback/ {print $2}')
11293 touch $DIR/$tdir/f1
11294 can2=$(do_facet $SINGLEMDS \
11295 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11296 awk '/ldlm_cancel/ {print $2}')
11297 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11298 awk '/ldlm_bl_callback/ {print $2}')
11299 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11300 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11301 lru_resize_enable mdc
11302 lru_resize_enable osc
11304 run_test 120b "Early Lock Cancel: create test"
11307 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11308 remote_mds_nodsh && skip "remote MDS with nodsh"
11309 test_mkdir -i0 -c1 $DIR/$tdir
11310 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11311 skip "no early lock cancel on server"
11313 lru_resize_disable mdc
11314 lru_resize_disable osc
11315 test_mkdir -i0 -c1 $DIR/$tdir/d1
11316 test_mkdir -i0 -c1 $DIR/$tdir/d2
11317 touch $DIR/$tdir/d1/f1
11318 cancel_lru_locks mdc
11319 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
11320 can1=$(do_facet mds1 \
11321 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11322 awk '/ldlm_cancel/ {print $2}')
11323 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11324 awk '/ldlm_bl_callback/ {print $2}')
11325 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
11326 can2=$(do_facet mds1 \
11327 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11328 awk '/ldlm_cancel/ {print $2}')
11329 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11330 awk '/ldlm_bl_callback/ {print $2}')
11331 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11332 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11333 lru_resize_enable mdc
11334 lru_resize_enable osc
11336 run_test 120c "Early Lock Cancel: link test"
11339 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11340 remote_mds_nodsh && skip "remote MDS with nodsh"
11341 test_mkdir -i0 -c1 $DIR/$tdir
11342 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11343 skip_env "no early lock cancel on server"
11345 lru_resize_disable mdc
11346 lru_resize_disable osc
11348 cancel_lru_locks mdc
11349 stat $DIR/$tdir > /dev/null
11350 can1=$(do_facet mds1 \
11351 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11352 awk '/ldlm_cancel/ {print $2}')
11353 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11354 awk '/ldlm_bl_callback/ {print $2}')
11355 chmod a+x $DIR/$tdir
11356 can2=$(do_facet mds1 \
11357 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11358 awk '/ldlm_cancel/ {print $2}')
11359 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11360 awk '/ldlm_bl_callback/ {print $2}')
11361 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11362 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11363 lru_resize_enable mdc
11364 lru_resize_enable osc
11366 run_test 120d "Early Lock Cancel: setattr test"
11369 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11370 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11371 skip_env "no early lock cancel on server"
11372 remote_mds_nodsh && skip "remote MDS with nodsh"
11374 local dlmtrace_set=false
11376 test_mkdir -i0 -c1 $DIR/$tdir
11377 lru_resize_disable mdc
11378 lru_resize_disable osc
11379 ! $LCTL get_param debug | grep -q dlmtrace &&
11380 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
11381 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
11382 cancel_lru_locks mdc
11383 cancel_lru_locks osc
11384 dd if=$DIR/$tdir/f1 of=/dev/null
11385 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
11386 # XXX client can not do early lock cancel of OST lock
11387 # during unlink (LU-4206), so cancel osc lock now.
11389 cancel_lru_locks osc
11390 can1=$(do_facet mds1 \
11391 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11392 awk '/ldlm_cancel/ {print $2}')
11393 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11394 awk '/ldlm_bl_callback/ {print $2}')
11395 unlink $DIR/$tdir/f1
11397 can2=$(do_facet mds1 \
11398 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11399 awk '/ldlm_cancel/ {print $2}')
11400 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11401 awk '/ldlm_bl_callback/ {print $2}')
11402 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
11403 $LCTL dk $TMP/cancel.debug.txt
11404 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
11405 $LCTL dk $TMP/blocking.debug.txt
11406 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
11407 lru_resize_enable mdc
11408 lru_resize_enable osc
11410 run_test 120e "Early Lock Cancel: unlink test"
11413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11414 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11415 skip_env "no early lock cancel on server"
11416 remote_mds_nodsh && skip "remote MDS with nodsh"
11418 test_mkdir -i0 -c1 $DIR/$tdir
11419 lru_resize_disable mdc
11420 lru_resize_disable osc
11421 test_mkdir -i0 -c1 $DIR/$tdir/d1
11422 test_mkdir -i0 -c1 $DIR/$tdir/d2
11423 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
11424 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
11425 cancel_lru_locks mdc
11426 cancel_lru_locks osc
11427 dd if=$DIR/$tdir/d1/f1 of=/dev/null
11428 dd if=$DIR/$tdir/d2/f2 of=/dev/null
11429 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
11430 # XXX client can not do early lock cancel of OST lock
11431 # during rename (LU-4206), so cancel osc lock now.
11433 cancel_lru_locks osc
11434 can1=$(do_facet mds1 \
11435 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11436 awk '/ldlm_cancel/ {print $2}')
11437 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11438 awk '/ldlm_bl_callback/ {print $2}')
11439 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
11441 can2=$(do_facet mds1 \
11442 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11443 awk '/ldlm_cancel/ {print $2}')
11444 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11445 awk '/ldlm_bl_callback/ {print $2}')
11446 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11447 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11448 lru_resize_enable mdc
11449 lru_resize_enable osc
11451 run_test 120f "Early Lock Cancel: rename test"
11454 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11455 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11456 skip_env "no early lock cancel on server"
11457 remote_mds_nodsh && skip "remote MDS with nodsh"
11459 lru_resize_disable mdc
11460 lru_resize_disable osc
11462 echo create $count files
11463 test_mkdir $DIR/$tdir
11464 cancel_lru_locks mdc
11465 cancel_lru_locks osc
11468 can0=$(do_facet $SINGLEMDS \
11469 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11470 awk '/ldlm_cancel/ {print $2}')
11471 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11472 awk '/ldlm_bl_callback/ {print $2}')
11473 createmany -o $DIR/$tdir/f $count
11475 can1=$(do_facet $SINGLEMDS \
11476 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11477 awk '/ldlm_cancel/ {print $2}')
11478 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11479 awk '/ldlm_bl_callback/ {print $2}')
11481 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
11482 echo rm $count files
11485 can2=$(do_facet $SINGLEMDS \
11486 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11487 awk '/ldlm_cancel/ {print $2}')
11488 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11489 awk '/ldlm_bl_callback/ {print $2}')
11491 echo total: $count removes in $((t2-t1))
11492 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
11494 # wait for commitment of removal
11495 lru_resize_enable mdc
11496 lru_resize_enable osc
11498 run_test 120g "Early Lock Cancel: performance test"
11500 test_121() { #bug #10589
11501 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11504 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
11505 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
11506 lctl set_param fail_loc=0x310
11507 cancel_lru_locks osc > /dev/null
11508 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
11509 lctl set_param fail_loc=0
11510 [[ $reads -eq $writes ]] ||
11511 error "read $reads blocks, must be $writes blocks"
11513 run_test 121 "read cancel race ========="
11515 test_123a() { # was test 123, statahead(bug 11401)
11516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11519 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
11520 log "testing UP system. Performance may be lower than expected."
11525 test_mkdir $DIR/$tdir
11526 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
11527 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
11529 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
11530 createmany -o $DIR/$tdir/$tfile $j $((i - j))
11532 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
11533 lctl set_param -n llite.*.statahead_max 0
11534 lctl get_param llite.*.statahead_max
11535 cancel_lru_locks mdc
11536 cancel_lru_locks osc
11538 time ls -l $DIR/$tdir | wc -l
11540 delta=$((etime - stime))
11541 log "ls $i files without statahead: $delta sec"
11542 lctl set_param llite.*.statahead_max=$max
11544 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
11545 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
11546 cancel_lru_locks mdc
11547 cancel_lru_locks osc
11549 time ls -l $DIR/$tdir | wc -l
11551 delta_sa=$((etime - stime))
11552 log "ls $i files with statahead: $delta_sa sec"
11553 lctl get_param -n llite.*.statahead_stats
11554 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
11556 [[ $swrong -lt $ewrong ]] &&
11557 log "statahead was stopped, maybe too many locks held!"
11558 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
11560 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
11561 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
11562 lctl set_param -n llite.*.statahead_max 0
11563 lctl get_param llite.*.statahead_max
11564 cancel_lru_locks mdc
11565 cancel_lru_locks osc
11567 time ls -l $DIR/$tdir | wc -l
11569 delta=$((etime - stime))
11570 log "ls $i files again without statahead: $delta sec"
11571 lctl set_param llite.*.statahead_max=$max
11572 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
11573 if [ $SLOWOK -eq 0 ]; then
11574 error "ls $i files is slower with statahead!"
11576 log "ls $i files is slower with statahead!"
11582 [ $delta -gt 20 ] && break
11583 [ $delta -gt 8 ] && MULT=$((50 / delta))
11584 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
11592 delta=$((etime - stime))
11593 log "rm -r $DIR/$tdir/: $delta seconds"
11595 lctl get_param -n llite.*.statahead_stats
11597 run_test 123a "verify statahead work"
11599 test_123b () { # statahead(bug 15027)
11600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11602 test_mkdir $DIR/$tdir
11603 createmany -o $DIR/$tdir/$tfile-%d 1000
11605 cancel_lru_locks mdc
11606 cancel_lru_locks osc
11608 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
11609 lctl set_param fail_loc=0x80000803
11610 ls -lR $DIR/$tdir > /dev/null
11612 lctl set_param fail_loc=0x0
11613 lctl get_param -n llite.*.statahead_stats
11618 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
11621 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
11623 test_mkdir -i 0 -c 1 $DIR/$tdir.0
11624 test_mkdir -i 1 -c 1 $DIR/$tdir.1
11625 touch $DIR/$tdir.1/{1..3}
11626 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
11628 remount_client $MOUNT
11630 $MULTIOP $DIR/$tdir.0 Q
11632 # let statahead to complete
11633 ls -l $DIR/$tdir.0 > /dev/null
11635 testid=$(echo $TESTNAME | tr '_' ' ')
11636 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
11637 error "statahead warning" || true
11639 run_test 123c "Can not initialize inode warning on DNE statahead"
11642 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11643 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11644 skip_env "no lru resize on server"
11648 test_mkdir $DIR/$tdir
11650 log "create $NR files at $DIR/$tdir"
11651 createmany -o $DIR/$tdir/f $NR ||
11652 error "failed to create $NR files in $DIR/$tdir"
11654 cancel_lru_locks mdc
11655 ls -l $DIR/$tdir > /dev/null
11659 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
11660 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
11661 LRU_SIZE=$($LCTL get_param -n $PARAM)
11662 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
11663 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
11665 log "NS=$(basename $NSDIR)"
11670 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
11671 skip "Not enough cached locks created!"
11673 log "LRU=$LRU_SIZE"
11677 # We know that lru resize allows one client to hold $LIMIT locks
11678 # for 10h. After that locks begin to be killed by client.
11680 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
11682 if [ $LIMIT -lt $LRU_SIZE ]; then
11683 skip "Limit is too small $LIMIT"
11686 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
11687 # killing locks. Some time was spent for creating locks. This means
11688 # that up to the moment of sleep finish we must have killed some of
11689 # them (10-100 locks). This depends on how fast ther were created.
11690 # Many of them were touched in almost the same moment and thus will
11691 # be killed in groups.
11692 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
11694 # Use $LRU_SIZE_B here to take into account real number of locks
11695 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
11696 local LRU_SIZE_B=$LRU_SIZE
11698 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
11699 log "OLD_LVF=$OLD_LVF"
11700 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
11702 # Let's make sure that we really have some margin. Client checks
11703 # cached locks every 10 sec.
11704 SLEEP=$((SLEEP+20))
11705 log "Sleep ${SLEEP} sec"
11707 while ((SEC<$SLEEP)); do
11711 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
11712 echo -n "$LRU_SIZE"
11715 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
11716 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
11718 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
11719 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
11720 unlinkmany $DIR/$tdir/f $NR
11724 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
11725 log "unlink $NR files at $DIR/$tdir"
11726 unlinkmany $DIR/$tdir/f $NR
11728 run_test 124a "lru resize ======================================="
11730 get_max_pool_limit()
11732 local limit=$($LCTL get_param \
11733 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
11735 for l in $limit; do
11736 if [[ $l -gt $max ]]; then
11744 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11745 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11746 skip_env "no lru resize on server"
11748 LIMIT=$(get_max_pool_limit)
11750 NR=$(($(default_lru_size)*20))
11751 if [[ $NR -gt $LIMIT ]]; then
11752 log "Limit lock number by $LIMIT locks"
11756 IFree=$(mdsrate_inodes_available)
11757 if [ $IFree -lt $NR ]; then
11758 log "Limit lock number by $IFree inodes"
11762 lru_resize_disable mdc
11763 test_mkdir -p $DIR/$tdir/disable_lru_resize
11765 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
11766 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
11767 cancel_lru_locks mdc
11770 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11773 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11776 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11780 nolruresize_delta=$((etime-stime))
11781 log "ls -la time: $nolruresize_delta seconds"
11782 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11783 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
11785 lru_resize_enable mdc
11786 test_mkdir -p $DIR/$tdir/enable_lru_resize
11788 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
11789 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
11790 cancel_lru_locks mdc
11793 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11796 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11799 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11803 lruresize_delta=$((etime-stime))
11804 log "ls -la time: $lruresize_delta seconds"
11805 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11807 if [ $lruresize_delta -gt $nolruresize_delta ]; then
11808 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
11809 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
11810 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
11812 log "lru resize performs the same with no lru resize"
11814 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
11816 run_test 124b "lru resize (performance test) ======================="
11819 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11820 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11821 skip_env "no lru resize on server"
11823 # cache ununsed locks on client
11825 cancel_lru_locks mdc
11826 test_mkdir $DIR/$tdir
11827 createmany -o $DIR/$tdir/f $nr ||
11828 error "failed to create $nr files in $DIR/$tdir"
11829 ls -l $DIR/$tdir > /dev/null
11831 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11832 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11833 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11834 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11835 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11837 # set lru_max_age to 1 sec
11838 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11839 echo "sleep $((recalc_p * 2)) seconds..."
11840 sleep $((recalc_p * 2))
11842 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11843 # restore lru_max_age
11844 $LCTL set_param -n $nsdir.lru_max_age $max_age
11845 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11846 unlinkmany $DIR/$tdir/f $nr
11848 run_test 124c "LRUR cancel very aged locks"
11851 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11852 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11853 skip_env "no lru resize on server"
11855 # cache ununsed locks on client
11858 lru_resize_disable mdc
11859 stack_trap "lru_resize_enable mdc" EXIT
11861 cancel_lru_locks mdc
11863 # asynchronous object destroy at MDT could cause bl ast to client
11864 test_mkdir $DIR/$tdir
11865 createmany -o $DIR/$tdir/f $nr ||
11866 error "failed to create $nr files in $DIR/$tdir"
11867 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
11869 ls -l $DIR/$tdir > /dev/null
11871 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11872 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11873 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11874 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11876 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11878 # set lru_max_age to 1 sec
11879 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11880 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
11882 echo "sleep $((recalc_p * 2)) seconds..."
11883 sleep $((recalc_p * 2))
11885 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11887 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11889 run_test 124d "cancel very aged locks if lru-resize diasbaled"
11891 test_125() { # 13358
11892 $LCTL get_param -n llite.*.client_type | grep -q local ||
11893 skip "must run as local client"
11894 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
11895 skip_env "must have acl enabled"
11896 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11898 test_mkdir $DIR/$tdir
11899 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
11900 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
11901 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
11903 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
11905 test_126() { # bug 12829/13455
11906 $GSS && skip_env "must run as gss disabled"
11907 $LCTL get_param -n llite.*.client_type | grep -q local ||
11908 skip "must run as local client"
11909 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
11911 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
11912 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
11914 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
11916 run_test 126 "check that the fsgid provided by the client is taken into account"
11918 test_127a() { # bug 15521
11919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11920 local name count samp unit min max sum sumsq
11922 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
11923 echo "stats before reset"
11924 $LCTL get_param osc.*.stats
11925 $LCTL set_param osc.*.stats=0
11926 local fsize=$((2048 * 1024))
11928 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
11929 cancel_lru_locks osc
11930 dd if=$DIR/$tfile of=/dev/null bs=$fsize
11932 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
11933 stack_trap "rm -f $TMP/$tfile.tmp"
11934 while read name count samp unit min max sum sumsq; do
11935 echo "got name=$name count=$count unit=$unit min=$min max=$max"
11936 [ ! $min ] && error "Missing min value for $name proc entry"
11937 eval $name=$count || error "Wrong proc format"
11940 read_bytes|write_bytes)
11941 [[ "$unit" =~ "bytes" ]] ||
11942 error "unit is not 'bytes': $unit"
11943 (( $min >= 4096 )) || error "min is too small: $min"
11944 (( $min <= $fsize )) || error "min is too big: $min"
11945 (( $max >= 4096 )) || error "max is too small: $max"
11946 (( $max <= $fsize )) || error "max is too big: $max"
11947 (( $sum == $fsize )) || error "sum is wrong: $sum"
11948 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
11949 error "sumsquare is too small: $sumsq"
11950 (( $sumsq <= $fsize * $fsize )) ||
11951 error "sumsquare is too big: $sumsq"
11953 ost_read|ost_write)
11954 [[ "$unit" =~ "usec" ]] ||
11955 error "unit is not 'usec': $unit"
11959 done < $DIR/$tfile.tmp
11961 #check that we actually got some stats
11962 [ "$read_bytes" ] || error "Missing read_bytes stats"
11963 [ "$write_bytes" ] || error "Missing write_bytes stats"
11964 [ "$read_bytes" != 0 ] || error "no read done"
11965 [ "$write_bytes" != 0 ] || error "no write done"
11967 run_test 127a "verify the client stats are sane"
11969 test_127b() { # bug LU-333
11970 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11971 local name count samp unit min max sum sumsq
11973 echo "stats before reset"
11974 $LCTL get_param llite.*.stats
11975 $LCTL set_param llite.*.stats=0
11977 # perform 2 reads and writes so MAX is different from SUM.
11978 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11979 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11980 cancel_lru_locks osc
11981 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11982 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11984 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
11985 stack_trap "rm -f $TMP/$tfile.tmp"
11986 while read name count samp unit min max sum sumsq; do
11987 echo "got name=$name count=$count unit=$unit min=$min max=$max"
11988 eval $name=$count || error "Wrong proc format"
11991 read_bytes|write_bytes)
11992 [[ "$unit" =~ "bytes" ]] ||
11993 error "unit is not 'bytes': $unit"
11994 (( $count == 2 )) || error "count is not 2: $count"
11995 (( $min == $PAGE_SIZE )) ||
11996 error "min is not $PAGE_SIZE: $min"
11997 (( $max == $PAGE_SIZE )) ||
11998 error "max is not $PAGE_SIZE: $max"
11999 (( $sum == $PAGE_SIZE * 2 )) ||
12000 error "sum is not $((PAGE_SIZE * 2)): $sum"
12003 [[ "$unit" =~ "usec" ]] ||
12004 error "unit is not 'usec': $unit"
12008 done < $TMP/$tfile.tmp
12010 #check that we actually got some stats
12011 [ "$read_bytes" ] || error "Missing read_bytes stats"
12012 [ "$write_bytes" ] || error "Missing write_bytes stats"
12013 [ "$read_bytes" != 0 ] || error "no read done"
12014 [ "$write_bytes" != 0 ] || error "no write done"
12016 run_test 127b "verify the llite client stats are sane"
12018 test_127c() { # LU-12394
12019 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
12026 $LCTL set_param llite.*.extents_stats=1
12027 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
12029 # Use two stripes so there is enough space in default config
12030 $LFS setstripe -c 2 $DIR/$tfile
12032 # Extent stats start at 0-4K and go in power of two buckets
12033 # LL_HIST_START = 12 --> 2^12 = 4K
12034 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
12035 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
12037 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
12039 # Write and read, 2x each, second time at a non-zero offset
12040 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
12041 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
12042 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
12043 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
12047 $LCTL get_param llite.*.extents_stats
12050 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
12052 local bucket=$($LCTL get_param -n llite.*.extents_stats |
12054 reads=$(echo $bucket | awk '{print $5}')
12055 writes=$(echo $bucket | awk '{print $9}')
12056 [ "$reads" -eq $count ] ||
12057 error "$reads reads in < $bsize bucket, expect $count"
12058 [ "$writes" -eq $count ] ||
12059 error "$writes writes in < $bsize bucket, expect $count"
12062 # Test mmap write and read
12063 $LCTL set_param llite.*.extents_stats=c
12065 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
12066 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
12067 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
12069 $LCTL get_param llite.*.extents_stats
12071 count=$(((size*1024) / PAGE_SIZE))
12073 bsize=$((2 * PAGE_SIZE / 1024))K
12075 bucket=$($LCTL get_param -n llite.*.extents_stats |
12077 reads=$(echo $bucket | awk '{print $5}')
12078 writes=$(echo $bucket | awk '{print $9}')
12079 # mmap writes fault in the page first, creating an additonal read
12080 [ "$reads" -eq $((2 * count)) ] ||
12081 error "$reads reads in < $bsize bucket, expect $count"
12082 [ "$writes" -eq $count ] ||
12083 error "$writes writes in < $bsize bucket, expect $count"
12085 run_test 127c "test llite extent stats with regular & mmap i/o"
12087 test_128() { # bug 15212
12089 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
12094 result=$(grep error $TMP/$tfile.log)
12095 rm -f $DIR/$tfile $TMP/$tfile.log
12096 [ -z "$result" ] ||
12097 error "consecutive find's under interactive lfs failed"
12099 run_test 128 "interactive lfs for 2 consecutive find's"
12101 set_dir_limits () {
12106 local ldproc=/proc/fs/ldiskfs
12107 local facets=$(get_facets MDS)
12109 for facet in ${facets//,/ }; do
12110 canondev=$(ldiskfs_canon \
12111 *.$(convert_facet2label $facet).mntdev $facet)
12112 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
12113 ldproc=/sys/fs/ldiskfs
12114 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
12115 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
12119 check_mds_dmesg() {
12120 local facets=$(get_facets MDS)
12121 for facet in ${facets//,/ }; do
12122 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
12128 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12129 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
12130 skip "Need MDS version with at least 2.5.56"
12131 if [ "$mds1_FSTYPE" != ldiskfs ]; then
12132 skip_env "ldiskfs only test"
12134 remote_mds_nodsh && skip "remote MDS with nodsh"
12138 local has_warning=false
12141 mkdir -p $DIR/$tdir
12143 # block size of mds1
12144 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
12145 set_dir_limits $maxsize $maxsize
12146 local dirsize=$(stat -c%s "$DIR/$tdir")
12148 while [[ $dirsize -le $maxsize ]]; do
12149 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
12151 if ! $has_warning; then
12152 check_mds_dmesg '"is approaching"' && has_warning=true
12154 # check two errors:
12155 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
12156 # EFBIG for previous versions included in ldiskfs series
12157 if [ $rc -eq $EFBIG ] || [ $rc -eq $ENOSPC ]; then
12159 echo "return code $rc received as expected"
12161 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
12162 error_exit "create failed w/o dir size limit"
12164 check_mds_dmesg '"has reached"' ||
12165 error_exit "reached message should be output"
12167 [ $has_warning = "false" ] &&
12168 error_exit "warning message should be output"
12170 dirsize=$(stat -c%s "$DIR/$tdir")
12172 [[ $dirsize -ge $maxsize ]] && return 0
12173 error_exit "current dir size $dirsize, " \
12174 "previous limit $maxsize"
12175 elif [ $rc -ne 0 ]; then
12177 error_exit "return $rc received instead of expected " \
12178 "$EFBIG or $ENOSPC, files in dir $dirsize"
12180 nfiles=$((nfiles + 1))
12181 dirsize=$(stat -c%s "$DIR/$tdir")
12185 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
12187 run_test 129 "test directory size limit ========================"
12196 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12197 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12199 trap cleanup_130 EXIT RETURN
12201 local fm_file=$DIR/$tfile
12202 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
12203 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
12204 error "dd failed for $fm_file"
12206 # LU-1795: test filefrag/FIEMAP once, even if unsupported
12207 filefrag -ves $fm_file
12209 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12210 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12211 [ $RC != 0 ] && error "filefrag $fm_file failed"
12213 filefrag_op=$(filefrag -ve -k $fm_file |
12214 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12215 lun=$($LFS getstripe -i $fm_file)
12217 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
12220 for line in $filefrag_op
12222 frag_lun=`echo $line | cut -d: -f5`
12223 ext_len=`echo $line | cut -d: -f4`
12224 if (( $frag_lun != $lun )); then
12226 error "FIEMAP on 1-stripe file($fm_file) failed"
12229 (( tot_len += ext_len ))
12232 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
12234 error "FIEMAP on 1-stripe file($fm_file) failed;"
12240 echo "FIEMAP on single striped file succeeded"
12242 run_test 130a "FIEMAP (1-stripe file)"
12245 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
12247 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12248 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12250 trap cleanup_130 EXIT RETURN
12252 local fm_file=$DIR/$tfile
12253 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
12254 error "setstripe on $fm_file"
12255 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12256 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12258 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
12259 error "dd failed on $fm_file"
12261 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12262 filefrag_op=$(filefrag -ve -k $fm_file |
12263 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12265 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12266 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12271 for line in $filefrag_op
12273 frag_lun=$(echo $line | cut -d: -f5 |
12274 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12275 ext_len=$(echo $line | cut -d: -f4)
12276 if (( $frag_lun != $last_lun )); then
12277 if (( tot_len != 1024 )); then
12279 error "FIEMAP on $fm_file failed; returned " \
12280 "len $tot_len for OST $last_lun instead of 1024"
12283 (( num_luns += 1 ))
12287 (( tot_len += ext_len ))
12290 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
12292 error "FIEMAP on $fm_file failed; returned wrong number of " \
12293 "luns or wrong len for OST $last_lun"
12299 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
12301 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
12304 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12306 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12307 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12309 trap cleanup_130 EXIT RETURN
12311 local fm_file=$DIR/$tfile
12312 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
12313 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12314 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12316 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
12317 error "dd failed on $fm_file"
12319 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12320 filefrag_op=$(filefrag -ve -k $fm_file |
12321 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12323 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12324 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12329 for line in $filefrag_op
12331 frag_lun=$(echo $line | cut -d: -f5 |
12332 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12333 ext_len=$(echo $line | cut -d: -f4)
12334 if (( $frag_lun != $last_lun )); then
12335 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
12336 if (( logical != 512 )); then
12338 error "FIEMAP on $fm_file failed; returned " \
12339 "logical start for lun $logical instead of 512"
12342 if (( tot_len != 512 )); then
12344 error "FIEMAP on $fm_file failed; returned " \
12345 "len $tot_len for OST $last_lun instead of 1024"
12348 (( num_luns += 1 ))
12352 (( tot_len += ext_len ))
12355 if (( num_luns != 2 || tot_len != 512 )); then
12357 error "FIEMAP on $fm_file failed; returned wrong number of " \
12358 "luns or wrong len for OST $last_lun"
12364 echo "FIEMAP on 2-stripe file with hole succeeded"
12366 run_test 130c "FIEMAP (2-stripe file with hole)"
12369 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
12371 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12372 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12374 trap cleanup_130 EXIT RETURN
12376 local fm_file=$DIR/$tfile
12377 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
12378 error "setstripe on $fm_file"
12379 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12380 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12382 local actual_stripe_count=$($LFS getstripe -c $fm_file)
12383 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
12384 error "dd failed on $fm_file"
12386 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12387 filefrag_op=$(filefrag -ve -k $fm_file |
12388 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12390 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12391 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12396 for line in $filefrag_op
12398 frag_lun=$(echo $line | cut -d: -f5 |
12399 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12400 ext_len=$(echo $line | cut -d: -f4)
12401 if (( $frag_lun != $last_lun )); then
12402 if (( tot_len != 1024 )); then
12404 error "FIEMAP on $fm_file failed; returned " \
12405 "len $tot_len for OST $last_lun instead of 1024"
12408 (( num_luns += 1 ))
12412 (( tot_len += ext_len ))
12415 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
12417 error "FIEMAP on $fm_file failed; returned wrong number of " \
12418 "luns or wrong len for OST $last_lun"
12424 echo "FIEMAP on N-stripe file succeeded"
12426 run_test 130d "FIEMAP (N-stripe file)"
12429 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12431 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12432 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12434 trap cleanup_130 EXIT RETURN
12436 local fm_file=$DIR/$tfile
12437 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
12438 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12439 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12442 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
12443 for ((i = 0; i < $NUM_BLKS; i++))
12445 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
12448 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12449 filefrag_op=$(filefrag -ve -k $fm_file |
12450 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12452 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12453 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12458 for line in $filefrag_op
12460 frag_lun=$(echo $line | cut -d: -f5 |
12461 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12462 ext_len=$(echo $line | cut -d: -f4)
12463 if (( $frag_lun != $last_lun )); then
12464 if (( tot_len != $EXPECTED_LEN )); then
12466 error "FIEMAP on $fm_file failed; returned " \
12467 "len $tot_len for OST $last_lun instead " \
12471 (( num_luns += 1 ))
12475 (( tot_len += ext_len ))
12478 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
12480 error "FIEMAP on $fm_file failed; returned wrong number " \
12481 "of luns or wrong len for OST $last_lun"
12487 echo "FIEMAP with continuation calls succeeded"
12489 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
12492 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12493 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12495 local fm_file=$DIR/$tfile
12496 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
12497 error "multiop create with lov_delay_create on $fm_file"
12499 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12500 filefrag_extents=$(filefrag -vek $fm_file |
12501 awk '/extents? found/ { print $2 }')
12502 if [[ "$filefrag_extents" != "0" ]]; then
12503 error "FIEMAP on $fm_file failed; " \
12504 "returned $filefrag_extents expected 0"
12509 run_test 130f "FIEMAP (unstriped file)"
12511 # Test for writev/readv
12513 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
12514 error "writev test failed"
12515 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
12516 error "readv failed"
12519 run_test 131a "test iov's crossing stripe boundary for writev/readv"
12522 local fsize=$((524288 + 1048576 + 1572864))
12523 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
12524 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
12525 error "append writev test failed"
12527 ((fsize += 1572864 + 1048576))
12528 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
12529 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
12530 error "append writev test failed"
12533 run_test 131b "test append writev"
12536 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
12539 run_test 131c "test read/write on file w/o objects"
12542 rwv -f $DIR/$tfile -w -n 1 1572864
12543 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
12544 if [ "$NOB" != 1572864 ]; then
12545 error "Short read filed: read $NOB bytes instead of 1572864"
12549 run_test 131d "test short read"
12552 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
12553 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
12554 error "read hitting hole failed"
12557 run_test 131e "test read hitting hole"
12566 mds*) res=$(do_facet $facet \
12567 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
12569 ost*) res=$(do_facet $facet \
12570 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
12572 *) error "Wrong facet '$facet'" ;;
12574 [ "$res" ] || error "The counter for $op on $facet was not incremented"
12575 # if the argument $3 is zero, it means any stat increment is ok.
12576 if [[ $want -gt 0 ]]; then
12577 local count=$(echo $res | awk '{ print $2 }')
12578 [[ $count -ne $want ]] &&
12579 error "The $op counter on $facet is $count, not $want"
12584 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12585 remote_ost_nodsh && skip "remote OST with nodsh"
12586 remote_mds_nodsh && skip "remote MDS with nodsh"
12587 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12588 skip_env "MDS doesn't support rename stats"
12590 local testdir=$DIR/${tdir}/stats_testdir
12592 mkdir -p $DIR/${tdir}
12595 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12596 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12598 # verify mdt stats first.
12599 mkdir ${testdir} || error "mkdir failed"
12600 check_stats $SINGLEMDS "mkdir" 1
12601 touch ${testdir}/${tfile} || error "touch failed"
12602 check_stats $SINGLEMDS "open" 1
12603 check_stats $SINGLEMDS "close" 1
12604 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
12605 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
12606 check_stats $SINGLEMDS "mknod" 2
12608 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
12609 check_stats $SINGLEMDS "unlink" 1
12610 rm -f ${testdir}/${tfile} || error "file remove failed"
12611 check_stats $SINGLEMDS "unlink" 2
12613 # remove working dir and check mdt stats again.
12614 rmdir ${testdir} || error "rmdir failed"
12615 check_stats $SINGLEMDS "rmdir" 1
12617 local testdir1=$DIR/${tdir}/stats_testdir1
12618 mkdir -p ${testdir}
12619 mkdir -p ${testdir1}
12620 touch ${testdir1}/test1
12621 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
12622 check_stats $SINGLEMDS "crossdir_rename" 1
12624 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
12625 check_stats $SINGLEMDS "samedir_rename" 1
12627 rm -rf $DIR/${tdir}
12629 run_test 133a "Verifying MDT stats ========================================"
12634 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12635 remote_ost_nodsh && skip "remote OST with nodsh"
12636 remote_mds_nodsh && skip "remote MDS with nodsh"
12638 local testdir=$DIR/${tdir}/stats_testdir
12640 mkdir -p ${testdir} || error "mkdir failed"
12641 touch ${testdir}/${tfile} || error "touch failed"
12642 cancel_lru_locks mdc
12645 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12646 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12648 # extra mdt stats verification.
12649 chmod 444 ${testdir}/${tfile} || error "chmod failed"
12650 check_stats $SINGLEMDS "setattr" 1
12651 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12652 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
12654 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
12655 check_stats $SINGLEMDS "getattr" 1
12657 rm -rf $DIR/${tdir}
12659 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
12660 # so the check below is not reliable
12661 [ $MDSCOUNT -eq 1 ] || return 0
12663 # Sleep to avoid a cached response.
12664 #define OBD_STATFS_CACHE_SECONDS 1
12666 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12667 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12668 $LFS df || error "lfs failed"
12669 check_stats $SINGLEMDS "statfs" 1
12671 # check aggregated statfs (LU-10018)
12672 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
12674 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
12677 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12678 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12680 check_stats $SINGLEMDS "statfs" 1
12682 # We want to check that the client didn't send OST_STATFS to
12683 # ost1 but the MDT also uses OST_STATFS for precreate. So some
12684 # extra care is needed here.
12685 if remote_mds; then
12686 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
12687 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
12689 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
12690 [ "$res" ] && error "OST got STATFS"
12695 run_test 133b "Verifying extra MDT stats =================================="
12698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12699 remote_ost_nodsh && skip "remote OST with nodsh"
12700 remote_mds_nodsh && skip "remote MDS with nodsh"
12702 local testdir=$DIR/$tdir/stats_testdir
12704 test_mkdir -p $testdir
12706 # verify obdfilter stats.
12707 $LFS setstripe -c 1 -i 0 $testdir/$tfile
12709 cancel_lru_locks osc
12710 wait_delete_completed
12713 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12714 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12716 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
12719 cancel_lru_locks osc
12720 check_stats ost1 "write" 1
12722 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
12723 check_stats ost1 "read" 1
12725 > $testdir/$tfile || error "truncate failed"
12726 check_stats ost1 "punch" 1
12728 rm -f $testdir/$tfile || error "file remove failed"
12729 wait_delete_completed
12730 check_stats ost1 "destroy" 1
12734 run_test 133c "Verifying OST stats ========================================"
12741 while [ $value -ge 2 ]; do
12746 if [ $orig -gt $order ]; then
12754 local size=('K' 'M' 'G' 'T');
12756 local size_string=$value
12758 while [ $value -ge 1024 ]; do
12759 if [ $i -gt 3 ]; then
12760 #T is the biggest unit we get here, if that is bigger,
12762 size_string=${value}T
12765 value=$((value >> 10))
12766 if [ $value -lt 1024 ]; then
12767 size_string=${value}${size[$i]}
12776 get_rename_size() {
12778 local context=${2:-.}
12779 local sample=$(do_facet $SINGLEMDS $LCTL \
12780 get_param mdt.$FSNAME-MDT0000.rename_stats |
12781 grep -A1 $context |
12782 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
12787 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12788 remote_ost_nodsh && skip "remote OST with nodsh"
12789 remote_mds_nodsh && skip "remote MDS with nodsh"
12790 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12791 skip_env "MDS doesn't support rename stats"
12793 local testdir1=$DIR/${tdir}/stats_testdir1
12794 local testdir2=$DIR/${tdir}/stats_testdir2
12795 mkdir -p $DIR/${tdir}
12797 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12799 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
12800 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
12802 createmany -o $testdir1/test 512 || error "createmany failed"
12804 # check samedir rename size
12805 mv ${testdir1}/test0 ${testdir1}/test_0
12807 local testdir1_size=$(ls -l $DIR/${tdir} |
12808 awk '/stats_testdir1/ {print $5}')
12809 local testdir2_size=$(ls -l $DIR/${tdir} |
12810 awk '/stats_testdir2/ {print $5}')
12812 testdir1_size=$(order_2 $testdir1_size)
12813 testdir2_size=$(order_2 $testdir2_size)
12815 testdir1_size=$(size_in_KMGT $testdir1_size)
12816 testdir2_size=$(size_in_KMGT $testdir2_size)
12818 echo "source rename dir size: ${testdir1_size}"
12819 echo "target rename dir size: ${testdir2_size}"
12821 local cmd="do_facet $SINGLEMDS $LCTL "
12822 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
12824 eval $cmd || error "$cmd failed"
12825 local samedir=$($cmd | grep 'same_dir')
12826 local same_sample=$(get_rename_size $testdir1_size)
12827 [ -z "$samedir" ] && error "samedir_rename_size count error"
12828 [[ $same_sample -eq 1 ]] ||
12829 error "samedir_rename_size error $same_sample"
12830 echo "Check same dir rename stats success"
12832 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12834 # check crossdir rename size
12835 mv ${testdir1}/test_0 ${testdir2}/test_0
12837 testdir1_size=$(ls -l $DIR/${tdir} |
12838 awk '/stats_testdir1/ {print $5}')
12839 testdir2_size=$(ls -l $DIR/${tdir} |
12840 awk '/stats_testdir2/ {print $5}')
12842 testdir1_size=$(order_2 $testdir1_size)
12843 testdir2_size=$(order_2 $testdir2_size)
12845 testdir1_size=$(size_in_KMGT $testdir1_size)
12846 testdir2_size=$(size_in_KMGT $testdir2_size)
12848 echo "source rename dir size: ${testdir1_size}"
12849 echo "target rename dir size: ${testdir2_size}"
12851 eval $cmd || error "$cmd failed"
12852 local crossdir=$($cmd | grep 'crossdir')
12853 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
12854 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
12855 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
12856 [[ $src_sample -eq 1 ]] ||
12857 error "crossdir_rename_size error $src_sample"
12858 [[ $tgt_sample -eq 1 ]] ||
12859 error "crossdir_rename_size error $tgt_sample"
12860 echo "Check cross dir rename stats success"
12861 rm -rf $DIR/${tdir}
12863 run_test 133d "Verifying rename_stats ========================================"
12866 remote_mds_nodsh && skip "remote MDS with nodsh"
12867 remote_ost_nodsh && skip "remote OST with nodsh"
12868 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12870 local testdir=$DIR/${tdir}/stats_testdir
12871 local ctr f0 f1 bs=32768 count=42 sum
12873 mkdir -p ${testdir} || error "mkdir failed"
12875 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
12877 for ctr in {write,read}_bytes; do
12879 cancel_lru_locks osc
12881 do_facet ost1 $LCTL set_param -n \
12882 "obdfilter.*.exports.clear=clear"
12884 if [ $ctr = write_bytes ]; then
12886 f1=${testdir}/${tfile}
12888 f0=${testdir}/${tfile}
12892 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
12895 cancel_lru_locks osc
12897 sum=$(do_facet ost1 $LCTL get_param \
12898 "obdfilter.*.exports.*.stats" |
12899 awk -v ctr=$ctr 'BEGIN { sum = 0 }
12900 $1 == ctr { sum += $7 }
12901 END { printf("%0.0f", sum) }')
12903 if ((sum != bs * count)); then
12904 error "Bad $ctr sum, expected $((bs * count)), got $sum"
12908 rm -rf $DIR/${tdir}
12910 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
12912 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
12914 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
12915 # not honor the -ignore_readdir_race option correctly. So we call
12916 # error_ignore() rather than error() in these cases. See LU-11152.
12918 if (find --version; do_facet mds1 find --version) |
12919 grep -q '\b4\.5\.1[1-4]\b'; then
12920 error_ignore LU-11152 "$@"
12927 # First without trusting modes.
12928 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
12929 echo "proc_dirs='$proc_dirs'"
12930 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
12931 find $proc_dirs -exec cat '{}' \; &> /dev/null
12933 # Second verifying readability.
12934 $LCTL get_param -R '*' &> /dev/null
12936 # Verifing writability with badarea_io.
12938 -ignore_readdir_race \
12940 -not -name force_lbug \
12941 -not -name changelog_mask \
12942 -exec badarea_io '{}' \; ||
12943 error_133 "find $proc_dirs failed"
12945 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
12948 remote_mds_nodsh && skip "remote MDS with nodsh"
12949 remote_ost_nodsh && skip "remote OST with nodsh"
12952 for facet in mds1 ost1; do
12953 local facet_ver=$(lustre_version_code $facet)
12954 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
12955 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
12957 log "$facet: too old lustre for get_param -R"
12959 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
12960 do_facet $facet "$LCTL list_param -R '*' | grep '=' |
12961 tr -d = | egrep -v 'force_lbug|changelog_mask' |
12962 xargs badarea_io" ||
12963 error_133 "$facet badarea_io failed"
12965 skip_noexit "$facet: too old lustre for get_param -R"
12969 # remount the FS in case writes/reads /proc break the FS
12970 cleanup || error "failed to unmount"
12971 setup || error "failed to setup"
12974 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
12977 remote_mds_nodsh && skip "remote MDS with nodsh"
12978 remote_ost_nodsh && skip "remote OST with nodsh"
12979 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
12980 skip "Need MDS version at least 2.9.54"
12984 for facet in client mds1 ost1; do
12985 local facet_proc_dirs=$(do_facet $facet \
12986 \\\ls -d $proc_regexp 2> /dev/null)
12987 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12988 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12989 # Get the list of files that are missing the terminating newline
12990 local missing=($(do_facet $facet \
12991 find ${facet_proc_dirs} -type f \| \
12992 while read F\; do \
12993 awk -v FS='\v' -v RS='\v\v' \
12994 "'END { if(NR>0 && \
12995 \\\$NF !~ /.*\\\n\$/) \
12996 print FILENAME}'" \
12999 [ ${#missing[*]} -eq 0 ] ||
13000 error "files do not end with newline: ${missing[*]}"
13003 run_test 133h "Proc files should end with newlines"
13006 remote_mds_nodsh && skip "remote MDS with nodsh"
13007 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
13008 skip "Need MDS version at least 2.7.54"
13010 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
13011 cancel_lru_locks mdc
13013 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
13014 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13015 [ $unused -eq 0 ] || error "$unused locks are not cleared"
13018 createmany -o $DIR/$tdir/f $nr ||
13019 error "failed to create $nr files in $DIR/$tdir"
13020 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
13022 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
13023 do_facet mds1 $LCTL set_param fail_loc=0x327
13024 do_facet mds1 $LCTL set_param fail_val=500
13027 echo "sleep 10 seconds ..."
13029 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
13031 do_facet mds1 $LCTL set_param fail_loc=0
13032 do_facet mds1 $LCTL set_param fail_val=0
13033 [ $lck_cnt -lt $unused ] ||
13034 error "No locks reclaimed, before:$unused, after:$lck_cnt"
13037 unlinkmany $DIR/$tdir/f $nr
13039 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
13042 remote_mds_nodsh && skip "remote MDS with nodsh"
13043 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
13044 skip "Need MDS version at least 2.7.54"
13046 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
13047 cancel_lru_locks mdc
13049 local low_wm=$(do_facet mds1 $LCTL get_param -n \
13050 ldlm.lock_reclaim_threshold_mb)
13051 # disable reclaim temporarily
13052 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
13054 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
13055 do_facet mds1 $LCTL set_param fail_loc=0x328
13056 do_facet mds1 $LCTL set_param fail_val=500
13058 $LCTL set_param debug=+trace
13061 createmany -o $DIR/$tdir/f $nr &
13062 local create_pid=$!
13064 echo "Sleep $TIMEOUT seconds ..."
13066 if ! ps -p $create_pid > /dev/null 2>&1; then
13067 do_facet mds1 $LCTL set_param fail_loc=0
13068 do_facet mds1 $LCTL set_param fail_val=0
13069 do_facet mds1 $LCTL set_param \
13070 ldlm.lock_reclaim_threshold_mb=${low_wm}m
13071 error "createmany finished incorrectly!"
13073 do_facet mds1 $LCTL set_param fail_loc=0
13074 do_facet mds1 $LCTL set_param fail_val=0
13075 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
13076 wait $create_pid || return 1
13078 unlinkmany $DIR/$tdir/f $nr
13080 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
13083 remote_mds_nodsh && skip "remote MDS with nodsh"
13084 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
13085 skip "Need MDS version at least 2.13.50"
13088 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
13090 #define OBD_FAIL_PLAIN_RECORDS 0x1319
13091 #set only one record at plain llog
13092 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
13094 #fill already existed plain llog each 64767
13095 #wrapping whole catalog
13096 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
13098 createmany -o $DIR/$tdir/$tfile_ 64700
13099 for (( i = 0; i < 64700; i = i + 2 ))
13101 rm $DIR/$tdir/$tfile_$i &
13102 rm $DIR/$tdir/$tfile_$((i + 1)) &
13107 #waiting osp synchronization
13108 wait_delete_completed
13110 run_test 135 "Race catalog processing"
13113 remote_mds_nodsh && skip "remote MDS with nodsh"
13114 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
13115 skip "Need MDS version at least 2.13.50"
13118 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
13119 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
13120 #set only one record at plain llog
13121 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
13122 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
13124 #fill already existed 2 plain llogs each 64767
13125 #wrapping whole catalog
13126 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
13127 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
13128 wait_delete_completed
13130 createmany -o $DIR/$tdir/$tfile_ 10
13133 do_facet $SINGLEMDS $LCTL set_param fail_val=3
13134 for (( i = 0; i < 10; i = i + 3 ))
13136 rm $DIR/$tdir/$tfile_$i &
13137 rm $DIR/$tdir/$tfile_$((i + 1)) &
13141 rm $DIR/$tdir/$tfile_$((i + 2)) &
13144 #waiting osp synchronization
13145 wait_delete_completed
13147 run_test 136 "Race catalog processing 2"
13149 test_140() { #bug-17379
13150 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13152 test_mkdir $DIR/$tdir
13153 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
13154 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
13156 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
13157 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
13159 while i=$((i + 1)); do
13161 cd $i || error "Changing to $i"
13162 ln -s ../stat stat || error "Creating stat symlink"
13163 # Read the symlink until ELOOP present,
13164 # not LBUGing the system is considered success,
13165 # we didn't overrun the stack.
13166 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
13167 if [ $ret -ne 0 ]; then
13168 if [ $ret -eq 40 ]; then
13171 error "Open stat symlink"
13177 echo "The symlink depth = $i"
13178 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
13179 error "Invalid symlink depth"
13181 # Test recursive symlink
13182 ln -s symlink_self symlink_self
13183 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
13184 echo "open symlink_self returns $ret"
13185 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
13187 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
13190 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13192 local TF="$TMP/$tfile"
13194 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
13196 cancel_lru_locks $OSC
13197 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
13198 remount_client $MOUNT
13200 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
13203 $TRUNCATE $DIR/$tfile 6000
13204 cancel_lru_locks $OSC
13205 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
13208 echo "12345" >>$DIR/$tfile
13209 cancel_lru_locks $OSC
13210 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
13213 echo "12345" >>$DIR/$tfile
13214 cancel_lru_locks $OSC
13215 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
13220 run_test 150a "truncate/append tests"
13223 [ "$ost1_FSTYPE" != ldiskfs ] && skip "non-ldiskfs backend"
13224 [ $OST1_VERSION -lt $(version_code 2.13.50) ] &&
13225 skip "Need OST version at least 2.13.53"
13227 check_fallocate $DIR/$tfile || error "fallocate failed"
13229 run_test 150b "Verify fallocate (prealloc) functionality"
13235 [ "$ost1_FSTYPE" != ldiskfs ] && skip "non-ldiskfs backend"
13236 [ $OST1_VERSION -lt $(version_code 2.13.50) ] &&
13237 skip "Need OST version at least 2.13.53"
13239 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tdir || error "setstripe failed"
13240 fallocate -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
13241 sync; sync_all_data
13242 cancel_lru_locks $OSC
13244 bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
13245 want=$((OSTCOUNT * 1048576))
13247 # Must allocate all requested space, not more than 5% extra
13248 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
13249 error "bytes $bytes is not $want"
13251 run_test 150c "Verify fallocate Size and Blocks"
13257 [ "$ost1_FSTYPE" != ldiskfs ] && skip "non-ldiskfs backend"
13258 [ $OST1_VERSION -lt $(version_code 2.13.50) ] &&
13259 skip "Need OST version at least 2.13.53"
13261 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tdir || error "setstripe failed"
13262 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
13263 sync; sync_all_data
13264 cancel_lru_locks $OSC
13266 bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
13267 want=$((OSTCOUNT * 1048576))
13269 # Must allocate all requested space, not more than 5% extra
13270 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
13271 error "bytes $bytes is not $want"
13273 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
13275 #LU-2902 roc_hit was not able to read all values from lproc
13276 function roc_hit_init() {
13277 local list=$(comma_list $(osts_nodes))
13278 local dir=$DIR/$tdir-check
13279 local file=$dir/$tfile
13285 #use setstripe to do a write to every ost
13286 for i in $(seq 0 $((OSTCOUNT-1))); do
13287 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
13288 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
13289 idx=$(printf %04x $i)
13290 BEFORE=$(get_osd_param $list *OST*$idx stats |
13291 awk '$1 == "cache_access" {sum += $7}
13292 END { printf("%0.0f", sum) }')
13294 cancel_lru_locks osc
13295 cat $file >/dev/null
13297 AFTER=$(get_osd_param $list *OST*$idx stats |
13298 awk '$1 == "cache_access" {sum += $7}
13299 END { printf("%0.0f", sum) }')
13301 echo BEFORE:$BEFORE AFTER:$AFTER
13302 if ! let "AFTER - BEFORE == 4"; then
13304 error "roc_hit is not safe to use"
13312 function roc_hit() {
13313 local list=$(comma_list $(osts_nodes))
13314 echo $(get_osd_param $list '' stats |
13315 awk '$1 == "cache_hit" {sum += $7}
13316 END { printf("%0.0f", sum) }')
13319 function set_cache() {
13322 if [ "$2" == "off" ]; then
13325 local list=$(comma_list $(osts_nodes))
13326 set_osd_param $list '' $1_cache_enable $on
13328 cancel_lru_locks osc
13332 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13333 remote_ost_nodsh && skip "remote OST with nodsh"
13336 local list=$(comma_list $(osts_nodes))
13338 # check whether obdfilter is cache capable at all
13339 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
13340 skip "not cache-capable obdfilter"
13343 # check cache is enabled on all obdfilters
13344 if get_osd_param $list '' read_cache_enable | grep 0; then
13345 skip "oss cache is disabled"
13348 set_osd_param $list '' writethrough_cache_enable 1
13350 # check write cache is enabled on all obdfilters
13351 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
13352 skip "oss write cache is NOT enabled"
13357 #define OBD_FAIL_OBD_NO_LRU 0x609
13358 do_nodes $list $LCTL set_param fail_loc=0x609
13360 # pages should be in the case right after write
13361 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
13364 local BEFORE=$(roc_hit)
13365 cancel_lru_locks osc
13366 cat $DIR/$tfile >/dev/null
13367 local AFTER=$(roc_hit)
13369 do_nodes $list $LCTL set_param fail_loc=0
13371 if ! let "AFTER - BEFORE == CPAGES"; then
13372 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13375 cancel_lru_locks osc
13376 # invalidates OST cache
13377 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
13378 set_osd_param $list '' read_cache_enable 0
13379 cat $DIR/$tfile >/dev/null
13381 # now data shouldn't be found in the cache
13383 cancel_lru_locks osc
13384 cat $DIR/$tfile >/dev/null
13386 if let "AFTER - BEFORE != 0"; then
13387 error "IN CACHE: before: $BEFORE, after: $AFTER"
13390 set_osd_param $list '' read_cache_enable 1
13393 run_test 151 "test cache on oss and controls ==============================="
13396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13398 local TF="$TMP/$tfile"
13400 # simulate ENOMEM during write
13401 #define OBD_FAIL_OST_NOMEM 0x226
13402 lctl set_param fail_loc=0x80000226
13403 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
13405 sync || error "sync failed"
13406 lctl set_param fail_loc=0
13408 # discard client's cache
13409 cancel_lru_locks osc
13411 # simulate ENOMEM during read
13412 lctl set_param fail_loc=0x80000226
13413 cmp $TF $DIR/$tfile || error "cmp failed"
13414 lctl set_param fail_loc=0
13418 run_test 152 "test read/write with enomem ============================"
13421 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
13423 run_test 153 "test if fdatasync does not crash ======================="
13425 dot_lustre_fid_permission_check() {
13427 local ffid=$MOUNT/.lustre/fid/$fid
13430 echo "stat fid $fid"
13431 stat $ffid > /dev/null || error "stat $ffid failed."
13432 echo "touch fid $fid"
13433 touch $ffid || error "touch $ffid failed."
13434 echo "write to fid $fid"
13435 cat /etc/hosts > $ffid || error "write $ffid failed."
13436 echo "read fid $fid"
13437 diff /etc/hosts $ffid || error "read $ffid failed."
13438 echo "append write to fid $fid"
13439 cat /etc/hosts >> $ffid || error "append write $ffid failed."
13440 echo "rename fid $fid"
13441 mv $ffid $test_dir/$tfile.1 &&
13442 error "rename $ffid to $tfile.1 should fail."
13443 touch $test_dir/$tfile.1
13444 mv $test_dir/$tfile.1 $ffid &&
13445 error "rename $tfile.1 to $ffid should fail."
13446 rm -f $test_dir/$tfile.1
13447 echo "truncate fid $fid"
13448 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
13449 echo "link fid $fid"
13450 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
13451 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
13452 echo "setfacl fid $fid"
13453 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
13454 echo "getfacl fid $fid"
13455 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
13457 echo "unlink fid $fid"
13458 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
13459 echo "mknod fid $fid"
13460 mknod $ffid c 1 3 && error "mknod $ffid should fail."
13462 fid=[0xf00000400:0x1:0x0]
13463 ffid=$MOUNT/.lustre/fid/$fid
13465 echo "stat non-exist fid $fid"
13466 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
13467 echo "write to non-exist fid $fid"
13468 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
13469 echo "link new fid $fid"
13470 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
13472 mkdir -p $test_dir/$tdir
13473 touch $test_dir/$tdir/$tfile
13474 fid=$($LFS path2fid $test_dir/$tdir)
13477 error "error: could not get fid for $test_dir/$dir/$tfile."
13479 ffid=$MOUNT/.lustre/fid/$fid
13482 ls $ffid > /dev/null || error "ls $ffid failed."
13483 echo "touch $fid/$tfile.1"
13484 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
13486 echo "touch $MOUNT/.lustre/fid/$tfile"
13487 touch $MOUNT/.lustre/fid/$tfile && \
13488 error "touch $MOUNT/.lustre/fid/$tfile should fail."
13490 echo "setxattr to $MOUNT/.lustre/fid"
13491 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
13493 echo "listxattr for $MOUNT/.lustre/fid"
13494 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
13496 echo "delxattr from $MOUNT/.lustre/fid"
13497 setfattr -x trusted.name1 $MOUNT/.lustre/fid
13499 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
13500 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
13501 error "touch invalid fid should fail."
13503 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
13504 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
13505 error "touch non-normal fid should fail."
13507 echo "rename $tdir to $MOUNT/.lustre/fid"
13508 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
13509 error "rename to $MOUNT/.lustre/fid should fail."
13511 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
13513 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
13514 local new_obf_mode=777
13516 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
13517 chmod $new_obf_mode $DIR/.lustre/fid ||
13518 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
13520 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
13521 [ $obf_mode -eq $new_obf_mode ] ||
13522 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
13524 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
13525 chmod $old_obf_mode $DIR/.lustre/fid ||
13526 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
13529 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
13530 fid=$($LFS path2fid $test_dir/$tfile-2)
13532 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
13534 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
13535 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
13536 error "create lov data thru .lustre failed"
13538 echo "cp /etc/passwd $test_dir/$tfile-2"
13539 cp /etc/passwd $test_dir/$tfile-2 ||
13540 error "copy to $test_dir/$tfile-2 failed."
13541 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
13542 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
13543 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
13545 rm -rf $test_dir/tfile.lnk
13546 rm -rf $test_dir/$tfile-2
13550 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13551 skip "Need MDS version at least 2.4.1"
13553 local tf=$DIR/$tfile
13556 local fid=$($LFS path2fid $tf)
13557 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
13559 # check that we get the same pathname back
13560 local found=$($LFS fid2path $MOUNT "$fid")
13561 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
13562 [ "$found" == "$tf" ] ||
13563 error "fid2path($fid=path2fid($tf)) = $found != $tf"
13565 run_test 154A "lfs path2fid and fid2path basic checks"
13568 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13569 skip "Need MDS version at least 2.4.1"
13571 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
13572 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
13573 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
13574 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
13576 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
13577 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
13579 # check that we get the same pathname
13580 echo "PFID: $PFID, name: $name"
13581 local FOUND=$($LFS fid2path $MOUNT "$PFID")
13582 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
13583 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
13584 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
13586 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
13588 run_test 154B "verify the ll_decode_linkea tool"
13591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13592 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13593 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
13594 skip "Need MDS version at least 2.2.51"
13595 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13597 cp /etc/hosts $DIR/$tfile
13599 fid=$($LFS path2fid $DIR/$tfile)
13601 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
13603 dot_lustre_fid_permission_check "$fid" $DIR ||
13604 error "dot lustre permission check $fid failed"
13606 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
13608 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
13610 touch $MOUNT/.lustre/file &&
13611 error "creation is not allowed under .lustre"
13613 mkdir $MOUNT/.lustre/dir &&
13614 error "mkdir is not allowed under .lustre"
13618 run_test 154a "Open-by-FID"
13621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13622 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13623 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13624 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
13625 skip "Need MDS version at least 2.2.51"
13627 local remote_dir=$DIR/$tdir/remote_dir
13631 mkdir -p $DIR/$tdir
13632 $LFS mkdir -i $MDTIDX $remote_dir ||
13633 error "create remote directory failed"
13635 cp /etc/hosts $remote_dir/$tfile
13637 fid=$($LFS path2fid $remote_dir/$tfile)
13639 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
13641 dot_lustre_fid_permission_check "$fid" $remote_dir ||
13642 error "dot lustre permission check $fid failed"
13645 run_test 154b "Open-by-FID for remote directory"
13648 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13649 skip "Need MDS version at least 2.4.1"
13651 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
13652 local FID1=$($LFS path2fid $DIR/$tfile.1)
13653 local FID2=$($LFS path2fid $DIR/$tfile.2)
13654 local FID3=$($LFS path2fid $DIR/$tfile.3)
13657 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
13658 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
13659 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
13661 [ "$FID" = "${!want}" ] ||
13662 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
13666 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
13668 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
13669 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
13673 run_test 154c "lfs path2fid and fid2path multiple arguments"
13676 remote_mds_nodsh && skip "remote MDS with nodsh"
13677 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
13678 skip "Need MDS version at least 2.5.53"
13680 if remote_mds; then
13681 nid=$($LCTL list_nids | sed "s/\./\\\./g")
13685 local proc_ofile="mdt.*.exports.'$nid'.open_files"
13692 local fid=$($LFS path2fid $DIR/$tfile)
13695 cmd="exec $fd<$DIR/$tfile"
13697 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
13698 echo "$fid_list" | grep "$fid"
13701 cmd="exec $fd>/dev/null"
13703 if [ $rc -ne 0 ]; then
13704 error "FID $fid not found in open files list $fid_list"
13707 run_test 154d "Verify open file fid"
13711 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
13712 skip "Need MDS version at least 2.6.50"
13714 if ls -a $MOUNT | grep -q '^\.lustre$'; then
13715 error ".lustre returned by readdir"
13718 run_test 154e ".lustre is not returned by readdir"
13721 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13723 # create parent directory on a single MDT to avoid cross-MDT hardlinks
13724 test_mkdir -p -c1 $DIR/$tdir/d
13725 # test dirs inherit from its stripe
13726 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
13727 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
13728 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
13729 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
13732 # get fid of parents
13733 local FID0=$($LFS path2fid $DIR/$tdir/d)
13734 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
13735 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
13736 local FID3=$($LFS path2fid $DIR)
13738 # check that path2fid --parents returns expected <parent_fid>/name
13739 # 1) test for a directory (single parent)
13740 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
13741 [ "$parent" == "$FID0/foo1" ] ||
13742 error "expected parent: $FID0/foo1, got: $parent"
13744 # 2) test for a file with nlink > 1 (multiple parents)
13745 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
13746 echo "$parent" | grep -F "$FID1/$tfile" ||
13747 error "$FID1/$tfile not returned in parent list"
13748 echo "$parent" | grep -F "$FID2/link" ||
13749 error "$FID2/link not returned in parent list"
13751 # 3) get parent by fid
13752 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
13753 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13754 echo "$parent" | grep -F "$FID1/$tfile" ||
13755 error "$FID1/$tfile not returned in parent list (by fid)"
13756 echo "$parent" | grep -F "$FID2/link" ||
13757 error "$FID2/link not returned in parent list (by fid)"
13759 # 4) test for entry in root directory
13760 parent=$($LFS path2fid --parents $DIR/f)
13761 echo "$parent" | grep -F "$FID3/f" ||
13762 error "$FID3/f not returned in parent list"
13764 # 5) test it on root directory
13765 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
13766 error "$MOUNT should not have parents"
13768 # enable xattr caching and check that linkea is correctly updated
13769 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
13770 save_lustre_params client "llite.*.xattr_cache" > $save
13771 lctl set_param llite.*.xattr_cache 1
13773 # 6.1) linkea update on rename
13774 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
13776 # get parents by fid
13777 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13778 # foo1 should no longer be returned in parent list
13779 echo "$parent" | grep -F "$FID1" &&
13780 error "$FID1 should no longer be in parent list"
13781 # the new path should appear
13782 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
13783 error "$FID2/$tfile.moved is not in parent list"
13785 # 6.2) linkea update on unlink
13786 rm -f $DIR/$tdir/d/foo2/link
13787 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13788 # foo2/link should no longer be returned in parent list
13789 echo "$parent" | grep -F "$FID2/link" &&
13790 error "$FID2/link should no longer be in parent list"
13794 restore_lustre_params < $save
13797 run_test 154f "get parent fids by reading link ea"
13801 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13802 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
13803 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
13804 skip "Need MDS version at least 2.6.92"
13806 mkdir -p $DIR/$tdir
13807 llapi_fid_test -d $DIR/$tdir
13809 run_test 154g "various llapi FID tests"
13811 test_155_small_load() {
13812 local temp=$TMP/$tfile
13813 local file=$DIR/$tfile
13815 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
13816 error "dd of=$temp bs=6096 count=1 failed"
13818 cancel_lru_locks $OSC
13819 cmp $temp $file || error "$temp $file differ"
13821 $TRUNCATE $temp 6000
13822 $TRUNCATE $file 6000
13823 cmp $temp $file || error "$temp $file differ (truncate1)"
13825 echo "12345" >>$temp
13826 echo "12345" >>$file
13827 cmp $temp $file || error "$temp $file differ (append1)"
13829 echo "12345" >>$temp
13830 echo "12345" >>$file
13831 cmp $temp $file || error "$temp $file differ (append2)"
13837 test_155_big_load() {
13838 remote_ost_nodsh && skip "remote OST with nodsh"
13840 local temp=$TMP/$tfile
13841 local file=$DIR/$tfile
13844 local cache_size=$(do_facet ost$((MAXI+1)) \
13845 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
13846 local large_file_size=$((cache_size * 2))
13848 echo "OSS cache size: $cache_size KB"
13849 echo "Large file size: $large_file_size KB"
13851 [ $MAXV -le $large_file_size ] &&
13852 skip_env "max available OST size needs > $large_file_size KB"
13854 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
13856 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
13857 error "dd of=$temp bs=$large_file_size count=1k failed"
13860 cancel_lru_locks osc
13861 cmp $temp $file || error "$temp $file differ"
13867 save_writethrough() {
13868 local facets=$(get_facets OST)
13870 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
13874 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13876 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13878 save_writethrough $p
13881 set_cache writethrough on
13882 test_155_small_load
13883 restore_lustre_params < $p
13886 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
13889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13891 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13893 save_writethrough $p
13896 set_cache writethrough off
13897 test_155_small_load
13898 restore_lustre_params < $p
13901 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
13904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13906 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13908 save_writethrough $p
13911 set_cache writethrough on
13912 test_155_small_load
13913 restore_lustre_params < $p
13916 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
13919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13921 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13923 save_writethrough $p
13926 set_cache writethrough off
13927 test_155_small_load
13928 restore_lustre_params < $p
13931 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
13934 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13936 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13938 save_writethrough $p
13941 set_cache writethrough on
13943 restore_lustre_params < $p
13946 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
13949 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13951 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13953 save_writethrough $p
13956 set_cache writethrough off
13958 restore_lustre_params < $p
13961 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
13964 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13966 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13968 save_writethrough $p
13971 set_cache writethrough on
13973 restore_lustre_params < $p
13976 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
13979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13981 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13983 save_writethrough $p
13986 set_cache writethrough off
13988 restore_lustre_params < $p
13991 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
13994 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13995 remote_ost_nodsh && skip "remote OST with nodsh"
13996 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
13997 skip "stats not implemented on old servers"
13998 [ "$ost1_FSTYPE" = "zfs" ] &&
13999 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
14004 local file="$DIR/$tfile"
14005 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14007 save_writethrough $p
14010 log "Turn on read and write cache"
14012 set_cache writethrough on
14014 log "Write data and read it back."
14015 log "Read should be satisfied from the cache."
14016 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
14018 cancel_lru_locks osc
14019 cat $file >/dev/null
14021 if ! let "AFTER - BEFORE == CPAGES"; then
14022 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
14024 log "cache hits: before: $BEFORE, after: $AFTER"
14027 log "Read again; it should be satisfied from the cache."
14029 cancel_lru_locks osc
14030 cat $file >/dev/null
14032 if ! let "AFTER - BEFORE == CPAGES"; then
14033 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
14035 log "cache hits:: before: $BEFORE, after: $AFTER"
14038 log "Turn off the read cache and turn on the write cache"
14040 set_cache writethrough on
14042 log "Read again; it should be satisfied from the cache."
14044 cancel_lru_locks osc
14045 cat $file >/dev/null
14047 if ! let "AFTER - BEFORE == CPAGES"; then
14048 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
14050 log "cache hits:: before: $BEFORE, after: $AFTER"
14053 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
14054 # > 2.12.56 uses pagecache if cached
14055 log "Read again; it should not be satisfied from the cache."
14057 cancel_lru_locks osc
14058 cat $file >/dev/null
14060 if ! let "AFTER - BEFORE == 0"; then
14061 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
14063 log "cache hits:: before: $BEFORE, after: $AFTER"
14067 log "Write data and read it back."
14068 log "Read should be satisfied from the cache."
14069 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
14071 cancel_lru_locks osc
14072 cat $file >/dev/null
14074 if ! let "AFTER - BEFORE == CPAGES"; then
14075 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
14077 log "cache hits:: before: $BEFORE, after: $AFTER"
14080 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
14081 # > 2.12.56 uses pagecache if cached
14082 log "Read again; it should not be satisfied from the cache."
14084 cancel_lru_locks osc
14085 cat $file >/dev/null
14087 if ! let "AFTER - BEFORE == 0"; then
14088 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
14090 log "cache hits:: before: $BEFORE, after: $AFTER"
14094 log "Turn off read and write cache"
14096 set_cache writethrough off
14098 log "Write data and read it back"
14099 log "It should not be satisfied from the cache."
14101 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
14102 cancel_lru_locks osc
14104 cat $file >/dev/null
14106 if ! let "AFTER - BEFORE == 0"; then
14107 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
14109 log "cache hits:: before: $BEFORE, after: $AFTER"
14112 log "Turn on the read cache and turn off the write cache"
14114 set_cache writethrough off
14116 log "Write data and read it back"
14117 log "It should not be satisfied from the cache."
14119 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
14121 cancel_lru_locks osc
14122 cat $file >/dev/null
14124 if ! let "AFTER - BEFORE == 0"; then
14125 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
14127 log "cache hits:: before: $BEFORE, after: $AFTER"
14130 log "Read again; it should be satisfied from the cache."
14132 cancel_lru_locks osc
14133 cat $file >/dev/null
14135 if ! let "AFTER - BEFORE == CPAGES"; then
14136 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
14138 log "cache hits:: before: $BEFORE, after: $AFTER"
14141 restore_lustre_params < $p
14144 run_test 156 "Verification of tunables"
14147 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14148 remote_mds_nodsh && skip "remote MDS with nodsh"
14149 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
14150 skip "Need MDS version at least 2.2.0"
14152 changelog_register || error "changelog_register failed"
14153 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14154 changelog_users $SINGLEMDS | grep -q $cl_user ||
14155 error "User $cl_user not found in changelog_users"
14158 test_mkdir -p $DIR/$tdir/pics/2008/zachy
14159 changelog_clear 0 || error "changelog_clear failed"
14160 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
14161 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
14162 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14163 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14164 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14165 rm $DIR/$tdir/pics/desktop.jpg
14167 changelog_dump | tail -10
14169 echo "verifying changelog mask"
14170 changelog_chmask "-MKDIR"
14171 changelog_chmask "-CLOSE"
14173 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
14174 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
14176 changelog_chmask "+MKDIR"
14177 changelog_chmask "+CLOSE"
14179 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
14180 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
14182 changelog_dump | tail -10
14183 MKDIRS=$(changelog_dump | grep -c "MKDIR")
14184 CLOSES=$(changelog_dump | grep -c "CLOSE")
14185 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
14186 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
14189 echo "verifying target fid"
14190 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
14191 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
14192 [ "$fidc" == "$fidf" ] ||
14193 error "changelog '$tfile' fid $fidc != file fid $fidf"
14194 echo "verifying parent fid"
14195 # The FID returned from the Changelog may be the directory shard on
14196 # a different MDT, and not the FID returned by path2fid on the parent.
14197 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
14198 # since this is what will matter when recreating this file in the tree.
14199 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
14200 local pathp=$($LFS fid2path $MOUNT "$fidp")
14201 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
14202 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
14204 echo "getting records for $cl_user"
14205 changelog_users $SINGLEMDS
14206 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
14208 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
14209 error "changelog_clear failed"
14210 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
14211 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
14212 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
14213 error "user index expect $user_rec1 + $nclr != $user_rec2"
14215 local min0_rec=$(changelog_users $SINGLEMDS |
14216 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
14217 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
14218 awk '{ print $1; exit; }')
14220 changelog_dump | tail -n 5
14221 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
14222 [ $first_rec == $((min0_rec + 1)) ] ||
14223 error "first index should be $min0_rec + 1 not $first_rec"
14225 # LU-3446 changelog index reset on MDT restart
14226 local cur_rec1=$(changelog_users $SINGLEMDS |
14227 awk '/^current.index:/ { print $NF }')
14228 changelog_clear 0 ||
14229 error "clear all changelog records for $cl_user failed"
14230 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
14231 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
14232 error "Fail to start $SINGLEMDS"
14233 local cur_rec2=$(changelog_users $SINGLEMDS |
14234 awk '/^current.index:/ { print $NF }')
14235 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
14236 [ $cur_rec1 == $cur_rec2 ] ||
14237 error "current index should be $cur_rec1 not $cur_rec2"
14239 echo "verifying users from this test are deregistered"
14240 changelog_deregister || error "changelog_deregister failed"
14241 changelog_users $SINGLEMDS | grep -q $cl_user &&
14242 error "User '$cl_user' still in changelog_users"
14244 # lctl get_param -n mdd.*.changelog_users
14245 # current index: 144
14246 # ID index (idle seconds)
14248 if ! changelog_users $SINGLEMDS | grep "^cl"; then
14249 # this is the normal case where all users were deregistered
14250 # make sure no new records are added when no users are present
14251 local last_rec1=$(changelog_users $SINGLEMDS |
14252 awk '/^current.index:/ { print $NF }')
14253 touch $DIR/$tdir/chloe
14254 local last_rec2=$(changelog_users $SINGLEMDS |
14255 awk '/^current.index:/ { print $NF }')
14256 echo "verify changelogs are off: $last_rec1 == $last_rec2"
14257 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
14259 # any changelog users must be leftovers from a previous test
14260 changelog_users $SINGLEMDS
14261 echo "other changelog users; can't verify off"
14264 run_test 160a "changelog sanity"
14266 test_160b() { # LU-3587
14267 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14268 remote_mds_nodsh && skip "remote MDS with nodsh"
14269 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
14270 skip "Need MDS version at least 2.2.0"
14272 changelog_register || error "changelog_register failed"
14273 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14274 changelog_users $SINGLEMDS | grep -q $cl_user ||
14275 error "User '$cl_user' not found in changelog_users"
14277 local longname1=$(str_repeat a 255)
14278 local longname2=$(str_repeat b 255)
14281 echo "creating very long named file"
14282 touch $longname1 || error "create of '$longname1' failed"
14283 echo "renaming very long named file"
14284 mv $longname1 $longname2
14286 changelog_dump | grep RENME | tail -n 5
14289 run_test 160b "Verify that very long rename doesn't crash in changelog"
14292 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14293 remote_mds_nodsh && skip "remote MDS with nodsh"
14295 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
14296 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
14297 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
14298 skip "Need MDS version at least 2.5.58 or 2.5.2+"
14302 # Registration step
14303 changelog_register || error "changelog_register failed"
14306 mkdir -p $DIR/$tdir
14307 $MCREATE $DIR/$tdir/foo_160c
14308 changelog_chmask "-TRUNC"
14309 $TRUNCATE $DIR/$tdir/foo_160c 200
14310 changelog_chmask "+TRUNC"
14311 $TRUNCATE $DIR/$tdir/foo_160c 199
14312 changelog_dump | tail -n 5
14313 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
14314 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
14316 run_test 160c "verify that changelog log catch the truncate event"
14319 remote_mds_nodsh && skip "remote MDS with nodsh"
14320 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14321 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14322 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
14323 skip "Need MDS version at least 2.7.60"
14325 # Registration step
14326 changelog_register || error "changelog_register failed"
14328 mkdir -p $DIR/$tdir/migrate_dir
14329 changelog_clear 0 || error "changelog_clear failed"
14331 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
14332 changelog_dump | tail -n 5
14333 local migrates=$(changelog_dump | grep -c "MIGRT")
14334 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
14336 run_test 160d "verify that changelog log catch the migrate event"
14339 remote_mds_nodsh && skip "remote MDS with nodsh"
14342 changelog_register || error "changelog_register failed"
14344 # Delete a future user (expect fail)
14345 local MDT0=$(facet_svc $SINGLEMDS)
14346 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
14349 if [ $rc -eq 0 ]; then
14350 error "Deleted non-existant user cl77"
14351 elif [ $rc -ne 2 ]; then
14352 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
14355 # Clear to a bad index (1 billion should be safe)
14356 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
14359 if [ $rc -eq 0 ]; then
14360 error "Successfully cleared to invalid CL index"
14361 elif [ $rc -ne 22 ]; then
14362 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
14365 run_test 160e "changelog negative testing (should return errors)"
14368 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14369 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14370 skip "Need MDS version at least 2.10.56"
14372 local mdts=$(comma_list $(mdts_nodes))
14375 changelog_register || error "first changelog_register failed"
14376 changelog_register || error "second changelog_register failed"
14378 declare -A cl_user1
14379 declare -A cl_user2
14384 # generate some changelog records to accumulate on each MDT
14385 # use fnv1a because created files should be evenly distributed
14386 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14387 error "test_mkdir $tdir failed"
14388 log "$(date +%s): creating first files"
14389 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14390 error "create $DIR/$tdir/$tfile failed"
14392 # check changelogs have been generated
14393 local start=$SECONDS
14394 local idle_time=$((MDSCOUNT * 5 + 5))
14395 local nbcl=$(changelog_dump | wc -l)
14396 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14398 for param in "changelog_max_idle_time=$idle_time" \
14400 "changelog_min_gc_interval=2" \
14401 "changelog_min_free_cat_entries=3"; do
14402 local MDT0=$(facet_svc $SINGLEMDS)
14403 local var="${param%=*}"
14404 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14406 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14407 do_nodes $mdts $LCTL set_param mdd.*.$param
14410 # force cl_user2 to be idle (1st part), but also cancel the
14411 # cl_user1 records so that it is not evicted later in the test.
14412 local sleep1=$((idle_time / 2))
14413 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
14416 # simulate changelog catalog almost full
14417 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
14418 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
14420 for i in $(seq $MDSCOUNT); do
14421 cl_users=(${CL_USERS[mds$i]})
14422 cl_user1[mds$i]="${cl_users[0]}"
14423 cl_user2[mds$i]="${cl_users[1]}"
14425 [ -n "${cl_user1[mds$i]}" ] ||
14426 error "mds$i: no user registered"
14427 [ -n "${cl_user2[mds$i]}" ] ||
14428 error "mds$i: only ${cl_user2[mds$i]} is registered"
14430 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14431 [ -n "$user_rec1" ] ||
14432 error "mds$i: User ${cl_user1[mds$i]} not registered"
14433 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14434 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14435 [ -n "$user_rec2" ] ||
14436 error "mds$i: User ${cl_user1[mds$i]} not registered"
14437 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14438 "$user_rec1 + 2 == $user_rec2"
14439 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14440 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14441 "$user_rec1 + 2, but is $user_rec2"
14442 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14443 [ -n "$user_rec2" ] ||
14444 error "mds$i: User ${cl_user2[mds$i]} not registered"
14445 [ $user_rec1 == $user_rec2 ] ||
14446 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14447 "$user_rec1, but is $user_rec2"
14450 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
14451 local sleep2=$((idle_time - (SECONDS - start) + 1))
14452 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
14455 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
14456 # cl_user1 should be OK because it recently processed records.
14457 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
14458 createmany -m $DIR/$tdir/${tfile}b $((MDSCOUNT * 2)) ||
14459 error "create $DIR/$tdir/${tfile}b failed"
14461 # ensure gc thread is done
14462 for i in $(mdts_nodes); do
14464 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
14465 error "$i: GC-thread not done"
14469 for i in $(seq $MDSCOUNT); do
14470 # check cl_user1 still registered
14471 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14472 error "mds$i: User ${cl_user1[mds$i]} not registered"
14473 # check cl_user2 unregistered
14474 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14475 error "mds$i: User ${cl_user2[mds$i]} still registered"
14477 # check changelogs are present and starting at $user_rec1 + 1
14478 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14479 [ -n "$user_rec1" ] ||
14480 error "mds$i: User ${cl_user1[mds$i]} not registered"
14481 first_rec=$($LFS changelog $(facet_svc mds$i) |
14482 awk '{ print $1; exit; }')
14484 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14485 [ $((user_rec1 + 1)) == $first_rec ] ||
14486 error "mds$i: first index should be $user_rec1 + 1, " \
14487 "but is $first_rec"
14490 run_test 160f "changelog garbage collect (timestamped users)"
14493 remote_mds_nodsh && skip "remote MDS with nodsh"
14494 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14495 skip "Need MDS version at least 2.10.56"
14497 local mdts=$(comma_list $(mdts_nodes))
14499 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
14500 do_nodes $mdts $LCTL set_param fail_loc=0x1314
14503 changelog_register || error "first changelog_register failed"
14504 changelog_register || error "second changelog_register failed"
14506 declare -A cl_user1
14507 declare -A cl_user2
14512 # generate some changelog records to accumulate on each MDT
14513 # use fnv1a because created files should be evenly distributed
14514 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14515 error "mkdir $tdir failed"
14516 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14517 error "create $DIR/$tdir/$tfile failed"
14519 # check changelogs have been generated
14520 local nbcl=$(changelog_dump | wc -l)
14521 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14523 # reduce the max_idle_indexes value to make sure we exceed it
14524 max_ndx=$((nbcl / 2 - 1))
14526 for param in "changelog_max_idle_indexes=$max_ndx" \
14528 "changelog_min_gc_interval=2" \
14529 "changelog_min_free_cat_entries=3"; do
14530 local MDT0=$(facet_svc $SINGLEMDS)
14531 local var="${param%=*}"
14532 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14534 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14535 do_nodes $mdts $LCTL set_param mdd.*.$param ||
14536 error "unable to set mdd.*.$param"
14539 # simulate changelog catalog almost full
14540 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
14541 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
14543 for i in $(seq $MDSCOUNT); do
14544 cl_users=(${CL_USERS[mds$i]})
14545 cl_user1[mds$i]="${cl_users[0]}"
14546 cl_user2[mds$i]="${cl_users[1]}"
14548 [ -n "${cl_user1[mds$i]}" ] ||
14549 error "mds$i: no user registered"
14550 [ -n "${cl_user2[mds$i]}" ] ||
14551 error "mds$i: only ${cl_user1[mds$i]} is registered"
14553 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14554 [ -n "$user_rec1" ] ||
14555 error "mds$i: User ${cl_user1[mds$i]} not registered"
14556 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14557 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14558 [ -n "$user_rec2" ] ||
14559 error "mds$i: User ${cl_user1[mds$i]} not registered"
14560 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14561 "$user_rec1 + 2 == $user_rec2"
14562 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14563 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14564 "$user_rec1 + 2, but is $user_rec2"
14565 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14566 [ -n "$user_rec2" ] ||
14567 error "mds$i: User ${cl_user2[mds$i]} not registered"
14568 [ $user_rec1 == $user_rec2 ] ||
14569 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14570 "$user_rec1, but is $user_rec2"
14573 # ensure we are past the previous changelog_min_gc_interval set above
14576 # generate one more changelog to trigger fail_loc
14577 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14578 error "create $DIR/$tdir/${tfile}bis failed"
14580 # ensure gc thread is done
14581 for i in $(mdts_nodes); do
14583 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
14584 error "$i: GC-thread not done"
14588 for i in $(seq $MDSCOUNT); do
14589 # check cl_user1 still registered
14590 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14591 error "mds$i: User ${cl_user1[mds$i]} not registered"
14592 # check cl_user2 unregistered
14593 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14594 error "mds$i: User ${cl_user2[mds$i]} still registered"
14596 # check changelogs are present and starting at $user_rec1 + 1
14597 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14598 [ -n "$user_rec1" ] ||
14599 error "mds$i: User ${cl_user1[mds$i]} not registered"
14600 first_rec=$($LFS changelog $(facet_svc mds$i) |
14601 awk '{ print $1; exit; }')
14603 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14604 [ $((user_rec1 + 1)) == $first_rec ] ||
14605 error "mds$i: first index should be $user_rec1 + 1, " \
14606 "but is $first_rec"
14609 run_test 160g "changelog garbage collect (old users)"
14612 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14613 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14614 skip "Need MDS version at least 2.10.56"
14616 local mdts=$(comma_list $(mdts_nodes))
14619 changelog_register || error "first changelog_register failed"
14620 changelog_register || error "second changelog_register failed"
14622 declare -A cl_user1
14623 declare -A cl_user2
14628 # generate some changelog records to accumulate on each MDT
14629 # use fnv1a because created files should be evenly distributed
14630 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14631 error "test_mkdir $tdir failed"
14632 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14633 error "create $DIR/$tdir/$tfile failed"
14635 # check changelogs have been generated
14636 local nbcl=$(changelog_dump | wc -l)
14637 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14639 for param in "changelog_max_idle_time=10" \
14641 "changelog_min_gc_interval=2"; do
14642 local MDT0=$(facet_svc $SINGLEMDS)
14643 local var="${param%=*}"
14644 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14646 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14647 do_nodes $mdts $LCTL set_param mdd.*.$param
14650 # force cl_user2 to be idle (1st part)
14653 for i in $(seq $MDSCOUNT); do
14654 cl_users=(${CL_USERS[mds$i]})
14655 cl_user1[mds$i]="${cl_users[0]}"
14656 cl_user2[mds$i]="${cl_users[1]}"
14658 [ -n "${cl_user1[mds$i]}" ] ||
14659 error "mds$i: no user registered"
14660 [ -n "${cl_user2[mds$i]}" ] ||
14661 error "mds$i: only ${cl_user2[mds$i]} is registered"
14663 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14664 [ -n "$user_rec1" ] ||
14665 error "mds$i: User ${cl_user1[mds$i]} not registered"
14666 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14667 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14668 [ -n "$user_rec2" ] ||
14669 error "mds$i: User ${cl_user1[mds$i]} not registered"
14670 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14671 "$user_rec1 + 2 == $user_rec2"
14672 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14673 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14674 "$user_rec1 + 2, but is $user_rec2"
14675 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14676 [ -n "$user_rec2" ] ||
14677 error "mds$i: User ${cl_user2[mds$i]} not registered"
14678 [ $user_rec1 == $user_rec2 ] ||
14679 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14680 "$user_rec1, but is $user_rec2"
14683 # force cl_user2 to be idle (2nd part) and to reach
14684 # changelog_max_idle_time
14687 # force each GC-thread start and block then
14688 # one per MDT/MDD, set fail_val accordingly
14689 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
14690 do_nodes $mdts $LCTL set_param fail_loc=0x1316
14692 # generate more changelogs to trigger fail_loc
14693 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14694 error "create $DIR/$tdir/${tfile}bis failed"
14696 # stop MDT to stop GC-thread, should be done in back-ground as it will
14697 # block waiting for the thread to be released and exit
14698 declare -A stop_pids
14699 for i in $(seq $MDSCOUNT); do
14701 stop_pids[mds$i]=$!
14704 for i in $(mdts_nodes); do
14707 local facets=$(facets_up_on_host $i)
14709 for facet in ${facets//,/ }; do
14710 if [[ $facet == mds* ]]; then
14714 # ensure each MDS's gc threads are still present and all in "R"
14715 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
14716 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
14717 error "$i: expected $nb GC-thread"
14719 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
14721 error "$i: GC-thread not found in R-state"
14722 # check umounts of each MDT on MDS have reached kthread_stop()
14723 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
14724 error "$i: expected $nb umount"
14726 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
14727 error "$i: umount not found in D-state"
14730 # release all GC-threads
14731 do_nodes $mdts $LCTL set_param fail_loc=0
14733 # wait for MDT stop to complete
14734 for i in $(seq $MDSCOUNT); do
14735 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
14739 # may try to check if any orphan changelog records are present
14740 # via ldiskfs/zfs and llog_reader...
14742 # re-start/mount MDTs
14743 for i in $(seq $MDSCOUNT); do
14744 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
14745 error "Fail to start mds$i"
14749 for i in $(seq $MDSCOUNT); do
14750 # check cl_user1 still registered
14751 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14752 error "mds$i: User ${cl_user1[mds$i]} not registered"
14753 # check cl_user2 unregistered
14754 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14755 error "mds$i: User ${cl_user2[mds$i]} still registered"
14757 # check changelogs are present and starting at $user_rec1 + 1
14758 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14759 [ -n "$user_rec1" ] ||
14760 error "mds$i: User ${cl_user1[mds$i]} not registered"
14761 first_rec=$($LFS changelog $(facet_svc mds$i) |
14762 awk '{ print $1; exit; }')
14764 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14765 [ $((user_rec1 + 1)) == $first_rec ] ||
14766 error "mds$i: first index should be $user_rec1 + 1, " \
14767 "but is $first_rec"
14770 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
14775 local mdts=$(comma_list $(mdts_nodes))
14777 changelog_register || error "first changelog_register failed"
14779 # generate some changelog records to accumulate on each MDT
14780 # use fnv1a because created files should be evenly distributed
14781 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14782 error "mkdir $tdir failed"
14783 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14784 error "create $DIR/$tdir/$tfile failed"
14786 # check changelogs have been generated
14787 local nbcl=$(changelog_dump | wc -l)
14788 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14790 # simulate race between register and unregister
14791 # XXX as fail_loc is set per-MDS, with DNE configs the race
14792 # simulation will only occur for one MDT per MDS and for the
14793 # others the normal race scenario will take place
14794 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
14795 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
14796 do_nodes $mdts $LCTL set_param fail_val=1
14798 # unregister 1st user
14799 changelog_deregister &
14801 # wait some time for deregister work to reach race rdv
14803 # register 2nd user
14804 changelog_register || error "2nd user register failed"
14806 wait $pid1 || error "1st user deregister failed"
14810 declare -A LAST_REC
14811 for i in $(seq $MDSCOUNT); do
14812 if changelog_users mds$i | grep "^cl"; then
14813 # make sure new records are added with one user present
14814 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
14815 awk '/^current.index:/ { print $NF }')
14817 error "mds$i has no user registered"
14821 # generate more changelog records to accumulate on each MDT
14822 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14823 error "create $DIR/$tdir/${tfile}bis failed"
14825 for i in $(seq $MDSCOUNT); do
14826 last_rec=$(changelog_users $SINGLEMDS |
14827 awk '/^current.index:/ { print $NF }')
14828 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
14829 [ $last_rec != ${LAST_REC[mds$i]} ] ||
14830 error "changelogs are off on mds$i"
14833 run_test 160i "changelog user register/unregister race"
14836 remote_mds_nodsh && skip "remote MDS with nodsh"
14837 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
14838 skip "Need MDS version at least 2.12.56"
14840 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
14841 stack_trap "umount $MOUNT2" EXIT
14843 changelog_register || error "first changelog_register failed"
14844 stack_trap "changelog_deregister" EXIT
14846 # generate some changelog
14847 # use fnv1a because created files should be evenly distributed
14848 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14849 error "mkdir $tdir failed"
14850 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14851 error "create $DIR/$tdir/${tfile}bis failed"
14853 # open the changelog device
14854 exec 3>/dev/changelog-$FSNAME-MDT0000
14855 stack_trap "exec 3>&-" EXIT
14856 exec 4</dev/changelog-$FSNAME-MDT0000
14857 stack_trap "exec 4<&-" EXIT
14859 # umount the first lustre mount
14861 stack_trap "mount_client $MOUNT" EXIT
14864 cat <&4 >/dev/null || error "read changelog failed"
14867 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14868 changelog_users $SINGLEMDS | grep -q $cl_user ||
14869 error "User $cl_user not found in changelog_users"
14871 printf 'clear:'$cl_user':0' >&3
14873 run_test 160j "client can be umounted while its chanangelog is being used"
14876 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14877 remote_mds_nodsh && skip "remote MDS with nodsh"
14879 mkdir -p $DIR/$tdir/1/1
14881 changelog_register || error "changelog_register failed"
14882 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14884 changelog_users $SINGLEMDS | grep -q $cl_user ||
14885 error "User '$cl_user' not found in changelog_users"
14886 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
14887 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
14888 rmdir $DIR/$tdir/1/1 & sleep 1
14890 touch $DIR/$tdir/2/2
14891 rm -rf $DIR/$tdir/2
14896 changelog_dump | grep rmdir || error "rmdir not recorded"
14899 changelog_deregister
14901 run_test 160k "Verify that changelog records are not lost"
14904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14906 test_mkdir -c1 $DIR/$tdir
14907 cp /etc/hosts $DIR/$tdir/$tfile
14908 test_mkdir -c1 $DIR/$tdir/foo1
14909 test_mkdir -c1 $DIR/$tdir/foo2
14910 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
14911 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
14912 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
14913 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
14914 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
14915 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14916 $LFS fid2path $DIR $FID
14917 error "bad link ea"
14920 rm $DIR/$tdir/foo2/zachary
14922 rm $DIR/$tdir/foo2/thor
14924 rm $DIR/$tdir/$tfile
14926 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
14927 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
14928 { $LFS fid2path $DIR $FID; error "bad link rename"; }
14929 rm $DIR/$tdir/foo2/maggie
14932 local longname=$tfile.avg_len_is_thirty_two_
14933 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
14934 error_noexit 'failed to unlink many hardlinks'" EXIT
14935 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
14936 error "failed to hardlink many files"
14937 links=$($LFS fid2path $DIR $FID | wc -l)
14938 echo -n "${links}/1000 links in link EA"
14939 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
14941 run_test 161a "link ea sanity"
14944 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14945 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
14948 local remote_dir=$DIR/$tdir/remote_dir
14950 mkdir -p $DIR/$tdir
14951 $LFS mkdir -i $MDTIDX $remote_dir ||
14952 error "create remote directory failed"
14954 cp /etc/hosts $remote_dir/$tfile
14955 mkdir -p $remote_dir/foo1
14956 mkdir -p $remote_dir/foo2
14957 ln $remote_dir/$tfile $remote_dir/foo1/sofia
14958 ln $remote_dir/$tfile $remote_dir/foo2/zachary
14959 ln $remote_dir/$tfile $remote_dir/foo1/luna
14960 ln $remote_dir/$tfile $remote_dir/foo2/thor
14962 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
14964 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14965 $LFS fid2path $DIR $FID
14966 error "bad link ea"
14969 rm $remote_dir/foo2/zachary
14971 rm $remote_dir/foo2/thor
14973 rm $remote_dir/$tfile
14975 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
14976 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
14977 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
14978 $LFS fid2path $DIR $FID
14979 error "bad link rename"
14981 rm $remote_dir/foo2/maggie
14984 local longname=filename_avg_len_is_thirty_two_
14985 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
14986 error "failed to hardlink many files"
14987 links=$($LFS fid2path $DIR $FID | wc -l)
14988 echo -n "${links}/1000 links in link EA"
14989 [[ ${links} -gt 60 ]] ||
14990 error "expected at least 60 links in link EA"
14991 unlinkmany $remote_dir/foo2/$longname 1000 ||
14992 error "failed to unlink many hardlinks"
14994 run_test 161b "link ea sanity under remote directory"
14997 remote_mds_nodsh && skip "remote MDS with nodsh"
14998 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14999 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
15000 skip "Need MDS version at least 2.1.5"
15002 # define CLF_RENAME_LAST 0x0001
15003 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
15004 changelog_register || error "changelog_register failed"
15007 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
15008 touch $DIR/$tdir/foo_161c
15009 touch $DIR/$tdir/bar_161c
15010 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
15011 changelog_dump | grep RENME | tail -n 5
15012 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
15013 changelog_clear 0 || error "changelog_clear failed"
15014 if [ x$flags != "x0x1" ]; then
15015 error "flag $flags is not 0x1"
15018 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
15019 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
15020 touch $DIR/$tdir/foo_161c
15021 touch $DIR/$tdir/bar_161c
15022 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
15023 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
15024 changelog_dump | grep RENME | tail -n 5
15025 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
15026 changelog_clear 0 || error "changelog_clear failed"
15027 if [ x$flags != "x0x0" ]; then
15028 error "flag $flags is not 0x0"
15030 echo "rename overwrite a target having nlink > 1," \
15031 "changelog record has flags of $flags"
15033 # rename doesn't overwrite a target (changelog flag 0x0)
15034 touch $DIR/$tdir/foo_161c
15035 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
15036 changelog_dump | grep RENME | tail -n 5
15037 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
15038 changelog_clear 0 || error "changelog_clear failed"
15039 if [ x$flags != "x0x0" ]; then
15040 error "flag $flags is not 0x0"
15042 echo "rename doesn't overwrite a target," \
15043 "changelog record has flags of $flags"
15045 # define CLF_UNLINK_LAST 0x0001
15046 # unlink a file having nlink = 1 (changelog flag 0x1)
15047 rm -f $DIR/$tdir/foo2_161c
15048 changelog_dump | grep UNLNK | tail -n 5
15049 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
15050 changelog_clear 0 || error "changelog_clear failed"
15051 if [ x$flags != "x0x1" ]; then
15052 error "flag $flags is not 0x1"
15054 echo "unlink a file having nlink = 1," \
15055 "changelog record has flags of $flags"
15057 # unlink a file having nlink > 1 (changelog flag 0x0)
15058 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
15059 rm -f $DIR/$tdir/foobar_161c
15060 changelog_dump | grep UNLNK | tail -n 5
15061 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
15062 changelog_clear 0 || error "changelog_clear failed"
15063 if [ x$flags != "x0x0" ]; then
15064 error "flag $flags is not 0x0"
15066 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
15068 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
15071 remote_mds_nodsh && skip "remote MDS with nodsh"
15072 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
15077 changelog_register || error "changelog_register failed"
15079 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
15080 # interfer with $MOUNT/.lustre/fid/ access
15082 [[ $? -eq 0 ]] || error "mkdir failed"
15084 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
15085 $LCTL set_param fail_loc=0x8000140c
15087 $LCTL set_param fail_val=5
15090 echo foofoo > $DIR/$tdir/$tfile &
15093 # wait for create to be delayed
15097 [[ $? -eq 0 ]] || error "create should be blocked"
15099 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
15100 stack_trap "rm -f $tempfile"
15101 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
15102 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
15103 # some delay may occur during ChangeLog publishing and file read just
15104 # above, that could allow file write to happen finally
15105 [[ -s $tempfile ]] && echo "file should be empty"
15107 $LCTL set_param fail_loc=0
15110 [[ $? -eq 0 ]] || error "create failed"
15112 run_test 161d "create with concurrent .lustre/fid access"
15115 local expected="$1"
15120 path=$($LFS fid2path "$@")
15123 if [ $rc -ne 0 ]; then
15124 error "path looked up of '$expected' failed: rc=$rc"
15125 elif [ "$path" != "$expected" ]; then
15126 error "path looked up '$path' instead of '$expected'"
15128 echo "FID '$fid' resolves to path '$path' as expected"
15132 test_162a() { # was test_162
15133 test_mkdir -p -c1 $DIR/$tdir/d2
15134 touch $DIR/$tdir/d2/$tfile
15135 touch $DIR/$tdir/d2/x1
15136 touch $DIR/$tdir/d2/x2
15137 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
15138 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
15140 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
15141 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
15144 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
15145 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
15146 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
15148 # softlink to wrong file
15149 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
15150 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
15151 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
15154 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
15155 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
15156 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
15157 # fid2path dir/fsname should both work
15158 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
15159 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
15161 # hardlink count: check that there are 2 links
15162 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
15163 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
15165 # hardlink indexing: remove the first link
15166 rm $DIR/$tdir/d2/p/q/r/hlink
15167 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
15169 run_test 162a "path lookup sanity"
15172 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15173 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15176 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
15177 error "create striped dir failed"
15179 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
15180 tail -n 1 | awk '{print $2}')
15181 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
15183 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
15184 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
15187 for ((i=0;i<5;i++)); do
15188 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
15189 error "get fid for f$i failed"
15190 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
15192 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
15193 error "get fid for d$i failed"
15194 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
15199 run_test 162b "striped directory path lookup sanity"
15201 # LU-4239: Verify fid2path works with paths 100 or more directories deep
15203 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
15204 skip "Need MDS version at least 2.7.51"
15206 local lpath=$tdir.local
15207 local rpath=$tdir.remote
15209 test_mkdir $DIR/$lpath
15210 test_mkdir $DIR/$rpath
15212 for ((i = 0; i <= 101; i++)); do
15215 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
15216 error "get fid for local directory $DIR/$lpath failed"
15217 check_path "$DIR/$lpath" $MOUNT $FID --link 0
15220 test_mkdir $DIR/$rpath
15221 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
15222 error "get fid for remote directory $DIR/$rpath failed"
15223 check_path "$DIR/$rpath" $MOUNT $FID --link 0
15228 run_test 162c "fid2path works with paths 100 or more directories deep"
15230 oalr_event_count() {
15234 awk -v name="${FSNAME}-OST0000" \
15235 -v event="${event}" \
15236 '$1 == "TRACE" && $2 == event && $3 == name' \
15241 oalr_expect_event_count() {
15244 local expect="${3}"
15247 count=$(oalr_event_count "${event}" "${trace}")
15248 if ((count == expect)); then
15252 error_noexit "${event} event count was '${count}', expected ${expect}"
15258 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
15260 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
15264 sync # Flush previous IOs so we can count log entries.
15265 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
15266 stack_trap cleanup_165 EXIT
15270 local trace="/tmp/${tfile}.trace"
15274 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
15278 do_facet ost1 ofd_access_log_reader --list
15281 do_facet ost1 killall -TERM ofd_access_log_reader
15285 if ((rc != 0)); then
15286 error "ofd_access_log_reader exited with rc = '${rc}'"
15289 # Parse trace file for discovery events:
15290 oalr_expect_event_count alr_log_add "${trace}" 1
15291 oalr_expect_event_count alr_log_eof "${trace}" 1
15292 oalr_expect_event_count alr_log_free "${trace}" 1
15294 run_test 165a "ofd access log discovery"
15297 local trace="/tmp/${tfile}.trace"
15298 local file="${DIR}/${tfile}"
15309 lfs setstripe -c 1 -i 0 "${file}"
15310 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15311 do_facet ost1 ofd_access_log_reader --list
15313 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
15315 do_facet ost1 killall -TERM ofd_access_log_reader
15319 if ((rc != 0)); then
15320 error "ofd_access_log_reader exited with rc = '${rc}'"
15323 oalr_expect_event_count alr_log_entry "${trace}" 1
15325 pfid1=$($LFS path2fid "${file}")
15327 # 1 2 3 4 5 6 7 8 9 10
15328 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
15329 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
15331 echo "entry = '${entry[*]}'" >&2
15334 if [[ "${pfid1}" != "${pfid2}" ]]; then
15335 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
15339 if ((size != 1048576)); then
15340 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
15344 if [[ "${flags}" != "w" ]]; then
15345 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
15348 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
15349 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c || error "cannot read '${file}'"
15351 do_facet ost1 killall -TERM ofd_access_log_reader
15355 if ((rc != 0)); then
15356 error "ofd_access_log_reader exited with rc = '${rc}'"
15359 oalr_expect_event_count alr_log_entry "${trace}" 1
15361 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
15362 echo "entry = '${entry[*]}'" >&2
15365 if [[ "${pfid1}" != "${pfid2}" ]]; then
15366 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
15370 if ((size != 524288)); then
15371 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
15375 if [[ "${flags}" != "r" ]]; then
15376 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
15379 run_test 165b "ofd access log entries are produced and consumed"
15382 local file="${DIR}/${tdir}/${tfile}"
15383 test_mkdir "${DIR}/${tdir}"
15387 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
15389 # 4096 / 64 = 64. Create twice as many entries.
15390 for ((i = 0; i < 128; i++)); do
15391 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c || error "cannot create file"
15395 do_facet ost1 ofd_access_log_reader --list
15396 unlinkmany "${file}-%d" 128
15398 run_test 165c "full ofd access logs do not block IOs"
15400 oal_peek_entry_count() {
15401 do_facet ost1 ofd_access_log_reader --list | awk '$1 == "_entry_count:" { print $2; }'
15404 oal_expect_entry_count() {
15405 local entry_count=$(oal_peek_entry_count)
15408 if ((entry_count == expect)); then
15412 error_noexit "bad entry count, got ${entry_count}, expected ${expect}"
15413 do_facet ost1 ofd_access_log_reader --list >&2
15418 local trace="/tmp/${tfile}.trace"
15419 local file="${DIR}/${tdir}/${tfile}"
15420 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
15422 test_mkdir "${DIR}/${tdir}"
15425 lfs setstripe -c 1 -i 0 "${file}"
15427 do_facet ost1 lctl set_param "${param}=rw"
15428 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15429 oal_expect_entry_count 1
15431 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15432 oal_expect_entry_count 2
15434 do_facet ost1 lctl set_param "${param}=r"
15435 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15436 oal_expect_entry_count 2
15438 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15439 oal_expect_entry_count 3
15441 do_facet ost1 lctl set_param "${param}=w"
15442 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15443 oal_expect_entry_count 4
15445 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15446 oal_expect_entry_count 4
15448 do_facet ost1 lctl set_param "${param}=0"
15449 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15450 oal_expect_entry_count 4
15452 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15453 oal_expect_entry_count 4
15455 run_test 165d "ofd_access_log mask works"
15458 # do directio so as not to populate the page cache
15459 log "creating a 10 Mb file"
15460 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
15461 log "starting reads"
15462 dd if=$DIR/$tfile of=/dev/null bs=4096 &
15463 log "truncating the file"
15464 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
15466 kill %+ || true # reads might have finished
15467 echo "wait until dd is finished"
15469 log "removing the temporary file"
15470 rm -rf $DIR/$tfile || error "tmp file removal failed"
15472 run_test 169 "parallel read and truncate should not deadlock"
15475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15477 $LCTL clear # bug 18514
15478 $LCTL debug_daemon start $TMP/${tfile}_log_good
15480 $LCTL debug_daemon stop
15481 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
15482 error "sed failed to read log_good"
15484 $LCTL debug_daemon start $TMP/${tfile}_log_good
15486 $LCTL debug_daemon stop
15488 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
15489 error "lctl df log_bad failed"
15491 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
15492 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
15494 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
15495 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
15497 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
15498 error "bad_line good_line1 good_line2 are empty"
15500 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
15501 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
15502 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
15504 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
15505 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
15506 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
15508 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
15509 error "bad_line_new good_line_new are empty"
15511 local expected_good=$((good_line1 + good_line2*2))
15513 rm -f $TMP/${tfile}*
15514 # LU-231, short malformed line may not be counted into bad lines
15515 if [ $bad_line -ne $bad_line_new ] &&
15516 [ $bad_line -ne $((bad_line_new - 1)) ]; then
15517 error "expected $bad_line bad lines, but got $bad_line_new"
15521 if [ $expected_good -ne $good_line_new ]; then
15522 error "expected $expected_good good lines, but got $good_line_new"
15527 run_test 170 "test lctl df to handle corrupted log ====================="
15529 test_171() { # bug20592
15530 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15532 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
15533 $LCTL set_param fail_loc=0x50e
15534 $LCTL set_param fail_val=3000
15535 multiop_bg_pause $DIR/$tfile O_s || true
15537 kill -USR1 $MULTIPID
15541 if dmesg | grep "recursive fault"; then
15542 error "caught a recursive fault"
15544 $LCTL set_param fail_loc=0
15547 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
15549 # it would be good to share it with obdfilter-survey/iokit-libecho code
15550 setup_obdecho_osc () {
15553 local obdfilter_name=$2
15554 echo "Creating new osc for $obdfilter_name on $ost_nid"
15555 # make sure we can find loopback nid
15556 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
15558 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
15559 ${obdfilter_name}_osc_UUID || rc=2; }
15560 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
15561 ${obdfilter_name}_UUID $ost_nid || rc=3; }
15565 cleanup_obdecho_osc () {
15566 local obdfilter_name=$1
15567 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
15568 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
15575 local pages=${3:-64}
15580 local obd_size=$(get_obd_size $node $OBD)
15581 local page_size=$(get_page_size $node)
15582 if [[ -n "$obd_size" ]]; then
15583 local new_count=$((obd_size / (pages * page_size / 1024)))
15584 [[ $new_count -ge $count ]] || count=$new_count
15587 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
15588 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
15590 if [ $rc -eq 0 ]; then
15591 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
15592 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
15594 echo "New object id is $id"
15595 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
15597 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
15598 "test_brw $count w v $pages $id" || rc=4; }
15599 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
15601 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
15602 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
15603 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
15604 { do_facet $node "$LCTL --device ec detach" || rc=6; }
15605 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
15610 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15612 if ! module_loaded obdecho; then
15613 load_module obdecho/obdecho &&
15614 stack_trap "rmmod obdecho" EXIT ||
15615 error "unable to load obdecho on client"
15618 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
15619 local host=$($LCTL get_param -n osc.$osc.import |
15620 awk '/current_connection:/ { print $2 }' )
15621 local target=$($LCTL get_param -n osc.$osc.import |
15622 awk '/target:/ { print $2 }' )
15623 target=${target%_UUID}
15625 if [ -n "$target" ]; then
15626 setup_obdecho_osc $host $target &&
15627 stack_trap "cleanup_obdecho_osc $target" EXIT ||
15628 { error "obdecho setup failed with $?"; return; }
15630 obdecho_test ${target}_osc client ||
15631 error "obdecho_test failed on ${target}_osc"
15633 $LCTL get_param osc.$osc.import
15634 error "there is no osc.$osc.import target"
15637 run_test 180a "test obdecho on osc"
15640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15641 remote_ost_nodsh && skip "remote OST with nodsh"
15643 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
15644 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
15645 error "failed to load module obdecho"
15647 local target=$(do_facet ost1 $LCTL dl |
15648 awk '/obdfilter/ { print $4; exit; }')
15650 if [ -n "$target" ]; then
15651 obdecho_test $target ost1 || error "obdecho_test failed with $?"
15653 do_facet ost1 $LCTL dl
15654 error "there is no obdfilter target on ost1"
15657 run_test 180b "test obdecho directly on obdfilter"
15659 test_180c() { # LU-2598
15660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15661 remote_ost_nodsh && skip "remote OST with nodsh"
15662 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
15663 skip "Need MDS version at least 2.4.0"
15665 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
15666 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
15667 error "failed to load module obdecho"
15669 local target=$(do_facet ost1 $LCTL dl |
15670 awk '/obdfilter/ { print $4; exit; }')
15672 if [ -n "$target" ]; then
15673 local pages=16384 # 64MB bulk I/O RPC size
15675 obdecho_test "$target" ost1 "$pages" ||
15676 error "obdecho_test with pages=$pages failed with $?"
15678 do_facet ost1 $LCTL dl
15679 error "there is no obdfilter target on ost1"
15682 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
15684 test_181() { # bug 22177
15685 test_mkdir $DIR/$tdir
15686 # create enough files to index the directory
15687 createmany -o $DIR/$tdir/foobar 4000
15688 # print attributes for debug purpose
15691 multiop_bg_pause $DIR/$tdir D_Sc || return 1
15693 # remove the files & current working dir
15694 unlinkmany $DIR/$tdir/foobar 4000
15696 kill -USR1 $MULTIPID
15698 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
15701 run_test 181 "Test open-unlinked dir ========================"
15707 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15709 $LCTL set_param mdc.*.rpc_stats=clear
15711 for (( i = 0; i < $tcount; i++ )) ; do
15712 mkdir $DIR/$tdir/$i
15715 for (( i = 0; i < $tcount; i++ )) ; do
15716 createmany -o $DIR/$tdir/$i/f- $fcount &
15720 for (( i = 0; i < $tcount; i++ )) ; do
15721 unlinkmany $DIR/$tdir/$i/f- $fcount &
15725 $LCTL get_param mdc.*.rpc_stats
15729 run_test 182 "Test parallel modify metadata operations ================"
15731 test_183() { # LU-2275
15732 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15733 remote_mds_nodsh && skip "remote MDS with nodsh"
15734 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
15735 skip "Need MDS version at least 2.3.56"
15737 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15738 echo aaa > $DIR/$tdir/$tfile
15740 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
15741 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
15743 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
15744 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
15746 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
15748 # Flush negative dentry cache
15749 touch $DIR/$tdir/$tfile
15751 # We are not checking for any leaked references here, they'll
15752 # become evident next time we do cleanup with module unload.
15755 run_test 183 "No crash or request leak in case of strange dispositions ========"
15757 # test suite 184 is for LU-2016, LU-2017
15759 check_swap_layouts_support
15761 dir0=$DIR/$tdir/$testnum
15762 test_mkdir -p -c1 $dir0
15767 $LFS setstripe -c1 $file1
15769 $LFS setstripe -c2 $file2
15771 gen1=$($LFS getstripe -g $file1)
15772 gen2=$($LFS getstripe -g $file2)
15774 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
15775 gen=$($LFS getstripe -g $file1)
15776 [[ $gen1 != $gen ]] ||
15777 "Layout generation on $file1 does not change"
15778 gen=$($LFS getstripe -g $file2)
15779 [[ $gen2 != $gen ]] ||
15780 "Layout generation on $file2 does not change"
15782 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
15783 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
15785 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
15787 run_test 184a "Basic layout swap"
15790 check_swap_layouts_support
15792 dir0=$DIR/$tdir/$testnum
15793 mkdir -p $dir0 || error "creating dir $dir0"
15800 $LFS setstripe -c1 $file1
15801 $LFS setstripe -c2 $file2
15802 $LFS setstripe -c1 $file3
15803 chown $RUNAS_ID $file3
15804 gen1=$($LFS getstripe -g $file1)
15805 gen2=$($LFS getstripe -g $file2)
15807 $LFS swap_layouts $dir1 $dir2 &&
15808 error "swap of directories layouts should fail"
15809 $LFS swap_layouts $dir1 $file1 &&
15810 error "swap of directory and file layouts should fail"
15811 $RUNAS $LFS swap_layouts $file1 $file2 &&
15812 error "swap of file we cannot write should fail"
15813 $LFS swap_layouts $file1 $file3 &&
15814 error "swap of file with different owner should fail"
15815 /bin/true # to clear error code
15817 run_test 184b "Forbidden layout swap (will generate errors)"
15820 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
15821 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
15822 check_swap_layouts_support
15824 local dir0=$DIR/$tdir/$testnum
15825 mkdir -p $dir0 || error "creating dir $dir0"
15827 local ref1=$dir0/ref1
15828 local ref2=$dir0/ref2
15829 local file1=$dir0/file1
15830 local file2=$dir0/file2
15831 # create a file large enough for the concurrent test
15832 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
15833 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
15834 echo "ref file size: ref1($(stat -c %s $ref1))," \
15835 "ref2($(stat -c %s $ref2))"
15838 dd if=$ref1 of=$file1 bs=16k &
15841 # Make sure dd starts to copy file
15842 while [ ! -f $file1 ]; do sleep 0.1; done
15844 $LFS swap_layouts $file1 $file2
15847 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
15848 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
15850 # how many bytes copied before swapping layout
15851 local copied=$(stat -c %s $file2)
15852 local remaining=$(stat -c %s $ref1)
15853 remaining=$((remaining - copied))
15854 echo "Copied $copied bytes before swapping layout..."
15856 cmp -n $copied $file1 $ref2 | grep differ &&
15857 error "Content mismatch [0, $copied) of ref2 and file1"
15858 cmp -n $copied $file2 $ref1 ||
15859 error "Content mismatch [0, $copied) of ref1 and file2"
15860 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
15861 error "Content mismatch [$copied, EOF) of ref1 and file1"
15864 rm -f $ref1 $ref2 $file1 $file2
15866 run_test 184c "Concurrent write and layout swap"
15869 check_swap_layouts_support
15870 [ -z "$(which getfattr 2>/dev/null)" ] &&
15871 skip_env "no getfattr command"
15873 local file1=$DIR/$tdir/$tfile-1
15874 local file2=$DIR/$tdir/$tfile-2
15875 local file3=$DIR/$tdir/$tfile-3
15879 mkdir -p $DIR/$tdir
15880 touch $file1 || error "create $file1 failed"
15881 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
15882 error "create $file2 failed"
15883 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
15884 error "create $file3 failed"
15885 lovea1=$(get_layout_param $file1)
15887 $LFS swap_layouts $file2 $file3 ||
15888 error "swap $file2 $file3 layouts failed"
15889 $LFS swap_layouts $file1 $file2 ||
15890 error "swap $file1 $file2 layouts failed"
15892 lovea2=$(get_layout_param $file2)
15895 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
15897 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
15898 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
15900 run_test 184d "allow stripeless layouts swap"
15903 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
15904 skip "Need MDS version at least 2.6.94"
15905 check_swap_layouts_support
15906 [ -z "$(which getfattr 2>/dev/null)" ] &&
15907 skip_env "no getfattr command"
15909 local file1=$DIR/$tdir/$tfile-1
15910 local file2=$DIR/$tdir/$tfile-2
15911 local file3=$DIR/$tdir/$tfile-3
15914 mkdir -p $DIR/$tdir
15915 touch $file1 || error "create $file1 failed"
15916 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
15917 error "create $file2 failed"
15918 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
15919 error "create $file3 failed"
15921 $LFS swap_layouts $file1 $file2 ||
15922 error "swap $file1 $file2 layouts failed"
15924 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
15925 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
15927 echo 123 > $file1 || error "Should be able to write into $file1"
15929 $LFS swap_layouts $file1 $file3 ||
15930 error "swap $file1 $file3 layouts failed"
15932 echo 123 > $file1 || error "Should be able to write into $file1"
15934 rm -rf $file1 $file2 $file3
15936 run_test 184e "Recreate layout after stripeless layout swaps"
15939 # Create a file with name longer than sizeof(struct stat) ==
15940 # 144 to see if we can get chars from the file name to appear
15941 # in the returned striping. Note that 'f' == 0x66.
15942 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
15944 mkdir -p $DIR/$tdir
15945 mcreate $DIR/$tdir/$file
15946 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
15947 error "IOC_MDC_GETFILEINFO returned garbage striping"
15950 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
15952 test_185() { # LU-2441
15953 # LU-3553 - no volatile file support in old servers
15954 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
15955 skip "Need MDS version at least 2.3.60"
15957 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15958 touch $DIR/$tdir/spoo
15959 local mtime1=$(stat -c "%Y" $DIR/$tdir)
15960 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
15961 error "cannot create/write a volatile file"
15962 [ "$FILESET" == "" ] &&
15963 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
15964 error "FID is still valid after close"
15966 multiop_bg_pause $DIR/$tdir vVw4096_c
15973 # assume that the next FID for this client is sequential, since stdout
15974 # is unfortunately eaten by multiop_bg_pause
15975 local n=$((${fidv[1]} + 1))
15976 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
15977 if [ "$FILESET" == "" ]; then
15978 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
15979 error "FID is missing before close"
15981 kill -USR1 $multi_pid
15982 # 1 second delay, so if mtime change we will see it
15984 local mtime2=$(stat -c "%Y" $DIR/$tdir)
15985 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
15987 run_test 185 "Volatile file support"
15989 function create_check_volatile() {
15993 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
15996 local FID=$(cat /tmp/${tfile}.fid)
15997 [ "$FID" == "" ] && error "can't get FID for volatile"
15998 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
15999 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
16000 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
16004 cancel_lru_locks mdc # flush opencache
16005 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
16010 # LU-12516 - volatile creation via .lustre
16011 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
16012 skip "Need MDS version at least 2.3.55"
16014 create_check_volatile 0
16015 [ $MDSCOUNT -lt 2 ] && return 0
16018 create_check_volatile 1
16022 run_test 185a "Volatile file creation in .lustre/fid/"
16025 remote_mds_nodsh && skip "remote MDS with nodsh"
16026 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
16027 skip "Need MDS version at least 2.3.0"
16029 local dir0=$DIR/$tdir/$testnum
16030 mkdir -p $dir0 || error "creating dir $dir0"
16032 local file=$dir0/file1
16033 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
16034 local dv1=$($LFS data_version $file)
16035 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
16036 local dv2=$($LFS data_version $file)
16037 [[ $dv1 != $dv2 ]] ||
16038 error "data version did not change on write $dv1 == $dv2"
16043 run_test 187a "Test data version change"
16046 remote_mds_nodsh && skip "remote MDS with nodsh"
16047 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
16048 skip "Need MDS version at least 2.3.0"
16050 local dir0=$DIR/$tdir/$testnum
16051 mkdir -p $dir0 || error "creating dir $dir0"
16053 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
16054 [[ ${DV[0]} != ${DV[1]} ]] ||
16055 error "data version did not change on write"\
16056 " ${DV[0]} == ${DV[1]}"
16061 run_test 187b "Test data version change on volatile file"
16064 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16065 remote_mgs_nodsh && skip "remote MGS with nodsh"
16066 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16068 local POOL=${POOL:-cea1}
16069 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
16070 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
16073 local last_ost=$(($OSTCOUNT - 1))
16075 local ost_list=$(seq $first_ost $ost_step $last_ost)
16076 local ost_range="$first_ost $last_ost $ost_step"
16077 local test_path=$POOL_ROOT/$POOL_DIR_NAME
16078 local file_dir=$POOL_ROOT/file_tst
16079 local subdir=$test_path/subdir
16083 # former test_200a test_200b
16084 pool_add $POOL || { rc=$? ; break; }
16085 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
16086 # former test_200c test_200d
16087 mkdir -p $test_path
16088 pool_set_dir $POOL $test_path || { rc=$? ; break; }
16089 pool_check_dir $POOL $test_path || { rc=$? ; break; }
16091 pool_check_dir $POOL $subdir || { rc=$? ; break; }
16092 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
16093 || { rc=$? ; break; }
16094 # former test_200e test_200f
16095 local files=$((OSTCOUNT*3))
16096 pool_alloc_files $POOL $test_path $files "$ost_list" \
16097 || { rc=$? ; break; }
16098 pool_create_files $POOL $file_dir $files "$ost_list" \
16099 || { rc=$? ; break; }
16100 # former test_200g test_200h
16101 pool_lfs_df $POOL || { rc=$? ; break; }
16102 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
16104 # former test_201a test_201b test_201c
16105 pool_remove_first_target $POOL || { rc=$? ; break; }
16107 local f=$test_path/$tfile
16108 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
16109 pool_remove $POOL $f || { rc=$? ; break; }
16117 run_test 200 "OST pools"
16119 # usage: default_attr <count | size | offset>
16121 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
16124 # usage: check_default_stripe_attr
16125 check_default_stripe_attr() {
16126 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
16129 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
16131 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
16135 error "unknown getstripe attr '$1'"
16138 [ $ACTUAL == $EXPECTED ] ||
16139 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
16143 test_mkdir $DIR/$tdir
16144 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
16146 check_default_stripe_attr --stripe-count
16147 check_default_stripe_attr --stripe-size
16148 check_default_stripe_attr --stripe-index
16150 run_test 204a "Print default stripe attributes"
16153 test_mkdir $DIR/$tdir
16154 $LFS setstripe --stripe-count 1 $DIR/$tdir
16156 check_default_stripe_attr --stripe-size
16157 check_default_stripe_attr --stripe-index
16159 run_test 204b "Print default stripe size and offset"
16162 test_mkdir $DIR/$tdir
16163 $LFS setstripe --stripe-size 65536 $DIR/$tdir
16165 check_default_stripe_attr --stripe-count
16166 check_default_stripe_attr --stripe-index
16168 run_test 204c "Print default stripe count and offset"
16171 test_mkdir $DIR/$tdir
16172 $LFS setstripe --stripe-index 0 $DIR/$tdir
16174 check_default_stripe_attr --stripe-count
16175 check_default_stripe_attr --stripe-size
16177 run_test 204d "Print default stripe count and size"
16180 test_mkdir $DIR/$tdir
16181 $LFS setstripe -d $DIR/$tdir
16183 check_default_stripe_attr --stripe-count --raw
16184 check_default_stripe_attr --stripe-size --raw
16185 check_default_stripe_attr --stripe-index --raw
16187 run_test 204e "Print raw stripe attributes"
16190 test_mkdir $DIR/$tdir
16191 $LFS setstripe --stripe-count 1 $DIR/$tdir
16193 check_default_stripe_attr --stripe-size --raw
16194 check_default_stripe_attr --stripe-index --raw
16196 run_test 204f "Print raw stripe size and offset"
16199 test_mkdir $DIR/$tdir
16200 $LFS setstripe --stripe-size 65536 $DIR/$tdir
16202 check_default_stripe_attr --stripe-count --raw
16203 check_default_stripe_attr --stripe-index --raw
16205 run_test 204g "Print raw stripe count and offset"
16208 test_mkdir $DIR/$tdir
16209 $LFS setstripe --stripe-index 0 $DIR/$tdir
16211 check_default_stripe_attr --stripe-count --raw
16212 check_default_stripe_attr --stripe-size --raw
16214 run_test 204h "Print raw stripe count and size"
16216 # Figure out which job scheduler is being used, if any,
16217 # or use a fake one
16218 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
16219 JOBENV=SLURM_JOB_ID
16220 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
16222 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
16224 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
16225 JOBENV=LOADL_STEP_ID
16226 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
16229 $LCTL list_param jobid_name > /dev/null 2>&1
16230 if [ $? -eq 0 ]; then
16236 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
16238 verify_jobstats() {
16243 # we don't really need to clear the stats for this test to work, since each
16244 # command has a unique jobid, but it makes debugging easier if needed.
16245 # for facet in $facets; do
16246 # local dev=$(convert_facet2label $facet)
16247 # # clear old jobstats
16248 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
16251 # use a new JobID for each test, or we might see an old one
16252 [ "$JOBENV" = "FAKE_JOBID" ] &&
16253 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
16255 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
16257 [ "$JOBENV" = "nodelocal" ] && {
16258 FAKE_JOBID=id.$testnum.%e.$RANDOM
16259 $LCTL set_param jobid_name=$FAKE_JOBID
16260 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
16263 log "Test: ${cmd[*]}"
16264 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
16266 if [ $JOBENV = "FAKE_JOBID" ]; then
16267 FAKE_JOBID=$JOBVAL ${cmd[*]}
16272 # all files are created on OST0000
16273 for facet in $facets; do
16274 local stats="*.$(convert_facet2label $facet).job_stats"
16276 # strip out libtool wrappers for in-tree executables
16277 if [ $(do_facet $facet lctl get_param $stats |
16278 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
16279 do_facet $facet lctl get_param $stats
16280 error "No jobstats for $JOBVAL found on $facet::$stats"
16286 local new_jobenv=$1
16288 set_persistent_param_and_check client "jobid_var" \
16289 "$FSNAME.sys.jobid_var" $new_jobenv
16292 test_205a() { # Job stats
16293 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16294 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
16295 skip "Need MDS version with at least 2.7.1"
16296 remote_mgs_nodsh && skip "remote MGS with nodsh"
16297 remote_mds_nodsh && skip "remote MDS with nodsh"
16298 remote_ost_nodsh && skip "remote OST with nodsh"
16299 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
16300 skip "Server doesn't support jobstats"
16301 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
16303 local old_jobenv=$($LCTL get_param -n jobid_var)
16304 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
16306 if [[ $PERM_CMD == *"set_param -P"* ]]; then
16307 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
16309 stack_trap "do_facet mgs $PERM_CMD \
16310 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
16314 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
16315 mdt.*.job_cleanup_interval | head -n 1)
16316 local new_interval=5
16317 do_facet $SINGLEMDS \
16318 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
16319 stack_trap "do_facet $SINGLEMDS \
16320 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
16321 local start=$SECONDS
16325 cmd="mkdir $DIR/$tdir"
16326 verify_jobstats "$cmd" "$SINGLEMDS"
16328 cmd="rmdir $DIR/$tdir"
16329 verify_jobstats "$cmd" "$SINGLEMDS"
16330 # mkdir on secondary MDT
16331 if [ $MDSCOUNT -gt 1 ]; then
16332 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
16333 verify_jobstats "$cmd" "mds2"
16336 cmd="mknod $DIR/$tfile c 1 3"
16337 verify_jobstats "$cmd" "$SINGLEMDS"
16339 cmd="rm -f $DIR/$tfile"
16340 verify_jobstats "$cmd" "$SINGLEMDS"
16341 # create all files on OST0000 so verify_jobstats can find OST stats
16343 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
16344 verify_jobstats "$cmd" "$SINGLEMDS"
16346 cmd="touch $DIR/$tfile"
16347 verify_jobstats "$cmd" "$SINGLEMDS ost1"
16349 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
16350 verify_jobstats "$cmd" "ost1"
16352 cancel_lru_locks osc
16353 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
16354 verify_jobstats "$cmd" "ost1"
16356 cmd="$TRUNCATE $DIR/$tfile 0"
16357 verify_jobstats "$cmd" "$SINGLEMDS ost1"
16359 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
16360 verify_jobstats "$cmd" "$SINGLEMDS"
16361 # jobstats expiry - sleep until old stats should be expired
16362 local left=$((new_interval + 5 - (SECONDS - start)))
16363 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
16364 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
16366 cmd="mkdir $DIR/$tdir.expire"
16367 verify_jobstats "$cmd" "$SINGLEMDS"
16368 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
16369 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
16371 # Ensure that jobid are present in changelog (if supported by MDS)
16372 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
16373 changelog_dump | tail -10
16374 jobids=$(changelog_dump | tail -9 | grep -c "j=")
16375 [ $jobids -eq 9 ] ||
16376 error "Wrong changelog jobid count $jobids != 9"
16380 jobstats_set $JOBENV
16382 changelog_dump | grep $tfile
16383 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
16384 [ $jobids -eq 0 ] ||
16385 error "Unexpected jobids when jobid_var=$JOBENV"
16388 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
16389 JOBENV="JOBCOMPLEX"
16390 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
16392 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
16394 run_test 205a "Verify job stats"
16398 $LCTL set_param jobid_var=USER jobid_name="%e.%u"
16399 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
16400 do_facet $SINGLEMDS $LCTL get_param mdt.*.job_stats |
16401 grep job_id: | grep foolish &&
16402 error "Unexpected jobid found"
16405 run_test 205b "Verify job stats jobid parsing"
16407 # LU-1480, LU-1773 and LU-1657
16409 mkdir -p $DIR/$tdir
16410 $LFS setstripe -c -1 $DIR/$tdir
16411 #define OBD_FAIL_LOV_INIT 0x1403
16412 $LCTL set_param fail_loc=0xa0001403
16413 $LCTL set_param fail_val=1
16414 touch $DIR/$tdir/$tfile || true
16416 run_test 206 "fail lov_init_raid0() doesn't lbug"
16419 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
16420 local fsz=`stat -c %s $DIR/$tfile`
16421 cancel_lru_locks mdc
16423 # do not return layout in getattr intent
16424 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
16425 $LCTL set_param fail_loc=0x170
16426 local sz=`stat -c %s $DIR/$tfile`
16428 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
16432 run_test 207a "can refresh layout at glimpse"
16435 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
16436 local cksum=`md5sum $DIR/$tfile`
16437 local fsz=`stat -c %s $DIR/$tfile`
16438 cancel_lru_locks mdc
16439 cancel_lru_locks osc
16441 # do not return layout in getattr intent
16442 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
16443 $LCTL set_param fail_loc=0x171
16445 # it will refresh layout after the file is opened but before read issues
16446 echo checksum is "$cksum"
16447 echo "$cksum" |md5sum -c --quiet || error "file differs"
16451 run_test 207b "can refresh layout at open"
16454 # FIXME: in this test suite, only RD lease is used. This is okay
16455 # for now as only exclusive open is supported. After generic lease
16456 # is done, this test suite should be revised. - Jinshan
16458 remote_mds_nodsh && skip "remote MDS with nodsh"
16459 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
16460 skip "Need MDS version at least 2.4.52"
16462 echo "==== test 1: verify get lease work"
16463 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
16465 echo "==== test 2: verify lease can be broken by upcoming open"
16466 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
16470 $MULTIOP $DIR/$tfile oO_RDONLY:c
16471 kill -USR1 $PID && wait $PID || error "break lease error"
16473 echo "==== test 3: verify lease can't be granted if an open already exists"
16474 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
16478 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
16479 kill -USR1 $PID && wait $PID || error "open file error"
16481 echo "==== test 4: lease can sustain over recovery"
16482 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
16488 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
16490 echo "==== test 5: lease broken can't be regained by replay"
16491 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
16495 # open file to break lease and then recovery
16496 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
16499 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
16503 run_test 208 "Exclusive open"
16506 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
16507 skip_env "must have disp_stripe"
16510 sync; sleep 5; sync;
16512 echo 3 > /proc/sys/vm/drop_caches
16513 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
16515 # open/close 500 times
16516 for i in $(seq 500); do
16520 echo 3 > /proc/sys/vm/drop_caches
16521 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
16523 echo "before: $req_before, after: $req_after"
16524 [ $((req_after - req_before)) -ge 300 ] &&
16525 error "open/close requests are not freed"
16528 run_test 209 "read-only open/close requests should be freed promptly"
16532 size=$((size % 8192 + 1))
16533 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
16534 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
16535 rm -f $DIR/f212 $DIR/f212.xyz
16537 run_test 212 "Sendfile test ============================================"
16540 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
16541 cancel_lru_locks osc
16542 lctl set_param fail_loc=0x8000040f
16543 # generate a read lock
16544 cat $DIR/$tfile > /dev/null
16545 # write to the file, it will try to cancel the above read lock.
16546 cat /etc/hosts >> $DIR/$tfile
16548 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
16550 test_214() { # for bug 20133
16551 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
16552 for (( i=0; i < 340; i++ )) ; do
16553 touch $DIR/$tdir/d214c/a$i
16556 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
16557 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
16558 ls $DIR/d214c || error "ls $DIR/d214c failed"
16559 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
16560 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
16562 run_test 214 "hash-indexed directory test - bug 20133"
16564 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
16565 create_lnet_proc_files() {
16566 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
16569 # counterpart of create_lnet_proc_files
16570 remove_lnet_proc_files() {
16571 rm -f $TMP/lnet_$1.sys
16574 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
16575 # 3rd arg as regexp for body
16576 check_lnet_proc_stats() {
16577 local l=$(cat "$TMP/lnet_$1" |wc -l)
16578 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
16580 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
16583 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
16584 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
16585 # optional and can be regexp for 2nd line (lnet.routes case)
16586 check_lnet_proc_entry() {
16587 local blp=2 # blp stands for 'position of 1st line of body'
16588 [ -z "$5" ] || blp=3 # lnet.routes case
16590 local l=$(cat "$TMP/lnet_$1" |wc -l)
16591 # subtracting one from $blp because the body can be empty
16592 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
16594 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
16595 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
16597 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
16598 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
16600 # bail out if any unexpected line happened
16601 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
16602 [ "$?" != 0 ] || error "$2 misformatted"
16605 test_215() { # for bugs 18102, 21079, 21517
16606 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16608 local N='(0|[1-9][0-9]*)' # non-negative numeric
16609 local P='[1-9][0-9]*' # positive numeric
16610 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
16611 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
16612 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
16613 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
16615 local L1 # regexp for 1st line
16616 local L2 # regexp for 2nd line (optional)
16617 local BR # regexp for the rest (body)
16619 # lnet.stats should look as 11 space-separated non-negative numerics
16620 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
16621 create_lnet_proc_files "stats"
16622 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
16623 remove_lnet_proc_files "stats"
16625 # lnet.routes should look like this:
16626 # Routing disabled/enabled
16627 # net hops priority state router
16628 # where net is a string like tcp0, hops > 0, priority >= 0,
16629 # state is up/down,
16630 # router is a string like 192.168.1.1@tcp2
16631 L1="^Routing (disabled|enabled)$"
16632 L2="^net +hops +priority +state +router$"
16633 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
16634 create_lnet_proc_files "routes"
16635 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
16636 remove_lnet_proc_files "routes"
16638 # lnet.routers should look like this:
16639 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
16640 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
16641 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
16642 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
16643 L1="^ref +rtr_ref +alive +router$"
16644 BR="^$P +$P +(up|down) +$NID$"
16645 create_lnet_proc_files "routers"
16646 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
16647 remove_lnet_proc_files "routers"
16649 # lnet.peers should look like this:
16650 # nid refs state last max rtr min tx min queue
16651 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
16652 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
16653 # numeric (0 or >0 or <0), queue >= 0.
16654 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
16655 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
16656 create_lnet_proc_files "peers"
16657 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
16658 remove_lnet_proc_files "peers"
16660 # lnet.buffers should look like this:
16661 # pages count credits min
16662 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
16663 L1="^pages +count +credits +min$"
16664 BR="^ +$N +$N +$I +$I$"
16665 create_lnet_proc_files "buffers"
16666 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
16667 remove_lnet_proc_files "buffers"
16669 # lnet.nis should look like this:
16670 # nid status alive refs peer rtr max tx min
16671 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
16672 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
16673 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
16674 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
16675 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
16676 create_lnet_proc_files "nis"
16677 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
16678 remove_lnet_proc_files "nis"
16680 # can we successfully write to lnet.stats?
16681 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
16683 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
16685 test_216() { # bug 20317
16686 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16687 remote_ost_nodsh && skip "remote OST with nodsh"
16690 local facets=$(get_facets OST)
16691 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16693 save_lustre_params client "osc.*.contention_seconds" > $p
16694 save_lustre_params $facets \
16695 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
16696 save_lustre_params $facets \
16697 "ldlm.namespaces.filter-*.contended_locks" >> $p
16698 save_lustre_params $facets \
16699 "ldlm.namespaces.filter-*.contention_seconds" >> $p
16700 clear_stats osc.*.osc_stats
16702 # agressive lockless i/o settings
16703 do_nodes $(comma_list $(osts_nodes)) \
16704 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
16705 ldlm.namespaces.filter-*.contended_locks=0 \
16706 ldlm.namespaces.filter-*.contention_seconds=60"
16707 lctl set_param -n osc.*.contention_seconds=60
16709 $DIRECTIO write $DIR/$tfile 0 10 4096
16710 $CHECKSTAT -s 40960 $DIR/$tfile
16712 # disable lockless i/o
16713 do_nodes $(comma_list $(osts_nodes)) \
16714 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
16715 ldlm.namespaces.filter-*.contended_locks=32 \
16716 ldlm.namespaces.filter-*.contention_seconds=0"
16717 lctl set_param -n osc.*.contention_seconds=0
16718 clear_stats osc.*.osc_stats
16720 dd if=/dev/zero of=$DIR/$tfile count=0
16721 $CHECKSTAT -s 0 $DIR/$tfile
16723 restore_lustre_params <$p
16727 run_test 216 "check lockless direct write updates file size and kms correctly"
16729 test_217() { # bug 22430
16730 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16735 for node in $(nodes_list); do
16736 nid=$(host_nids_address $node $NETTYPE)
16737 if [[ $nid = *-* ]] ; then
16738 echo "lctl ping $(h2nettype $nid)"
16739 lctl ping $(h2nettype $nid)
16741 echo "skipping $node (no hyphen detected)"
16745 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
16748 # do directio so as not to populate the page cache
16749 log "creating a 10 Mb file"
16750 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
16751 log "starting reads"
16752 dd if=$DIR/$tfile of=/dev/null bs=4096 &
16753 log "truncating the file"
16754 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
16756 kill %+ || true # reads might have finished
16757 echo "wait until dd is finished"
16759 log "removing the temporary file"
16760 rm -rf $DIR/$tfile || error "tmp file removal failed"
16762 run_test 218 "parallel read and truncate should not deadlock"
16765 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16767 # write one partial page
16768 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
16769 # set no grant so vvp_io_commit_write will do sync write
16770 $LCTL set_param fail_loc=0x411
16771 # write a full page at the end of file
16772 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
16774 $LCTL set_param fail_loc=0
16775 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
16776 $LCTL set_param fail_loc=0x411
16777 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
16780 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
16781 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
16783 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
16785 test_220() { #LU-325
16786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16787 remote_ost_nodsh && skip "remote OST with nodsh"
16788 remote_mds_nodsh && skip "remote MDS with nodsh"
16789 remote_mgs_nodsh && skip "remote MGS with nodsh"
16793 # create on MDT0000 so the last_id and next_id are correct
16795 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
16799 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
16800 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
16801 osp.$mdtosc_proc1.prealloc_last_id)
16802 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
16803 osp.$mdtosc_proc1.prealloc_next_id)
16807 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
16808 #define OBD_FAIL_OST_ENOINO 0x229
16809 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
16810 create_pool $FSNAME.$TESTNAME || return 1
16811 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
16813 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
16815 MDSOBJS=$((last_id - next_id))
16816 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
16818 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
16819 echo "OST still has $count kbytes free"
16821 echo "create $MDSOBJS files @next_id..."
16822 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
16824 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
16825 osp.$mdtosc_proc1.prealloc_last_id)
16826 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
16827 osp.$mdtosc_proc1.prealloc_next_id)
16829 echo "after creation, last_id=$last_id2, next_id=$next_id2"
16834 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
16835 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
16837 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
16838 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
16839 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
16840 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
16841 echo "unlink $MDSOBJS files @$next_id..."
16842 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
16844 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
16847 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16849 dd if=`which date` of=$MOUNT/date oflag=sync
16850 chmod +x $MOUNT/date
16852 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
16853 $LCTL set_param fail_loc=0x80001401
16855 $MOUNT/date > /dev/null
16858 run_test 221 "make sure fault and truncate race to not cause OOM"
16861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16864 test_mkdir $DIR/$tdir
16865 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16866 createmany -o $DIR/$tdir/$tfile 10
16867 cancel_lru_locks mdc
16868 cancel_lru_locks osc
16869 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
16870 $LCTL set_param fail_loc=0x31a
16871 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
16872 $LCTL set_param fail_loc=0
16875 run_test 222a "AGL for ls should not trigger CLIO lock failure"
16878 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16881 test_mkdir $DIR/$tdir
16882 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16883 createmany -o $DIR/$tdir/$tfile 10
16884 cancel_lru_locks mdc
16885 cancel_lru_locks osc
16886 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
16887 $LCTL set_param fail_loc=0x31a
16888 rm -r $DIR/$tdir || error "AGL for rmdir failed"
16889 $LCTL set_param fail_loc=0
16891 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
16894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16897 test_mkdir $DIR/$tdir
16898 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16899 createmany -o $DIR/$tdir/$tfile 10
16900 cancel_lru_locks mdc
16901 cancel_lru_locks osc
16902 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
16903 $LCTL set_param fail_loc=0x31b
16904 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
16905 $LCTL set_param fail_loc=0
16908 run_test 223 "osc reenqueue if without AGL lock granted ======================="
16910 test_224a() { # LU-1039, MRP-303
16911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16913 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
16914 $LCTL set_param fail_loc=0x508
16915 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
16916 $LCTL set_param fail_loc=0
16919 run_test 224a "Don't panic on bulk IO failure"
16921 test_224b() { # LU-1039, MRP-303
16922 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16924 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
16925 cancel_lru_locks osc
16926 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
16927 $LCTL set_param fail_loc=0x515
16928 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
16929 $LCTL set_param fail_loc=0
16932 run_test 224b "Don't panic on bulk IO failure"
16934 test_224c() { # LU-6441
16935 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16936 remote_mds_nodsh && skip "remote MDS with nodsh"
16938 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16939 save_writethrough $p
16940 set_cache writethrough on
16942 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
16943 local at_max=$($LCTL get_param -n at_max)
16944 local timeout=$($LCTL get_param -n timeout)
16945 local test_at="at_max"
16946 local param_at="$FSNAME.sys.at_max"
16947 local test_timeout="timeout"
16948 local param_timeout="$FSNAME.sys.timeout"
16950 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
16952 set_persistent_param_and_check client "$test_at" "$param_at" 0
16953 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
16955 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
16956 do_facet ost1 "$LCTL set_param fail_loc=0x520"
16957 $LFS setstripe -c 1 -i 0 $DIR/$tfile
16958 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
16960 do_facet ost1 "$LCTL set_param fail_loc=0"
16962 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
16963 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
16966 $LCTL set_param -n $pages_per_rpc
16967 restore_lustre_params < $p
16970 run_test 224c "Don't hang if one of md lost during large bulk RPC"
16972 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
16974 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16975 if [ -z ${MDSSURVEY} ]; then
16976 skip_env "mds-survey not found"
16978 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16979 skip "Need MDS version at least 2.2.51"
16981 local mds=$(facet_host $SINGLEMDS)
16982 local target=$(do_nodes $mds 'lctl dl' |
16983 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
16985 local cmd1="file_count=1000 thrhi=4"
16986 local cmd2="dir_count=2 layer=mdd stripe_count=0"
16987 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16988 local cmd="$cmd1 $cmd2 $cmd3"
16990 rm -f ${TMP}/mds_survey*
16992 eval $cmd || error "mds-survey with zero-stripe failed"
16993 cat ${TMP}/mds_survey*
16994 rm -f ${TMP}/mds_survey*
16996 run_test 225a "Metadata survey sanity with zero-stripe"
16999 if [ -z ${MDSSURVEY} ]; then
17000 skip_env "mds-survey not found"
17002 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
17003 skip "Need MDS version at least 2.2.51"
17004 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17005 remote_mds_nodsh && skip "remote MDS with nodsh"
17006 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
17007 skip_env "Need to mount OST to test"
17010 local mds=$(facet_host $SINGLEMDS)
17011 local target=$(do_nodes $mds 'lctl dl' |
17012 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
17014 local cmd1="file_count=1000 thrhi=4"
17015 local cmd2="dir_count=2 layer=mdd stripe_count=1"
17016 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
17017 local cmd="$cmd1 $cmd2 $cmd3"
17019 rm -f ${TMP}/mds_survey*
17021 eval $cmd || error "mds-survey with stripe_count failed"
17022 cat ${TMP}/mds_survey*
17023 rm -f ${TMP}/mds_survey*
17025 run_test 225b "Metadata survey sanity with stripe_count = 1"
17027 mcreate_path2fid () {
17033 local path=$DIR/$tdir/$name
17038 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
17039 error "cannot create $desc"
17041 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
17043 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
17045 fid_path=$($LFS fid2path $MOUNT $fid)
17047 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
17049 [ "$path" == "$fid_path" ] ||
17050 error "fid2path returned $fid_path, expected $path"
17052 echo "pass with $path and $fid"
17057 mkdir -p $DIR/$tdir
17059 mcreate_path2fid 0010666 0 0 fifo "FIFO"
17060 mcreate_path2fid 0020666 1 3 null "character special file (null)"
17061 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
17062 mcreate_path2fid 0040666 0 0 dir "directory"
17063 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
17064 mcreate_path2fid 0100666 0 0 file "regular file"
17065 mcreate_path2fid 0120666 0 0 link "symbolic link"
17066 mcreate_path2fid 0140666 0 0 sock "socket"
17068 run_test 226a "call path2fid and fid2path on files of all type"
17071 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17076 mkdir -p $DIR/$tdir
17077 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
17078 error "create remote directory failed"
17079 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
17080 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
17081 "character special file (null)"
17082 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
17083 "character special file (no device)"
17084 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
17085 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
17086 "block special file (loop)"
17087 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
17088 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
17089 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
17091 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
17093 # LU-1299 Executing or running ldd on a truncated executable does not
17094 # cause an out-of-memory condition.
17096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17097 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
17099 dd if=$(which date) of=$MOUNT/date bs=1k count=1
17100 chmod +x $MOUNT/date
17102 $MOUNT/date > /dev/null
17103 ldd $MOUNT/date > /dev/null
17106 run_test 227 "running truncated executable does not cause OOM"
17108 # LU-1512 try to reuse idle OI blocks
17110 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17111 remote_mds_nodsh && skip "remote MDS with nodsh"
17112 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
17114 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
17115 local myDIR=$DIR/$tdir
17118 #define OBD_FAIL_SEQ_EXHAUST 0x1002
17119 $LCTL set_param fail_loc=0x80001002
17120 createmany -o $myDIR/t- 10000
17121 $LCTL set_param fail_loc=0
17122 # The guard is current the largest FID holder
17124 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
17126 local IDX=$(($SEQ % 64))
17128 do_facet $SINGLEMDS sync
17129 # Make sure journal flushed.
17131 local blk1=$(do_facet $SINGLEMDS \
17132 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17133 grep Blockcount | awk '{print $4}')
17135 # Remove old files, some OI blocks will become idle.
17136 unlinkmany $myDIR/t- 10000
17137 # Create new files, idle OI blocks should be reused.
17138 createmany -o $myDIR/t- 2000
17139 do_facet $SINGLEMDS sync
17140 # Make sure journal flushed.
17142 local blk2=$(do_facet $SINGLEMDS \
17143 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17144 grep Blockcount | awk '{print $4}')
17146 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
17148 run_test 228a "try to reuse idle OI blocks"
17151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17152 remote_mds_nodsh && skip "remote MDS with nodsh"
17153 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
17155 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
17156 local myDIR=$DIR/$tdir
17159 #define OBD_FAIL_SEQ_EXHAUST 0x1002
17160 $LCTL set_param fail_loc=0x80001002
17161 createmany -o $myDIR/t- 10000
17162 $LCTL set_param fail_loc=0
17163 # The guard is current the largest FID holder
17165 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
17167 local IDX=$(($SEQ % 64))
17169 do_facet $SINGLEMDS sync
17170 # Make sure journal flushed.
17172 local blk1=$(do_facet $SINGLEMDS \
17173 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17174 grep Blockcount | awk '{print $4}')
17176 # Remove old files, some OI blocks will become idle.
17177 unlinkmany $myDIR/t- 10000
17180 stop $SINGLEMDS || error "Fail to stop MDT."
17182 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
17184 df $MOUNT || error "Fail to df."
17185 # Create new files, idle OI blocks should be reused.
17186 createmany -o $myDIR/t- 2000
17187 do_facet $SINGLEMDS sync
17188 # Make sure journal flushed.
17190 local blk2=$(do_facet $SINGLEMDS \
17191 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17192 grep Blockcount | awk '{print $4}')
17194 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
17196 run_test 228b "idle OI blocks can be reused after MDT restart"
17200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17201 remote_mds_nodsh && skip "remote MDS with nodsh"
17202 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
17204 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
17205 local myDIR=$DIR/$tdir
17208 #define OBD_FAIL_SEQ_EXHAUST 0x1002
17209 $LCTL set_param fail_loc=0x80001002
17210 # 20000 files can guarantee there are index nodes in the OI file
17211 createmany -o $myDIR/t- 20000
17212 $LCTL set_param fail_loc=0
17213 # The guard is current the largest FID holder
17215 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
17217 local IDX=$(($SEQ % 64))
17219 do_facet $SINGLEMDS sync
17220 # Make sure journal flushed.
17222 local blk1=$(do_facet $SINGLEMDS \
17223 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17224 grep Blockcount | awk '{print $4}')
17226 # Remove old files, some OI blocks will become idle.
17227 unlinkmany $myDIR/t- 20000
17229 # The OI file should become empty now
17231 # Create new files, idle OI blocks should be reused.
17232 createmany -o $myDIR/t- 2000
17233 do_facet $SINGLEMDS sync
17234 # Make sure journal flushed.
17236 local blk2=$(do_facet $SINGLEMDS \
17237 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17238 grep Blockcount | awk '{print $4}')
17240 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
17242 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
17244 test_229() { # LU-2482, LU-3448
17245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17246 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
17247 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
17248 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
17252 # Create a file with a released layout and stripe count 2.
17253 $MULTIOP $DIR/$tfile H2c ||
17254 error "failed to create file with released layout"
17256 $LFS getstripe -v $DIR/$tfile
17258 local pattern=$($LFS getstripe -L $DIR/$tfile)
17259 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
17261 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
17263 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
17264 stat $DIR/$tfile || error "failed to stat released file"
17266 chown $RUNAS_ID $DIR/$tfile ||
17267 error "chown $RUNAS_ID $DIR/$tfile failed"
17269 chgrp $RUNAS_ID $DIR/$tfile ||
17270 error "chgrp $RUNAS_ID $DIR/$tfile failed"
17272 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
17273 rm $DIR/$tfile || error "failed to remove released file"
17275 run_test 229 "getstripe/stat/rm/attr changes work on released files"
17278 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17279 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17280 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17281 skip "Need MDS version at least 2.11.52"
17285 test_mkdir $DIR/$tdir
17286 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
17287 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
17288 [ $mdt_idx -ne 0 ] &&
17289 error "create local directory on wrong MDT $mdt_idx"
17291 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
17292 error "create remote directory failed"
17293 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
17294 [ $mdt_idx -ne $MDTIDX ] &&
17295 error "create remote directory on wrong MDT $mdt_idx"
17297 createmany -o $DIR/$tdir/test_230/t- 10 ||
17298 error "create files on remote directory failed"
17299 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
17300 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
17301 rm -r $DIR/$tdir || error "unlink remote directory failed"
17303 run_test 230a "Create remote directory and files under the remote directory"
17306 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17307 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17308 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17309 skip "Need MDS version at least 2.11.52"
17317 local migrate_dir=$DIR/$tdir/migrate_dir
17318 local other_dir=$DIR/$tdir/other_dir
17320 test_mkdir $DIR/$tdir
17321 test_mkdir -i0 -c1 $migrate_dir
17322 test_mkdir -i0 -c1 $other_dir
17323 for ((i=0; i<10; i++)); do
17324 mkdir -p $migrate_dir/dir_${i}
17325 createmany -o $migrate_dir/dir_${i}/f 10 ||
17326 error "create files under remote dir failed $i"
17329 cp /etc/passwd $migrate_dir/$tfile
17330 cp /etc/passwd $other_dir/$tfile
17331 chattr +SAD $migrate_dir
17332 chattr +SAD $migrate_dir/$tfile
17334 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
17335 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
17336 local old_dir_mode=$(stat -c%f $migrate_dir)
17337 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
17339 mkdir -p $migrate_dir/dir_default_stripe2
17340 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
17341 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
17343 mkdir -p $other_dir
17344 ln $migrate_dir/$tfile $other_dir/luna
17345 ln $migrate_dir/$tfile $migrate_dir/sofia
17346 ln $other_dir/$tfile $migrate_dir/david
17347 ln -s $migrate_dir/$tfile $other_dir/zachary
17348 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
17349 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
17355 for len in 58 59 60; do
17356 lnktgt=$(str_repeat 'l' $len)
17357 touch $migrate_dir/$lnktgt
17358 ln -s $lnktgt $migrate_dir/${len}char_ln
17362 for len in 4094 4095; do
17363 lnktgt=$(str_repeat 'l' $len)
17364 ln -s $lnktgt $migrate_dir/${len}char_ln
17368 for len in 254 255; do
17369 touch $migrate_dir/$(str_repeat 'l' $len)
17372 $LFS migrate -m $MDTIDX $migrate_dir ||
17373 error "fails on migrating remote dir to MDT1"
17375 echo "migratate to MDT1, then checking.."
17376 for ((i = 0; i < 10; i++)); do
17377 for file in $(find $migrate_dir/dir_${i}); do
17378 mdt_index=$($LFS getstripe -m $file)
17379 # broken symlink getstripe will fail
17380 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
17381 error "$file is not on MDT${MDTIDX}"
17385 # the multiple link file should still in MDT0
17386 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
17387 [ $mdt_index == 0 ] ||
17388 error "$file is not on MDT${MDTIDX}"
17390 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
17391 [ "$old_dir_flag" = "$new_dir_flag" ] ||
17392 error " expect $old_dir_flag get $new_dir_flag"
17394 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
17395 [ "$old_file_flag" = "$new_file_flag" ] ||
17396 error " expect $old_file_flag get $new_file_flag"
17398 local new_dir_mode=$(stat -c%f $migrate_dir)
17399 [ "$old_dir_mode" = "$new_dir_mode" ] ||
17400 error "expect mode $old_dir_mode get $new_dir_mode"
17402 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
17403 [ "$old_file_mode" = "$new_file_mode" ] ||
17404 error "expect mode $old_file_mode get $new_file_mode"
17406 diff /etc/passwd $migrate_dir/$tfile ||
17407 error "$tfile different after migration"
17409 diff /etc/passwd $other_dir/luna ||
17410 error "luna different after migration"
17412 diff /etc/passwd $migrate_dir/sofia ||
17413 error "sofia different after migration"
17415 diff /etc/passwd $migrate_dir/david ||
17416 error "david different after migration"
17418 diff /etc/passwd $other_dir/zachary ||
17419 error "zachary different after migration"
17421 diff /etc/passwd $migrate_dir/${tfile}_ln ||
17422 error "${tfile}_ln different after migration"
17424 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
17425 error "${tfile}_ln_other different after migration"
17427 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
17428 [ $stripe_count = 2 ] ||
17429 error "dir strpe_count $d != 2 after migration."
17431 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
17432 [ $stripe_count = 2 ] ||
17433 error "file strpe_count $d != 2 after migration."
17435 #migrate back to MDT0
17438 $LFS migrate -m $MDTIDX $migrate_dir ||
17439 error "fails on migrating remote dir to MDT0"
17441 echo "migrate back to MDT0, checking.."
17442 for file in $(find $migrate_dir); do
17443 mdt_index=$($LFS getstripe -m $file)
17444 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
17445 error "$file is not on MDT${MDTIDX}"
17448 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
17449 [ "$old_dir_flag" = "$new_dir_flag" ] ||
17450 error " expect $old_dir_flag get $new_dir_flag"
17452 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
17453 [ "$old_file_flag" = "$new_file_flag" ] ||
17454 error " expect $old_file_flag get $new_file_flag"
17456 local new_dir_mode=$(stat -c%f $migrate_dir)
17457 [ "$old_dir_mode" = "$new_dir_mode" ] ||
17458 error "expect mode $old_dir_mode get $new_dir_mode"
17460 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
17461 [ "$old_file_mode" = "$new_file_mode" ] ||
17462 error "expect mode $old_file_mode get $new_file_mode"
17464 diff /etc/passwd ${migrate_dir}/$tfile ||
17465 error "$tfile different after migration"
17467 diff /etc/passwd ${other_dir}/luna ||
17468 error "luna different after migration"
17470 diff /etc/passwd ${migrate_dir}/sofia ||
17471 error "sofia different after migration"
17473 diff /etc/passwd ${other_dir}/zachary ||
17474 error "zachary different after migration"
17476 diff /etc/passwd $migrate_dir/${tfile}_ln ||
17477 error "${tfile}_ln different after migration"
17479 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
17480 error "${tfile}_ln_other different after migration"
17482 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
17483 [ $stripe_count = 2 ] ||
17484 error "dir strpe_count $d != 2 after migration."
17486 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
17487 [ $stripe_count = 2 ] ||
17488 error "file strpe_count $d != 2 after migration."
17490 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17492 run_test 230b "migrate directory"
17495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17496 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17497 remote_mds_nodsh && skip "remote MDS with nodsh"
17498 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17499 skip "Need MDS version at least 2.11.52"
17505 local migrate_dir=$DIR/$tdir/migrate_dir
17507 #If migrating directory fails in the middle, all entries of
17508 #the directory is still accessiable.
17509 test_mkdir $DIR/$tdir
17510 test_mkdir -i0 -c1 $migrate_dir
17511 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
17513 createmany -o $migrate_dir/f $total ||
17514 error "create files under ${migrate_dir} failed"
17516 # fail after migrating top dir, and this will fail only once, so the
17517 # first sub file migration will fail (currently f3), others succeed.
17518 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
17519 do_facet mds1 lctl set_param fail_loc=0x1801
17520 local t=$(ls $migrate_dir | wc -l)
17521 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
17522 error "migrate should fail"
17523 local u=$(ls $migrate_dir | wc -l)
17524 [ "$u" == "$t" ] || error "$u != $t during migration"
17526 # add new dir/file should succeed
17527 mkdir $migrate_dir/dir ||
17528 error "mkdir failed under migrating directory"
17529 touch $migrate_dir/file ||
17530 error "create file failed under migrating directory"
17532 # add file with existing name should fail
17533 for file in $migrate_dir/f*; do
17534 stat $file > /dev/null || error "stat $file failed"
17535 $OPENFILE -f O_CREAT:O_EXCL $file &&
17536 error "open(O_CREAT|O_EXCL) $file should fail"
17537 $MULTIOP $file m && error "create $file should fail"
17538 touch $DIR/$tdir/remote_dir/$tfile ||
17539 error "touch $tfile failed"
17540 ln $DIR/$tdir/remote_dir/$tfile $file &&
17541 error "link $file should fail"
17542 mdt_index=$($LFS getstripe -m $file)
17543 if [ $mdt_index == 0 ]; then
17544 # file failed to migrate is not allowed to rename to
17545 mv $DIR/$tdir/remote_dir/$tfile $file &&
17546 error "rename to $file should fail"
17548 mv $DIR/$tdir/remote_dir/$tfile $file ||
17549 error "rename to $file failed"
17551 echo hello >> $file || error "write $file failed"
17554 # resume migration with different options should fail
17555 $LFS migrate -m 0 $migrate_dir &&
17556 error "migrate -m 0 $migrate_dir should fail"
17558 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
17559 error "migrate -c 2 $migrate_dir should fail"
17561 # resume migration should succeed
17562 $LFS migrate -m $MDTIDX $migrate_dir ||
17563 error "migrate $migrate_dir failed"
17565 echo "Finish migration, then checking.."
17566 for file in $(find $migrate_dir); do
17567 mdt_index=$($LFS getstripe -m $file)
17568 [ $mdt_index == $MDTIDX ] ||
17569 error "$file is not on MDT${MDTIDX}"
17572 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17574 run_test 230c "check directory accessiblity if migration failed"
17577 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17578 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17579 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17580 skip "Need MDS version at least 2.11.52"
17582 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
17584 local migrate_dir=$DIR/$tdir/migrate_dir
17594 old_index=$((RANDOM % MDSCOUNT))
17595 old_count=$((MDSCOUNT - old_index))
17596 new_index=$((RANDOM % MDSCOUNT))
17597 new_count=$((MDSCOUNT - new_index))
17598 new_hash=1 # for all_char
17600 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
17601 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
17603 test_mkdir $DIR/$tdir
17604 test_mkdir -i $old_index -c $old_count $migrate_dir
17606 for ((i=0; i<100; i++)); do
17607 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
17608 createmany -o $migrate_dir/dir_${i}/f 100 ||
17609 error "create files under remote dir failed $i"
17612 echo -n "Migrate from MDT$old_index "
17613 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
17614 echo -n "to MDT$new_index"
17615 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
17618 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
17619 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
17620 error "migrate remote dir error"
17622 echo "Finish migration, then checking.."
17623 for file in $(find $migrate_dir); do
17624 mdt_index=$($LFS getstripe -m $file)
17625 if [ $mdt_index -lt $new_index ] ||
17626 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
17627 error "$file is on MDT$mdt_index"
17631 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17633 run_test 230d "check migrate big directory"
17636 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17637 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17638 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17639 skip "Need MDS version at least 2.11.52"
17646 mkdir -p $DIR/$tdir
17647 mkdir $DIR/$tdir/migrate_dir
17648 mkdir $DIR/$tdir/other_dir
17649 touch $DIR/$tdir/migrate_dir/a
17650 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
17651 ls $DIR/$tdir/other_dir
17653 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17654 error "migrate dir fails"
17656 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
17657 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
17659 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17660 [ $mdt_index == 0 ] || error "a is not on MDT0"
17662 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
17663 error "migrate dir fails"
17665 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
17666 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
17668 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17669 [ $mdt_index == 1 ] || error "a is not on MDT1"
17671 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
17672 [ $mdt_index == 1 ] || error "b is not on MDT1"
17674 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
17675 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
17677 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
17679 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17681 run_test 230e "migrate mulitple local link files"
17684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17685 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17686 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17687 skip "Need MDS version at least 2.11.52"
17692 mkdir -p $DIR/$tdir
17693 mkdir $DIR/$tdir/migrate_dir
17694 $LFS mkdir -i1 $DIR/$tdir/other_dir
17695 touch $DIR/$tdir/migrate_dir/a
17696 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
17697 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
17698 ls $DIR/$tdir/other_dir
17700 # a should be migrated to MDT1, since no other links on MDT0
17701 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17702 error "#1 migrate dir fails"
17703 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
17704 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
17705 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17706 [ $mdt_index == 1 ] || error "a is not on MDT1"
17708 # a should stay on MDT1, because it is a mulitple link file
17709 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
17710 error "#2 migrate dir fails"
17711 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17712 [ $mdt_index == 1 ] || error "a is not on MDT1"
17714 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17715 error "#3 migrate dir fails"
17717 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
17718 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
17719 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
17721 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
17722 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
17724 # a should be migrated to MDT0, since no other links on MDT1
17725 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
17726 error "#4 migrate dir fails"
17727 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17728 [ $mdt_index == 0 ] || error "a is not on MDT0"
17730 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17732 run_test 230f "migrate mulitple remote link files"
17735 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17736 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17737 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17738 skip "Need MDS version at least 2.11.52"
17740 mkdir -p $DIR/$tdir/migrate_dir
17742 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
17743 error "migrating dir to non-exist MDT succeeds"
17746 run_test 230g "migrate dir to non-exist MDT"
17749 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17750 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17751 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17752 skip "Need MDS version at least 2.11.52"
17756 mkdir -p $DIR/$tdir/migrate_dir
17758 $LFS migrate -m1 $DIR &&
17759 error "migrating mountpoint1 should fail"
17761 $LFS migrate -m1 $DIR/$tdir/.. &&
17762 error "migrating mountpoint2 should fail"
17765 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
17766 error "migrating $tdir/migrate_dir/.. should fail"
17770 run_test 230h "migrate .. and root"
17773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17774 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17775 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17776 skip "Need MDS version at least 2.11.52"
17778 mkdir -p $DIR/$tdir/migrate_dir
17780 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
17781 error "migration fails with a tailing slash"
17783 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
17784 error "migration fails with two tailing slashes"
17786 run_test 230i "lfs migrate -m tolerates trailing slashes"
17789 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17790 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17791 skip "Need MDS version at least 2.11.52"
17793 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
17794 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
17795 error "create $tfile failed"
17796 cat /etc/passwd > $DIR/$tdir/$tfile
17798 $LFS migrate -m 1 $DIR/$tdir
17800 cmp /etc/passwd $DIR/$tdir/$tfile ||
17801 error "DoM file mismatch after migration"
17803 run_test 230j "DoM file data not changed after dir migration"
17806 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
17807 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17808 skip "Need MDS version at least 2.11.56"
17811 local files_on_starting_mdt=0
17813 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
17814 $LFS getdirstripe $DIR/$tdir
17815 for i in $(seq $total); do
17816 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
17817 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
17818 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17821 echo "$files_on_starting_mdt files on MDT0"
17823 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
17824 $LFS getdirstripe $DIR/$tdir
17826 files_on_starting_mdt=0
17827 for i in $(seq $total); do
17828 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
17829 error "file $tfile.$i mismatch after migration"
17830 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
17831 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17834 echo "$files_on_starting_mdt files on MDT1 after migration"
17835 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
17837 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
17838 $LFS getdirstripe $DIR/$tdir
17840 files_on_starting_mdt=0
17841 for i in $(seq $total); do
17842 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
17843 error "file $tfile.$i mismatch after 2nd migration"
17844 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
17845 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17848 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
17849 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
17853 run_test 230k "file data not changed after dir migration"
17856 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17857 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17858 skip "Need MDS version at least 2.11.56"
17860 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
17861 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
17862 error "create files under remote dir failed $i"
17863 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
17865 run_test 230l "readdir between MDTs won't crash"
17868 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17869 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17870 skip "Need MDS version at least 2.11.56"
17873 local mig_dir=$DIR/$tdir/migrate_dir
17874 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
17878 echo "Creating files and dirs with xattrs"
17879 test_mkdir $DIR/$tdir
17880 test_mkdir -i0 -c1 $mig_dir
17882 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
17883 error "cannot set xattr attr1 on dir"
17884 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
17885 error "cannot set xattr attr2 on dir"
17886 touch $mig_dir/dir/f0
17887 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
17888 error "cannot set xattr attr1 on file"
17889 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
17890 error "cannot set xattr attr2 on file"
17891 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
17892 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
17893 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
17894 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
17895 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
17896 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
17897 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
17898 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
17899 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
17901 echo "Migrating to MDT1"
17902 $LFS migrate -m $MDTIDX $mig_dir ||
17903 error "fails on migrating dir to MDT1"
17905 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
17906 echo "Checking xattrs"
17907 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
17908 [ "$val" = $longstr ] ||
17909 error "expecting xattr1 $longstr on dir, found $val"
17910 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
17911 [ "$val" = $shortstr ] ||
17912 error "expecting xattr2 $shortstr on dir, found $val"
17913 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
17914 [ "$val" = $longstr ] ||
17915 error "expecting xattr1 $longstr on file, found $val"
17916 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
17917 [ "$val" = $shortstr ] ||
17918 error "expecting xattr2 $shortstr on file, found $val"
17920 run_test 230m "xattrs not changed after dir migration"
17923 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17924 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
17925 skip "Need MDS version at least 2.13.53"
17927 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
17928 cat /etc/hosts > $DIR/$tdir/$tfile
17929 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
17930 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
17932 cmp /etc/hosts $DIR/$tdir/$tfile ||
17933 error "File data mismatch after migration"
17935 run_test 230n "Dir migration with mirrored file"
17939 # For simplicity this test assumes that max_pages_per_rpc
17940 # is the same across all OSCs
17941 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
17942 local bulk_size=$((max_pages * PAGE_SIZE))
17943 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
17946 mkdir -p $DIR/$tdir
17947 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
17948 error "failed to set stripe with -S ${brw_size}M option"
17950 # clear the OSC stats
17951 $LCTL set_param osc.*.stats=0 &>/dev/null
17954 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
17955 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
17956 oflag=direct &>/dev/null || error "dd failed"
17958 sync; sleep 1; sync # just to be safe
17959 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
17960 if [ x$nrpcs != "x1" ]; then
17961 $LCTL get_param osc.*.stats
17962 error "found $nrpcs ost_write RPCs, not 1 as expected"
17966 # Drop the OSC cache, otherwise we will read from it
17967 cancel_lru_locks osc
17969 # clear the OSC stats
17970 $LCTL set_param osc.*.stats=0 &>/dev/null
17972 # Client reads $bulk_size.
17973 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
17974 iflag=direct &>/dev/null || error "dd failed"
17976 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
17977 if [ x$nrpcs != "x1" ]; then
17978 $LCTL get_param osc.*.stats
17979 error "found $nrpcs ost_read RPCs, not 1 as expected"
17982 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
17985 mkdir -p $DIR/$tdir
17987 for i in {0..1023}; do
17988 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
17989 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
17990 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
17994 run_test 231b "must not assert on fully utilized OST request buffer"
17997 mkdir -p $DIR/$tdir
17998 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
18000 #define OBD_FAIL_LDLM_OST_LVB 0x31c
18001 do_facet ost1 $LCTL set_param fail_loc=0x31c
18003 # ignore dd failure
18004 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
18006 do_facet ost1 $LCTL set_param fail_loc=0
18007 umount_client $MOUNT || error "umount failed"
18008 mount_client $MOUNT || error "mount failed"
18009 stop ost1 || error "cannot stop ost1"
18010 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18012 run_test 232a "failed lock should not block umount"
18015 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
18016 skip "Need MDS version at least 2.10.58"
18018 mkdir -p $DIR/$tdir
18019 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
18020 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
18022 cancel_lru_locks osc
18024 #define OBD_FAIL_LDLM_OST_LVB 0x31c
18025 do_facet ost1 $LCTL set_param fail_loc=0x31c
18028 $LFS data_version $DIR/$tdir/$tfile || true
18030 do_facet ost1 $LCTL set_param fail_loc=0
18031 umount_client $MOUNT || error "umount failed"
18032 mount_client $MOUNT || error "mount failed"
18033 stop ost1 || error "cannot stop ost1"
18034 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18036 run_test 232b "failed data version lock should not block umount"
18039 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
18040 skip "Need MDS version at least 2.3.64"
18041 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
18043 local fid=$($LFS path2fid $MOUNT)
18045 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
18046 error "cannot access $MOUNT using its FID '$fid'"
18048 run_test 233a "checking that OBF of the FS root succeeds"
18051 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
18052 skip "Need MDS version at least 2.5.90"
18053 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
18055 local fid=$($LFS path2fid $MOUNT/.lustre)
18057 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
18058 error "cannot access $MOUNT/.lustre using its FID '$fid'"
18060 fid=$($LFS path2fid $MOUNT/.lustre/fid)
18061 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
18062 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
18064 run_test 233b "checking that OBF of the FS .lustre succeeds"
18067 local p="$TMP/sanityN-$TESTNAME.parameters"
18068 save_lustre_params client "llite.*.xattr_cache" > $p
18069 lctl set_param llite.*.xattr_cache 1 ||
18070 skip_env "xattr cache is not supported"
18072 mkdir -p $DIR/$tdir || error "mkdir failed"
18073 touch $DIR/$tdir/$tfile || error "touch failed"
18074 # OBD_FAIL_LLITE_XATTR_ENOMEM
18075 $LCTL set_param fail_loc=0x1405
18076 getfattr -n user.attr $DIR/$tdir/$tfile &&
18077 error "getfattr should have failed with ENOMEM"
18078 $LCTL set_param fail_loc=0x0
18081 restore_lustre_params < $p
18084 run_test 234 "xattr cache should not crash on ENOMEM"
18087 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
18088 skip "Need MDS version at least 2.4.52"
18090 flock_deadlock $DIR/$tfile
18095 124) error "process hangs on a deadlock"
18097 *) error "error executing flock_deadlock $DIR/$tfile"
18101 run_test 235 "LU-1715: flock deadlock detection does not work properly"
18105 check_swap_layouts_support
18107 local ref1=/etc/passwd
18108 local ref2=/etc/group
18109 local file1=$DIR/$tdir/f1
18110 local file2=$DIR/$tdir/f2
18112 test_mkdir -c1 $DIR/$tdir
18113 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
18114 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
18115 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
18116 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
18117 local fd=$(free_fd)
18118 local cmd="exec $fd<>$file2"
18121 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
18122 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
18125 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
18130 run_test 236 "Layout swap on open unlinked file"
18132 # LU-4659 linkea consistency
18134 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
18135 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
18136 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
18137 skip "Need MDS version at least 2.5.58 or 2.5.2+"
18140 ln $DIR/$tfile $DIR/$tfile.lnk
18141 touch $DIR/$tfile.new
18142 mv $DIR/$tfile.new $DIR/$tfile
18143 local fid1=$($LFS path2fid $DIR/$tfile)
18144 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
18145 local path1=$($LFS fid2path $FSNAME "$fid1")
18146 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
18147 local path2=$($LFS fid2path $FSNAME "$fid2")
18148 [ $tfile.lnk == $path2 ] ||
18149 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
18152 run_test 238 "Verify linkea consistency"
18154 test_239A() { # was test_239
18155 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
18156 skip "Need MDS version at least 2.5.60"
18158 local list=$(comma_list $(mdts_nodes))
18160 mkdir -p $DIR/$tdir
18161 createmany -o $DIR/$tdir/f- 5000
18162 unlinkmany $DIR/$tdir/f- 5000
18163 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
18164 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
18165 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
18166 osp.*MDT*.sync_in_flight" | calc_sum)
18167 [ "$changes" -eq 0 ] || error "$changes not synced"
18169 run_test 239A "osp_sync test"
18171 test_239a() { #LU-5297
18172 remote_mds_nodsh && skip "remote MDS with nodsh"
18175 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
18176 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
18177 chgrp $RUNAS_GID $DIR/$tfile
18178 wait_delete_completed
18180 run_test 239a "process invalid osp sync record correctly"
18182 test_239b() { #LU-5297
18183 remote_mds_nodsh && skip "remote MDS with nodsh"
18186 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
18187 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
18188 chgrp $RUNAS_GID $DIR/$tfile1
18189 wait_delete_completed
18190 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18192 chgrp $RUNAS_GID $DIR/$tfile2
18193 wait_delete_completed
18195 run_test 239b "process osp sync record with ENOMEM error correctly"
18198 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18199 remote_mds_nodsh && skip "remote MDS with nodsh"
18201 mkdir -p $DIR/$tdir
18203 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
18204 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
18205 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
18206 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
18208 umount_client $MOUNT || error "umount failed"
18209 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
18210 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
18211 mount_client $MOUNT || error "failed to mount client"
18213 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
18214 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
18216 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
18222 for LOOP in $(seq $count); do
18223 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
18224 cancel_lru_locks $OSC || true
18232 for LOOP in $(seq $1); do
18233 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
18238 test_241a() { # was test_241
18239 local bsize=$PAGE_SIZE
18241 (( bsize < 40960 )) && bsize=40960
18242 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
18244 cancel_lru_locks $OSC
18245 test_241_bio 1000 $bsize &
18247 test_241_dio 1000 $bsize
18250 run_test 241a "bio vs dio"
18253 local bsize=$PAGE_SIZE
18255 (( bsize < 40960 )) && bsize=40960
18256 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
18258 test_241_dio 1000 $bsize &
18260 test_241_dio 1000 $bsize
18263 run_test 241b "dio vs dio"
18266 remote_mds_nodsh && skip "remote MDS with nodsh"
18268 mkdir -p $DIR/$tdir
18269 touch $DIR/$tdir/$tfile
18271 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
18272 do_facet mds1 lctl set_param fail_loc=0x105
18273 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
18275 do_facet mds1 lctl set_param fail_loc=0
18276 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
18278 run_test 242 "mdt_readpage failure should not cause directory unreadable"
18282 test_mkdir $DIR/$tdir
18283 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
18285 run_test 243 "various group lock tests"
18289 test_mkdir $DIR/$tdir
18290 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
18291 sendfile_grouplock $DIR/$tdir/$tfile || \
18292 error "sendfile+grouplock failed"
18295 run_test 244a "sendfile with group lock tests"
18299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18302 local size=$((1024*1024))
18304 test_mkdir $DIR/$tdir
18305 for i in $(seq 1 $threads); do
18306 local file=$DIR/$tdir/file_$((i / 10))
18307 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
18310 for i in $(seq 1 $threads); do
18314 run_test 244b "multi-threaded write with group lock"
18317 local flagname="multi_mod_rpcs"
18318 local connect_data_name="max_mod_rpcs"
18321 # check if multiple modify RPCs flag is set
18322 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
18323 grep "connect_flags:")
18326 echo "$out" | grep -qw $flagname
18327 if [ $? -ne 0 ]; then
18328 echo "connect flag $flagname is not set"
18332 # check if multiple modify RPCs data is set
18333 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
18336 echo "$out" | grep -qw $connect_data_name ||
18337 error "import should have connect data $connect_data_name"
18339 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
18345 umount_client $submount
18350 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
18352 skip_env "Fileset feature is not supported"
18354 local submount=${MOUNT}_$tdir
18357 mkdir -p $submount || error "mkdir $submount failed"
18358 FILESET="$FILESET/$tdir" mount_client $submount ||
18359 error "mount $submount failed"
18360 trap "cleanup_247 $submount" EXIT
18361 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
18362 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
18363 error "read $MOUNT/$tdir/$tfile failed"
18364 cleanup_247 $submount
18366 run_test 247a "mount subdir as fileset"
18369 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
18370 skip_env "Fileset feature is not supported"
18372 local submount=${MOUNT}_$tdir
18374 rm -rf $MOUNT/$tdir
18375 mkdir -p $submount || error "mkdir $submount failed"
18377 FILESET="$FILESET/$tdir" mount_client $submount &&
18378 error "mount $submount should fail"
18381 run_test 247b "mount subdir that dose not exist"
18384 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
18385 skip_env "Fileset feature is not supported"
18387 local submount=${MOUNT}_$tdir
18389 mkdir -p $MOUNT/$tdir/dir1
18390 mkdir -p $submount || error "mkdir $submount failed"
18391 trap "cleanup_247 $submount" EXIT
18392 FILESET="$FILESET/$tdir" mount_client $submount ||
18393 error "mount $submount failed"
18394 local fid=$($LFS path2fid $MOUNT/)
18395 $LFS fid2path $submount $fid && error "fid2path should fail"
18396 cleanup_247 $submount
18398 run_test 247c "running fid2path outside root"
18401 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
18402 skip "Fileset feature is not supported"
18404 local submount=${MOUNT}_$tdir
18406 mkdir -p $MOUNT/$tdir/dir1
18407 mkdir -p $submount || error "mkdir $submount failed"
18408 FILESET="$FILESET/$tdir" mount_client $submount ||
18409 error "mount $submount failed"
18410 trap "cleanup_247 $submount" EXIT
18411 local fid=$($LFS path2fid $submount/dir1)
18412 $LFS fid2path $submount $fid || error "fid2path should succeed"
18413 cleanup_247 $submount
18415 run_test 247d "running fid2path inside root"
18419 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
18421 skip "Fileset feature is not supported"
18423 local submount=${MOUNT}_$tdir
18426 mkdir -p $submount || error "mkdir $submount failed"
18427 FILESET="$FILESET/.." mount_client $submount &&
18428 error "mount $submount should fail"
18431 run_test 247e "mount .. as fileset"
18434 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18435 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
18436 skip "Need at least version 2.13.52"
18437 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
18439 skip "Fileset feature is not supported"
18441 mkdir $DIR/$tdir || error "mkdir $tdir failed"
18442 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
18443 error "mkdir remote failed"
18444 mkdir $DIR/$tdir/remote/subdir || error "mkdir remote/subdir failed"
18445 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/striped ||
18446 error "mkdir striped failed"
18447 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
18449 local submount=${MOUNT}_$tdir
18451 mkdir -p $submount || error "mkdir $submount failed"
18454 local fileset=$FILESET
18456 for dir in $tdir/remote $tdir/remote/subdir \
18457 $tdir/striped $tdir/striped/subdir $tdir/striped/. ; do
18458 FILESET="$fileset/$dir" mount_client $submount ||
18459 error "mount $dir failed"
18460 umount_client $submount
18463 run_test 247f "mount striped or remote directory as fileset"
18466 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
18467 [ -z "$fast_read_sav" ] && skip "no fast read support"
18469 # create a large file for fast read verification
18470 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
18472 # make sure the file is created correctly
18473 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
18474 { rm -f $DIR/$tfile; skip "file creation error"; }
18476 echo "Test 1: verify that fast read is 4 times faster on cache read"
18478 # small read with fast read enabled
18479 $LCTL set_param -n llite.*.fast_read=1
18480 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
18481 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18482 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18483 # small read with fast read disabled
18484 $LCTL set_param -n llite.*.fast_read=0
18485 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
18486 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18487 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18489 # verify that fast read is 4 times faster for cache read
18490 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
18491 error_not_in_vm "fast read was not 4 times faster: " \
18492 "$t_fast vs $t_slow"
18494 echo "Test 2: verify the performance between big and small read"
18495 $LCTL set_param -n llite.*.fast_read=1
18497 # 1k non-cache read
18498 cancel_lru_locks osc
18499 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
18500 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18501 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18503 # 1M non-cache read
18504 cancel_lru_locks osc
18505 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
18506 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18507 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18509 # verify that big IO is not 4 times faster than small IO
18510 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
18511 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
18513 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
18516 run_test 248a "fast read verification"
18519 # Default short_io_bytes=16384, try both smaller and larger sizes.
18520 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
18521 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
18522 echo "bs=53248 count=113 normal buffered write"
18523 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
18524 error "dd of initial data file failed"
18525 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
18527 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
18528 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
18529 error "dd with sync normal writes failed"
18530 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
18532 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
18533 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
18534 error "dd with sync small writes failed"
18535 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
18537 cancel_lru_locks osc
18539 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
18540 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
18541 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
18542 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
18543 iflag=direct || error "dd with O_DIRECT small read failed"
18544 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
18545 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
18546 error "compare $TMP/$tfile.1 failed"
18548 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
18549 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
18551 # just to see what the maximum tunable value is, and test parsing
18552 echo "test invalid parameter 2MB"
18553 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
18554 error "too-large short_io_bytes allowed"
18555 echo "test maximum parameter 512KB"
18556 # if we can set a larger short_io_bytes, run test regardless of version
18557 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
18558 # older clients may not allow setting it this large, that's OK
18559 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
18560 skip "Need at least client version 2.13.50"
18561 error "medium short_io_bytes failed"
18563 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
18564 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
18566 echo "test large parameter 64KB"
18567 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
18568 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
18570 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
18571 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
18572 error "dd with sync large writes failed"
18573 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
18575 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
18576 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
18577 num=$((113 * 4096 / PAGE_SIZE))
18578 echo "bs=$size count=$num oflag=direct large write $tfile.3"
18579 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
18580 error "dd with O_DIRECT large writes failed"
18581 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
18582 error "compare $DIR/$tfile.3 failed"
18584 cancel_lru_locks osc
18586 echo "bs=$size count=$num iflag=direct large read $tfile.2"
18587 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
18588 error "dd with O_DIRECT large read failed"
18589 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
18590 error "compare $TMP/$tfile.2 failed"
18592 echo "bs=$size count=$num iflag=direct large read $tfile.3"
18593 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
18594 error "dd with O_DIRECT large read failed"
18595 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
18596 error "compare $TMP/$tfile.3 failed"
18598 run_test 248b "test short_io read and write for both small and large sizes"
18600 test_249() { # LU-7890
18601 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
18602 skip "Need at least version 2.8.54"
18605 $LFS setstripe -c 1 $DIR/$tfile
18606 # Offset 2T == 4k * 512M
18607 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
18608 error "dd to 2T offset failed"
18610 run_test 249 "Write above 2T file size"
18613 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
18614 && skip "no 16TB file size limit on ZFS"
18616 $LFS setstripe -c 1 $DIR/$tfile
18617 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
18618 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
18619 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
18620 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
18621 conv=notrunc,fsync && error "append succeeded"
18624 run_test 250 "Write above 16T limit"
18627 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
18629 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
18630 #Skip once - writing the first stripe will succeed
18631 $LCTL set_param fail_loc=0xa0001407 fail_val=1
18632 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
18633 error "short write happened"
18635 $LCTL set_param fail_loc=0xa0001407 fail_val=1
18636 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
18637 error "short read happened"
18641 run_test 251 "Handling short read and write correctly"
18644 remote_mds_nodsh && skip "remote MDS with nodsh"
18645 remote_ost_nodsh && skip "remote OST with nodsh"
18646 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
18647 skip_env "ldiskfs only test"
18657 # check lr_reader on OST0000
18659 dev=$(facet_device $tgt)
18660 out=$(do_facet $tgt $LR_READER $dev)
18661 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18663 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
18664 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
18665 error "Invalid uuid returned by $LR_READER on target $tgt"
18666 echo -e "uuid returned by $LR_READER is '$uuid'\n"
18668 # check lr_reader -c on MDT0000
18670 dev=$(facet_device $tgt)
18671 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
18672 skip "$LR_READER does not support additional options"
18674 out=$(do_facet $tgt $LR_READER -c $dev)
18675 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18677 num=$(echo "$out" | grep -c "mdtlov")
18678 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
18679 error "Invalid number of mdtlov clients returned by $LR_READER"
18680 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
18682 # check lr_reader -cr on MDT0000
18683 out=$(do_facet $tgt $LR_READER -cr $dev)
18684 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18686 echo "$out" | grep -q "^reply_data:$" ||
18687 error "$LR_READER should have returned 'reply_data' section"
18688 num=$(echo "$out" | grep -c "client_generation")
18689 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
18691 run_test 252 "check lr_reader tool"
18694 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18695 remote_mds_nodsh && skip "remote MDS with nodsh"
18696 remote_mgs_nodsh && skip "remote MGS with nodsh"
18700 local ost_name=$(ostname_from_index $ostidx)
18703 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
18704 do_facet $SINGLEMDS $LCTL get_param -n \
18705 osp.$mdtosc_proc1.reserved_mb_high ||
18706 skip "remote MDS does not support reserved_mb_high"
18710 wait_delete_completed
18713 pool_add $TESTNAME || error "Pool creation failed"
18714 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
18716 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
18717 error "Setstripe failed"
18719 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
18721 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
18723 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
18725 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
18726 osp.$mdtosc_proc1.prealloc_status)
18727 echo "prealloc_status $oa_status"
18729 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
18730 error "File creation should fail"
18732 #object allocation was stopped, but we still able to append files
18733 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
18734 oflag=append || error "Append failed"
18736 rm -f $DIR/$tdir/$tfile.0
18738 # For this test, we want to delete the files we created to go out of
18739 # space but leave the watermark, so we remain nearly out of space
18740 ost_watermarks_enospc_delete_files $tfile $ostidx
18742 wait_delete_completed
18746 for i in $(seq 10 12); do
18747 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
18748 2>/dev/null || error "File creation failed after rm"
18751 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
18752 osp.$mdtosc_proc1.prealloc_status)
18753 echo "prealloc_status $oa_status"
18755 if (( oa_status != 0 )); then
18756 error "Object allocation still disable after rm"
18759 run_test 253 "Check object allocation limit"
18762 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18763 remote_mds_nodsh && skip "remote MDS with nodsh"
18764 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
18765 skip "MDS does not support changelog_size"
18768 local MDT0=$(facet_svc $SINGLEMDS)
18770 changelog_register || error "changelog_register failed"
18772 changelog_clear 0 || error "changelog_clear failed"
18774 local size1=$(do_facet $SINGLEMDS \
18775 $LCTL get_param -n mdd.$MDT0.changelog_size)
18776 echo "Changelog size $size1"
18779 $LFS mkdir -i 0 $DIR/$tdir
18781 mkdir -p $DIR/$tdir/pics/2008/zachy
18782 touch $DIR/$tdir/pics/2008/zachy/timestamp
18783 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
18784 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
18785 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
18786 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
18787 rm $DIR/$tdir/pics/desktop.jpg
18789 local size2=$(do_facet $SINGLEMDS \
18790 $LCTL get_param -n mdd.$MDT0.changelog_size)
18791 echo "Changelog size after work $size2"
18793 (( $size2 > $size1 )) ||
18794 error "new Changelog size=$size2 less than old size=$size1"
18796 run_test 254 "Check changelog size"
18803 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
18804 awk -F: '{print $2}' | grep $type > /dev/null
18805 if [ $? -ne 0 ]; then
18815 lfs ladvise -a willread $file > /dev/null 2>&1
18816 if [ $? -eq 0 ]; then
18820 lfs ladvise -a willread $file 2>&1 |
18821 grep "Inappropriate ioctl for device" > /dev/null
18822 if [ $? -eq 0 ]; then
18829 bc <<<"scale=2; ($1 - $2) * 100 / $2"
18832 # run a random read IO workload
18833 # usage: random_read_iops <filename> <filesize> <iosize>
18834 random_read_iops() {
18837 local iosize=${3:-4096}
18839 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
18840 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
18843 drop_file_oss_cache() {
18847 $LFS ladvise -a dontneed $file 2>/dev/null ||
18848 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
18851 ladvise_willread_performance()
18854 local average_origin=0
18855 local average_cache=0
18856 local average_ladvise=0
18858 for ((i = 1; i <= $repeat; i++)); do
18859 echo "Iter $i/$repeat: reading without willread hint"
18860 cancel_lru_locks osc
18861 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
18862 local speed_origin=$(random_read_iops $DIR/$tfile $size)
18863 echo "Iter $i/$repeat: uncached speed: $speed_origin"
18864 average_origin=$(bc <<<"$average_origin + $speed_origin")
18866 cancel_lru_locks osc
18867 local speed_cache=$(random_read_iops $DIR/$tfile $size)
18868 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
18869 average_cache=$(bc <<<"$average_cache + $speed_cache")
18871 cancel_lru_locks osc
18872 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
18873 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
18874 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
18875 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
18876 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
18878 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
18879 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
18880 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
18882 speedup_cache=$(percent $average_cache $average_origin)
18883 speedup_ladvise=$(percent $average_ladvise $average_origin)
18885 echo "Average uncached read: $average_origin"
18886 echo "Average speedup with OSS cached read: " \
18887 "$average_cache = +$speedup_cache%"
18888 echo "Average speedup with ladvise willread: " \
18889 "$average_ladvise = +$speedup_ladvise%"
18891 local lowest_speedup=20
18892 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
18893 echo "Speedup with OSS cached read less than $lowest_speedup%," \
18894 "got $average_cache%. Skipping ladvise willread check."
18898 # the test won't work on ZFS until it supports 'ladvise dontneed', but
18899 # it is still good to run until then to exercise 'ladvise willread'
18900 ! $LFS ladvise -a dontneed $DIR/$tfile &&
18901 [ "$ost1_FSTYPE" = "zfs" ] &&
18902 echo "osd-zfs does not support dontneed or drop_caches" &&
18905 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
18906 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
18907 error_not_in_vm "Speedup with willread is less than " \
18908 "$lowest_speedup%, got $average_ladvise%"
18912 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
18913 skip "lustre < 2.8.54 does not support ladvise "
18914 remote_ost_nodsh && skip "remote OST with nodsh"
18916 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
18918 ladvise_no_type willread $DIR/$tfile &&
18919 skip "willread ladvise is not supported"
18921 ladvise_no_ioctl $DIR/$tfile &&
18922 skip "ladvise ioctl is not supported"
18925 local size=$((size_mb * 1048576))
18926 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
18927 error "dd to $DIR/$tfile failed"
18929 lfs ladvise -a willread $DIR/$tfile ||
18930 error "Ladvise failed with no range argument"
18932 lfs ladvise -a willread -s 0 $DIR/$tfile ||
18933 error "Ladvise failed with no -l or -e argument"
18935 lfs ladvise -a willread -e 1 $DIR/$tfile ||
18936 error "Ladvise failed with only -e argument"
18938 lfs ladvise -a willread -l 1 $DIR/$tfile ||
18939 error "Ladvise failed with only -l argument"
18941 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
18942 error "End offset should not be smaller than start offset"
18944 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
18945 error "End offset should not be equal to start offset"
18947 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
18948 error "Ladvise failed with overflowing -s argument"
18950 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
18951 error "Ladvise failed with overflowing -e argument"
18953 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
18954 error "Ladvise failed with overflowing -l argument"
18956 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
18957 error "Ladvise succeeded with conflicting -l and -e arguments"
18959 echo "Synchronous ladvise should wait"
18961 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
18962 do_nodes $(comma_list $(osts_nodes)) \
18963 $LCTL set_param fail_val=$delay fail_loc=0x237
18965 local start_ts=$SECONDS
18966 lfs ladvise -a willread $DIR/$tfile ||
18967 error "Ladvise failed with no range argument"
18968 local end_ts=$SECONDS
18969 local inteval_ts=$((end_ts - start_ts))
18971 if [ $inteval_ts -lt $(($delay - 1)) ]; then
18972 error "Synchronous advice didn't wait reply"
18975 echo "Asynchronous ladvise shouldn't wait"
18976 local start_ts=$SECONDS
18977 lfs ladvise -a willread -b $DIR/$tfile ||
18978 error "Ladvise failed with no range argument"
18979 local end_ts=$SECONDS
18980 local inteval_ts=$((end_ts - start_ts))
18982 if [ $inteval_ts -gt $(($delay / 2)) ]; then
18983 error "Asynchronous advice blocked"
18986 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
18987 ladvise_willread_performance
18989 run_test 255a "check 'lfs ladvise -a willread'"
18995 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
18999 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
19000 skip "lustre < 2.8.54 does not support ladvise "
19001 remote_ost_nodsh && skip "remote OST with nodsh"
19003 lfs setstripe -c 1 -i 0 $DIR/$tfile
19005 ladvise_no_type dontneed $DIR/$tfile &&
19006 skip "dontneed ladvise is not supported"
19008 ladvise_no_ioctl $DIR/$tfile &&
19009 skip "ladvise ioctl is not supported"
19011 ! $LFS ladvise -a dontneed $DIR/$tfile &&
19012 [ "$ost1_FSTYPE" = "zfs" ] &&
19013 skip "zfs-osd does not support 'ladvise dontneed'"
19016 local size=$((size_mb * 1048576))
19017 # In order to prevent disturbance of other processes, only check 3/4
19018 # of the memory usage
19019 local kibibytes=$((size_mb * 1024 * 3 / 4))
19021 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
19022 error "dd to $DIR/$tfile failed"
19024 #force write to complete before dropping OST cache & checking memory
19027 local total=$(facet_meminfo ost1 MemTotal)
19028 echo "Total memory: $total KiB"
19030 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
19031 local before_read=$(facet_meminfo ost1 Cached)
19032 echo "Cache used before read: $before_read KiB"
19034 lfs ladvise -a willread $DIR/$tfile ||
19035 error "Ladvise willread failed"
19036 local after_read=$(facet_meminfo ost1 Cached)
19037 echo "Cache used after read: $after_read KiB"
19039 lfs ladvise -a dontneed $DIR/$tfile ||
19040 error "Ladvise dontneed again failed"
19041 local no_read=$(facet_meminfo ost1 Cached)
19042 echo "Cache used after dontneed ladvise: $no_read KiB"
19044 if [ $total -lt $((before_read + kibibytes)) ]; then
19045 echo "Memory is too small, abort checking"
19049 if [ $((before_read + kibibytes)) -gt $after_read ]; then
19050 error "Ladvise willread should use more memory" \
19051 "than $kibibytes KiB"
19054 if [ $((no_read + kibibytes)) -gt $after_read ]; then
19055 error "Ladvise dontneed should release more memory" \
19056 "than $kibibytes KiB"
19059 run_test 255b "check 'lfs ladvise -a dontneed'"
19062 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
19063 skip "lustre < 2.10.50 does not support lockahead"
19071 test_mkdir -p $DIR/$tdir
19072 $LFS setstripe -i 0 -c 1 $DIR/$tdir
19074 #test 10 returns only success/failure
19076 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19078 if [ $rc -eq 255 ]; then
19079 error "Ladvise test${i} failed, ${rc}"
19082 #test 11 counts lock enqueue requests, all others count new locks
19084 count=$(do_facet ost1 \
19085 $LCTL get_param -n ost.OSS.ost.stats)
19086 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
19088 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19090 if [ $rc -eq 255 ]; then
19091 error "Ladvise test${i} failed, ${rc}"
19094 new_count=$(do_facet ost1 \
19095 $LCTL get_param -n ost.OSS.ost.stats)
19096 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
19097 awk '{ print $2 }')
19099 difference="$((new_count - count))"
19100 if [ $difference -ne $rc ]; then
19101 error "Ladvise test${i}, bad enqueue count, returned " \
19102 "${rc}, actual ${difference}"
19105 for i in $(seq 12 21); do
19106 # If we do not do this, we run the risk of having too many
19107 # locks and starting lock cancellation while we are checking
19109 cancel_lru_locks osc
19111 count=$($LCTL get_param -n \
19112 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
19114 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19116 if [ $rc -eq 255 ]; then
19117 error "Ladvise test ${i} failed, ${rc}"
19120 new_count=$($LCTL get_param -n \
19121 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
19122 difference="$((new_count - count))"
19124 # Test 15 output is divided by 100 to map down to valid return
19125 if [ $i -eq 15 ]; then
19129 if [ $difference -ne $rc ]; then
19130 error "Ladvise test ${i}, bad lock count, returned " \
19131 "${rc}, actual ${difference}"
19135 #test 22 returns only success/failure
19137 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19139 if [ $rc -eq 255 ]; then
19140 error "Ladvise test${i} failed, ${rc}"
19143 run_test 255c "suite of ladvise lockahead tests"
19146 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19147 remote_mds_nodsh && skip "remote MDS with nodsh"
19148 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
19149 changelog_users $SINGLEMDS | grep "^cl" &&
19150 skip "active changelog user"
19156 mdt_dev=$(mdsdevname 1)
19159 changelog_register || error "changelog_register failed"
19162 mkdir -p $DIR/$tdir
19164 changelog_clear 0 || error "changelog_clear failed"
19167 touch $DIR/$tdir/{1..10}
19170 stop $SINGLEMDS || error "Fail to stop MDT"
19174 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
19176 #after mount new plainllog is used
19177 touch $DIR/$tdir/{11..19}
19178 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
19179 stack_trap "rm -f $tmpfile"
19180 cat_sl=$(do_facet $SINGLEMDS "sync; \
19181 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
19182 llog_reader $tmpfile | grep -c type=1064553b")
19183 do_facet $SINGLEMDS llog_reader $tmpfile
19185 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
19187 changelog_clear 0 || error "changelog_clear failed"
19189 cat_sl=$(do_facet $SINGLEMDS "sync; \
19190 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
19191 llog_reader $tmpfile | grep -c type=1064553b")
19193 if (( cat_sl == 2 )); then
19194 error "Empty plain llog was not deleted from changelog catalog"
19195 elif (( cat_sl != 1 )); then
19196 error "Active plain llog shouldn't be deleted from catalog"
19199 run_test 256 "Check llog delete for empty and not full state"
19202 remote_mds_nodsh && skip "remote MDS with nodsh"
19203 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
19204 skip "Need MDS version at least 2.8.55"
19206 test_mkdir $DIR/$tdir
19208 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
19209 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
19212 #define OBD_FAIL_MDS_XATTR_REP 0x161
19213 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
19214 local facet=mds$((mdtidx + 1))
19215 set_nodes_failloc $(facet_active_host $facet) 0x80000161
19216 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
19218 stop $facet || error "stop MDS failed"
19219 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
19220 error "start MDS fail"
19221 wait_recovery_complete $facet
19223 run_test 257 "xattr locks are not lost"
19225 # Verify we take the i_mutex when security requires it
19227 #define OBD_FAIL_IMUTEX_SEC 0x141c
19228 $LCTL set_param fail_loc=0x141c
19230 chmod u+s $DIR/$tfile
19231 chmod a+rwx $DIR/$tfile
19232 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
19234 if [ $RC -ne 0 ]; then
19235 error "error, failed to take i_mutex, rc=$?"
19239 run_test 258a "verify i_mutex security behavior when suid attributes is set"
19241 # Verify we do NOT take the i_mutex in the normal case
19243 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
19244 $LCTL set_param fail_loc=0x141d
19247 chmod a+rw $DIR/$tfile
19248 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
19250 if [ $RC -ne 0 ]; then
19251 error "error, took i_mutex unnecessarily, rc=$?"
19256 run_test 258b "verify i_mutex security behavior"
19259 local file=$DIR/$tfile
19263 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
19265 stack_trap "rm -f $file" EXIT
19267 wait_delete_completed
19268 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19269 echo "before: $before"
19271 $LFS setstripe -i 0 -c 1 $file
19272 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
19274 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19275 echo "after write: $after"
19277 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
19278 do_facet ost1 $LCTL set_param fail_loc=0x2301
19280 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19281 echo "after truncate: $after"
19284 do_facet ost1 $LCTL set_param fail_loc=0
19285 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
19287 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19288 echo "after restart: $after"
19289 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
19290 error "missing truncate?"
19294 run_test 259 "crash at delayed truncate"
19297 #define OBD_FAIL_MDC_CLOSE 0x806
19298 $LCTL set_param fail_loc=0x80000806
19302 run_test 260 "Check mdc_close fail"
19304 ### Data-on-MDT sanity tests ###
19306 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19307 skip "Need MDS version at least 2.10.55 for DoM"
19310 local dom=$DIR/$tdir/dom_file
19311 local tmp=$DIR/$tdir/tmp_file
19313 mkdir -p $DIR/$tdir
19315 # basic checks for DoM component creation
19316 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
19317 error "Can set MDT layout to non-first entry"
19319 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
19320 error "Can define multiple entries as MDT layout"
19322 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
19324 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
19325 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
19326 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
19328 local mdtidx=$($LFS getstripe -m $dom)
19329 local mdtname=MDT$(printf %04x $mdtidx)
19330 local facet=mds$((mdtidx + 1))
19331 local space_check=1
19333 # Skip free space checks with ZFS
19334 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
19338 local size_tmp=$((65536 * 3))
19339 local mdtfree1=$(do_facet $facet \
19340 lctl get_param -n osd*.*$mdtname.kbytesfree)
19342 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
19343 # check also direct IO along write
19344 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
19345 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
19347 cmp $tmp $dom || error "file data is different"
19348 [ $(stat -c%s $dom) == $size_tmp ] ||
19349 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
19350 if [ $space_check == 1 ]; then
19351 local mdtfree2=$(do_facet $facet \
19352 lctl get_param -n osd*.*$mdtname.kbytesfree)
19354 # increase in usage from by $size_tmp
19355 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
19356 error "MDT free space wrong after write: " \
19357 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
19361 local size_dom=10000
19363 $TRUNCATE $dom $size_dom
19364 [ $(stat -c%s $dom) == $size_dom ] ||
19365 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
19366 if [ $space_check == 1 ]; then
19367 mdtfree1=$(do_facet $facet \
19368 lctl get_param -n osd*.*$mdtname.kbytesfree)
19369 # decrease in usage from $size_tmp to new $size_dom
19370 [ $(($mdtfree1 - $mdtfree2)) -ge \
19371 $(((size_tmp - size_dom) / 1024)) ] ||
19372 error "MDT free space is wrong after truncate: " \
19373 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
19379 size_dom=$((size_dom + size_tmp))
19380 [ $(stat -c%s $dom) == $size_dom ] ||
19381 error "bad size after append: $(stat -c%s $dom) != $size_dom"
19382 if [ $space_check == 1 ]; then
19383 mdtfree2=$(do_facet $facet \
19384 lctl get_param -n osd*.*$mdtname.kbytesfree)
19385 # increase in usage by $size_tmp from previous
19386 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
19387 error "MDT free space is wrong after append: " \
19388 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
19393 if [ $space_check == 1 ]; then
19394 mdtfree1=$(do_facet $facet \
19395 lctl get_param -n osd*.*$mdtname.kbytesfree)
19396 # decrease in usage by $size_dom from previous
19397 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
19398 error "MDT free space is wrong after removal: " \
19399 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
19402 # combined striping
19403 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
19404 error "Can't create DoM + OST striping"
19406 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
19407 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
19408 # check also direct IO along write
19409 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
19411 cmp $tmp $dom || error "file data is different"
19412 [ $(stat -c%s $dom) == $size_tmp ] ||
19413 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
19418 run_test 270a "DoM: basic functionality tests"
19421 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19422 skip "Need MDS version at least 2.10.55"
19424 local dom=$DIR/$tdir/dom_file
19425 local max_size=1048576
19427 mkdir -p $DIR/$tdir
19428 $LFS setstripe -E $max_size -L mdt $dom
19430 # truncate over the limit
19431 $TRUNCATE $dom $(($max_size + 1)) &&
19432 error "successful truncate over the maximum size"
19433 # write over the limit
19434 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
19435 error "successful write over the maximum size"
19436 # append over the limit
19437 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
19438 echo "12345" >> $dom && error "successful append over the maximum size"
19443 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
19446 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19447 skip "Need MDS version at least 2.10.55"
19449 mkdir -p $DIR/$tdir
19450 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19452 # check files inherit DoM EA
19453 touch $DIR/$tdir/first
19454 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
19455 error "bad pattern"
19456 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
19457 error "bad stripe count"
19458 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
19459 error "bad stripe size"
19461 # check directory inherits DoM EA and uses it as default
19462 mkdir $DIR/$tdir/subdir
19463 touch $DIR/$tdir/subdir/second
19464 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
19465 error "bad pattern in sub-directory"
19466 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
19467 error "bad stripe count in sub-directory"
19468 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
19469 error "bad stripe size in sub-directory"
19472 run_test 270c "DoM: DoM EA inheritance tests"
19475 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19476 skip "Need MDS version at least 2.10.55"
19478 mkdir -p $DIR/$tdir
19479 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19481 # inherit default DoM striping
19482 mkdir $DIR/$tdir/subdir
19483 touch $DIR/$tdir/subdir/f1
19485 # change default directory striping
19486 $LFS setstripe -c 1 $DIR/$tdir/subdir
19487 touch $DIR/$tdir/subdir/f2
19488 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
19489 error "wrong default striping in file 2"
19490 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
19491 error "bad pattern in file 2"
19494 run_test 270d "DoM: change striping from DoM to RAID0"
19497 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19498 skip "Need MDS version at least 2.10.55"
19500 mkdir -p $DIR/$tdir/dom
19501 mkdir -p $DIR/$tdir/norm
19504 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
19505 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
19507 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
19508 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
19510 # find DoM files by layout
19511 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
19512 [ $NUM -eq $DOMFILES ] ||
19513 error "lfs find -L: found $NUM, expected $DOMFILES"
19514 echo "Test 1: lfs find 20 DOM files by layout: OK"
19516 # there should be 1 dir with default DOM striping
19517 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
19519 error "lfs find -L: found $NUM, expected 1 dir"
19520 echo "Test 2: lfs find 1 DOM dir by layout: OK"
19522 # find DoM files by stripe size
19523 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
19524 [ $NUM -eq $DOMFILES ] ||
19525 error "lfs find -S: found $NUM, expected $DOMFILES"
19526 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
19528 # find files by stripe offset except DoM files
19529 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
19530 [ $NUM -eq $NORMFILES ] ||
19531 error "lfs find -i: found $NUM, expected $NORMFILES"
19532 echo "Test 5: lfs find no DOM files by stripe index: OK"
19535 run_test 270e "DoM: lfs find with DoM files test"
19538 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19539 skip "Need MDS version at least 2.10.55"
19541 local mdtname=${FSNAME}-MDT0000-mdtlov
19542 local dom=$DIR/$tdir/dom_file
19543 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
19544 lod.$mdtname.dom_stripesize)
19545 local dom_limit=131072
19547 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
19548 local dom_current=$(do_facet mds1 $LCTL get_param -n \
19549 lod.$mdtname.dom_stripesize)
19550 [ ${dom_limit} -eq ${dom_current} ] ||
19551 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
19553 $LFS mkdir -i 0 -c 1 $DIR/$tdir
19554 $LFS setstripe -d $DIR/$tdir
19555 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
19556 error "Can't set directory default striping"
19558 # exceed maximum stripe size
19559 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
19560 error "Can't create file with $((dom_limit * 2)) DoM stripe"
19561 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
19562 error "Able to create DoM component size more than LOD limit"
19564 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
19565 dom_current=$(do_facet mds1 $LCTL get_param -n \
19566 lod.$mdtname.dom_stripesize)
19567 [ 0 -eq ${dom_current} ] ||
19568 error "Can't set zero DoM stripe limit"
19571 # attempt to create DoM file on server with disabled DoM should
19572 # remove DoM entry from layout and be succeed
19573 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
19574 error "Can't create DoM file (DoM is disabled)"
19575 [ $($LFS getstripe -L $dom) == "mdt" ] &&
19576 error "File has DoM component while DoM is disabled"
19579 # attempt to create DoM file with only DoM stripe should return error
19580 $LFS setstripe -E $dom_limit -L mdt $dom &&
19581 error "Able to create DoM-only file while DoM is disabled"
19583 # too low values to be aligned with smallest stripe size 64K
19584 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
19585 dom_current=$(do_facet mds1 $LCTL get_param -n \
19586 lod.$mdtname.dom_stripesize)
19587 [ 30000 -eq ${dom_current} ] &&
19588 error "Can set too small DoM stripe limit"
19590 # 64K is a minimal stripe size in Lustre, expect limit of that size
19591 [ 65536 -eq ${dom_current} ] ||
19592 error "Limit is not set to 64K but ${dom_current}"
19594 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
19595 dom_current=$(do_facet mds1 $LCTL get_param -n \
19596 lod.$mdtname.dom_stripesize)
19598 [ 2147483648 -eq ${dom_current} ] &&
19599 error "Can set too large DoM stripe limit"
19601 do_facet mds1 $LCTL set_param -n \
19602 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
19603 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
19604 error "Can't create DoM component size after limit change"
19605 do_facet mds1 $LCTL set_param -n \
19606 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
19607 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
19608 error "Can't create DoM file after limit decrease"
19609 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
19610 error "Can create big DoM component after limit decrease"
19611 touch ${dom}_def ||
19612 error "Can't create file with old default layout"
19614 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
19617 run_test 270f "DoM: maximum DoM stripe size checks"
19620 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
19621 skip "Need MDS version at least 2.13.52"
19622 local dom=$DIR/$tdir/$tfile
19624 $LFS mkdir -i 0 -c 1 $DIR/$tdir
19625 local lodname=${FSNAME}-MDT0000-mdtlov
19627 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
19628 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
19629 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
19630 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
19632 local dom_limit=1024
19633 local dom_threshold="50%"
19635 $LFS setstripe -d $DIR/$tdir
19636 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
19637 error "Can't set directory default striping"
19639 do_facet mds1 $LCTL set_param -n \
19640 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
19641 # set 0 threshold and create DOM file to change tunable stripesize
19642 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
19643 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
19644 error "Failed to create $dom file"
19645 # now tunable dom_cur_stripesize should reach maximum
19646 local dom_current=$(do_facet mds1 $LCTL get_param -n \
19647 lod.${lodname}.dom_stripesize_cur_kb)
19648 [[ $dom_current == $dom_limit ]] ||
19649 error "Current DOM stripesize is not maximum"
19652 # set threshold for further tests
19653 do_facet mds1 $LCTL set_param -n \
19654 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
19655 echo "DOM threshold is $dom_threshold free space"
19658 # Spoof bfree to exceed threshold
19659 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
19660 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
19661 for spfree in 40 20 0 15 30 55; do
19662 do_facet mds1 $LCTL set_param -n fail_val=$spfree
19663 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
19664 error "Failed to create $dom file"
19665 dom_def=$(do_facet mds1 $LCTL get_param -n \
19666 lod.${lodname}.dom_stripesize_cur_kb)
19667 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
19668 [[ $dom_def != $dom_current ]] ||
19669 error "Default stripe size was not changed"
19670 if [[ $spfree > 0 ]] ; then
19671 dom_set=$($LFS getstripe -S $dom)
19672 [[ $dom_set == $((dom_def * 1024)) ]] ||
19673 error "DOM component size is still old"
19675 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
19676 error "DoM component is set with no free space"
19679 dom_current=$dom_def
19682 run_test 270g "DoM: default DoM stripe size depends on free space"
19685 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19686 skip "Need MDS version at least 2.10.55"
19688 local dom=$DIR/$tdir/dom
19690 mkdir -p $DIR/$tdir
19692 $LFS setstripe -E 1024K -L mdt $dom
19694 lctl set_param -n mdc.*.stats=clear
19695 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
19696 cat $dom > /dev/null
19697 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
19698 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
19702 run_test 271a "DoM: data is cached for read after write"
19705 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19706 skip "Need MDS version at least 2.10.55"
19708 local dom=$DIR/$tdir/dom
19710 mkdir -p $DIR/$tdir
19712 $LFS setstripe -E 1024K -L mdt -E EOF $dom
19714 lctl set_param -n mdc.*.stats=clear
19715 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
19716 cancel_lru_locks mdc
19717 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
19718 # second stat to check size is cached on client
19719 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
19720 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
19721 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
19724 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
19727 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19728 skip "Need MDS version at least 2.10.55"
19730 local dom=$DIR/$tdir/dom
19732 mkdir -p $DIR/$tdir
19734 $LFS setstripe -E 1024K -L mdt -E EOF $dom
19736 lctl set_param -n mdc.*.stats=clear
19737 lctl set_param -n osc.*.stats=clear
19738 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
19739 cancel_lru_locks mdc
19740 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
19741 # second stat to check size is cached on client
19742 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
19743 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
19744 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
19745 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
19746 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
19749 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
19755 local mdt=MDT$(printf %04x $mdtidx)
19757 if [ -z $param ]; then
19758 lctl get_param -n mdc.*$mdt*.stats
19760 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
19765 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19766 skip "Need MDS version at least 2.10.55"
19768 local dom=$DIR/$tdir/dom
19770 mkdir -p $DIR/$tdir
19772 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19774 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
19775 local facet=mds$((mdtidx + 1))
19777 cancel_lru_locks mdc
19778 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
19779 createmany -o $dom 1000
19780 lctl set_param -n mdc.*.stats=clear
19781 smalliomany -w $dom 1000 200
19782 get_mdc_stats $mdtidx
19783 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
19784 # Each file has 1 open, 1 IO enqueues, total 2000
19785 # but now we have also +1 getxattr for security.capability, total 3000
19786 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
19787 unlinkmany $dom 1000
19789 cancel_lru_locks mdc
19790 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
19791 createmany -o $dom 1000
19792 lctl set_param -n mdc.*.stats=clear
19793 smalliomany -w $dom 1000 200
19794 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
19795 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
19796 # for OPEN and IO lock.
19797 [ $((enq - enq_2)) -ge 1000 ] ||
19798 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
19799 unlinkmany $dom 1000
19802 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
19804 cleanup_271def_tests() {
19810 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
19811 skip "Need MDS version at least 2.10.57"
19813 local dom=$DIR/$tdir/dom
19814 local tmp=$TMP/$tfile
19815 trap "cleanup_271def_tests $tmp" EXIT
19817 mkdir -p $DIR/$tdir
19819 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19821 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
19823 cancel_lru_locks mdc
19824 dd if=/dev/urandom of=$tmp bs=1000 count=1
19825 dd if=$tmp of=$dom bs=1000 count=1
19826 cancel_lru_locks mdc
19828 cat /etc/hosts >> $tmp
19829 lctl set_param -n mdc.*.stats=clear
19831 # append data to the same file it should update local page
19832 echo "Append to the same page"
19833 cat /etc/hosts >> $dom
19834 local num=$(get_mdc_stats $mdtidx ost_read)
19835 local ra=$(get_mdc_stats $mdtidx req_active)
19836 local rw=$(get_mdc_stats $mdtidx req_waittime)
19838 [ -z $num ] || error "$num READ RPC occured"
19839 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19843 cmp $tmp $dom || error "file miscompare"
19845 cancel_lru_locks mdc
19846 lctl set_param -n mdc.*.stats=clear
19848 echo "Open and read file"
19849 cat $dom > /dev/null
19850 local num=$(get_mdc_stats $mdtidx ost_read)
19851 local ra=$(get_mdc_stats $mdtidx req_active)
19852 local rw=$(get_mdc_stats $mdtidx req_waittime)
19854 [ -z $num ] || error "$num READ RPC occured"
19855 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19859 cmp $tmp $dom || error "file miscompare"
19863 run_test 271d "DoM: read on open (1K file in reply buffer)"
19866 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
19867 skip "Need MDS version at least 2.10.57"
19869 local dom=$DIR/$tdir/dom
19870 local tmp=$TMP/$tfile
19871 trap "cleanup_271def_tests $tmp" EXIT
19873 mkdir -p $DIR/$tdir
19875 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19877 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
19879 cancel_lru_locks mdc
19880 dd if=/dev/urandom of=$tmp bs=265000 count=1
19881 dd if=$tmp of=$dom bs=265000 count=1
19882 cancel_lru_locks mdc
19883 cat /etc/hosts >> $tmp
19884 lctl set_param -n mdc.*.stats=clear
19886 echo "Append to the same page"
19887 cat /etc/hosts >> $dom
19888 local num=$(get_mdc_stats $mdtidx ost_read)
19889 local ra=$(get_mdc_stats $mdtidx req_active)
19890 local rw=$(get_mdc_stats $mdtidx req_waittime)
19892 [ -z $num ] || error "$num READ RPC occured"
19893 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19897 cmp $tmp $dom || error "file miscompare"
19899 cancel_lru_locks mdc
19900 lctl set_param -n mdc.*.stats=clear
19902 echo "Open and read file"
19903 cat $dom > /dev/null
19904 local num=$(get_mdc_stats $mdtidx ost_read)
19905 local ra=$(get_mdc_stats $mdtidx req_active)
19906 local rw=$(get_mdc_stats $mdtidx req_waittime)
19908 [ -z $num ] && num=0
19909 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
19910 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19914 cmp $tmp $dom || error "file miscompare"
19918 run_test 271f "DoM: read on open (200K file and read tail)"
19921 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
19922 skip "Skipping due to old client or server version"
19924 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
19926 $CHECKSTAT -t file $DIR1/$tfile
19928 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
19931 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
19932 $LCTL set_param fail_loc=0x80000314
19933 rm $DIR1/$tfile || error "Unlink fails"
19935 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
19936 [ $RC -eq 0 ] || error "Failed write to stale object"
19938 run_test 271g "Discard DoM data vs client flush race"
19941 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19942 skip "Need MDS version at least 2.11.50"
19944 local dom=$DIR/$tdir/dom
19945 mkdir -p $DIR/$tdir
19947 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
19948 dd if=/dev/urandom of=$dom bs=512K count=1 ||
19949 error "failed to write data into $dom"
19950 local old_md5=$(md5sum $dom)
19952 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
19953 error "failed to migrate to the same DoM component"
19955 local new_md5=$(md5sum $dom)
19957 [ "$old_md5" == "$new_md5" ] ||
19958 error "md5sum differ: $old_md5, $new_md5"
19960 [ $($LFS getstripe -c $dom) -eq 2 ] ||
19961 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
19963 run_test 272a "DoM migration: new layout with the same DOM component"
19966 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19967 skip "Need MDS version at least 2.11.50"
19969 local dom=$DIR/$tdir/dom
19970 mkdir -p $DIR/$tdir
19971 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
19973 local mdtidx=$($LFS getstripe -m $dom)
19974 local mdtname=MDT$(printf %04x $mdtidx)
19975 local facet=mds$((mdtidx + 1))
19977 local mdtfree1=$(do_facet $facet \
19978 lctl get_param -n osd*.*$mdtname.kbytesfree)
19979 dd if=/dev/urandom of=$dom bs=2M count=1 ||
19980 error "failed to write data into $dom"
19981 local old_md5=$(md5sum $dom)
19982 cancel_lru_locks mdc
19983 local mdtfree1=$(do_facet $facet \
19984 lctl get_param -n osd*.*$mdtname.kbytesfree)
19986 $LFS migrate -c2 $dom ||
19987 error "failed to migrate to the new composite layout"
19988 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
19989 error "MDT stripe was not removed"
19991 cancel_lru_locks mdc
19992 local new_md5=$(md5sum $dom)
19993 [ "$old_md5" == "$new_md5" ] ||
19994 error "$old_md5 != $new_md5"
19996 # Skip free space checks with ZFS
19997 if [ "$(facet_fstype $facet)" != "zfs" ]; then
19998 local mdtfree2=$(do_facet $facet \
19999 lctl get_param -n osd*.*$mdtname.kbytesfree)
20000 [ $mdtfree2 -gt $mdtfree1 ] ||
20001 error "MDT space is not freed after migration"
20005 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
20008 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
20009 skip "Need MDS version at least 2.11.50"
20011 local dom=$DIR/$tdir/$tfile
20012 mkdir -p $DIR/$tdir
20013 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
20015 local mdtidx=$($LFS getstripe -m $dom)
20016 local mdtname=MDT$(printf %04x $mdtidx)
20017 local facet=mds$((mdtidx + 1))
20019 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
20020 error "failed to write data into $dom"
20021 local old_md5=$(md5sum $dom)
20022 cancel_lru_locks mdc
20023 local mdtfree1=$(do_facet $facet \
20024 lctl get_param -n osd*.*$mdtname.kbytesfree)
20026 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
20027 error "failed to migrate to the new composite layout"
20028 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
20029 error "MDT stripe was not removed"
20031 cancel_lru_locks mdc
20032 local new_md5=$(md5sum $dom)
20033 [ "$old_md5" == "$new_md5" ] ||
20034 error "$old_md5 != $new_md5"
20036 # Skip free space checks with ZFS
20037 if [ "$(facet_fstype $facet)" != "zfs" ]; then
20038 local mdtfree2=$(do_facet $facet \
20039 lctl get_param -n osd*.*$mdtname.kbytesfree)
20040 [ $mdtfree2 -gt $mdtfree1 ] ||
20041 error "MDS space is not freed after migration"
20045 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
20048 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
20049 skip "Need MDS version at least 2.12.55"
20051 local dom=$DIR/$tdir/$tfile
20052 mkdir -p $DIR/$tdir
20053 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
20055 local mdtidx=$($LFS getstripe -m $dom)
20056 local mdtname=MDT$(printf %04x $mdtidx)
20057 local facet=mds$((mdtidx + 1))
20059 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
20060 error "failed to write data into $dom"
20061 local old_md5=$(md5sum $dom)
20062 cancel_lru_locks mdc
20063 local mdtfree1=$(do_facet $facet \
20064 lctl get_param -n osd*.*$mdtname.kbytesfree)
20066 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
20067 error "failed mirroring to the new composite layout"
20068 $LFS mirror resync $dom ||
20069 error "failed mirror resync"
20070 $LFS mirror split --mirror-id 1 -d $dom ||
20071 error "failed mirror split"
20073 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
20074 error "MDT stripe was not removed"
20076 cancel_lru_locks mdc
20077 local new_md5=$(md5sum $dom)
20078 [ "$old_md5" == "$new_md5" ] ||
20079 error "$old_md5 != $new_md5"
20081 # Skip free space checks with ZFS
20082 if [ "$(facet_fstype $facet)" != "zfs" ]; then
20083 local mdtfree2=$(do_facet $facet \
20084 lctl get_param -n osd*.*$mdtname.kbytesfree)
20085 [ $mdtfree2 -gt $mdtfree1 ] ||
20086 error "MDS space is not freed after DOM mirror deletion"
20090 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
20093 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
20094 skip "Need MDS version at least 2.12.55"
20096 local dom=$DIR/$tdir/$tfile
20097 mkdir -p $DIR/$tdir
20098 $LFS setstripe -c 2 $dom
20100 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
20101 error "failed to write data into $dom"
20102 local old_md5=$(md5sum $dom)
20103 cancel_lru_locks mdc
20105 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
20106 error "failed mirroring to the DOM layout"
20107 $LFS mirror resync $dom ||
20108 error "failed mirror resync"
20109 $LFS mirror split --mirror-id 1 -d $dom ||
20110 error "failed mirror split"
20112 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
20113 error "MDT stripe was not removed"
20115 cancel_lru_locks mdc
20116 local new_md5=$(md5sum $dom)
20117 [ "$old_md5" == "$new_md5" ] ||
20118 error "$old_md5 != $new_md5"
20122 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
20125 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
20126 skip "Need MDS version at least 2.12.55"
20128 local dom=$DIR/$tdir/$tfile
20129 mkdir -p $DIR/$tdir
20130 $LFS setstripe -c 2 $dom
20132 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
20133 error "failed to write data into $dom"
20134 local old_md5=$(md5sum $dom)
20135 cancel_lru_locks mdc
20137 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
20138 error "failed migrating to the DOM file"
20140 cancel_lru_locks mdc
20141 local new_md5=$(md5sum $dom)
20142 [ "$old_md5" != "$new_md5" ] &&
20143 error "$old_md5 != $new_md5"
20147 run_test 272f "DoM migration: OST-striped file to DOM file"
20150 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
20151 skip "Need MDS version at least 2.11.50"
20153 # Layout swap cannot be done if either file has DOM component,
20154 # this will never be supported, migration should be used instead
20156 local dom=$DIR/$tdir/$tfile
20157 mkdir -p $DIR/$tdir
20159 $LFS setstripe -c2 ${dom}_plain
20160 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
20161 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
20162 error "can swap layout with DoM component"
20163 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
20164 error "can swap layout with DoM component"
20166 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
20167 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
20168 error "can swap layout with DoM component"
20169 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
20170 error "can swap layout with DoM component"
20173 run_test 273a "DoM: layout swapping should fail with DOM"
20176 remote_ost_nodsh && skip "remote OST with nodsh"
20177 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
20178 skip "Need OST version >= 2.10.57"
20180 local file=$DIR/$tfile
20183 oss=$(comma_list $(osts_nodes))
20185 dd if=/dev/urandom of=$file bs=1M count=2 ||
20186 error "failed to create a file"
20187 cancel_lru_locks osc
20190 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
20191 error "failed to read a file"
20193 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
20194 $LCTL set_param fail_loc=0x8000031f
20196 cancel_lru_locks osc &
20199 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
20200 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
20201 #IO takes another lock, but matches the PENDING one
20202 #and places it to the IO RPC
20203 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
20204 error "failed to read a file with PENDING lock"
20206 run_test 275 "Read on a canceled duplicate lock"
20209 remote_ost_nodsh && skip "remote OST with nodsh"
20212 do_facet ost1 "(while true; do \
20213 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
20214 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
20217 for LOOP in $(seq 20); do
20219 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
20222 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
20223 rm $TMP/sanity_276_pid"
20225 run_test 276 "Race between mount and obd_statfs"
20228 $LCTL set_param ldlm.namespaces.*.lru_size=0
20229 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
20230 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
20231 grep ^used_mb | awk '{print $2}')
20232 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
20233 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
20234 oflag=direct conv=notrunc
20235 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
20236 grep ^used_mb | awk '{print $2}')
20237 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
20239 run_test 277 "Direct IO shall drop page cache"
20242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
20243 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
20244 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
20245 skip "needs the same host for mdt1 mdt2" && return
20250 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
20251 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
20257 echo "Starting MDTs"
20258 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
20260 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
20262 do_facet mds2 $LCTL set_param fail_loc=0
20264 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
20265 wait_recovery_complete mds2
20267 run_test 278 "Race starting MDS between MDTs stop/start"
20270 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
20271 skip "Need MGS version at least 2.13.52"
20272 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20273 combined_mgs_mds || skip "needs combined MGS/MDT"
20275 umount_client $MOUNT
20276 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
20277 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
20279 mount_client $MOUNT &
20281 stop mgs || error "stop mgs failed"
20282 #for a race mgs would crash
20283 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
20284 mount_client $MOUNT || error "mount client failed"
20286 run_test 280 "Race between MGS umount and client llog processing"
20288 cleanup_test_300() {
20292 test_striped_dir() {
20297 mkdir -p $DIR/$tdir
20299 SAVE_UMASK=$(umask)
20300 trap cleanup_test_300 RETURN EXIT
20302 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
20303 $DIR/$tdir/striped_dir ||
20304 error "set striped dir error"
20306 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
20307 [ "$mode" = "755" ] || error "expect 755 got $mode"
20309 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
20310 error "getdirstripe failed"
20311 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
20312 if [ "$stripe_count" != "2" ]; then
20313 error "1:stripe_count is $stripe_count, expect 2"
20315 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
20316 if [ "$stripe_count" != "2" ]; then
20317 error "2:stripe_count is $stripe_count, expect 2"
20320 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
20321 if [ "$stripe_index" != "$mdt_index" ]; then
20322 error "stripe_index is $stripe_index, expect $mdt_index"
20325 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
20326 error "nlink error after create striped dir"
20328 mkdir $DIR/$tdir/striped_dir/a
20329 mkdir $DIR/$tdir/striped_dir/b
20331 stat $DIR/$tdir/striped_dir/a ||
20332 error "create dir under striped dir failed"
20333 stat $DIR/$tdir/striped_dir/b ||
20334 error "create dir under striped dir failed"
20336 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
20337 error "nlink error after mkdir"
20339 rmdir $DIR/$tdir/striped_dir/a
20340 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
20341 error "nlink error after rmdir"
20343 rmdir $DIR/$tdir/striped_dir/b
20344 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
20345 error "nlink error after rmdir"
20347 chattr +i $DIR/$tdir/striped_dir
20348 createmany -o $DIR/$tdir/striped_dir/f 10 &&
20349 error "immutable flags not working under striped dir!"
20350 chattr -i $DIR/$tdir/striped_dir
20352 rmdir $DIR/$tdir/striped_dir ||
20353 error "rmdir striped dir error"
20361 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20362 skip "skipped for lustre < 2.7.0"
20363 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20364 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20366 test_striped_dir 0 || error "failed on striped dir on MDT0"
20367 test_striped_dir 1 || error "failed on striped dir on MDT0"
20369 run_test 300a "basic striped dir sanity test"
20372 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20373 skip "skipped for lustre < 2.7.0"
20374 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20375 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20382 test_mkdir $DIR/$tdir || error "mkdir fail"
20383 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20384 error "set striped dir error"
20385 for i in {0..9}; do
20386 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
20388 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
20389 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
20390 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
20392 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
20393 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
20394 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
20398 run_test 300b "check ctime/mtime for striped dir"
20401 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20402 skip "skipped for lustre < 2.7.0"
20403 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20404 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20408 mkdir -p $DIR/$tdir
20409 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
20410 error "set striped dir error"
20412 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
20413 error "chown striped dir failed"
20415 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
20416 error "create 5k files failed"
20418 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
20420 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
20424 run_test 300c "chown && check ls under striped directory"
20427 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20428 skip "skipped for lustre < 2.7.0"
20429 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20430 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20435 mkdir -p $DIR/$tdir
20436 $LFS setstripe -c 2 $DIR/$tdir
20438 #local striped directory
20439 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20440 error "set striped dir error"
20441 #look at the directories for debug purposes
20443 $LFS getdirstripe $DIR/$tdir
20444 ls -l $DIR/$tdir/striped_dir
20445 $LFS getdirstripe $DIR/$tdir/striped_dir
20446 createmany -o $DIR/$tdir/striped_dir/f 10 ||
20447 error "create 10 files failed"
20449 #remote striped directory
20450 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
20451 error "set striped dir error"
20452 #look at the directories for debug purposes
20454 $LFS getdirstripe $DIR/$tdir
20455 ls -l $DIR/$tdir/remote_striped_dir
20456 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
20457 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
20458 error "create 10 files failed"
20460 for file in $(find $DIR/$tdir); do
20461 stripe_count=$($LFS getstripe -c $file)
20462 [ $stripe_count -eq 2 ] ||
20463 error "wrong stripe $stripe_count for $file"
20468 run_test 300d "check default stripe under striped directory"
20471 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20472 skip "Need MDS version at least 2.7.55"
20473 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20474 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20479 mkdir -p $DIR/$tdir
20481 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20482 error "set striped dir error"
20484 touch $DIR/$tdir/striped_dir/a
20485 touch $DIR/$tdir/striped_dir/b
20486 touch $DIR/$tdir/striped_dir/c
20488 mkdir $DIR/$tdir/striped_dir/dir_a
20489 mkdir $DIR/$tdir/striped_dir/dir_b
20490 mkdir $DIR/$tdir/striped_dir/dir_c
20492 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
20493 error "set striped adir under striped dir error"
20495 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
20496 error "set striped bdir under striped dir error"
20498 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
20499 error "set striped cdir under striped dir error"
20501 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
20502 error "rename dir under striped dir fails"
20504 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
20505 error "rename dir under different stripes fails"
20507 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
20508 error "rename file under striped dir should succeed"
20510 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
20511 error "rename dir under striped dir should succeed"
20515 run_test 300e "check rename under striped directory"
20518 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20519 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20520 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20521 skip "Need MDS version at least 2.7.55"
20527 mkdir -p $DIR/$tdir
20529 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20530 error "set striped dir error"
20532 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
20533 error "set striped dir error"
20535 touch $DIR/$tdir/striped_dir/a
20536 mkdir $DIR/$tdir/striped_dir/dir_a
20537 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
20538 error "create striped dir under striped dir fails"
20540 touch $DIR/$tdir/striped_dir1/b
20541 mkdir $DIR/$tdir/striped_dir1/dir_b
20542 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
20543 error "create striped dir under striped dir fails"
20545 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
20546 error "rename dir under different striped dir should fail"
20548 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
20549 error "rename striped dir under diff striped dir should fail"
20551 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
20552 error "rename file under diff striped dirs fails"
20556 run_test 300f "check rename cross striped directory"
20558 test_300_check_default_striped_dir()
20561 local default_count=$2
20562 local default_index=$3
20565 local dir_stripe_index
20568 echo "checking $dirname $default_count $default_index"
20569 $LFS setdirstripe -D -c $default_count -i $default_index \
20570 -t all_char $DIR/$tdir/$dirname ||
20571 error "set default stripe on striped dir error"
20572 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
20573 [ $stripe_count -eq $default_count ] ||
20574 error "expect $default_count get $stripe_count for $dirname"
20576 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
20577 [ $stripe_index -eq $default_index ] ||
20578 error "expect $default_index get $stripe_index for $dirname"
20580 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
20581 error "create dirs failed"
20583 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
20584 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
20585 for dir in $(find $DIR/$tdir/$dirname/*); do
20586 stripe_count=$($LFS getdirstripe -c $dir)
20587 [ $stripe_count -eq $default_count ] ||
20588 [ $stripe_count -eq 0 ] || [ $default_count -eq 1 ] ||
20589 error "stripe count $default_count != $stripe_count for $dir"
20591 stripe_index=$($LFS getdirstripe -i $dir)
20592 [ $default_index -eq -1 ] ||
20593 [ $stripe_index -eq $default_index ] ||
20594 error "$stripe_index != $default_index for $dir"
20596 #check default stripe
20597 stripe_count=$($LFS getdirstripe -D -c $dir)
20598 [ $stripe_count -eq $default_count ] ||
20599 error "default count $default_count != $stripe_count for $dir"
20601 stripe_index=$($LFS getdirstripe -D -i $dir)
20602 [ $stripe_index -eq $default_index ] ||
20603 error "default index $default_index != $stripe_index for $dir"
20605 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
20609 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20610 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20611 skip "Need MDS version at least 2.7.55"
20618 mkdir $DIR/$tdir/normal_dir
20620 #Checking when client cache stripe index
20621 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
20622 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
20623 error "create striped_dir failed"
20625 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
20626 error "create dir0 fails"
20627 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
20628 [ $stripe_index -eq 0 ] ||
20629 error "dir0 expect index 0 got $stripe_index"
20631 mkdir $DIR/$tdir/striped_dir/dir1 ||
20632 error "create dir1 fails"
20633 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
20634 [ $stripe_index -eq 1 ] ||
20635 error "dir1 expect index 1 got $stripe_index"
20637 #check default stripe count/stripe index
20638 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
20639 test_300_check_default_striped_dir normal_dir 1 0
20640 test_300_check_default_striped_dir normal_dir 2 1
20641 test_300_check_default_striped_dir normal_dir 2 -1
20643 #delete default stripe information
20644 echo "delete default stripeEA"
20645 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
20646 error "set default stripe on striped dir error"
20648 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
20649 for dir in $(find $DIR/$tdir/normal_dir/*); do
20650 stripe_count=$($LFS getdirstripe -c $dir)
20651 [ $stripe_count -eq 0 ] ||
20652 error "expect 1 get $stripe_count for $dir"
20653 stripe_index=$($LFS getdirstripe -i $dir)
20654 [ $stripe_index -eq 0 ] ||
20655 error "expect 0 get $stripe_index for $dir"
20658 run_test 300g "check default striped directory for normal directory"
20661 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20662 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20663 skip "Need MDS version at least 2.7.55"
20669 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
20670 error "set striped dir error"
20672 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
20673 test_300_check_default_striped_dir striped_dir 1 0
20674 test_300_check_default_striped_dir striped_dir 2 1
20675 test_300_check_default_striped_dir striped_dir 2 -1
20677 #delete default stripe information
20678 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
20679 error "set default stripe on striped dir error"
20681 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
20682 for dir in $(find $DIR/$tdir/striped_dir/*); do
20683 stripe_count=$($LFS getdirstripe -c $dir)
20684 [ $stripe_count -eq 0 ] ||
20685 error "expect 1 get $stripe_count for $dir"
20688 run_test 300h "check default striped directory for striped directory"
20691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20692 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20693 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20694 skip "Need MDS version at least 2.7.55"
20701 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
20702 error "set striped dir error"
20704 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
20705 error "create files under striped dir failed"
20707 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
20708 error "set striped hashdir error"
20710 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
20711 error "create dir0 under hash dir failed"
20712 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
20713 error "create dir1 under hash dir failed"
20715 # unfortunately, we need to umount to clear dir layout cache for now
20716 # once we fully implement dir layout, we can drop this
20717 umount_client $MOUNT || error "umount failed"
20718 mount_client $MOUNT || error "mount failed"
20720 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
20721 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
20722 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
20724 #set the stripe to be unknown hash type
20725 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
20726 $LCTL set_param fail_loc=0x1901
20727 for ((i = 0; i < 10; i++)); do
20728 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
20729 error "stat f-$i failed"
20730 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
20733 touch $DIR/$tdir/striped_dir/f0 &&
20734 error "create under striped dir with unknown hash should fail"
20736 $LCTL set_param fail_loc=0
20738 umount_client $MOUNT || error "umount failed"
20739 mount_client $MOUNT || error "mount failed"
20743 run_test 300i "client handle unknown hash type striped directory"
20746 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20747 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20748 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20749 skip "Need MDS version at least 2.7.55"
20756 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
20757 $LCTL set_param fail_loc=0x1702
20758 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
20759 error "set striped dir error"
20761 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
20762 error "create files under striped dir failed"
20764 $LCTL set_param fail_loc=0
20766 rm -rf $DIR/$tdir || error "unlink striped dir fails"
20770 run_test 300j "test large update record"
20773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20774 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20775 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20776 skip "Need MDS version at least 2.7.55"
20778 # this test needs a huge transaction
20780 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
20781 osd*.$FSNAME-MDT0000.kbytestotal")
20782 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
20789 #define OBD_FAIL_LARGE_STRIPE 0x1703
20790 $LCTL set_param fail_loc=0x1703
20791 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
20792 error "set striped dir error"
20793 $LCTL set_param fail_loc=0
20795 $LFS getdirstripe $DIR/$tdir/striped_dir ||
20796 error "getstripeddir fails"
20797 rm -rf $DIR/$tdir/striped_dir ||
20798 error "unlink striped dir fails"
20802 run_test 300k "test large striped directory"
20805 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20806 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20807 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20808 skip "Need MDS version at least 2.7.55"
20812 test_mkdir -p $DIR/$tdir/striped_dir
20813 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
20814 error "chown $RUNAS_ID failed"
20815 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
20816 error "set default striped dir failed"
20818 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
20819 $LCTL set_param fail_loc=0x80000158
20820 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
20822 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
20823 [ $stripe_index -eq 1 ] ||
20824 error "expect 1 get $stripe_index for $dir"
20826 run_test 300l "non-root user to create dir under striped dir with stale layout"
20829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20830 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
20831 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20832 skip "Need MDS version at least 2.7.55"
20834 mkdir -p $DIR/$tdir/striped_dir
20835 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
20836 error "set default stripes dir error"
20838 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
20840 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
20841 [ $stripe_count -eq 0 ] ||
20842 error "expect 0 get $stripe_count for a"
20844 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
20845 error "set default stripes dir error"
20847 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
20849 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
20850 [ $stripe_count -eq 0 ] ||
20851 error "expect 0 get $stripe_count for b"
20853 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
20854 error "set default stripes dir error"
20856 mkdir $DIR/$tdir/striped_dir/c &&
20857 error "default stripe_index is invalid, mkdir c should fails"
20859 rm -rf $DIR/$tdir || error "rmdir fails"
20861 run_test 300m "setstriped directory on single MDT FS"
20864 local list=$(comma_list $(mdts_nodes))
20867 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20872 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20873 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20874 skip "Need MDS version at least 2.7.55"
20875 remote_mds_nodsh && skip "remote MDS with nodsh"
20878 local list=$(comma_list $(mdts_nodes))
20880 trap cleanup_300n RETURN EXIT
20881 mkdir -p $DIR/$tdir
20882 chmod 777 $DIR/$tdir
20883 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
20884 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
20885 error "create striped dir succeeds with gid=0"
20887 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
20888 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
20889 error "create striped dir fails with gid=-1"
20891 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20892 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
20893 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
20894 error "set default striped dir succeeds with gid=0"
20897 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
20898 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
20899 error "set default striped dir fails with gid=-1"
20902 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20903 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
20904 error "create test_dir fails"
20905 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
20906 error "create test_dir1 fails"
20907 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
20908 error "create test_dir2 fails"
20911 run_test 300n "non-root user to create dir under striped dir with default EA"
20914 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20915 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20916 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20917 skip "Need MDS version at least 2.7.55"
20922 mkdir -p $DIR/$tdir
20924 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
20925 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
20926 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
20927 skip "not enough free inodes $numfree1 $numfree2"
20930 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
20931 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
20932 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
20933 skip "not enough free space $numfree1 $numfree2"
20936 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
20937 error "setdirstripe fails"
20939 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
20940 error "create dirs fails"
20942 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
20943 ls $DIR/$tdir/striped_dir > /dev/null ||
20944 error "ls striped dir fails"
20945 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
20946 error "unlink big striped dir fails"
20948 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
20951 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20952 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20953 remote_mds_nodsh && skip "remote MDS with nodsh"
20955 mkdir -p $DIR/$tdir
20957 #define OBD_FAIL_OUT_ENOSPC 0x1704
20958 do_facet mds2 lctl set_param fail_loc=0x80001704
20959 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
20960 && error "create striped directory should fail"
20962 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
20964 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
20967 run_test 300p "create striped directory without space"
20970 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20971 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20973 local fd=$(free_fd)
20974 local cmd="exec $fd<$tdir"
20976 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
20979 trap "eval $cmd" EXIT
20980 cd $tdir || error "cd $tdir fails"
20981 rmdir ../$tdir || error "rmdir $tdir fails"
20982 mkdir local_dir && error "create dir succeeds"
20983 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
20987 run_test 300q "create remote directory under orphan directory"
20990 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20991 skip "Need MDS version at least 2.7.55" && return
20992 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
20996 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
20997 error "set striped dir error"
20999 $LFS getdirstripe $DIR/$tdir/striped_dir ||
21000 error "getstripeddir fails"
21003 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
21004 awk '/lmv_stripe_count:/ { print $2 }')
21006 [ $MDSCOUNT -ne $stripe_count ] &&
21007 error "wrong stripe count $stripe_count expected $MDSCOUNT"
21009 rm -rf $DIR/$tdir/striped_dir ||
21010 error "unlink striped dir fails"
21012 run_test 300r "test -1 striped directory"
21014 prepare_remote_file() {
21015 mkdir $DIR/$tdir/src_dir ||
21016 error "create remote source failed"
21018 cp /etc/hosts $DIR/$tdir/src_dir/a ||
21019 error "cp to remote source failed"
21020 touch $DIR/$tdir/src_dir/a
21022 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
21023 error "create remote target dir failed"
21025 touch $DIR/$tdir/tgt_dir/b
21027 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
21028 error "rename dir cross MDT failed!"
21030 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
21031 error "src_child still exists after rename"
21033 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
21034 error "missing file(a) after rename"
21036 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
21037 error "diff after rename"
21041 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
21042 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21044 local remote_file=$DIR/$tdir/tgt_dir/b
21046 mkdir -p $DIR/$tdir
21048 prepare_remote_file || error "prepare remote file failed"
21051 $OPENUNLINK $remote_file $remote_file ||
21052 error "openunlink $remote_file failed"
21053 $CHECKSTAT -a $remote_file || error "$remote_file exists"
21055 run_test 310a "open unlink remote file"
21058 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
21059 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21061 local remote_file=$DIR/$tdir/tgt_dir/b
21063 mkdir -p $DIR/$tdir
21065 prepare_remote_file || error "prepare remote file failed"
21067 ln $remote_file $DIR/$tfile || error "link failed for remote file"
21068 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
21069 $CHECKSTAT -t file $remote_file || error "check file failed"
21071 run_test 310b "unlink remote file with multiple links while open"
21074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21075 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
21077 local remote_file=$DIR/$tdir/tgt_dir/b
21079 mkdir -p $DIR/$tdir
21081 prepare_remote_file || error "prepare remote file failed"
21083 ln $remote_file $DIR/$tfile || error "link failed for remote file"
21084 multiop_bg_pause $remote_file O_uc ||
21085 error "mulitop failed for remote file"
21087 $MULTIOP $DIR/$tfile Ouc
21088 kill -USR1 $MULTIPID
21091 run_test 310c "open-unlink remote file with multiple links"
21095 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21096 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
21097 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
21098 skip "lustre < 2.8.54 does not contain LU-4825 fix"
21099 remote_mds_nodsh && skip "remote MDS with nodsh"
21101 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
21102 local mdts=$(comma_list $(mdts_nodes))
21104 mkdir -p $DIR/$tdir
21105 $LFS setstripe -i 0 -c 1 $DIR/$tdir
21106 createmany -o $DIR/$tdir/$tfile. 1000
21108 # statfs data is not real time, let's just calculate it
21109 old_iused=$((old_iused + 1000))
21111 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
21112 osp.*OST0000*MDT0000.create_count")
21113 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
21114 osp.*OST0000*MDT0000.max_create_count")
21115 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
21117 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
21118 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
21119 [ $index -ne 0 ] || error "$tfile stripe index is 0"
21121 unlinkmany $DIR/$tdir/$tfile. 1000
21123 do_nodes $mdts "$LCTL set_param -n \
21124 osp.*OST0000*.max_create_count=$max_count"
21125 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
21126 do_nodes $mdts "$LCTL set_param -n \
21127 osp.*OST0000*.create_count=$count"
21128 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
21129 grep "=0" && error "create_count is zero"
21132 for i in $(seq 120); do
21133 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
21134 # system may be too busy to destroy all objs in time, use
21135 # a somewhat small value to not fail autotest
21136 [ $((old_iused - new_iused)) -gt 400 ] && break
21140 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
21141 [ $((old_iused - new_iused)) -gt 400 ] ||
21142 error "objs not destroyed after unlink"
21144 run_test 311 "disable OSP precreate, and unlink should destroy objs"
21151 local vdevdir=$(dirname $(facet_vdevice $ost))
21152 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
21153 local zfs_zapid=$(do_facet $ost $cmd |
21154 grep -w "/O/0/d$((objid%32))" -C 5 |
21155 awk '/Object/{getline; print $1}')
21156 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
21157 awk "/$objid = /"'{printf $3}')
21162 zfs_object_blksz() {
21166 local vdevdir=$(dirname $(facet_vdevice $ost))
21167 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
21168 local blksz=$(do_facet $ost $cmd $objid |
21169 awk '/dblk/{getline; printf $4}')
21171 case "${blksz: -1}" in
21172 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
21173 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
21180 test_312() { # LU-4856
21181 remote_ost_nodsh && skip "remote OST with nodsh"
21182 [ "$ost1_FSTYPE" = "zfs" ] ||
21183 skip_env "the test only applies to zfs"
21185 local max_blksz=$(do_facet ost1 \
21186 $ZFS get -p recordsize $(facet_device ost1) |
21187 awk '!/VALUE/{print $3}')
21189 # to make life a little bit easier
21190 $LFS mkdir -c 1 -i 0 $DIR/$tdir
21191 $LFS setstripe -c 1 -i 0 $DIR/$tdir
21193 local tf=$DIR/$tdir/$tfile
21195 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
21197 # Get ZFS object id
21198 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
21199 # block size change by sequential overwrite
21202 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
21203 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
21205 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
21206 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
21210 # block size change by sequential append write
21211 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
21212 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
21213 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
21216 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
21217 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
21218 oflag=sync conv=notrunc
21220 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21221 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
21222 error "blksz error, actual $blksz, " \
21223 "expected: 2 * $count * $PAGE_SIZE"
21229 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
21230 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
21232 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
21233 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21234 [ $blksz -eq $PAGE_SIZE ] ||
21235 error "blksz error: $blksz, expected: $PAGE_SIZE"
21237 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
21238 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21239 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
21241 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
21242 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21243 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
21245 run_test 312 "make sure ZFS adjusts its block size by write pattern"
21248 remote_ost_nodsh && skip "remote OST with nodsh"
21250 local file=$DIR/$tfile
21253 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
21255 # define OBD_FAIL_TGT_RCVD_EIO 0x720
21256 do_facet ost1 "$LCTL set_param fail_loc=0x720"
21257 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
21258 error "write should failed"
21259 do_facet ost1 "$LCTL set_param fail_loc=0"
21262 run_test 313 "io should fail after last_rcvd update fail"
21265 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
21267 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
21268 do_facet ost1 "$LCTL set_param fail_loc=0x720"
21270 wait_delete_completed
21271 do_facet ost1 "$LCTL set_param fail_loc=0"
21273 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
21275 test_315() { # LU-618
21276 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
21278 local file=$DIR/$tfile
21281 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
21282 error "multiop file write failed"
21283 $MULTIOP $file oO_RDONLY:r4063232_c &
21288 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
21291 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
21294 run_test 315 "read should be accounted"
21297 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21298 large_xattr_enabled || skip_env "ea_inode feature disabled"
21300 rm -rf $DIR/$tdir/d
21301 mkdir -p $DIR/$tdir/d
21302 chown nobody $DIR/$tdir/d
21303 touch $DIR/$tdir/d/file
21305 $LFS mv -m1 $DIR/$tdir/d || error "lfs mv failed"
21307 run_test 316 "lfs mv"
21310 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
21311 skip "Need MDS version at least 2.11.53"
21312 if [ "$ost1_FSTYPE" == "zfs" ]; then
21313 skip "LU-10370: no implementation for ZFS"
21317 local grant_blk_size
21319 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
21320 awk '/grant_block_size:/ { print $2; exit; }')
21322 # Create File of size 5M. Truncate it to below size's and verify
21325 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
21326 error "Create file $DIR/$tfile failed"
21327 stack_trap "rm -f $DIR/$tfile" EXIT
21329 for trunc_sz in 2097152 4097 4000 509 0; do
21330 $TRUNCATE $DIR/$tfile $trunc_sz ||
21331 error "truncate $tfile to $trunc_sz failed"
21332 local sz=$(stat --format=%s $DIR/$tfile)
21333 local blk=$(stat --format=%b $DIR/$tfile)
21334 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
21335 grant_blk_size) * 8))
21337 if [[ $blk -ne $trunc_blk ]]; then
21338 $(which stat) $DIR/$tfile
21339 error "Expected Block $trunc_blk got $blk for $tfile"
21342 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
21343 error "Expected Size $trunc_sz got $sz for $tfile"
21348 # Create file with a hole and write actual two blocks. Block count
21351 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
21352 conv=fsync || error "Create file : $DIR/$tfile"
21354 # Calculate the final truncate size.
21355 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
21358 # truncate to size $trunc_sz bytes. Strip the last block
21359 # The block count must drop to 8
21361 $TRUNCATE $DIR/$tfile $trunc_sz ||
21362 error "truncate $tfile to $trunc_sz failed"
21364 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
21365 sz=$(stat --format=%s $DIR/$tfile)
21366 blk=$(stat --format=%b $DIR/$tfile)
21368 if [[ $blk -ne $trunc_bsz ]]; then
21369 $(which stat) $DIR/$tfile
21370 error "Expected Block $trunc_bsz got $blk for $tfile"
21373 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
21374 error "Expected Size $trunc_sz got $sz for $tfile"
21376 run_test 317 "Verify blocks get correctly update after truncate"
21379 local old_max_active=$($LCTL get_param -n \
21380 llite.*.max_read_ahead_async_active 2>/dev/null)
21382 $LCTL set_param llite.*.max_read_ahead_async_active=256
21383 local max_active=$($LCTL get_param -n \
21384 llite.*.max_read_ahead_async_active 2>/dev/null)
21385 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
21387 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
21388 error "set max_read_ahead_async_active should succeed"
21390 $LCTL set_param llite.*.max_read_ahead_async_active=512
21391 max_active=$($LCTL get_param -n \
21392 llite.*.max_read_ahead_async_active 2>/dev/null)
21393 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
21395 # restore @max_active
21396 [ $old_max_active -ne 0 ] && $LCTL set_param \
21397 llite.*.max_read_ahead_async_active=$old_max_active
21399 local old_threshold=$($LCTL get_param -n \
21400 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
21401 local max_per_file_mb=$($LCTL get_param -n \
21402 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
21404 local invalid=$(($max_per_file_mb + 1))
21406 llite.*.read_ahead_async_file_threshold_mb=$invalid\
21407 && error "set $invalid should fail"
21409 local valid=$(($invalid - 1))
21411 llite.*.read_ahead_async_file_threshold_mb=$valid ||
21412 error "set $valid should succeed"
21413 local threshold=$($LCTL get_param -n \
21414 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
21415 [ $threshold -eq $valid ] || error \
21416 "expect threshold $valid got $threshold"
21418 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
21420 run_test 318 "Verify async readahead tunables"
21423 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
21425 local before=$(date +%s)
21427 local mdir=$DIR/$tdir
21428 local file=$mdir/xxx
21430 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
21433 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
21434 $LCTL set_param fail_val=5 fail_loc=0x8000032c
21435 $LFS mv -m1 $file &
21438 dd if=$file of=/dev/null
21440 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
21441 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
21443 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
21445 run_test 319 "lost lease lock on migrate error"
21447 test_398a() { # LU-4198
21448 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21449 $LCTL set_param ldlm.namespaces.*.lru_size=clear
21451 # request a new lock on client
21452 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21454 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
21455 local lock_count=$($LCTL get_param -n \
21456 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
21457 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
21459 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
21461 # no lock cached, should use lockless IO and not enqueue new lock
21462 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
21463 lock_count=$($LCTL get_param -n \
21464 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
21465 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
21467 run_test 398a "direct IO should cancel lock otherwise lockless"
21469 test_398b() { # LU-4198
21470 which fio || skip_env "no fio installed"
21471 $LFS setstripe -c -1 $DIR/$tfile
21474 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
21477 echo "mix direct rw ${size}M to OST0 by fio with $njobs jobs..."
21478 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
21479 --numjobs=$njobs --fallocate=none \
21480 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21481 --filename=$DIR/$tfile &
21484 echo "mix buffer rw ${size}M to OST0 by fio with $njobs jobs..."
21485 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE \
21486 --numjobs=$njobs --fallocate=none \
21487 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21488 --filename=$DIR/$tfile || true
21493 run_test 398b "DIO and buffer IO race"
21495 test_398c() { # LU-4198
21496 which fio || skip_env "no fio installed"
21498 saved_debug=$($LCTL get_param -n debug)
21499 $LCTL set_param debug=0
21501 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
21502 ((size /= 1024)) # by megabytes
21503 ((size /= 2)) # write half of the OST at most
21504 [ $size -gt 40 ] && size=40 #reduce test time anyway
21506 $LFS setstripe -c 1 $DIR/$tfile
21508 # it seems like ldiskfs reserves more space than necessary if the
21509 # writing blocks are not mapped, so it extends the file firstly
21510 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
21511 cancel_lru_locks osc
21513 # clear and verify rpc_stats later
21514 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
21517 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
21518 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
21519 --numjobs=$njobs --fallocate=none --ioengine=libaio \
21520 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21521 --filename=$DIR/$tfile
21522 [ $? -eq 0 ] || error "fio write error"
21524 [ $($LCTL get_param -n \
21525 ldlm.namespaces.${FSNAME}-OST0000-osc-ffff*.lock_count) -eq 0 ] ||
21526 error "Locks were requested while doing AIO"
21528 # get the percentage of 1-page I/O
21529 pct=$($LCTL get_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats |
21530 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
21532 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
21534 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
21535 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
21536 --numjobs=$njobs --fallocate=none --ioengine=libaio \
21537 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21538 --filename=$DIR/$tfile
21539 [ $? -eq 0 ] || error "fio mixed read write error"
21542 $LCTL set_param debug="$saved_debug"
21544 run_test 398c "run fio to test AIO"
21547 local read_write=$1
21548 if [ "$read_write" = "write" ]; then
21549 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
21550 elif [ "$read_write" = "read" ]; then
21551 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
21553 error "argument error"
21556 # turn off debug for performance testing
21557 local saved_debug=$($LCTL get_param -n debug)
21558 $LCTL set_param debug=0
21560 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21562 # get ost1 size - $FSNAME-OST0000
21563 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
21564 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
21565 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
21567 if [ "$read_write" = "read" ]; then
21568 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
21571 local start_time=$(date +%s.%N)
21572 $dd_cmd bs=1M count=$blocks oflag=sync ||
21573 error "real dd $read_write error"
21574 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
21576 if [ "$read_write" = "write" ]; then
21580 # define OBD_FAIL_OST_FAKE_RW 0x238
21581 do_facet ost1 $LCTL set_param fail_loc=0x238
21583 local start_time=$(date +%s.%N)
21584 $dd_cmd bs=1M count=$blocks oflag=sync ||
21585 error "fake dd $read_write error"
21586 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
21588 if [ "$read_write" = "write" ]; then
21590 cancel_lru_locks osc
21591 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
21592 error "$tfile size not $blocks MB"
21594 do_facet ost1 $LCTL set_param fail_loc=0
21596 echo "fake $read_write $duration_fake vs. normal $read_write" \
21597 "$duration in seconds"
21598 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
21599 error_not_in_vm "fake write is slower"
21601 $LCTL set_param -n debug="$saved_debug"
21604 test_399a() { # LU-7655 for OST fake write
21605 remote_ost_nodsh && skip "remote OST with nodsh"
21609 run_test 399a "fake write should not be slower than normal write"
21611 test_399b() { # LU-8726 for OST fake read
21612 remote_ost_nodsh && skip "remote OST with nodsh"
21613 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
21614 skip_env "ldiskfs only test"
21619 run_test 399b "fake read should not be slower than normal read"
21621 test_400a() { # LU-1606, was conf-sanity test_74
21622 if ! which $CC > /dev/null 2>&1; then
21623 skip_env "$CC is not installed"
21626 local extra_flags=''
21627 local out=$TMP/$tfile
21628 local prefix=/usr/include/lustre
21631 # Oleg removes c files in his test rig so test if any c files exist
21632 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
21633 skip_env "Needed c test files are missing"
21635 if ! [[ -d $prefix ]]; then
21636 # Assume we're running in tree and fixup the include path.
21637 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
21638 extra_flags+=" -L$LUSTRE/utils/.lib"
21641 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
21642 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
21643 error "client api broken"
21647 run_test 400a "Lustre client api program can compile and link"
21649 test_400b() { # LU-1606, LU-5011
21651 local out=$TMP/$tfile
21652 local prefix=/usr/include/linux/lustre
21654 # We use a hard coded prefix so that this test will not fail
21655 # when run in tree. There are headers in lustre/include/lustre/
21656 # that are not packaged (like lustre_idl.h) and have more
21657 # complicated include dependencies (like config.h and lnet/types.h).
21658 # Since this test about correct packaging we just skip them when
21659 # they don't exist (see below) rather than try to fixup cppflags.
21661 if ! which $CC > /dev/null 2>&1; then
21662 skip_env "$CC is not installed"
21665 for header in $prefix/*.h; do
21666 if ! [[ -f "$header" ]]; then
21670 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
21671 continue # lustre_ioctl.h is internal header
21674 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
21675 error "cannot compile '$header'"
21679 run_test 400b "packaged headers can be compiled"
21681 test_401a() { #LU-7437
21682 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
21683 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
21685 #count the number of parameters by "list_param -R"
21686 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
21687 #count the number of parameters by listing proc files
21688 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
21689 echo "proc_dirs='$proc_dirs'"
21690 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
21691 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
21694 [ $params -eq $procs ] ||
21695 error "found $params parameters vs. $procs proc files"
21697 # test the list_param -D option only returns directories
21698 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
21699 #count the number of parameters by listing proc directories
21700 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
21703 [ $params -eq $procs ] ||
21704 error "found $params parameters vs. $procs proc files"
21706 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
21709 local save=$($LCTL get_param -n jobid_var)
21712 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
21713 error "no error returned when setting bad parameters"
21715 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
21716 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
21718 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
21719 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
21720 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
21722 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
21725 local jobid_var_old=$($LCTL get_param -n jobid_var)
21726 local jobid_var_new
21728 $LCTL set_param jobid_var= &&
21729 error "no error returned for 'set_param a='"
21731 jobid_var_new=$($LCTL get_param -n jobid_var)
21732 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
21733 error "jobid_var was changed by setting without value"
21735 $LCTL set_param jobid_var &&
21736 error "no error returned for 'set_param a'"
21738 jobid_var_new=$($LCTL get_param -n jobid_var)
21739 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
21740 error "jobid_var was changed by setting without value"
21742 run_test 401c "Verify 'lctl set_param' without value fails in either format."
21745 local jobid_var_old=$($LCTL get_param -n jobid_var)
21746 local jobid_var_new
21747 local new_value="foo=bar"
21749 $LCTL set_param jobid_var=$new_value ||
21750 error "'set_param a=b' did not accept a value containing '='"
21752 jobid_var_new=$($LCTL get_param -n jobid_var)
21753 [[ "$jobid_var_new" == "$new_value" ]] ||
21754 error "'set_param a=b' failed on a value containing '='"
21756 # Reset the jobid_var to test the other format
21757 $LCTL set_param jobid_var=$jobid_var_old
21758 jobid_var_new=$($LCTL get_param -n jobid_var)
21759 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
21760 error "failed to reset jobid_var"
21762 $LCTL set_param jobid_var $new_value ||
21763 error "'set_param a b' did not accept a value containing '='"
21765 jobid_var_new=$($LCTL get_param -n jobid_var)
21766 [[ "$jobid_var_new" == "$new_value" ]] ||
21767 error "'set_param a b' failed on a value containing '='"
21769 $LCTL set_param jobid_var $jobid_var_old
21770 jobid_var_new=$($LCTL get_param -n jobid_var)
21771 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
21772 error "failed to reset jobid_var"
21774 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
21777 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
21778 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
21779 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
21780 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
21781 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
21782 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
21783 remote_mds_nodsh && skip "remote MDS with nodsh"
21785 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
21786 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
21787 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
21788 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
21789 echo "Touch failed - OK"
21791 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
21794 local file1=$DIR/$tfile.1
21795 local file2=$DIR/$tfile.2
21796 local tfile=$TMP/$tfile
21798 rm -f $file1 $file2 $tfile
21803 # 30 sec OBD_TIMEOUT in ll_getattr()
21804 # right before populating st_nlink
21805 $LCTL set_param fail_loc=0x80001409
21806 stat -c %h $file1 > $tfile &
21808 # create an alias, drop all locks and reclaim the dentry
21810 cancel_lru_locks mdc
21811 cancel_lru_locks osc
21812 sysctl -w vm.drop_caches=2
21816 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
21818 rm -f $tfile $file1 $file2
21820 run_test 403 "i_nlink should not drop to zero due to aliasing"
21822 test_404() { # LU-6601
21823 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
21824 skip "Need server version newer than 2.8.52"
21825 remote_mds_nodsh && skip "remote MDS with nodsh"
21827 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
21828 awk '/osp .*-osc-MDT/ { print $4}')
21831 for osp in $mosps; do
21832 echo "Deactivate: " $osp
21833 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
21834 local stat=$(do_facet $SINGLEMDS $LCTL dl |
21835 awk -vp=$osp '$4 == p { print $2 }')
21836 [ $stat = IN ] || {
21837 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
21838 error "deactivate error"
21840 echo "Activate: " $osp
21841 do_facet $SINGLEMDS $LCTL --device %$osp activate
21842 local stat=$(do_facet $SINGLEMDS $LCTL dl |
21843 awk -vp=$osp '$4 == p { print $2 }')
21844 [ $stat = UP ] || {
21845 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
21846 error "activate error"
21850 run_test 404 "validate manual {de}activated works properly for OSPs"
21853 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
21854 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
21855 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
21856 skip "Layout swap lock is not supported"
21858 check_swap_layouts_support
21860 test_mkdir $DIR/$tdir
21861 swap_lock_test -d $DIR/$tdir ||
21862 error "One layout swap locked test failed"
21864 run_test 405 "Various layout swap lock tests"
21867 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21868 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
21869 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
21870 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21871 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
21872 skip "Need MDS version at least 2.8.50"
21874 local def_stripe_size=$($LFS getstripe -S $MOUNT)
21875 local test_pool=$TESTNAME
21877 pool_add $test_pool || error "pool_add failed"
21878 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
21879 error "pool_add_targets failed"
21881 save_layout_restore_at_exit $MOUNT
21883 # parent set default stripe count only, child will stripe from both
21884 # parent and fs default
21885 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
21886 error "setstripe $MOUNT failed"
21887 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
21888 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
21889 for i in $(seq 10); do
21890 local f=$DIR/$tdir/$tfile.$i
21891 touch $f || error "touch failed"
21892 local count=$($LFS getstripe -c $f)
21893 [ $count -eq $OSTCOUNT ] ||
21894 error "$f stripe count $count != $OSTCOUNT"
21895 local offset=$($LFS getstripe -i $f)
21896 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
21897 local size=$($LFS getstripe -S $f)
21898 [ $size -eq $((def_stripe_size * 2)) ] ||
21899 error "$f stripe size $size != $((def_stripe_size * 2))"
21900 local pool=$($LFS getstripe -p $f)
21901 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
21904 # change fs default striping, delete parent default striping, now child
21905 # will stripe from new fs default striping only
21906 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
21907 error "change $MOUNT default stripe failed"
21908 $LFS setstripe -c 0 $DIR/$tdir ||
21909 error "delete $tdir default stripe failed"
21910 for i in $(seq 11 20); do
21911 local f=$DIR/$tdir/$tfile.$i
21912 touch $f || error "touch $f failed"
21913 local count=$($LFS getstripe -c $f)
21914 [ $count -eq 1 ] || error "$f stripe count $count != 1"
21915 local offset=$($LFS getstripe -i $f)
21916 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
21917 local size=$($LFS getstripe -S $f)
21918 [ $size -eq $def_stripe_size ] ||
21919 error "$f stripe size $size != $def_stripe_size"
21920 local pool=$($LFS getstripe -p $f)
21921 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
21924 unlinkmany $DIR/$tdir/$tfile. 1 20
21926 local f=$DIR/$tdir/$tfile
21927 pool_remove_all_targets $test_pool $f
21928 pool_remove $test_pool $f
21930 run_test 406 "DNE support fs default striping"
21933 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21934 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
21935 skip "Need MDS version at least 2.8.55"
21936 remote_mds_nodsh && skip "remote MDS with nodsh"
21938 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
21939 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
21940 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
21941 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
21942 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
21944 #define OBD_FAIL_DT_TXN_STOP 0x2019
21945 for idx in $(seq $MDSCOUNT); do
21946 do_facet mds$idx "lctl set_param fail_loc=0x2019"
21948 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
21949 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
21950 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
21953 run_test 407 "transaction fail should cause operation fail"
21956 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
21958 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
21959 lctl set_param fail_loc=0x8000040a
21960 # let ll_prepare_partial_page() fail
21961 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
21965 # create at least 100 unused inodes so that
21966 # shrink_icache_memory(0) should not return 0
21967 touch $DIR/$tfile-{0..100}
21968 rm -f $DIR/$tfile-{0..100}
21971 echo 2 > /proc/sys/vm/drop_caches
21973 run_test 408 "drop_caches should not hang due to page leaks"
21977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21979 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
21980 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
21981 touch $DIR/$tdir/guard || error "(2) Fail to create"
21983 local PREFIX=$(str_repeat 'A' 128)
21984 echo "Create 1K hard links start at $(date)"
21985 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
21986 error "(3) Fail to hard link"
21988 echo "Links count should be right although linkEA overflow"
21989 stat $DIR/$tdir/guard || error "(4) Fail to stat"
21990 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
21991 [ $linkcount -eq 1001 ] ||
21992 error "(5) Unexpected hard links count: $linkcount"
21994 echo "List all links start at $(date)"
21995 ls -l $DIR/$tdir/foo > /dev/null ||
21996 error "(6) Fail to list $DIR/$tdir/foo"
21998 echo "Unlink hard links start at $(date)"
21999 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
22000 error "(7) Fail to unlink"
22001 echo "Unlink hard links finished at $(date)"
22003 run_test 409 "Large amount of cross-MDTs hard links on the same file"
22007 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
22008 skip "Need client version at least 2.9.59"
22010 # Create a file, and stat it from the kernel
22011 local testfile=$DIR/$tfile
22014 local run_id=$RANDOM
22015 local my_ino=$(stat --format "%i" $testfile)
22017 # Try to insert the module. This will always fail as the
22018 # module is designed to not be inserted.
22019 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
22022 # Anything but success is a test failure
22024 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
22025 error "no inode match"
22027 run_test 410 "Test inode number returned from kernel thread"
22029 cleanup_test411_cgroup() {
22035 local cg_basedir=/sys/fs/cgroup/memory
22037 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
22038 skip "no setup for cgroup"
22040 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
22041 error "test file creation failed"
22042 cancel_lru_locks osc
22044 # Create a very small memory cgroup to force a slab allocation error
22045 local cgdir=$cg_basedir/osc_slab_alloc
22046 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
22047 trap "cleanup_test411_cgroup $cgdir" EXIT
22048 echo 2M > $cgdir/memory.kmem.limit_in_bytes
22049 echo 1M > $cgdir/memory.limit_in_bytes
22051 # Should not LBUG, just be killed by oom-killer
22052 # dd will return 0 even allocation failure in some environment.
22053 # So don't check return value
22054 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
22055 cleanup_test411_cgroup $cgdir
22059 run_test 411 "Slab allocation error with cgroup does not LBUG"
22062 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22063 if [ $MDS1_VERSION -lt $(version_code 2.10.55) ]; then
22064 skip "Need server version at least 2.10.55"
22067 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
22068 error "mkdir failed"
22069 $LFS getdirstripe $DIR/$tdir
22070 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
22071 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
22072 error "expect $((MDSCOUT - 1)) get $stripe_index"
22073 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
22074 [ $stripe_count -eq 2 ] ||
22075 error "expect 2 get $stripe_count"
22077 run_test 412 "mkdir on specific MDTs"
22081 local stripe_count=$2
22082 local mdts=$(comma_list $(mdts_nodes))
22085 local lmv_qos_prio_free
22086 local lmv_qos_threshold_rr
22087 local lmv_qos_maxage
22088 local lod_qos_prio_free
22089 local lod_qos_threshold_rr
22090 local lod_qos_maxage
22094 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
22095 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
22096 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
22098 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
22099 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
22100 stack_trap "$LCTL set_param \
22101 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null" EXIT
22102 stack_trap "$LCTL set_param \
22103 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
22104 stack_trap "$LCTL set_param \
22105 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" EXIT
22107 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
22108 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
22109 lod_qos_prio_free=${lod_qos_prio_free%%%}
22110 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
22111 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
22112 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
22113 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
22114 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
22115 stack_trap "do_nodes $mdts $LCTL set_param \
22116 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null" EXIT
22117 stack_trap "do_nodes $mdts $LCTL set_param \
22118 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null" \
22120 stack_trap "do_nodes $mdts $LCTL set_param \
22121 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" EXIT
22124 echo "Mkdir (stripe_count $stripe_count) roundrobin:"
22126 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
22127 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
22129 testdir=$DIR/$tdir-s$stripe_count/rr
22131 for i in $(seq $((100 * MDSCOUNT))); do
22132 eval $mkdir_cmd $testdir/subdir$i ||
22133 error "$mkdir_cmd subdir$i failed"
22136 for i in $(seq $MDSCOUNT); do
22137 count=$($LFS getdirstripe -i $testdir/* |
22138 grep ^$((i - 1))$ | wc -l)
22139 echo "$count directories created on MDT$((i - 1))"
22140 [ $count -eq 100 ] || error "subdirs are not evenly distributed"
22142 if [ $stripe_count -gt 1 ]; then
22143 count=$($LFS getdirstripe $testdir/* |
22144 grep -P "^\s+$((i - 1))\t" | wc -l)
22145 echo "$count stripes created on MDT$((i - 1))"
22146 # deviation should < 5% of average
22147 [ $count -lt $((95 * stripe_count)) ] ||
22148 [ $count -gt $((105 * stripe_count)) ] &&
22149 error "stripes are not evenly distributed"
22153 $LCTL set_param lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null
22154 do_nodes $mdts $LCTL set_param \
22155 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null
22158 echo "Check for uneven MDTs: "
22168 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
22169 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
22170 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
22172 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
22173 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
22176 for ((i = 1; i < ${#ffree[@]}; i++)); do
22177 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
22178 if [ $tmp -gt $max ]; then
22182 if [ $tmp -lt $min ]; then
22188 [ ${ffree[min_index]} -eq 0 ] &&
22189 skip "no free files in MDT$min_index"
22190 [ ${ffree[min_index]} -gt 100000000 ] &&
22191 skip "too much free files in MDT$min_index"
22193 # Check if we need to generate uneven MDTs
22195 local diff=$(((max - min) * 100 / min))
22196 local value="$(generate_string 1024)"
22198 while [ $diff -lt $threshold ]; do
22199 # generate uneven MDTs, create till $threshold% diff
22200 echo -n "weight diff=$diff% must be > $threshold% ..."
22201 count=$((${ffree[min_index]} / 10))
22202 # 50 sec per 10000 files in vm
22203 [ $count -gt 40000 ] && [ "$SLOW" = "no" ] &&
22204 skip "$count files to create"
22205 echo "Fill MDT$min_index with $count files"
22206 [ -d $DIR/$tdir-MDT$min_index ] ||
22207 $LFS mkdir -i $min_index $DIR/$tdir-MDT$min_index ||
22208 error "mkdir $tdir-MDT$min_index failed"
22209 for i in $(seq $count); do
22210 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE \
22211 $DIR/$tdir-MDT$min_index/f$j_$i > /dev/null ||
22212 error "create f$j_$i failed"
22213 setfattr -n user.413b -v $value \
22214 $DIR/$tdir-MDT$min_index/f$j_$i ||
22215 error "setfattr f$j_$i failed"
22218 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
22219 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
22220 max=$(((${ffree[max_index]} >> 8) * \
22221 (${bavail[max_index]} * bsize >> 16)))
22222 min=$(((${ffree[min_index]} >> 8) * \
22223 (${bavail[min_index]} * bsize >> 16)))
22224 diff=$(((max - min) * 100 / min))
22227 echo "MDT filesfree available: ${ffree[@]}"
22228 echo "MDT blocks available: ${bavail[@]}"
22229 echo "weight diff=$diff%"
22232 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
22234 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
22235 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
22236 # decrease statfs age, so that it can be updated in time
22237 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
22238 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
22242 testdir=$DIR/$tdir-s$stripe_count/qos
22244 for i in $(seq $((100 * MDSCOUNT))); do
22245 eval $mkdir_cmd $testdir/subdir$i ||
22246 error "$mkdir_cmd subdir$i failed"
22249 for i in $(seq $MDSCOUNT); do
22250 count=$($LFS getdirstripe -i $testdir/* | grep ^$((i - 1))$ |
22252 echo "$count directories created on MDT$((i - 1))"
22254 if [ $stripe_count -gt 1 ]; then
22255 count=$($LFS getdirstripe $testdir/* |
22256 grep -P "^\s+$((i - 1))\t" | wc -l)
22257 echo "$count stripes created on MDT$((i - 1))"
22261 max=$($LFS getdirstripe -i $testdir/* | grep ^$max_index$ | wc -l)
22262 min=$($LFS getdirstripe -i $testdir/* | grep ^$min_index$ | wc -l)
22264 # D-value should > 10% of averge
22265 [ $((max - min)) -lt 10 ] &&
22266 error "subdirs shouldn't be evenly distributed"
22269 if [ $stripe_count -gt 1 ]; then
22270 max=$($LFS getdirstripe $testdir/* |
22271 grep -P "^\s+$max_index\t" | wc -l)
22272 min=$($LFS getdirstripe $testdir/* |
22273 grep -P "^\s+$min_index\t" | wc -l)
22274 [ $((max - min)) -le $((10 * stripe_count)) ] &&
22275 error "stripes shouldn't be evenly distributed"|| true
22280 [ $MDSCOUNT -lt 2 ] &&
22281 skip "We need at least 2 MDTs for this test"
22283 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
22284 skip "Need server version at least 2.12.52"
22288 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
22289 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
22290 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
22291 mkdir $DIR/$tdir-s$stripe_count/qos || error "mkdir failed"
22292 test_qos_mkdir "$LFS mkdir -c $stripe_count" $stripe_count
22295 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
22298 [ $MDSCOUNT -lt 2 ] &&
22299 skip "We need at least 2 MDTs for this test"
22301 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
22302 skip "Need server version at least 2.12.52"
22306 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
22307 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
22308 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
22309 mkdir $DIR/$tdir-s$stripe_count/qos || error "mkdir failed"
22310 $LFS setdirstripe -D -c $stripe_count \
22311 $DIR/$tdir-s$stripe_count/rr ||
22312 error "setdirstripe failed"
22313 $LFS setdirstripe -D -c $stripe_count \
22314 $DIR/$tdir-s$stripe_count/qos ||
22315 error "setdirstripe failed"
22316 test_qos_mkdir "mkdir" $stripe_count
22319 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
22322 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
22323 $LCTL set_param fail_loc=0x80000521
22324 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
22327 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
22330 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22331 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22332 skip "Need server version at least 2.11.52"
22342 # this test may be slow on ZFS
22343 [ "$mds1_FSTYPE" == "zfs" ] && total=100
22345 # though this test is designed for striped directory, let's test normal
22346 # directory too since lock is always saved as CoS lock.
22347 test_mkdir $DIR/$tdir || error "mkdir $tdir"
22348 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
22357 start_time=$(date +%s)
22358 for i in $(seq $total); do
22359 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
22362 end_time=$(date +%s)
22363 duration=$((end_time - start_time))
22365 kill -9 $setattr_pid
22367 echo "rename $total files took $duration sec"
22368 [ $duration -lt 100 ] || error "rename took $duration sec"
22370 run_test 415 "lock revoke is not missing"
22373 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
22374 skip "Need server version at least 2.11.55"
22376 # define OBD_FAIL_OSD_TXN_START 0x19a
22377 do_facet mds1 lctl set_param fail_loc=0x19a
22379 lfs mkdir -c $MDSCOUNT $DIR/$tdir
22383 run_test 416 "transaction start failure won't cause system hung"
22387 do_nodes $(comma_list $(mdts_nodes)) \
22388 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
22389 do_nodes $(comma_list $(mdts_nodes)) \
22390 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
22391 do_nodes $(comma_list $(mdts_nodes)) \
22392 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
22396 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22397 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
22398 skip "Need MDS version at least 2.11.56"
22400 trap cleanup_417 RETURN EXIT
22402 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
22403 do_nodes $(comma_list $(mdts_nodes)) \
22404 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
22405 $LFS migrate -m 0 $DIR/$tdir.1 &&
22406 error "migrate dir $tdir.1 should fail"
22408 do_nodes $(comma_list $(mdts_nodes)) \
22409 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
22410 $LFS mkdir -i 1 $DIR/$tdir.2 &&
22411 error "create remote dir $tdir.2 should fail"
22413 do_nodes $(comma_list $(mdts_nodes)) \
22414 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
22415 $LFS mkdir -c 2 $DIR/$tdir.3 &&
22416 error "create striped dir $tdir.3 should fail"
22419 run_test 417 "disable remote dir, striped dir and dir migration"
22421 # Checks that the outputs of df [-i] and lfs df [-i] match
22423 # usage: check_lfs_df <blocks | inodes> <mountpoint>
22433 [ "$1" == "blocks" ] && inodes= || inodes="-i"
22435 for count in {1..100}; do
22439 # read the lines of interest
22440 df_out=($(df -P $inodes $dir | tail -n +2)) ||
22441 error "df $inodes $dir | tail -n +2 failed"
22442 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
22443 error "lfs df $inodes $dir | grep summary: failed"
22445 # skip first substrings of each output as they are different
22446 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
22447 # compare the two outputs
22449 for i in {1..5}; do
22450 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
22458 lfs df $inodes $dir
22459 error "df and lfs df $1 output mismatch: " \
22460 "df ${inodes}: ${df_out[*]}, " \
22461 "lfs df ${inodes}: ${lfs_df_out[*]}"
22466 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22468 local dir=$DIR/$tdir
22469 local numfiles=$((RANDOM % 4096 + 2))
22470 local numblocks=$((RANDOM % 256 + 1))
22472 wait_delete_completed
22475 # check block output
22476 check_lfs_df blocks $dir
22477 # check inode output
22478 check_lfs_df inodes $dir
22480 # create a single file and retest
22481 echo "Creating a single file and testing"
22482 createmany -o $dir/$tfile- 1 &>/dev/null ||
22483 error "creating 1 file in $dir failed"
22484 check_lfs_df blocks $dir
22485 check_lfs_df inodes $dir
22487 # create a random number of files
22488 echo "Creating $((numfiles - 1)) files and testing"
22489 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
22490 error "creating $((numfiles - 1)) files in $dir failed"
22492 # write a random number of blocks to the first test file
22493 echo "Writing $numblocks 4K blocks and testing"
22494 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
22495 count=$numblocks &>/dev/null ||
22496 error "dd to $dir/${tfile}-0 failed"
22499 check_lfs_df blocks $dir
22500 check_lfs_df inodes $dir
22502 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
22503 error "unlinking $numfiles files in $dir failed"
22505 run_test 418 "df and lfs df outputs match"
22509 local dir=$DIR/$tdir
22514 cancel_lru_locks mdc
22516 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
22517 $LCTL set_param fail_loc=0x1410
22519 $LCTL set_param fail_loc=0
22522 run_test 419 "Verify open file by name doesn't crash kernel"
22526 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
22527 skip "Need MDS version at least 2.12.53"
22529 local SAVE_UMASK=$(umask)
22530 local dir=$DIR/$tdir
22531 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
22535 mkdir -m03777 $dir/testdir
22536 ls -dn $dir/testdir
22537 # Need to remove trailing '.' when SELinux is enabled
22538 local dirperms=$(ls -dn $dir/testdir |
22539 awk '{ sub(/\.$/, "", $1); print $1}')
22540 [ $dirperms == "drwxrwsrwt" ] ||
22541 error "incorrect perms on $dir/testdir"
22543 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
22544 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
22545 ls -n $dir/testdir/testfile
22546 local fileperms=$(ls -n $dir/testdir/testfile |
22547 awk '{ sub(/\.$/, "", $1); print $1}')
22548 [ $fileperms == "-rwxr-xr-x" ] ||
22549 error "incorrect perms on $dir/testdir/testfile"
22553 run_test 420 "clear SGID bit on non-directories for non-members"
22560 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22561 skip "Need MDS version at least 2.12.54"
22563 test_mkdir $DIR/$tdir
22564 createmany -o $DIR/$tdir/f 3
22565 cnt=$(ls -1 $DIR/$tdir | wc -l)
22566 [ $cnt != 3 ] && error "unexpected #files: $cnt"
22568 fid1=$(lfs path2fid $DIR/$tdir/f1)
22569 fid2=$(lfs path2fid $DIR/$tdir/f2)
22570 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
22572 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
22573 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
22575 cnt=$(ls -1 $DIR/$tdir | wc -l)
22576 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
22578 rm -f $DIR/$tdir/f3 || error "can't remove f3"
22579 createmany -o $DIR/$tdir/f 3
22580 cnt=$(ls -1 $DIR/$tdir | wc -l)
22581 [ $cnt != 3 ] && error "unexpected #files: $cnt"
22583 fid1=$(lfs path2fid $DIR/$tdir/f1)
22584 fid2=$(lfs path2fid $DIR/$tdir/f2)
22585 echo "remove using fsname $FSNAME"
22586 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
22588 cnt=$(ls -1 $DIR/$tdir | wc -l)
22589 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
22591 run_test 421a "simple rm by fid"
22598 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22599 skip "Need MDS version at least 2.12.54"
22601 test_mkdir $DIR/$tdir
22602 createmany -o $DIR/$tdir/f 3
22603 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
22606 FID1=$(lfs path2fid $DIR/$tdir/f1)
22607 FID2=$(lfs path2fid $DIR/$tdir/f2)
22608 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
22610 kill -USR1 $MULTIPID
22613 cnt=$(ls $DIR/$tdir | wc -l)
22614 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
22616 run_test 421b "rm by fid on open file"
22622 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22623 skip "Need MDS version at least 2.12.54"
22625 test_mkdir $DIR/$tdir
22626 createmany -o $DIR/$tdir/f 3
22627 touch $DIR/$tdir/$tfile
22628 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
22629 cnt=$(ls -1 $DIR/$tdir | wc -l)
22630 [ $cnt != 184 ] && error "unexpected #files: $cnt"
22632 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
22633 $LFS rmfid $DIR $FID1 || error "rmfid failed"
22635 cnt=$(ls $DIR/$tdir | wc -l)
22636 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
22638 run_test 421c "rm by fid against hardlinked files"
22644 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22645 skip "Need MDS version at least 2.12.54"
22647 test_mkdir $DIR/$tdir
22648 createmany -o $DIR/$tdir/f 4097
22649 cnt=$(ls -1 $DIR/$tdir | wc -l)
22650 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
22652 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
22653 $LFS rmfid $DIR $FIDS || error "rmfid failed"
22655 cnt=$(ls $DIR/$tdir | wc -l)
22657 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
22659 run_test 421d "rmfid en masse"
22665 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22666 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22667 skip "Need MDS version at least 2.12.54"
22669 mkdir -p $DIR/$tdir
22670 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
22671 createmany -o $DIR/$tdir/striped_dir/f 512
22672 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22673 [ $cnt != 512 ] && error "unexpected #files: $cnt"
22675 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
22676 sed "s/[/][^:]*://g")
22677 $LFS rmfid $DIR $FIDS || error "rmfid failed"
22679 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
22681 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
22683 run_test 421e "rmfid in DNE"
22689 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22690 skip "Need MDS version at least 2.12.54"
22692 test_mkdir $DIR/$tdir
22694 cnt=$(ls -1 $DIR/$tdir | wc -l)
22695 [ $cnt != 1 ] && error "unexpected #files: $cnt"
22697 FID=$(lfs path2fid $DIR/$tdir/f)
22698 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
22699 # rmfid should fail
22700 cnt=$(ls -1 $DIR/$tdir | wc -l)
22701 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
22703 chmod a+rw $DIR/$tdir
22705 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
22706 # rmfid should fail
22707 cnt=$(ls -1 $DIR/$tdir | wc -l)
22708 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
22711 $RUNAS touch $DIR/$tdir/f
22712 FID=$(lfs path2fid $DIR/$tdir/f)
22713 echo "rmfid as root"
22714 $LFS rmfid $DIR $FID || error "rmfid as root failed"
22715 cnt=$(ls -1 $DIR/$tdir | wc -l)
22716 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
22719 $RUNAS touch $DIR/$tdir/f
22720 cnt=$(ls -1 $DIR/$tdir | wc -l)
22721 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
22722 FID=$(lfs path2fid $DIR/$tdir/f)
22723 # rmfid w/o user_fid2path mount option should fail
22724 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
22725 cnt=$(ls -1 $DIR/$tdir | wc -l)
22726 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
22728 umount_client $MOUNT || error "failed to umount client"
22729 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
22730 error "failed to mount client'"
22732 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
22733 # rmfid should succeed
22734 cnt=$(ls -1 $DIR/$tdir | wc -l)
22735 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
22737 # rmfid shouldn't allow to remove files due to dir's permission
22738 chmod a+rwx $DIR/$tdir
22741 FID=$(lfs path2fid $DIR/$tdir/f)
22742 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
22744 umount_client $MOUNT || error "failed to umount client"
22745 mount_client $MOUNT "$MOUNT_OPTS" ||
22746 error "failed to mount client'"
22749 run_test 421f "rmfid checks permissions"
22755 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22756 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22757 skip "Need MDS version at least 2.12.54"
22759 mkdir -p $DIR/$tdir
22760 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
22761 createmany -o $DIR/$tdir/striped_dir/f 512
22762 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22763 [ $cnt != 512 ] && error "unexpected #files: $cnt"
22765 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
22766 sed "s/[/][^:]*://g")
22768 rm -f $DIR/$tdir/striped_dir/f1*
22769 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22770 removed=$((512 - cnt))
22772 # few files have been just removed, so we expect
22773 # rmfid to fail on their fids
22774 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
22775 [ $removed != $errors ] && error "$errors != $removed"
22777 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
22779 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
22781 run_test 421g "rmfid to return errors properly"
22784 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
22785 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
22786 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
22787 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
22788 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
22790 local amc=$(at_max_get client)
22791 local amo=$(at_max_get mds1)
22792 local timeout=`lctl get_param -n timeout`
22794 at_max_set 0 client
22797 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
22798 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
22799 fail_val=$(((2*timeout + 10)*1000))
22800 touch $DIR/$tdir/d3/file &
22802 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
22803 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
22804 fail_val=$((2*timeout + 5))
22805 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
22809 sleep $((2 * timeout))
22813 touch $DIR/$tdir/d2/file3
22814 touch $DIR/$tdir/d2/file4
22815 touch $DIR/$tdir/d2/file5
22818 at_max_set $amc client
22819 at_max_set $amo mds1
22821 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
22822 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
22823 error "Watchdog is always throttled"
22825 run_test 422 "kill a process with RPC in progress"
22838 # ensure statfs cache is expired
22841 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
22842 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
22846 run_test 423 "statfs should return a right data"
22849 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
22850 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
22851 skip "Need server version at least 2.9.55"
22853 start_full_debug_logging
22857 stop_full_debug_logging
22861 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
22862 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
22863 awk '/The barrier for/ { print $7 }')
22866 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
22871 barrier_expired() {
22874 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
22875 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
22876 awk '/will be expired/ { print $7 }')
22878 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
22887 echo "Start barrier_freeze at: $(date)"
22888 #define OBD_FAIL_BARRIER_DELAY 0x2202
22889 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
22890 # Do not reduce barrier time - See LU-11873
22891 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
22894 local b_status=$(barrier_stat)
22895 echo "Got barrier status at: $(date)"
22896 [ "$b_status" = "'freezing_p1'" ] ||
22897 error "(1) unexpected barrier status $b_status"
22899 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
22901 b_status=$(barrier_stat)
22902 [ "$b_status" = "'frozen'" ] ||
22903 error "(2) unexpected barrier status $b_status"
22905 local expired=$(barrier_expired)
22906 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
22907 sleep $((expired + 3))
22909 b_status=$(barrier_stat)
22910 [ "$b_status" = "'expired'" ] ||
22911 error "(3) unexpected barrier status $b_status"
22913 # Do not reduce barrier time - See LU-11873
22914 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
22915 error "(4) fail to freeze barrier"
22917 b_status=$(barrier_stat)
22918 [ "$b_status" = "'frozen'" ] ||
22919 error "(5) unexpected barrier status $b_status"
22921 echo "Start barrier_thaw at: $(date)"
22922 #define OBD_FAIL_BARRIER_DELAY 0x2202
22923 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
22924 do_facet mgs $LCTL barrier_thaw $FSNAME &
22927 b_status=$(barrier_stat)
22928 echo "Got barrier status at: $(date)"
22929 [ "$b_status" = "'thawing'" ] ||
22930 error "(6) unexpected barrier status $b_status"
22932 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
22934 b_status=$(barrier_stat)
22935 [ "$b_status" = "'thawed'" ] ||
22936 error "(7) unexpected barrier status $b_status"
22938 #define OBD_FAIL_BARRIER_FAILURE 0x2203
22939 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
22940 do_facet mgs $LCTL barrier_freeze $FSNAME
22942 b_status=$(barrier_stat)
22943 [ "$b_status" = "'failed'" ] ||
22944 error "(8) unexpected barrier status $b_status"
22946 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
22947 do_facet mgs $LCTL barrier_thaw $FSNAME
22951 run_test 801a "write barrier user interfaces and stat machine"
22956 mkdir $DIR/$tdir || error "(1) fail to mkdir"
22957 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
22958 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
22959 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
22960 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
22962 cancel_lru_locks mdc
22964 # 180 seconds should be long enough
22965 do_facet mgs $LCTL barrier_freeze $FSNAME 180
22967 local b_status=$(barrier_stat)
22968 [ "$b_status" = "'frozen'" ] ||
22969 error "(6) unexpected barrier status $b_status"
22971 mkdir $DIR/$tdir/d0/d10 &
22974 touch $DIR/$tdir/d1/f13 &
22977 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
22980 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
22983 rm -f $DIR/$tdir/d4/f12 &
22986 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
22988 # To guarantee taht the 'stat' is not blocked
22989 b_status=$(barrier_stat)
22990 [ "$b_status" = "'frozen'" ] ||
22991 error "(8) unexpected barrier status $b_status"
22993 # let above commands to run at background
22996 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
22997 ps -p $touch_pid || error "(10) touch should be blocked"
22998 ps -p $ln_pid || error "(11) link should be blocked"
22999 ps -p $mv_pid || error "(12) rename should be blocked"
23000 ps -p $rm_pid || error "(13) unlink should be blocked"
23002 b_status=$(barrier_stat)
23003 [ "$b_status" = "'frozen'" ] ||
23004 error "(14) unexpected barrier status $b_status"
23006 do_facet mgs $LCTL barrier_thaw $FSNAME
23007 b_status=$(barrier_stat)
23008 [ "$b_status" = "'thawed'" ] ||
23009 error "(15) unexpected barrier status $b_status"
23011 wait $mkdir_pid || error "(16) mkdir should succeed"
23012 wait $touch_pid || error "(17) touch should succeed"
23013 wait $ln_pid || error "(18) link should succeed"
23014 wait $mv_pid || error "(19) rename should succeed"
23015 wait $rm_pid || error "(20) unlink should succeed"
23019 run_test 801b "modification will be blocked by write barrier"
23022 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23026 stop mds2 || error "(1) Fail to stop mds2"
23028 do_facet mgs $LCTL barrier_freeze $FSNAME 30
23030 local b_status=$(barrier_stat)
23031 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
23032 do_facet mgs $LCTL barrier_thaw $FSNAME
23033 error "(2) unexpected barrier status $b_status"
23036 do_facet mgs $LCTL barrier_rescan $FSNAME ||
23037 error "(3) Fail to rescan barrier bitmap"
23039 # Do not reduce barrier time - See LU-11873
23040 do_facet mgs $LCTL barrier_freeze $FSNAME 20
23042 b_status=$(barrier_stat)
23043 [ "$b_status" = "'frozen'" ] ||
23044 error "(4) unexpected barrier status $b_status"
23046 do_facet mgs $LCTL barrier_thaw $FSNAME
23047 b_status=$(barrier_stat)
23048 [ "$b_status" = "'thawed'" ] ||
23049 error "(5) unexpected barrier status $b_status"
23051 local devname=$(mdsdevname 2)
23053 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
23055 do_facet mgs $LCTL barrier_rescan $FSNAME ||
23056 error "(7) Fail to rescan barrier bitmap"
23060 run_test 801c "rescan barrier bitmap"
23062 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
23063 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
23064 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
23065 saved_MOUNT_OPTS=$MOUNT_OPTS
23071 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
23072 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
23073 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
23074 MOUNT_OPTS=$saved_MOUNT_OPTS
23079 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
23080 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
23081 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
23082 skip "Need server version at least 2.9.55"
23084 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
23086 mkdir $DIR/$tdir || error "(1) fail to mkdir"
23088 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
23089 error "(2) Fail to copy"
23091 trap cleanup_802a EXIT
23093 # sync by force before remount as readonly
23094 sync; sync_all_data; sleep 3; sync_all_data
23098 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
23099 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
23100 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
23102 echo "Mount the server as read only"
23103 setupall server_only || error "(3) Fail to start servers"
23105 echo "Mount client without ro should fail"
23106 mount_client $MOUNT &&
23107 error "(4) Mount client without 'ro' should fail"
23109 echo "Mount client with ro should succeed"
23110 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
23111 mount_client $MOUNT ||
23112 error "(5) Mount client with 'ro' should succeed"
23114 echo "Modify should be refused"
23115 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
23117 echo "Read should be allowed"
23118 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
23119 error "(7) Read should succeed under ro mode"
23123 run_test 802a "simulate readonly device"
23126 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23127 remote_mds_nodsh && skip "remote MDS with nodsh"
23129 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
23130 skip "readonly option not available"
23132 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
23134 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
23135 error "(2) Fail to copy"
23137 # write back all cached data before setting MDT to readonly
23141 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
23142 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
23144 echo "Modify should be refused"
23145 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
23147 echo "Read should be allowed"
23148 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
23149 error "(7) Read should succeed under ro mode"
23152 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
23154 run_test 802b "be able to set MDTs to readonly"
23157 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23158 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
23159 skip "MDS needs to be newer than 2.10.54"
23161 mkdir -p $DIR/$tdir
23162 # Create some objects on all MDTs to trigger related logs objects
23163 for idx in $(seq $MDSCOUNT); do
23164 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
23165 $DIR/$tdir/dir${idx} ||
23166 error "Fail to create $DIR/$tdir/dir${idx}"
23170 wait_delete_completed # ensure old test cleanups are finished
23171 echo "before create:"
23173 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
23175 for i in {1..10}; do
23176 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
23177 error "Fail to create $DIR/$tdir/foo$i"
23181 echo "after create:"
23183 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
23185 # allow for an llog to be cleaned up during the test
23186 [ $after_used -ge $((before_used + 10 - 1)) ] ||
23187 error "before ($before_used) + 10 > after ($after_used)"
23189 for i in {1..10}; do
23190 rm -rf $DIR/$tdir/foo$i ||
23191 error "Fail to remove $DIR/$tdir/foo$i"
23194 sleep 3 # avoid MDT return cached statfs
23195 wait_delete_completed
23196 echo "after unlink:"
23198 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
23200 # allow for an llog to be created during the test
23201 [ $after_used -le $((before_used + 1)) ] ||
23202 error "after ($after_used) > before ($before_used) + 1"
23204 run_test 803 "verify agent object for remote object"
23207 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23208 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
23209 skip "MDS needs to be newer than 2.10.54"
23210 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
23212 mkdir -p $DIR/$tdir
23213 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
23214 error "Fail to create $DIR/$tdir/dir0"
23216 local fid=$($LFS path2fid $DIR/$tdir/dir0)
23217 local dev=$(mdsdevname 2)
23219 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23220 grep ${fid} || error "NOT found agent entry for dir0"
23222 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
23223 error "Fail to create $DIR/$tdir/dir1"
23225 touch $DIR/$tdir/dir1/foo0 ||
23226 error "Fail to create $DIR/$tdir/dir1/foo0"
23227 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
23230 for idx in $(seq $MDSCOUNT); do
23231 dev=$(mdsdevname $idx)
23232 do_facet mds${idx} \
23233 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23234 grep ${fid} && rc=$idx
23237 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
23238 error "Fail to rename foo0 to foo1"
23239 if [ $rc -eq 0 ]; then
23240 for idx in $(seq $MDSCOUNT); do
23241 dev=$(mdsdevname $idx)
23242 do_facet mds${idx} \
23243 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23244 grep ${fid} && rc=$idx
23248 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
23249 error "Fail to rename foo1 to foo2"
23250 if [ $rc -eq 0 ]; then
23251 for idx in $(seq $MDSCOUNT); do
23252 dev=$(mdsdevname $idx)
23253 do_facet mds${idx} \
23254 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23255 grep ${fid} && rc=$idx
23259 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
23261 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
23262 error "Fail to link to $DIR/$tdir/dir1/foo2"
23263 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
23264 error "Fail to rename foo2 to foo0"
23265 unlink $DIR/$tdir/dir1/foo0 ||
23266 error "Fail to unlink $DIR/$tdir/dir1/foo0"
23267 rm -rf $DIR/$tdir/dir0 ||
23268 error "Fail to rm $DIR/$tdir/dir0"
23270 for idx in $(seq $MDSCOUNT); do
23271 dev=$(mdsdevname $idx)
23275 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
23277 start mds${idx} $dev $MDS_MOUNT_OPTS ||
23278 error "mount mds$idx failed"
23279 df $MOUNT > /dev/null 2>&1
23281 # e2fsck should not return error
23283 error "e2fsck detected error on MDT${idx}: rc=$rc"
23286 run_test 804 "verify agent entry for remote entry"
23289 do_facet $SINGLEMDS zfs set quota=$old $fsset
23290 unlinkmany $DIR/$tdir/f- 1000000
23295 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
23296 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
23297 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
23298 skip "netfree not implemented before 0.7"
23299 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
23300 skip "Need MDS version at least 2.10.57"
23307 local pref="osd-zfs.$FSNAME-MDT0000."
23309 # limit available space on MDS dataset to meet nospace issue
23310 # quickly. then ZFS 0.7.2 can use reserved space if asked
23311 # properly (using netfree flag in osd_declare_destroy()
23312 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
23313 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
23315 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
23316 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
23317 let "usedkb=usedkb-freekb"
23318 let "freekb=freekb/2"
23319 if let "freekb > 5000"; then
23322 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
23323 trap cleanup_805 EXIT
23325 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
23326 error "Can't set PFL layout"
23327 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
23328 rm -rf $DIR/$tdir || error "not able to remove"
23329 do_facet $SINGLEMDS zfs set quota=$old $fsset
23332 run_test 805 "ZFS can remove from full fs"
23338 local size=$($LFS getsom -s $file)
23339 local expect=$(stat -c %s $file)
23341 [[ $size == $expect ]] ||
23342 error "$file expected size: $expect, got: $size"
23344 local blocks=$($LFS getsom -b $file)
23345 expect=$(stat -c %b $file)
23346 [[ $blocks == $expect ]] ||
23347 error "$file expected blocks: $expect, got: $blocks"
23352 local size=$($LFS getsom -s $1)
23355 [[ $size == $expect ]] ||
23356 error "$file expected size: $expect, got: $size"
23360 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
23361 skip "Need MDS version at least 2.11.52"
23365 touch $DIR/$tfile || error "touch $tfile failed"
23367 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
23368 save_lustre_params client "llite.*.xattr_cache" > $save
23369 lctl set_param llite.*.xattr_cache=0
23370 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
23372 # single-threaded write
23373 echo "Test SOM for single-threaded write"
23374 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
23375 error "write $tfile failed"
23376 check_lsom_size $DIR/$tfile $bs
23379 local size=$(($num * $bs))
23383 echo "Test SOM for single client multi-threaded($num) write"
23384 $TRUNCATE $DIR/$tfile 0
23385 for ((i = 0; i < $num; i++)); do
23386 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23388 offset=$((offset + $bs))
23390 for (( i=0; i < $num; i++ )); do
23393 check_lsom_size $DIR/$tfile $size
23395 $TRUNCATE $DIR/$tfile 0
23396 for ((i = 0; i < $num; i++)); do
23397 offset=$((offset - $bs))
23398 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23401 for (( i=0; i < $num; i++ )); do
23404 check_lsom_size $DIR/$tfile $size
23406 # multi-client writes
23407 num=$(get_node_count ${CLIENTS//,/ })
23408 size=$(($num * $bs))
23412 echo "Test SOM for multi-client ($num) writes"
23413 $TRUNCATE $DIR/$tfile 0
23414 for client in ${CLIENTS//,/ }; do
23415 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23418 offset=$((offset + $bs))
23420 for (( i=0; i < $num; i++ )); do
23423 check_lsom_size $DIR/$tfile $offset
23426 $TRUNCATE $DIR/$tfile 0
23427 for client in ${CLIENTS//,/ }; do
23428 offset=$((offset - $bs))
23429 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23433 for (( i=0; i < $num; i++ )); do
23436 check_lsom_size $DIR/$tfile $size
23439 echo "Test SOM for truncate"
23440 $TRUNCATE $DIR/$tfile 1048576
23441 check_lsom_size $DIR/$tfile 1048576
23442 $TRUNCATE $DIR/$tfile 1234
23443 check_lsom_size $DIR/$tfile 1234
23445 # verify SOM blocks count
23446 echo "Verify SOM block count"
23447 $TRUNCATE $DIR/$tfile 0
23448 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
23449 error "failed to write file $tfile"
23450 check_lsom_data $DIR/$tfile
23452 run_test 806 "Verify Lazy Size on MDS"
23455 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
23456 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
23457 skip "Need MDS version at least 2.11.52"
23459 # Registration step
23460 changelog_register || error "changelog_register failed"
23461 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
23462 changelog_users $SINGLEMDS | grep -q $cl_user ||
23463 error "User $cl_user not found in changelog_users"
23465 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
23466 save_lustre_params client "llite.*.xattr_cache" > $save
23467 lctl set_param llite.*.xattr_cache=0
23468 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
23470 rm -rf $DIR/$tdir || error "rm $tdir failed"
23471 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
23472 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
23473 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
23474 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
23475 error "truncate $tdir/trunc failed"
23478 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
23479 error "write $tfile failed"
23481 # multi-client wirtes
23482 local num=$(get_node_count ${CLIENTS//,/ })
23486 echo "Test SOM for multi-client ($num) writes"
23487 touch $DIR/$tfile || error "touch $tfile failed"
23488 $TRUNCATE $DIR/$tfile 0
23489 for client in ${CLIENTS//,/ }; do
23490 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23493 offset=$((offset + $bs))
23495 for (( i=0; i < $num; i++ )); do
23499 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
23500 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
23501 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
23502 check_lsom_data $DIR/$tdir/trunc
23503 check_lsom_data $DIR/$tdir/single_dd
23504 check_lsom_data $DIR/$tfile
23507 # Deregistration step
23508 changelog_deregister || error "changelog_deregister failed"
23510 run_test 807 "verify LSOM syncing tool"
23512 check_som_nologged()
23514 local lines=$($LFS changelog $FSNAME-MDT0000 |
23515 grep 'x=trusted.som' | wc -l)
23516 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
23520 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
23521 skip "Need MDS version at least 2.11.55"
23523 # Registration step
23524 changelog_register || error "changelog_register failed"
23526 touch $DIR/$tfile || error "touch $tfile failed"
23529 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
23530 error "write $tfile failed"
23533 $TRUNCATE $DIR/$tfile 1234
23536 $TRUNCATE $DIR/$tfile 1048576
23539 # Deregistration step
23540 changelog_deregister || error "changelog_deregister failed"
23542 run_test 808 "Check trusted.som xattr not logged in Changelogs"
23547 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
23551 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
23552 skip "Need MDS version at least 2.11.56"
23554 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
23555 error "failed to create DoM-only file $DIR/$tfile"
23556 touch $DIR/$tfile || error "touch $tfile failed"
23557 check_som_nodata $DIR/$tfile
23559 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
23560 error "write $tfile failed"
23561 check_som_nodata $DIR/$tfile
23563 $TRUNCATE $DIR/$tfile 1234
23564 check_som_nodata $DIR/$tfile
23566 $TRUNCATE $DIR/$tfile 4097
23567 check_som_nodata $DIR/$file
23569 run_test 809 "Verify no SOM xattr store for DoM-only files"
23572 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23573 $GSS && skip_env "could not run with gss"
23574 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
23575 skip "OST < 2.12.58 doesn't align checksum"
23578 stack_trap "set_checksums $ORIG_CSUM" EXIT
23579 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
23584 for csum in $CKSUM_TYPES; do
23585 #define OBD_FAIL_OSC_NO_GRANT 0x411
23586 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
23587 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
23589 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
23590 before=$(md5sum $DIR/$tfile)
23591 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
23592 after=$(md5sum $DIR/$tfile)
23593 [ "$before" == "$after" ] ||
23594 error "$csum: $before != $after bs=$1 seek=$2"
23598 run_test 810 "partial page writes on ZFS (LU-11663)"
23601 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
23602 skip "OST < 2.12.51 doesn't support this fail_loc"
23603 [ "$SHARED_KEY" = true ] &&
23604 skip "OSC connections never go IDLE with Shared-Keys enabled"
23606 $LFS setstripe -c 1 -i 0 $DIR/$tfile
23607 # ensure ost1 is connected
23608 stat $DIR/$tfile >/dev/null || error "can't stat"
23609 wait_osc_import_state client ost1 FULL
23610 # no locks, no reqs to let the connection idle
23611 cancel_lru_locks osc
23613 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
23614 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
23615 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
23616 wait_osc_import_state client ost1 CONNECTING
23617 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
23619 stat $DIR/$tfile >/dev/null || error "can't stat file"
23621 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
23623 test_812b() { # LU-12378
23624 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
23625 skip "OST < 2.12.51 doesn't support this fail_loc"
23626 [ "$SHARED_KEY" = true ] &&
23627 skip "OSC connections never go IDLE with Shared-Keys enabled"
23629 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
23630 # ensure ost1 is connected
23631 stat $DIR/$tfile >/dev/null || error "can't stat"
23632 wait_osc_import_state client ost1 FULL
23633 # no locks, no reqs to let the connection idle
23634 cancel_lru_locks osc
23636 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
23637 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
23638 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
23639 wait_osc_import_state client ost1 CONNECTING
23640 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
23642 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
23643 wait_osc_import_state client ost1 IDLE
23645 run_test 812b "do not drop no resend request for idle connect"
23648 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
23649 [ -z "$file_heat_sav" ] && skip "no file heat support"
23660 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
23661 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
23663 $LCTL set_param -n llite.*.file_heat=1
23664 echo "Turn on file heat"
23665 echo "Period second: $period_second, Decay percentage: $decay_pct"
23667 echo "QQQQ" > $DIR/$tfile
23668 echo "QQQQ" > $DIR/$tfile
23669 echo "QQQQ" > $DIR/$tfile
23670 cat $DIR/$tfile > /dev/null
23671 cat $DIR/$tfile > /dev/null
23672 cat $DIR/$tfile > /dev/null
23673 cat $DIR/$tfile > /dev/null
23675 local out=$($LFS heat_get $DIR/$tfile)
23677 $LFS heat_get $DIR/$tfile
23678 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23679 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23680 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23681 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23683 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
23684 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
23685 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
23686 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
23688 sleep $((period_second + 3))
23689 echo "Sleep $((period_second + 3)) seconds..."
23690 # The recursion formula to calculate the heat of the file f is as
23692 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
23693 # Where Hi is the heat value in the period between time points i*I and
23694 # (i+1)*I; Ci is the access count in the period; the symbol P refers
23695 # to the weight of Ci.
23696 out=$($LFS heat_get $DIR/$tfile)
23697 $LFS heat_get $DIR/$tfile
23698 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23699 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23700 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23701 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23703 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
23704 error "read sample ($readsample) is wrong"
23705 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
23706 error "write sample ($writesample) is wrong"
23707 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
23708 error "read bytes ($readbyte) is wrong"
23709 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
23710 error "write bytes ($writebyte) is wrong"
23712 echo "QQQQ" > $DIR/$tfile
23713 echo "QQQQ" > $DIR/$tfile
23714 echo "QQQQ" > $DIR/$tfile
23715 cat $DIR/$tfile > /dev/null
23716 cat $DIR/$tfile > /dev/null
23717 cat $DIR/$tfile > /dev/null
23718 cat $DIR/$tfile > /dev/null
23720 sleep $((period_second + 3))
23721 echo "Sleep $((period_second + 3)) seconds..."
23723 out=$($LFS heat_get $DIR/$tfile)
23724 $LFS heat_get $DIR/$tfile
23725 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23726 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23727 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23728 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23730 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
23731 4 * $decay_pct) / 100") -eq 1 ] ||
23732 error "read sample ($readsample1) is wrong"
23733 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
23734 3 * $decay_pct) / 100") -eq 1 ] ||
23735 error "write sample ($writesample1) is wrong"
23736 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
23737 20 * $decay_pct) / 100") -eq 1 ] ||
23738 error "read bytes ($readbyte1) is wrong"
23739 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
23740 15 * $decay_pct) / 100") -eq 1 ] ||
23741 error "write bytes ($writebyte1) is wrong"
23743 echo "Turn off file heat for the file $DIR/$tfile"
23744 $LFS heat_set -o $DIR/$tfile
23746 echo "QQQQ" > $DIR/$tfile
23747 echo "QQQQ" > $DIR/$tfile
23748 echo "QQQQ" > $DIR/$tfile
23749 cat $DIR/$tfile > /dev/null
23750 cat $DIR/$tfile > /dev/null
23751 cat $DIR/$tfile > /dev/null
23752 cat $DIR/$tfile > /dev/null
23754 out=$($LFS heat_get $DIR/$tfile)
23755 $LFS heat_get $DIR/$tfile
23756 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23757 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23758 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23759 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23761 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
23762 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
23763 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
23764 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
23766 echo "Trun on file heat for the file $DIR/$tfile"
23767 $LFS heat_set -O $DIR/$tfile
23769 echo "QQQQ" > $DIR/$tfile
23770 echo "QQQQ" > $DIR/$tfile
23771 echo "QQQQ" > $DIR/$tfile
23772 cat $DIR/$tfile > /dev/null
23773 cat $DIR/$tfile > /dev/null
23774 cat $DIR/$tfile > /dev/null
23775 cat $DIR/$tfile > /dev/null
23777 out=$($LFS heat_get $DIR/$tfile)
23778 $LFS heat_get $DIR/$tfile
23779 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23780 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23781 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23782 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23784 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
23785 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
23786 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
23787 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
23789 $LFS heat_set -c $DIR/$tfile
23790 $LCTL set_param -n llite.*.file_heat=0
23791 echo "Turn off file heat support for the Lustre filesystem"
23793 echo "QQQQ" > $DIR/$tfile
23794 echo "QQQQ" > $DIR/$tfile
23795 echo "QQQQ" > $DIR/$tfile
23796 cat $DIR/$tfile > /dev/null
23797 cat $DIR/$tfile > /dev/null
23798 cat $DIR/$tfile > /dev/null
23799 cat $DIR/$tfile > /dev/null
23801 out=$($LFS heat_get $DIR/$tfile)
23802 $LFS heat_get $DIR/$tfile
23803 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23804 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23805 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23806 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23808 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
23809 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
23810 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
23811 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
23813 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
23816 run_test 813 "File heat verfication"
23820 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
23821 echo -n y >> $DIR/$tfile
23822 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
23823 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
23825 run_test 814 "sparse cp works as expected (LU-12361)"
23829 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
23830 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
23832 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
23835 [ "$SHARED_KEY" = true ] &&
23836 skip "OSC connections never go IDLE with Shared-Keys enabled"
23838 $LFS setstripe -c 1 -i 0 $DIR/$tfile
23839 # ensure ost1 is connected
23840 stat $DIR/$tfile >/dev/null || error "can't stat"
23841 wait_osc_import_state client ost1 FULL
23842 # no locks, no reqs to let the connection idle
23843 cancel_lru_locks osc
23844 lru_resize_disable osc
23847 before=$($LCTL get_param -n \
23848 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
23850 wait_osc_import_state client ost1 IDLE
23851 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
23852 now=$($LCTL get_param -n \
23853 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
23854 [ $before == $now ] || error "lru_size changed $before != $now"
23856 run_test 816 "do not reset lru_resize on idle reconnect"
23860 exportfs -u localhost:$DIR/nfsexp
23865 systemctl restart nfs-server.service || skip "failed to restart nfsd"
23867 mkdir -p $DIR/nfsexp
23868 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
23869 error "failed to export nfs"
23871 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
23872 stack_trap cleanup_817 EXIT
23874 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
23875 error "failed to mount nfs to $tmpdir"
23877 cp /bin/true $tmpdir
23878 $DIR/nfsexp/true || error "failed to execute 'true' command"
23880 run_test 817 "nfsd won't cache write lock for exec file"
23884 $LFS setstripe -c1 -i0 $DIR/$tfile
23885 $LFS setstripe -c1 -i1 $DIR/$tfile
23887 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
23888 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
23889 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
23890 error "start $SINGLEMDS failed"
23893 run_test 818 "unlink with failed llog"
23896 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23897 cancel_lru_locks osc
23898 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
23899 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
23900 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
23903 run_test 819a "too big niobuf in read"
23906 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
23907 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
23908 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23909 cancel_lru_locks osc
23913 run_test 819b "too big niobuf in write"
23916 function test_820_start_ost() {
23919 for num in $(seq $OSTCOUNT); do
23920 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
23925 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23928 umount_client $MOUNT || error "umount failed"
23929 for num in $(seq $OSTCOUNT); do
23933 # mount client with no active OSTs
23934 # so that the client can't initialize max LOV EA size
23935 # from OSC notifications
23936 mount_client $MOUNT || error "mount failed"
23937 # delay OST starting to keep this 0 max EA size for a while
23938 test_820_start_ost &
23940 # create a directory on MDS2
23941 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
23942 error "Failed to create directory"
23943 # open intent should update default EA size
23944 # see mdc_update_max_ea_from_body()
23945 # notice this is the very first RPC to MDS2
23946 cp /etc/services $DIR/$tdir/mds2 ||
23947 error "Failed to copy files to mds$n"
23949 run_test 820 "update max EA from open intent"
23952 # tests that do cleanup/setup should be run at the end
23956 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23959 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
23960 $LCTL set_param fail_loc=0x903
23962 cancel_lru_locks MGC
23964 FAIL_ON_ERROR=true cleanup
23965 FAIL_ON_ERROR=true setup
23967 run_test 900 "umount should not race with any mgc requeue thread"
23969 # LUS-6253/LU-11185
23975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23977 # some get_param have a bug to handle dot in param name
23978 cancel_lru_locks MGC
23979 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
23980 olds=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
23981 umount_client $MOUNT || error "umount failed"
23982 mount_client $MOUNT || error "mount failed"
23983 cancel_lru_locks MGC
23984 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
23985 news=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
23987 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
23988 [ $olds -lt $news ] && error "mgs lock leak ($olds != $news)"
23992 run_test 901 "don't leak a mgc lock on client umount"
23996 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
23997 skip "client does not have LU-13377 fix"
23998 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
23999 $LCTL set_param fail_loc=0x1415
24000 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24001 cancel_lru_locks osc
24004 run_test 902 "test short write doesn't hang lustre"
24007 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
24008 check_and_cleanup_lustre
24009 if [ "$I_MOUNTED" != "yes" ]; then
24010 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true