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_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
35 LUSTRE=${LUSTRE:-$(dirname $0)/..}
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 test_mkdir $DIR/$tdir
1640 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1641 error "setstripe failed"
1642 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1643 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1645 run_test 27d "create file with default settings"
1648 # LU-5839 adds check for existed layout before setting it
1649 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1650 skip "Need MDS version at least 2.7.56"
1652 test_mkdir $DIR/$tdir
1653 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1654 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1655 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1657 run_test 27e "setstripe existing file (should return error)"
1660 test_mkdir $DIR/$tdir
1661 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1662 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1663 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1664 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1665 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1666 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1668 run_test 27f "setstripe with bad stripe size (should return error)"
1671 test_mkdir $DIR/$tdir
1672 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1673 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1674 error "$DIR/$tdir/$tfile has object"
1676 run_test 27g "$LFS getstripe with no objects"
1679 test_mkdir $DIR/$tdir
1680 touch $DIR/$tdir/$tfile || error "touch failed"
1681 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1682 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1684 (( rc == 2 )) || error "getstripe did not return ENOENT"
1686 run_test 27ga "$LFS getstripe with missing file (should return error)"
1689 test_mkdir $DIR/$tdir
1690 touch $DIR/$tdir/$tfile || error "touch failed"
1691 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1692 error "missing objects"
1694 run_test 27i "$LFS getstripe with some objects"
1697 test_mkdir $DIR/$tdir
1698 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1699 error "setstripe failed" || true
1701 run_test 27j "setstripe with bad stripe offset (should return error)"
1703 test_27k() { # bug 2844
1704 test_mkdir $DIR/$tdir
1705 local file=$DIR/$tdir/$tfile
1706 local ll_max_blksize=$((4 * 1024 * 1024))
1707 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1708 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1709 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1710 dd if=/dev/zero of=$file bs=4k count=1
1711 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1712 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1714 run_test 27k "limit i_blksize for broken user apps"
1717 mcreate $DIR/$tfile || error "creating file"
1718 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1719 error "setstripe should have failed" || true
1721 run_test 27l "check setstripe permissions (should return error)"
1724 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1726 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1727 skip_env "multiple clients -- skipping"
1729 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1731 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1732 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1734 trap simple_cleanup_common EXIT
1735 test_mkdir $DIR/$tdir
1736 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1737 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1738 error "dd should fill OST0"
1740 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1742 [ $i -gt 256 ] && break
1745 touch $DIR/$tdir/$tfile.$i
1746 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1747 awk '{print $1}'| grep -w "0") ] &&
1748 error "OST0 was full but new created file still use it"
1750 touch $DIR/$tdir/$tfile.$i
1751 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1752 awk '{print $1}'| grep -w "0") ] &&
1753 error "OST0 was full but new created file still use it"
1754 simple_cleanup_common
1756 run_test 27m "create file while OST0 was full"
1758 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1759 # if the OST isn't full anymore.
1761 local OSTIDX=${1:-""}
1763 local list=$(comma_list $(osts_nodes))
1764 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1766 do_nodes $list lctl set_param fail_loc=0
1767 sync # initiate all OST_DESTROYs from MDS to OST
1771 exhaust_precreations() {
1774 local FAILIDX=${3:-$OSTIDX}
1775 local ofacet=ost$((OSTIDX + 1))
1777 test_mkdir -p -c1 $DIR/$tdir
1778 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1779 local mfacet=mds$((mdtidx + 1))
1780 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1782 local OST=$(ostname_from_index $OSTIDX)
1785 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1786 local last_id=$(do_facet $mfacet lctl get_param -n \
1787 osp.$mdtosc_proc1.prealloc_last_id)
1788 local next_id=$(do_facet $mfacet lctl get_param -n \
1789 osp.$mdtosc_proc1.prealloc_next_id)
1791 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1792 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1794 test_mkdir -p $DIR/$tdir/${OST}
1795 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1796 #define OBD_FAIL_OST_ENOSPC 0x215
1797 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1798 echo "Creating to objid $last_id on ost $OST..."
1799 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1800 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1801 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1805 exhaust_all_precreations() {
1807 for (( i=0; i < OSTCOUNT; i++ )) ; do
1808 exhaust_precreations $i $1 -1
1813 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1814 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1815 remote_mds_nodsh && skip "remote MDS with nodsh"
1816 remote_ost_nodsh && skip "remote OST with nodsh"
1819 rm -f $DIR/$tdir/$tfile
1820 exhaust_precreations 0 0x80000215
1821 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1822 touch $DIR/$tdir/$tfile || error "touch failed"
1823 $LFS getstripe $DIR/$tdir/$tfile
1826 run_test 27n "create file with some full OSTs"
1829 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1830 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1831 remote_mds_nodsh && skip "remote MDS with nodsh"
1832 remote_ost_nodsh && skip "remote OST with nodsh"
1835 rm -f $DIR/$tdir/$tfile
1836 exhaust_all_precreations 0x215
1838 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1843 run_test 27o "create file with all full OSTs (should error)"
1846 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1847 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1848 remote_mds_nodsh && skip "remote MDS with nodsh"
1849 remote_ost_nodsh && skip "remote OST with nodsh"
1852 rm -f $DIR/$tdir/$tfile
1853 test_mkdir $DIR/$tdir
1855 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1856 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1857 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1859 exhaust_precreations 0 0x80000215
1860 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1861 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1862 $LFS getstripe $DIR/$tdir/$tfile
1866 run_test 27p "append to a truncated file with some full OSTs"
1869 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1870 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1871 remote_mds_nodsh && skip "remote MDS with nodsh"
1872 remote_ost_nodsh && skip "remote OST with nodsh"
1875 rm -f $DIR/$tdir/$tfile
1877 test_mkdir $DIR/$tdir
1878 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1879 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1880 error "truncate $DIR/$tdir/$tfile failed"
1881 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1883 exhaust_all_precreations 0x215
1885 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1886 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1890 run_test 27q "append to truncated file with all OSTs full (should error)"
1893 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1895 remote_mds_nodsh && skip "remote MDS with nodsh"
1896 remote_ost_nodsh && skip "remote OST with nodsh"
1899 rm -f $DIR/$tdir/$tfile
1900 exhaust_precreations 0 0x80000215
1902 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1906 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1908 test_27s() { # bug 10725
1909 test_mkdir $DIR/$tdir
1910 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1911 local stripe_count=0
1912 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1913 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1914 error "stripe width >= 2^32 succeeded" || true
1917 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1919 test_27t() { # bug 10864
1924 $WLFS getstripe $tfile
1927 run_test 27t "check that utils parse path correctly"
1929 test_27u() { # bug 4900
1930 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1931 remote_mds_nodsh && skip "remote MDS with nodsh"
1934 local list=$(comma_list $(mdts_nodes))
1936 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1937 do_nodes $list $LCTL set_param fail_loc=0x139
1938 test_mkdir -p $DIR/$tdir
1939 trap simple_cleanup_common EXIT
1940 createmany -o $DIR/$tdir/t- 1000
1941 do_nodes $list $LCTL set_param fail_loc=0
1943 TLOG=$TMP/$tfile.getstripe
1944 $LFS getstripe $DIR/$tdir > $TLOG
1945 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1946 unlinkmany $DIR/$tdir/t- 1000
1948 [[ $OBJS -gt 0 ]] &&
1949 error "$OBJS objects created on OST-0. See $TLOG" ||
1952 run_test 27u "skip object creation on OSC w/o objects"
1954 test_27v() { # bug 4900
1955 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1956 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1957 remote_mds_nodsh && skip "remote MDS with nodsh"
1958 remote_ost_nodsh && skip "remote OST with nodsh"
1960 exhaust_all_precreations 0x215
1963 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1965 touch $DIR/$tdir/$tfile
1966 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1968 for (( i=1; i < OSTCOUNT; i++ )); do
1969 do_facet ost$i lctl set_param fail_loc=0x705
1971 local START=`date +%s`
1972 createmany -o $DIR/$tdir/$tfile 32
1974 local FINISH=`date +%s`
1975 local TIMEOUT=`lctl get_param -n timeout`
1976 local PROCESS=$((FINISH - START))
1977 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1978 error "$FINISH - $START >= $TIMEOUT / 2"
1979 sleep $((TIMEOUT / 2 - PROCESS))
1982 run_test 27v "skip object creation on slow OST"
1984 test_27w() { # bug 10997
1985 test_mkdir $DIR/$tdir
1986 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1987 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1988 error "stripe size $size != 65536" || true
1989 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1990 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1992 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1995 [[ $OSTCOUNT -lt 2 ]] &&
1996 skip_env "skipping multiple stripe count/offset test"
1998 test_mkdir $DIR/$tdir
1999 for i in $(seq 1 $OSTCOUNT); do
2001 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2002 error "setstripe -c $i -i $offset failed"
2003 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2004 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2005 [ $count -ne $i ] && error "stripe count $count != $i" || true
2006 [ $index -ne $offset ] &&
2007 error "stripe offset $index != $offset" || true
2010 run_test 27wa "check $LFS setstripe -c -i options"
2013 remote_ost_nodsh && skip "remote OST with nodsh"
2014 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2015 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2017 OFFSET=$(($OSTCOUNT - 1))
2019 local OST=$(ostname_from_index $OSTIDX)
2021 test_mkdir $DIR/$tdir
2022 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2023 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2025 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2026 for i in $(seq 0 $OFFSET); do
2027 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2028 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2029 error "OST0 was degraded but new created file still use it"
2031 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2033 run_test 27x "create files while OST0 is degraded"
2036 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2037 remote_mds_nodsh && skip "remote MDS with nodsh"
2038 remote_ost_nodsh && skip "remote OST with nodsh"
2039 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2041 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2042 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2043 osp.$mdtosc.prealloc_last_id)
2044 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2045 osp.$mdtosc.prealloc_next_id)
2046 local fcount=$((last_id - next_id))
2047 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2048 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2050 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2051 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2052 local OST_DEACTIVE_IDX=-1
2057 for OSC in $MDS_OSCS; do
2058 OST=$(osc_to_ost $OSC)
2059 OSTIDX=$(index_from_ostuuid $OST)
2060 if [ $OST_DEACTIVE_IDX == -1 ]; then
2061 OST_DEACTIVE_IDX=$OSTIDX
2063 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2064 echo $OSC "is Deactivated:"
2065 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2069 OSTIDX=$(index_from_ostuuid $OST)
2070 test_mkdir $DIR/$tdir
2071 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2073 for OSC in $MDS_OSCS; do
2074 OST=$(osc_to_ost $OSC)
2075 OSTIDX=$(index_from_ostuuid $OST)
2076 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2077 echo $OST "is degraded:"
2078 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2079 obdfilter.$OST.degraded=1
2084 createmany -o $DIR/$tdir/$tfile $fcount
2086 for OSC in $MDS_OSCS; do
2087 OST=$(osc_to_ost $OSC)
2088 OSTIDX=$(index_from_ostuuid $OST)
2089 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2090 echo $OST "is recovered from degraded:"
2091 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2092 obdfilter.$OST.degraded=0
2094 do_facet $SINGLEMDS lctl --device %$OSC activate
2098 # all osp devices get activated, hence -1 stripe count restored
2099 local stripe_count=0
2101 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2102 # devices get activated.
2104 $LFS setstripe -c -1 $DIR/$tfile
2105 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2107 [ $stripe_count -ne $OSTCOUNT ] &&
2108 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2111 run_test 27y "create files while OST0 is degraded and the rest inactive"
2117 lmm_count=$($LFS getstripe -c $1)
2118 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2119 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2121 local old_ifs="$IFS"
2123 fid=($($LFS path2fid $1))
2126 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2127 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2129 # compare lmm_seq and lu_fid->f_seq
2130 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2131 # compare lmm_object_id and lu_fid->oid
2132 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2134 # check the trusted.fid attribute of the OST objects of the file
2135 local have_obdidx=false
2137 $LFS getstripe $1 | while read obdidx oid hex seq; do
2138 # skip lines up to and including "obdidx"
2139 [ -z "$obdidx" ] && break
2140 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2141 $have_obdidx || continue
2143 local ost=$((obdidx + 1))
2144 local dev=$(ostdevname $ost)
2147 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2149 seq=$(echo $seq | sed -e "s/^0x//g")
2150 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2151 oid_hex=$(echo $oid)
2153 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2155 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2159 # Don't unmount/remount the OSTs if we don't need to do that.
2160 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2161 # update too, until that use mount/ll_decode_filter_fid/mount.
2162 # Re-enable when debugfs will understand new filter_fid.
2164 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2165 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2166 $dev 2>/dev/null" | grep "parent=")
2168 if [ -z "$ff" ]; then
2170 mount_fstype ost$ost
2171 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2172 $(facet_mntpt ost$ost)/$obj_file)
2173 unmount_fstype ost$ost
2174 start ost$ost $dev $OST_MOUNT_OPTS
2178 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2180 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2182 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2183 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2185 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2186 # stripe_size=1048576 component_id=1 component_start=0 \
2187 # component_end=33554432
2188 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2189 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2190 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2192 if grep -q 'stripe=' <<<$ff; then
2193 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2195 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2196 # into f_ver in this case. See comment on ff_parent.
2197 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2200 # compare lmm_seq and filter_fid->ff_parent.f_seq
2201 [ $ff_pseq = $lmm_seq ] ||
2202 error "FF parent SEQ $ff_pseq != $lmm_seq"
2203 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2204 [ $ff_poid = $lmm_oid ] ||
2205 error "FF parent OID $ff_poid != $lmm_oid"
2206 (($ff_pstripe == $stripe_nr)) ||
2207 error "FF stripe $ff_pstripe != $stripe_nr"
2209 stripe_nr=$((stripe_nr + 1))
2210 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2212 if grep -q 'stripe_count=' <<<$ff; then
2213 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2214 -e 's/ .*//' <<<$ff)
2215 [ $lmm_count = $ff_scnt ] ||
2216 error "FF stripe count $lmm_count != $ff_scnt"
2222 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2223 remote_ost_nodsh && skip "remote OST with nodsh"
2225 test_mkdir $DIR/$tdir
2226 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2227 { error "setstripe -c -1 failed"; return 1; }
2228 # We need to send a write to every object to get parent FID info set.
2229 # This _should_ also work for setattr, but does not currently.
2230 # touch $DIR/$tdir/$tfile-1 ||
2231 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2232 { error "dd $tfile-1 failed"; return 2; }
2233 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2234 { error "setstripe -c -1 failed"; return 3; }
2235 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2236 { error "dd $tfile-2 failed"; return 4; }
2238 # make sure write RPCs have been sent to OSTs
2241 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2242 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2244 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2246 test_27A() { # b=19102
2247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2249 save_layout_restore_at_exit $MOUNT
2250 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2251 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2252 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2253 local default_size=$($LFS getstripe -S $MOUNT)
2254 local default_offset=$($LFS getstripe -i $MOUNT)
2255 local dsize=$(do_facet $SINGLEMDS \
2256 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2257 [ $default_size -eq $dsize ] ||
2258 error "stripe size $default_size != $dsize"
2259 [ $default_offset -eq -1 ] ||
2260 error "stripe offset $default_offset != -1"
2262 run_test 27A "check filesystem-wide default LOV EA values"
2264 test_27B() { # LU-2523
2265 test_mkdir $DIR/$tdir
2266 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2268 # open f1 with O_LOV_DELAY_CREATE
2270 # call setstripe ioctl on open file descriptor for f1
2272 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2276 # open f1 with O_LOV_DELAY_CREATE
2278 # call setstripe ioctl on open file descriptor for f1
2280 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2282 # Allow multiop to fail in imitation of NFS's busted semantics.
2285 run_test 27B "call setstripe on open unlinked file/rename victim"
2287 # 27C family tests full striping and overstriping
2288 test_27Ca() { #LU-2871
2289 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2297 test_mkdir $DIR/$tdir
2299 for i in $(seq 0 $((OSTCOUNT - 1))); do
2300 # set stripe across all OSTs starting from OST$i
2301 $LFS setstripe -i $i -c -1 $tfile$i
2302 # get striping information
2303 ost_idx=($($LFS getstripe $tfile$i |
2304 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2308 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2309 error "${#ost_idx[@]} != $OSTCOUNT"
2311 for index in $(seq 0 $((OSTCOUNT - 1))); do
2313 for j in $(echo ${ost_idx[@]}); do
2314 if [ $index -eq $j ]; then
2320 error "Can not find $index in ${ost_idx[@]}"
2324 run_test 27Ca "check full striping across all OSTs"
2327 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2328 skip "server does not support overstriping"
2329 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2330 skip_env "too many osts, skipping"
2332 test_mkdir -p $DIR/$tdir
2333 local setcount=$(($OSTCOUNT * 2))
2334 [ $setcount -ge 160 ] || large_xattr_enabled ||
2335 skip_env "ea_inode feature disabled"
2337 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2338 error "setstripe failed"
2340 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2341 [ $count -eq $setcount ] ||
2342 error "stripe count $count, should be $setcount"
2344 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2345 error "overstriped should be set in pattern"
2347 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2350 run_test 27Cb "more stripes than OSTs with -C"
2353 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2354 skip "server does not support overstriping"
2355 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2357 test_mkdir -p $DIR/$tdir
2358 local setcount=$(($OSTCOUNT - 1))
2360 [ $setcount -ge 160 ] || large_xattr_enabled ||
2361 skip_env "ea_inode feature disabled"
2363 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2364 error "setstripe failed"
2366 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2367 [ $count -eq $setcount ] ||
2368 error "stripe count $count, should be $setcount"
2370 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2371 error "overstriped should not be set in pattern"
2373 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2376 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2379 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2380 skip "server does not support overstriping"
2381 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2382 large_xattr_enabled || skip_env "ea_inode feature disabled"
2384 test_mkdir -p $DIR/$tdir
2385 local setcount=$LOV_MAX_STRIPE_COUNT
2387 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2388 error "setstripe failed"
2390 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2391 [ $count -eq $setcount ] ||
2392 error "stripe count $count, should be $setcount"
2394 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2395 error "overstriped should be set in pattern"
2397 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2400 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2402 run_test 27Cd "test maximum stripe count"
2405 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2406 skip "server does not support overstriping"
2407 test_mkdir -p $DIR/$tdir
2409 pool_add $TESTNAME || error "Pool creation failed"
2410 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2414 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2415 error "setstripe failed"
2417 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2418 [ $count -eq $setcount ] ||
2419 error "stripe count $count, should be $setcount"
2421 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2422 error "overstriped should be set in pattern"
2424 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2427 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2429 run_test 27Ce "test pool with overstriping"
2432 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2433 skip "server does not support overstriping"
2434 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2435 skip_env "too many osts, skipping"
2437 test_mkdir -p $DIR/$tdir
2439 local setcount=$(($OSTCOUNT * 2))
2440 [ $setcount -ge 160 ] || large_xattr_enabled ||
2441 skip_env "ea_inode feature disabled"
2443 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2444 error "setstripe failed"
2446 echo 1 > $DIR/$tdir/$tfile
2448 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2449 [ $count -eq $setcount ] ||
2450 error "stripe count $count, should be $setcount"
2452 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2453 error "overstriped should be set in pattern"
2455 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2458 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2460 run_test 27Cf "test default inheritance with overstriping"
2463 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2464 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2465 remote_mds_nodsh && skip "remote MDS with nodsh"
2467 local POOL=${POOL:-testpool}
2469 local last_ost=$(($OSTCOUNT - 1))
2471 local ost_list=$(seq $first_ost $ost_step $last_ost)
2472 local ost_range="$first_ost $last_ost $ost_step"
2474 test_mkdir $DIR/$tdir
2475 pool_add $POOL || error "pool_add failed"
2476 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2479 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2481 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2482 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2483 skip27D+=" -s 30,31"
2484 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2485 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2486 skip27D+=" -s 32,33"
2487 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2489 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2490 error "llapi_layout_test failed"
2492 destroy_test_pools || error "destroy test pools failed"
2494 run_test 27D "validate llapi_layout API"
2496 # Verify that default_easize is increased from its initial value after
2497 # accessing a widely striped file.
2499 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2500 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2501 skip "client does not have LU-3338 fix"
2503 # 72 bytes is the minimum space required to store striping
2504 # information for a file striped across one OST:
2505 # (sizeof(struct lov_user_md_v3) +
2506 # sizeof(struct lov_user_ost_data_v1))
2508 $LCTL set_param -n llite.*.default_easize $min_easize ||
2509 error "lctl set_param failed"
2510 local easize=$($LCTL get_param -n llite.*.default_easize)
2512 [ $easize -eq $min_easize ] ||
2513 error "failed to set default_easize"
2515 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2516 error "setstripe failed"
2517 # In order to ensure stat() call actually talks to MDS we need to
2518 # do something drastic to this file to shake off all lock, e.g.
2519 # rename it (kills lookup lock forcing cache cleaning)
2520 mv $DIR/$tfile $DIR/${tfile}-1
2521 ls -l $DIR/${tfile}-1
2524 easize=$($LCTL get_param -n llite.*.default_easize)
2526 [ $easize -gt $min_easize ] ||
2527 error "default_easize not updated"
2529 run_test 27E "check that default extended attribute size properly increases"
2531 test_27F() { # LU-5346/LU-7975
2532 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2533 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2534 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2535 skip "Need MDS version at least 2.8.51"
2536 remote_ost_nodsh && skip "remote OST with nodsh"
2538 test_mkdir $DIR/$tdir
2540 $LFS setstripe -c 2 $DIR/$tdir
2542 # stop all OSTs to reproduce situation for LU-7975 ticket
2543 for num in $(seq $OSTCOUNT); do
2547 # open/create f0 with O_LOV_DELAY_CREATE
2548 # truncate f0 to a non-0 size
2550 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2552 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2553 # open/write it again to force delayed layout creation
2554 cat /etc/hosts > $DIR/$tdir/f0 &
2558 for num in $(seq $OSTCOUNT); do
2559 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2560 error "ost$num failed to start"
2563 wait $catpid || error "cat failed"
2565 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2566 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2567 error "wrong stripecount"
2570 run_test 27F "Client resend delayed layout creation with non-zero size"
2572 test_27G() { #LU-10629
2573 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2574 skip "Need MDS version at least 2.11.51"
2575 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2576 remote_mds_nodsh && skip "remote MDS with nodsh"
2577 local POOL=${POOL:-testpool}
2578 local ostrange="0 0 1"
2580 test_mkdir $DIR/$tdir
2581 pool_add $POOL || error "pool_add failed"
2582 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2583 $LFS setstripe -p $POOL $DIR/$tdir
2585 local pool=$($LFS getstripe -p $DIR/$tdir)
2587 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2589 $LFS setstripe -d $DIR/$tdir
2591 pool=$($LFS getstripe -p $DIR/$tdir)
2595 [ -z "$pool" ] || error "'$pool' is not empty"
2597 run_test 27G "Clear OST pool from stripe"
2600 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2601 skip "Need MDS version newer than 2.11.54"
2602 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2603 test_mkdir $DIR/$tdir
2604 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2605 touch $DIR/$tdir/$tfile
2606 $LFS getstripe -c $DIR/$tdir/$tfile
2607 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2608 error "two-stripe file doesn't have two stripes"
2610 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2611 $LFS getstripe -y $DIR/$tdir/$tfile
2612 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2613 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2614 error "expected l_ost_idx: [02]$ not matched"
2616 # make sure ost list has been cleared
2617 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2618 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2619 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2621 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2623 run_test 27H "Set specific OSTs stripe"
2626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2627 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2628 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2629 skip "Need MDS version newer than 2.12.52"
2630 local pool=$TESTNAME
2631 local ostrange="1 1 1"
2633 save_layout_restore_at_exit $MOUNT
2634 $LFS setstripe -c 2 -i 0 $MOUNT
2635 pool_add $pool || error "pool_add failed"
2636 pool_add_targets $pool $ostrange || "pool_add_targets failed"
2637 test_mkdir $DIR/$tdir
2638 $LFS setstripe -p $pool $DIR/$tdir
2639 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2640 $LFS getstripe $DIR/$tdir/$tfile
2642 run_test 27I "check that root dir striping does not break parent dir one"
2645 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2646 skip "Need MDS version newer than 2.12.51"
2648 test_mkdir $DIR/$tdir
2649 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2650 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2652 # create foreign file (raw way)
2653 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2654 -t 1 -F 0xda08 || error "create_foreign_file failed"
2656 # verify foreign file (raw way)
2657 parse_foreign_file -f $DIR/$tdir/$tfile |
2658 grep "lov_foreign_magic: 0x0BD70BD0" ||
2659 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2660 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2661 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2662 parse_foreign_file -f $DIR/$tdir/$tfile |
2663 grep "lov_foreign_size: 73" ||
2664 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2665 parse_foreign_file -f $DIR/$tdir/$tfile |
2666 grep "lov_foreign_type: 1" ||
2667 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2668 parse_foreign_file -f $DIR/$tdir/$tfile |
2669 grep "lov_foreign_flags: 0x0000DA08" ||
2670 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2671 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2672 grep "lov_foreign_value: 0x" |
2673 sed -e 's/lov_foreign_value: 0x//')
2674 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2675 [[ $lov = ${lov2// /} ]] ||
2676 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2678 # create foreign file (lfs + API)
2679 $LFS setstripe --foreign=daos --flags 0xda08 \
2680 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2681 error "$DIR/$tdir/${tfile}2: create failed"
2683 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2684 grep "lfm_magic:.*0x0BD70BD0" ||
2685 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2686 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2687 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2688 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2689 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
2690 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2691 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2692 grep "lfm_flags:.*0x0000DA08" ||
2693 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2694 $LFS getstripe $DIR/$tdir/${tfile}2 |
2695 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2696 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2698 # modify striping should fail
2699 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2700 error "$DIR/$tdir/$tfile: setstripe should fail"
2701 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2702 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2705 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2706 cat $DIR/$tdir/${tfile}2 &&
2707 error "$DIR/$tdir/${tfile}2: read should fail"
2708 cat /etc/passwd > $DIR/$tdir/$tfile &&
2709 error "$DIR/$tdir/$tfile: write should fail"
2710 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2711 error "$DIR/$tdir/${tfile}2: write should fail"
2714 chmod 222 $DIR/$tdir/$tfile ||
2715 error "$DIR/$tdir/$tfile: chmod failed"
2716 chmod 222 $DIR/$tdir/${tfile}2 ||
2717 error "$DIR/$tdir/${tfile}2: chmod failed"
2720 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2721 error "$DIR/$tdir/$tfile: chown failed"
2722 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2723 error "$DIR/$tdir/${tfile}2: chown failed"
2725 # rename should work
2726 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2727 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2728 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2729 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2731 #remove foreign file
2732 rm $DIR/$tdir/${tfile}.new ||
2733 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2734 rm $DIR/$tdir/${tfile}2.new ||
2735 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2737 run_test 27J "basic ops on file with foreign LOV"
2740 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2741 skip "Need MDS version newer than 2.12.49"
2743 test_mkdir $DIR/$tdir
2744 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2745 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2747 # create foreign dir (raw way)
2748 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2749 error "create_foreign_dir FAILED"
2751 # verify foreign dir (raw way)
2752 parse_foreign_dir -d $DIR/$tdir/$tdir |
2753 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2754 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2755 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2756 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2757 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2758 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2759 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
2760 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2761 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2762 grep "lmv_foreign_value: 0x" |
2763 sed 's/lmv_foreign_value: 0x//')
2764 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2766 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2768 # create foreign dir (lfs + API)
2769 $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2770 $DIR/$tdir/${tdir}2 ||
2771 error "$DIR/$tdir/${tdir}2: create failed"
2773 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2774 grep "lfm_magic:.*0x0CD50CD0" ||
2775 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2776 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2777 # - sizeof(lfm_type) - sizeof(lfm_flags)
2778 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2779 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2780 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
2781 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2782 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2783 grep "lfm_flags:.*0x0000DA05" ||
2784 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2785 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2786 grep "lfm_value.*${uuid1}@${uuid2}" ||
2787 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2789 # file create in dir should fail
2790 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2791 touch $DIR/$tdir/${tdir}2/$tfile &&
2792 "$DIR/${tdir}2: file create should fail"
2795 chmod 777 $DIR/$tdir/$tdir ||
2796 error "$DIR/$tdir: chmod failed"
2797 chmod 777 $DIR/$tdir/${tdir}2 ||
2798 error "$DIR/${tdir}2: chmod failed"
2801 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2802 error "$DIR/$tdir: chown failed"
2803 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2804 error "$DIR/${tdir}2: chown failed"
2806 # rename should work
2807 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2808 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2809 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2810 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2813 rmdir $DIR/$tdir/${tdir}.new ||
2814 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2815 rmdir $DIR/$tdir/${tdir}2.new ||
2816 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2818 run_test 27K "basic ops on dir with foreign LMV"
2821 remote_mds_nodsh && skip "remote MDS with nodsh"
2823 local POOL=${POOL:-$TESTNAME}
2825 pool_add $POOL || error "pool_add failed"
2827 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2828 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2829 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2831 run_test 27L "lfs pool_list gives correct pool name"
2834 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2835 skip "Need MDS version >= than 2.12.57"
2836 remote_mds_nodsh && skip "remote MDS with nodsh"
2837 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2839 test_mkdir $DIR/$tdir
2841 # Set default striping on directory
2842 $LFS setstripe -C 4 $DIR/$tdir
2844 echo 1 > $DIR/$tdir/${tfile}.1
2845 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2847 [ $count -eq $setcount ] ||
2848 error "(1) stripe count $count, should be $setcount"
2850 # Capture existing append_stripe_count setting for restore
2851 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2852 local mdts=$(comma_list $(mdts_nodes))
2853 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2855 local appendcount=$orig_count
2856 echo 1 >> $DIR/$tdir/${tfile}.2_append
2857 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2858 [ $count -eq $appendcount ] ||
2859 error "(2)stripe count $count, should be $appendcount for append"
2861 # Disable O_APPEND striping, verify it works
2862 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2864 # Should now get the default striping, which is 4
2866 echo 1 >> $DIR/$tdir/${tfile}.3_append
2867 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2868 [ $count -eq $setcount ] ||
2869 error "(3) stripe count $count, should be $setcount"
2871 # Try changing the stripe count for append files
2872 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2874 # Append striping is now 2 (directory default is still 4)
2876 echo 1 >> $DIR/$tdir/${tfile}.4_append
2877 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2878 [ $count -eq $appendcount ] ||
2879 error "(4) stripe count $count, should be $appendcount for append"
2881 # Test append stripe count of -1
2882 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2883 appendcount=$OSTCOUNT
2884 echo 1 >> $DIR/$tdir/${tfile}.5
2885 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2886 [ $count -eq $appendcount ] ||
2887 error "(5) stripe count $count, should be $appendcount for append"
2889 # Set append striping back to default of 1
2890 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2892 # Try a new default striping, PFL + DOM
2893 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2895 # Create normal DOM file, DOM returns stripe count == 0
2897 touch $DIR/$tdir/${tfile}.6
2898 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2899 [ $count -eq $setcount ] ||
2900 error "(6) stripe count $count, should be $setcount"
2904 echo 1 >> $DIR/$tdir/${tfile}.7_append
2905 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2906 [ $count -eq $appendcount ] ||
2907 error "(7) stripe count $count, should be $appendcount for append"
2909 # Clean up DOM layout
2910 $LFS setstripe -d $DIR/$tdir
2912 # Now test that append striping works when layout is from root
2913 $LFS setstripe -c 2 $MOUNT
2914 # Make a special directory for this
2915 mkdir $DIR/${tdir}/${tdir}.2
2916 stack_trap "$LFS setstripe -d $MOUNT" EXIT
2918 # Verify for normal file
2920 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2921 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2922 [ $count -eq $setcount ] ||
2923 error "(8) stripe count $count, should be $setcount"
2926 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2927 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2928 [ $count -eq $appendcount ] ||
2929 error "(9) stripe count $count, should be $appendcount for append"
2931 # Now test O_APPEND striping with pools
2932 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2933 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
2936 pool_add $TESTNAME || error "pool creation failed"
2937 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2939 echo 1 >> $DIR/$tdir/${tfile}.10_append
2941 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
2942 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
2944 # Check that count is still correct
2946 echo 1 >> $DIR/$tdir/${tfile}.11_append
2947 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
2948 [ $count -eq $appendcount ] ||
2949 error "(11) stripe count $count, should be $appendcount for append"
2951 # Disable O_APPEND stripe count, verify pool works separately
2952 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2954 echo 1 >> $DIR/$tdir/${tfile}.12_append
2956 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
2957 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
2959 # Remove pool setting, verify it's not applied
2960 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
2962 echo 1 >> $DIR/$tdir/${tfile}.13_append
2964 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
2965 [ "$pool" = "" ] || error "(13) pool found: $pool"
2967 run_test 27M "test O_APPEND striping"
2970 combined_mgs_mds && skip "needs separate MGS/MDT"
2972 pool_add $TESTNAME || error "pool_add failed"
2973 do_facet mgs "$LCTL pool_list $FSNAME" |
2974 grep -Fx "${FSNAME}.${TESTNAME}" ||
2975 error "lctl pool_list on MGS failed"
2977 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
2979 # createtest also checks that device nodes are created and
2980 # then visible correctly (#2091)
2981 test_28() { # bug 2091
2983 $CREATETEST $DIR/d28/ct || error "createtest failed"
2985 run_test 28 "create/mknod/mkdir with bad file types ============"
2988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2990 sync; sleep 1; sync # flush out any dirty pages from previous tests
2997 declare -i LOCKCOUNTORIG=0
2998 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2999 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3001 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3003 declare -i LOCKUNUSEDCOUNTORIG=0
3004 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3005 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3012 declare -i LOCKCOUNTCURRENT=0
3013 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3014 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3017 declare -i LOCKUNUSEDCOUNTCURRENT=0
3018 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3019 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3022 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3023 $LCTL set_param -n ldlm.dump_namespaces ""
3024 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3025 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3026 log "dumped log to $TMP/test_29.dk (bug 5793)"
3029 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3030 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3031 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3032 log "dumped log to $TMP/test_29.dk (bug 5793)"
3036 run_test 29 "IT_GETATTR regression ============================"
3038 test_30a() { # was test_30
3039 cp $(which ls) $DIR || cp /bin/ls $DIR
3040 $DIR/ls / || error "Can't execute binary from lustre"
3043 run_test 30a "execute binary from Lustre (execve) =============="
3046 cp `which ls` $DIR || cp /bin/ls $DIR
3048 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3051 run_test 30b "execute binary from Lustre as non-root ==========="
3053 test_30c() { # b=22376
3054 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3056 cp `which ls` $DIR || cp /bin/ls $DIR
3058 cancel_lru_locks mdc
3059 cancel_lru_locks osc
3060 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3063 run_test 30c "execute binary from Lustre without read perms ===="
3066 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3067 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3069 run_test 31a "open-unlink file =================================="
3072 touch $DIR/f31 || error "touch $DIR/f31 failed"
3073 ln $DIR/f31 $DIR/f31b || error "ln failed"
3074 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3075 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3077 run_test 31b "unlink file with multiple links while open ======="
3080 touch $DIR/f31 || error "touch $DIR/f31 failed"
3081 ln $DIR/f31 $DIR/f31c || error "ln failed"
3082 multiop_bg_pause $DIR/f31 O_uc ||
3083 error "multiop_bg_pause for $DIR/f31 failed"
3085 $MULTIOP $DIR/f31c Ouc
3086 kill -USR1 $MULTIPID
3089 run_test 31c "open-unlink file with multiple links ============="
3092 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3093 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3095 run_test 31d "remove of open directory ========================="
3097 test_31e() { # bug 2904
3098 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3100 run_test 31e "remove of open non-empty directory ==============="
3102 test_31f() { # bug 4554
3103 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3106 test_mkdir $DIR/d31f
3107 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3108 cp /etc/hosts $DIR/d31f
3110 $LFS getstripe $DIR/d31f/hosts
3111 multiop_bg_pause $DIR/d31f D_c || return 1
3114 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3115 test_mkdir $DIR/d31f
3116 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3117 cp /etc/hosts $DIR/d31f
3119 $LFS getstripe $DIR/d31f/hosts
3120 multiop_bg_pause $DIR/d31f D_c || return 1
3123 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3124 wait $MULTIPID || error "first opendir $MULTIPID failed"
3128 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3129 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3132 run_test 31f "remove of open directory with open-unlink file ==="
3135 echo "-- cross directory link --"
3136 test_mkdir -c1 $DIR/${tdir}ga
3137 test_mkdir -c1 $DIR/${tdir}gb
3138 touch $DIR/${tdir}ga/f
3139 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3140 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3141 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3142 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3143 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3145 run_test 31g "cross directory link==============="
3148 echo "-- cross directory link --"
3149 test_mkdir -c1 $DIR/${tdir}
3150 test_mkdir -c1 $DIR/${tdir}/dir
3151 touch $DIR/${tdir}/f
3152 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3153 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3154 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3155 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3156 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3158 run_test 31h "cross directory link under child==============="
3161 echo "-- cross directory link --"
3162 test_mkdir -c1 $DIR/$tdir
3163 test_mkdir -c1 $DIR/$tdir/dir
3164 touch $DIR/$tdir/dir/f
3165 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3166 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3167 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3168 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3169 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3171 run_test 31i "cross directory link under parent==============="
3174 test_mkdir -c1 -p $DIR/$tdir
3175 test_mkdir -c1 -p $DIR/$tdir/dir1
3176 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3177 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3178 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3179 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3182 run_test 31j "link for directory==============="
3185 test_mkdir -c1 -p $DIR/$tdir
3187 touch $DIR/$tdir/exist
3188 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3189 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3190 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3191 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3192 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3193 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3194 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3197 run_test 31k "link to file: the same, non-existing, dir==============="
3203 touch $DIR/d31m2/exist
3204 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3205 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3206 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3207 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3208 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3209 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3212 run_test 31m "link to file: the same, non-existing, dir==============="
3215 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3216 nlink=$(stat --format=%h $DIR/$tfile)
3217 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3219 local cmd="exec $fd<$DIR/$tfile"
3222 trap "eval $cmd" EXIT
3223 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3224 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3225 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3226 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3227 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3230 run_test 31n "check link count of unlinked file"
3233 local tempfile=$(mktemp $1_XXXXXX)
3234 mlink $tempfile $1 2> /dev/null &&
3235 echo "$BASHPID: link $tempfile to $1 succeeded"
3239 test_31o() { # LU-2901
3240 test_mkdir $DIR/$tdir
3241 for LOOP in $(seq 100); do
3242 rm -f $DIR/$tdir/$tfile*
3243 for THREAD in $(seq 8); do
3244 link_one $DIR/$tdir/$tfile.$LOOP &
3247 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3248 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3249 error "$LINKS duplicate links to $tfile.$LOOP" &&
3253 run_test 31o "duplicate hard links with same filename"
3256 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3258 test_mkdir $DIR/$tdir
3259 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3260 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3262 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3263 error "open unlink test1 failed"
3264 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3265 error "open unlink test2 failed"
3267 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3268 error "test1 still exists"
3269 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3270 error "test2 still exists"
3272 run_test 31p "remove of open striped directory"
3274 cleanup_test32_mount() {
3277 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3278 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3279 losetup -d $loopdev || true
3285 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3287 echo "== more mountpoints and symlinks ================="
3288 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3289 trap cleanup_test32_mount EXIT
3290 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3291 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3292 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3293 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3294 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3295 cleanup_test32_mount
3297 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3300 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3302 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3303 trap cleanup_test32_mount EXIT
3304 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3305 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3306 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3307 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3308 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3309 cleanup_test32_mount
3311 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3314 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3316 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3317 trap cleanup_test32_mount EXIT
3318 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3319 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3320 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3321 test_mkdir -p $DIR/$tdir/d2/test_dir
3322 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3323 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3324 cleanup_test32_mount
3326 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3329 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3331 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3332 trap cleanup_test32_mount EXIT
3333 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3334 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3335 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3336 test_mkdir -p $DIR/$tdir/d2/test_dir
3337 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3338 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3339 cleanup_test32_mount
3341 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3345 test_mkdir -p $DIR/$tdir/tmp
3346 local tmp_dir=$DIR/$tdir/tmp
3347 ln -s $DIR/$tdir $tmp_dir/symlink11
3348 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3349 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3350 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3352 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3356 test_mkdir -p $DIR/$tdir/tmp
3357 local tmp_dir=$DIR/$tdir/tmp
3358 ln -s $DIR/$tdir $tmp_dir/symlink11
3359 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3360 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3361 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3363 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3366 local tmp_dir=$DIR/$tdir/tmp
3367 test_mkdir -p $tmp_dir
3368 test_mkdir $DIR/${tdir}2
3369 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3370 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3371 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3372 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3373 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3374 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3376 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3379 rm -fr $DIR/$tdir $DIR/${tdir}2
3380 tmp_dir=$DIR/$tdir/tmp
3381 test_mkdir -p $tmp_dir
3382 test_mkdir $DIR/${tdir}2
3383 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3384 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3385 ls $tmp_dir/symlink12 || error "listing symlink12"
3386 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3388 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3391 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3393 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3394 trap cleanup_test32_mount EXIT
3395 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3396 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3397 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3398 touch $DIR/$tdir/test_file
3399 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3400 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3401 cleanup_test32_mount
3403 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3408 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3409 trap cleanup_test32_mount EXIT
3410 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3411 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3412 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3413 touch $DIR/$tdir/test_file
3414 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3415 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3416 cleanup_test32_mount
3418 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3421 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3424 trap cleanup_test32_mount EXIT
3425 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3426 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3427 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3428 test_mkdir -p $DIR/$tdir/d2
3429 touch $DIR/$tdir/d2/test_file || error "touch failed"
3430 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3431 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3432 cleanup_test32_mount
3434 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3437 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3440 trap cleanup_test32_mount EXIT
3441 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3442 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3443 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3444 test_mkdir -p $DIR/$tdir/d2
3445 touch $DIR/$tdir/d2/test_file || error "touch failed"
3446 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3447 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3448 cleanup_test32_mount
3450 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3454 test_mkdir -p $DIR/d32m/tmp
3455 TMP_DIR=$DIR/d32m/tmp
3456 ln -s $DIR $TMP_DIR/symlink11
3457 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3458 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3459 error "symlink11 not a link"
3460 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3461 error "symlink01 not a link"
3463 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3467 test_mkdir -p $DIR/d32n/tmp
3468 TMP_DIR=$DIR/d32n/tmp
3469 ln -s $DIR $TMP_DIR/symlink11
3470 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3471 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3472 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3474 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3478 test_mkdir -p $DIR/d32o/tmp
3479 TMP_DIR=$DIR/d32o/tmp
3480 ln -s $DIR/$tfile $TMP_DIR/symlink12
3481 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3482 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3483 error "symlink12 not a link"
3484 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3485 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3486 error "$DIR/d32o/tmp/symlink12 not file type"
3487 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3488 error "$DIR/d32o/symlink02 not file type"
3490 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3500 test_mkdir -p $DIR/d32p/tmp
3502 TMP_DIR=$DIR/d32p/tmp
3504 ln -s $DIR/$tfile $TMP_DIR/symlink12
3506 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3508 cat $DIR/d32p/tmp/symlink12 ||
3509 error "Can't open $DIR/d32p/tmp/symlink12"
3511 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3514 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3517 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3519 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3520 trap cleanup_test32_mount EXIT
3521 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3522 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3523 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3524 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3525 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3526 cleanup_test32_mount
3528 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3531 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3533 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3534 trap cleanup_test32_mount EXIT
3535 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3536 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3537 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3538 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3539 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3540 cleanup_test32_mount
3542 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3547 chmod 444 $DIR/$tfile
3548 chown $RUNAS_ID $DIR/$tfile
3550 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3553 run_test 33aa "write file with mode 444 (should return error)"
3557 test_mkdir $DIR/$tdir
3558 chown $RUNAS_ID $DIR/$tdir
3559 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3560 error "$RUNAS create $tdir/$tfile failed"
3561 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3562 error "open RDWR" || true
3564 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3568 test_mkdir $DIR/$tdir
3569 chown $RUNAS_ID $DIR/$tdir
3570 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3572 run_test 33b "test open file with malformed flags (No panic)"
3575 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3576 remote_ost_nodsh && skip "remote OST with nodsh"
3585 test_mkdir $DIR/$tdir
3586 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3589 for ostnum in $(seq $OSTCOUNT); do
3590 # test-framework's OST numbering is one-based, while Lustre's
3592 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3593 # Parsing llobdstat's output sucks; we could grep the /proc
3594 # path, but that's likely to not be as portable as using the
3595 # llobdstat utility. So we parse lctl output instead.
3596 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3597 obdfilter/$ostname/stats |
3598 awk '/^write_bytes/ {print $7}' )
3599 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3600 if (( ${write_bytes:-0} > 0 ))
3607 $all_zeros || return 0
3610 echo foo > $DIR/$tdir/bar
3614 # Total up write_bytes after writing. We'd better find non-zeros.
3615 for ostnum in $(seq $OSTCOUNT); do
3616 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3617 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3618 obdfilter/$ostname/stats |
3619 awk '/^write_bytes/ {print $7}' )
3620 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3621 if (( ${write_bytes:-0} > 0 ))
3630 for ostnum in $(seq $OSTCOUNT); do
3631 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3632 echo "Check that write_bytes is present in obdfilter/*/stats:"
3633 do_facet ost$ostnum lctl get_param -n \
3634 obdfilter/$ostname/stats
3636 error "OST not keeping write_bytes stats (b22312)"
3639 run_test 33c "test llobdstat and write_bytes"
3642 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3646 local remote_dir=$DIR/$tdir/remote_dir
3648 test_mkdir $DIR/$tdir
3649 $LFS mkdir -i $MDTIDX $remote_dir ||
3650 error "create remote directory failed"
3652 touch $remote_dir/$tfile
3653 chmod 444 $remote_dir/$tfile
3654 chown $RUNAS_ID $remote_dir/$tfile
3656 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3658 chown $RUNAS_ID $remote_dir
3659 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3660 error "create" || true
3661 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3662 error "open RDWR" || true
3663 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3665 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3668 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3672 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3673 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3674 mkdir $DIR/$tdir/local_dir
3676 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3677 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3678 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3680 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3681 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3683 rmdir $DIR/$tdir/* || error "rmdir failed"
3686 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3687 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3688 mkdir $DIR/$tdir/local_dir
3690 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3691 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3692 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3694 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3695 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3697 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3700 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3701 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3702 mkdir $DIR/$tdir/local_dir
3704 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3705 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3706 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3708 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3709 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3711 run_test 33e "mkdir and striped directory should have same mode"
3715 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3719 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3720 remote_mds_nodsh && skip "remote MDS with nodsh"
3723 chmod go+rwx $DIR/$tdir
3724 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3725 trap cleanup_33f EXIT
3727 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3728 error "cannot create striped directory"
3730 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3731 error "cannot create files in striped directory"
3733 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3734 error "cannot remove files in striped directory"
3736 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3737 error "cannot remove striped directory"
3741 run_test 33f "nonroot user can create, access, and remove a striped directory"
3744 mkdir -p $DIR/$tdir/dir2
3746 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3748 [[ $err =~ "exists" ]] || error "Not exists error"
3750 run_test 33g "nonroot user create already existing root created file"
3752 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3755 $MCREATE $DIR/f34 || error "mcreate failed"
3756 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3757 error "getstripe failed"
3758 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3759 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3760 error "getstripe failed"
3761 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3762 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3764 run_test 34a "truncate file that has not been opened ==========="
3767 [ ! -f $DIR/f34 ] && test_34a
3768 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3769 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3770 $OPENFILE -f O_RDONLY $DIR/f34
3771 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3772 error "getstripe failed"
3773 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3774 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3776 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3779 [ ! -f $DIR/f34 ] && test_34a
3780 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3781 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3782 $OPENFILE -f O_RDWR $DIR/f34
3783 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3784 error "$LFS getstripe failed"
3785 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3786 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3788 run_test 34c "O_RDWR opening file-with-size works =============="
3791 [ ! -f $DIR/f34 ] && test_34a
3792 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3794 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3795 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3798 run_test 34d "write to sparse file ============================="
3802 $MCREATE $DIR/f34e || error "mcreate failed"
3803 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3804 $CHECKSTAT -s 1000 $DIR/f34e ||
3805 error "Size of $DIR/f34e not equal to 1000 bytes"
3806 $OPENFILE -f O_RDWR $DIR/f34e
3807 $CHECKSTAT -s 1000 $DIR/f34e ||
3808 error "Size of $DIR/f34e not equal to 1000 bytes"
3810 run_test 34e "create objects, some with size and some without =="
3812 test_34f() { # bug 6242, 6243
3813 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3817 $MCREATE $DIR/f34f || error "mcreate failed"
3818 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3819 dd if=$DIR/f34f of=$TMP/f34f
3820 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3821 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3822 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3823 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3824 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3826 run_test 34f "read from a file with no objects until EOF ======="
3829 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3831 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3833 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3834 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3835 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3836 cancel_lru_locks osc
3837 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3838 error "wrong size after lock cancel"
3840 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3841 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3842 error "expanding truncate failed"
3843 cancel_lru_locks osc
3844 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3845 error "wrong expanded size after lock cancel"
3847 run_test 34g "truncate long file ==============================="
3850 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3855 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3856 sync # Flush the cache so that multiop below does not block on cache
3857 # flush when getting the group lock
3858 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3861 # Since just timed wait is not good enough, let's do a sync write
3862 # that way we are sure enough time for a roundtrip + processing
3863 # passed + 2 seconds of extra margin.
3864 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3868 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3869 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3873 local nsz=`stat -c %s $DIR/$tfile`
3874 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3876 run_test 34h "ftruncate file under grouplock should not block"
3879 cp /bin/sh $DIR/f35a
3881 chown $RUNAS_ID $DIR/f35a
3882 $RUNAS $DIR/f35a && error || true
3885 run_test 35a "exec file with mode 444 (should return and not leak)"
3889 utime $DIR/f36 || error "utime failed for MDS"
3891 run_test 36a "MDS utime check (mknod, utime)"
3895 utime $DIR/f36 || error "utime failed for OST"
3897 run_test 36b "OST utime check (open, utime)"
3902 chown $RUNAS_ID $DIR/d36
3903 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3905 run_test 36c "non-root MDS utime check (mknod, utime)"
3908 [ ! -d $DIR/d36 ] && test_36c
3909 echo "" > $DIR/d36/f36
3910 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3912 run_test 36d "non-root OST utime check (open, utime)"
3915 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3917 test_mkdir $DIR/$tdir
3918 touch $DIR/$tdir/$tfile
3919 $RUNAS utime $DIR/$tdir/$tfile &&
3920 error "utime worked, expected failure" || true
3922 run_test 36e "utime on non-owned file (should return error)"
3926 local LANG_SAVE=$LANG
3927 local LC_LANG_SAVE=$LC_LANG
3928 export LANG=C LC_LANG=C # for date language
3930 DATESTR="Dec 20 2000"
3931 test_mkdir $DIR/$tdir
3932 lctl set_param fail_loc=$fl
3934 cp /etc/hosts $DIR/$tdir/$tfile
3935 sync & # write RPC generated with "current" inode timestamp, but delayed
3937 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3938 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3939 cancel_lru_locks $OSC
3940 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3942 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3943 echo "BEFORE: $LS_BEFORE" && \
3944 echo "AFTER : $LS_AFTER" && \
3945 echo "WANT : $DATESTR" && \
3946 error "$DIR/$tdir/$tfile timestamps changed" || true
3948 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3952 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3954 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3955 subr_36fh "0x80000214"
3957 run_test 36f "utime on file racing with OST BRW write =========="
3960 remote_ost_nodsh && skip "remote OST with nodsh"
3961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3962 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
3963 skip "Need MDS version at least 2.12.51"
3968 local tgt="obdfilter"
3970 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
3972 test_mkdir $DIR/$tdir
3973 fmd_max_age=$(do_facet $facet \
3974 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
3977 echo "FMD max age: ${fmd_max_age}s"
3978 touch $DIR/$tdir/$tfile
3979 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3980 gawk '{cnt=cnt+$1} END{print cnt}')
3981 echo "FMD before: $fmd"
3983 error "FMD wasn't create by touch"
3984 sleep $((fmd_max_age + 12))
3985 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3986 gawk '{cnt=cnt+$1} END{print cnt}')
3987 echo "FMD after: $fmd"
3989 error "FMD wasn't expired by ping"
3991 run_test 36g "FMD cache expiry ====================="
3994 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3996 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3997 subr_36fh "0x80000227"
3999 run_test 36h "utime on file racing with OST BRW write =========="
4002 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4004 test_mkdir $DIR/$tdir
4005 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4007 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4008 local new_mtime=$((mtime + 200))
4010 #change Modify time of striped dir
4011 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4012 error "change mtime failed"
4014 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4016 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4018 run_test 36i "change mtime on striped directory"
4020 # test_37 - duplicate with tests 32q 32r
4023 local file=$DIR/$tfile
4025 openfile -f O_DIRECTORY $file
4028 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4029 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4031 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4033 test_39a() { # was test_39
4035 touch $DIR/${tfile}2
4036 # ls -l $DIR/$tfile $DIR/${tfile}2
4037 # ls -lu $DIR/$tfile $DIR/${tfile}2
4038 # ls -lc $DIR/$tfile $DIR/${tfile}2
4040 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4041 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4043 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4045 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4047 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4048 error "O_TRUNC didn't change timestamps"
4051 run_test 39a "mtime changed on create"
4054 test_mkdir -c1 $DIR/$tdir
4055 cp -p /etc/passwd $DIR/$tdir/fopen
4056 cp -p /etc/passwd $DIR/$tdir/flink
4057 cp -p /etc/passwd $DIR/$tdir/funlink
4058 cp -p /etc/passwd $DIR/$tdir/frename
4059 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4062 echo "aaaaaa" >> $DIR/$tdir/fopen
4063 echo "aaaaaa" >> $DIR/$tdir/flink
4064 echo "aaaaaa" >> $DIR/$tdir/funlink
4065 echo "aaaaaa" >> $DIR/$tdir/frename
4067 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4068 local link_new=`stat -c %Y $DIR/$tdir/flink`
4069 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4070 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4072 cat $DIR/$tdir/fopen > /dev/null
4073 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4074 rm -f $DIR/$tdir/funlink2
4075 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4077 for (( i=0; i < 2; i++ )) ; do
4078 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4079 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4080 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4081 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4083 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4084 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4085 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4086 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4088 cancel_lru_locks $OSC
4089 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4092 run_test 39b "mtime change on open, link, unlink, rename ======"
4094 # this should be set to past
4095 TEST_39_MTIME=`date -d "1 year ago" +%s`
4101 local mtime0=`stat -c %Y $DIR1/$tfile`
4103 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4104 local mtime1=`stat -c %Y $DIR1/$tfile`
4105 [ "$mtime1" = $TEST_39_MTIME ] || \
4106 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4109 echo hello >> $DIR1/$tfile
4111 local mtime2=`stat -c %Y $DIR1/$tfile`
4112 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4113 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4115 mv $DIR1/$tfile $DIR1/$tfile-1
4117 for (( i=0; i < 2; i++ )) ; do
4118 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4119 [ "$mtime2" = "$mtime3" ] || \
4120 error "mtime ($mtime2) changed (to $mtime3) on rename"
4122 cancel_lru_locks $OSC
4123 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4126 run_test 39c "mtime change on rename ==========================="
4130 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4133 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4135 for (( i=0; i < 2; i++ )) ; do
4136 local mtime=`stat -c %Y $DIR1/$tfile`
4137 [ $mtime = $TEST_39_MTIME ] || \
4138 error "mtime($mtime) is not set to $TEST_39_MTIME"
4140 cancel_lru_locks $OSC
4141 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4144 run_test 39d "create, utime, stat =============================="
4148 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4151 local mtime1=`stat -c %Y $DIR1/$tfile`
4153 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4155 for (( i=0; i < 2; i++ )) ; do
4156 local mtime2=`stat -c %Y $DIR1/$tfile`
4157 [ $mtime2 = $TEST_39_MTIME ] || \
4158 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4160 cancel_lru_locks $OSC
4161 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4164 run_test 39e "create, stat, utime, stat ========================"
4168 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4171 mtime1=`stat -c %Y $DIR1/$tfile`
4174 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4176 for (( i=0; i < 2; i++ )) ; do
4177 local mtime2=`stat -c %Y $DIR1/$tfile`
4178 [ $mtime2 = $TEST_39_MTIME ] || \
4179 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4181 cancel_lru_locks $OSC
4182 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4185 run_test 39f "create, stat, sleep, utime, stat ================="
4189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4191 echo hello >> $DIR1/$tfile
4192 local mtime1=`stat -c %Y $DIR1/$tfile`
4195 chmod o+r $DIR1/$tfile
4197 for (( i=0; i < 2; i++ )) ; do
4198 local mtime2=`stat -c %Y $DIR1/$tfile`
4199 [ "$mtime1" = "$mtime2" ] || \
4200 error "lost mtime: $mtime2, should be $mtime1"
4202 cancel_lru_locks $OSC
4203 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4206 run_test 39g "write, chmod, stat ==============================="
4210 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4216 echo hello >> $DIR1/$tfile
4217 local mtime1=`stat -c %Y $DIR1/$tfile`
4219 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4221 if [ "$d1" != "$d2" ]; then
4222 echo "write and touch not within one second"
4224 for (( i=0; i < 2; i++ )) ; do
4225 local mtime2=`stat -c %Y $DIR1/$tfile`
4226 [ "$mtime2" = $TEST_39_MTIME ] || \
4227 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4229 cancel_lru_locks $OSC
4230 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4234 run_test 39h "write, utime within one second, stat ============="
4237 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4242 echo hello >> $DIR1/$tfile
4243 local mtime1=`stat -c %Y $DIR1/$tfile`
4245 mv $DIR1/$tfile $DIR1/$tfile-1
4247 for (( i=0; i < 2; i++ )) ; do
4248 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4250 [ "$mtime1" = "$mtime2" ] || \
4251 error "lost mtime: $mtime2, should be $mtime1"
4253 cancel_lru_locks $OSC
4254 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4257 run_test 39i "write, rename, stat =============================="
4260 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4262 start_full_debug_logging
4266 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4267 lctl set_param fail_loc=0x80000412
4268 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4269 error "multiop failed"
4271 local mtime1=`stat -c %Y $DIR1/$tfile`
4273 mv $DIR1/$tfile $DIR1/$tfile-1
4275 kill -USR1 $multipid
4276 wait $multipid || error "multiop close failed"
4278 for (( i=0; i < 2; i++ )) ; do
4279 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4280 [ "$mtime1" = "$mtime2" ] ||
4281 error "mtime is lost on close: $mtime2, " \
4285 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4287 lctl set_param fail_loc=0
4288 stop_full_debug_logging
4290 run_test 39j "write, rename, close, stat ======================="
4293 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4298 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4300 local mtime1=`stat -c %Y $DIR1/$tfile`
4302 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4304 kill -USR1 $multipid
4305 wait $multipid || error "multiop close failed"
4307 for (( i=0; i < 2; i++ )) ; do
4308 local mtime2=`stat -c %Y $DIR1/$tfile`
4310 [ "$mtime2" = $TEST_39_MTIME ] || \
4311 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4314 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4317 run_test 39k "write, utime, close, stat ========================"
4319 # this should be set to future
4320 TEST_39_ATIME=`date -d "1 year" +%s`
4323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4324 remote_mds_nodsh && skip "remote MDS with nodsh"
4326 local atime_diff=$(do_facet $SINGLEMDS \
4327 lctl get_param -n mdd.*MDT0000*.atime_diff)
4331 # test setting directory atime to future
4332 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4333 local atime=$(stat -c %X $DIR/$tdir)
4334 [ "$atime" = $TEST_39_ATIME ] ||
4335 error "atime is not set to future: $atime, $TEST_39_ATIME"
4337 # test setting directory atime from future to now
4338 local now=$(date +%s)
4339 touch -a -d @$now $DIR/$tdir
4341 atime=$(stat -c %X $DIR/$tdir)
4342 [ "$atime" -eq "$now" ] ||
4343 error "atime is not updated from future: $atime, $now"
4345 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4348 # test setting directory atime when now > dir atime + atime_diff
4349 local d1=$(date +%s)
4351 local d2=$(date +%s)
4352 cancel_lru_locks mdc
4353 atime=$(stat -c %X $DIR/$tdir)
4354 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4355 error "atime is not updated : $atime, should be $d2"
4357 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4360 # test not setting directory atime when now < dir atime + atime_diff
4362 cancel_lru_locks mdc
4363 atime=$(stat -c %X $DIR/$tdir)
4364 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4365 error "atime is updated to $atime, should remain $d1<atime<$d2"
4367 do_facet $SINGLEMDS \
4368 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4370 run_test 39l "directory atime update ==========================="
4373 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4377 local far_past_mtime=$(date -d "May 29 1953" +%s)
4378 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4380 touch -m -d @$far_past_mtime $DIR1/$tfile
4381 touch -a -d @$far_past_atime $DIR1/$tfile
4383 for (( i=0; i < 2; i++ )) ; do
4384 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4385 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4386 error "atime or mtime set incorrectly"
4388 cancel_lru_locks $OSC
4389 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4392 run_test 39m "test atime and mtime before 1970"
4394 test_39n() { # LU-3832
4395 remote_mds_nodsh && skip "remote MDS with nodsh"
4397 local atime_diff=$(do_facet $SINGLEMDS \
4398 lctl get_param -n mdd.*MDT0000*.atime_diff)
4403 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4406 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4407 atime0=$(stat -c %X $DIR/$tfile)
4410 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4411 atime1=$(stat -c %X $DIR/$tfile)
4414 cancel_lru_locks mdc
4415 cancel_lru_locks osc
4416 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4417 atime2=$(stat -c %X $DIR/$tfile)
4419 do_facet $SINGLEMDS \
4420 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4422 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4423 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4425 run_test 39n "check that O_NOATIME is honored"
4428 TESTDIR=$DIR/$tdir/$tfile
4429 [ -e $TESTDIR ] && rm -rf $TESTDIR
4436 links2=$(stat -c %h .)
4437 [ $(($links1 + 2)) != $links2 ] &&
4438 error "wrong links count $(($links1 + 2)) != $links2"
4440 links3=$(stat -c %h .)
4441 [ $(($links1 + 1)) != $links3 ] &&
4442 error "wrong links count $links1 != $links3"
4445 run_test 39o "directory cached attributes updated after create"
4448 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4451 TESTDIR=$DIR/$tdir/$tdir
4452 [ -e $TESTDIR ] && rm -rf $TESTDIR
4453 test_mkdir -p $TESTDIR
4457 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4458 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4460 links2=$(stat -c %h .)
4461 [ $(($links1 + 2)) != $links2 ] &&
4462 error "wrong links count $(($links1 + 2)) != $links2"
4464 links3=$(stat -c %h .)
4465 [ $(($links1 + 1)) != $links3 ] &&
4466 error "wrong links count $links1 != $links3"
4469 run_test 39p "remote directory cached attributes updated after create ========"
4472 test_39q() { # LU-8041
4473 local testdir=$DIR/$tdir
4475 multiop_bg_pause $testdir D_c || error "multiop failed"
4477 cancel_lru_locks mdc
4478 kill -USR1 $multipid
4479 local atime=$(stat -c %X $testdir)
4480 [ "$atime" -ne 0 ] || error "atime is zero"
4482 run_test 39q "close won't zero out atime"
4485 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4486 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4487 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4488 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4489 error "$tfile is not 4096 bytes in size"
4491 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4495 small_write $DIR/f41 18
4497 run_test 41 "test small file write + fstat ====================="
4499 count_ost_writes() {
4500 lctl get_param -n ${OSC}.*.stats |
4501 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4502 END { printf("%0.0f", writes) }'
4509 BG_DIRTY_RATIO_SAVE=10
4510 MAX_BG_DIRTY_RATIO=25
4514 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4515 # dirty_ratio, dirty_background_ratio
4516 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4517 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4518 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4519 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4521 # if file not here, we are a 2.4 kernel
4522 kill -CONT `pidof kupdated`
4527 # setup the trap first, so someone cannot exit the test at the
4528 # exact wrong time and mess up a machine
4529 trap start_writeback EXIT
4530 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4531 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4532 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4533 sysctl -w vm.dirty_writeback_centisecs=0
4534 sysctl -w vm.dirty_writeback_centisecs=0
4535 # save and increase /proc/sys/vm/dirty_ratio
4536 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4537 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4538 # save and increase /proc/sys/vm/dirty_background_ratio
4539 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4540 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4542 # if file not here, we are a 2.4 kernel
4543 kill -STOP `pidof kupdated`
4547 # ensure that all stripes have some grant before we test client-side cache
4549 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4550 dd if=/dev/zero of=$i bs=4k count=1
4555 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4556 # file truncation, and file removal.
4558 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4561 cancel_lru_locks $OSC
4563 sync; sleep 1; sync # just to be safe
4564 BEFOREWRITES=`count_ost_writes`
4565 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4566 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4567 AFTERWRITES=`count_ost_writes`
4568 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4569 error "$BEFOREWRITES < $AFTERWRITES"
4572 run_test 42a "ensure that we don't flush on close"
4575 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4578 cancel_lru_locks $OSC
4581 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4582 BEFOREWRITES=$(count_ost_writes)
4583 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4584 AFTERWRITES=$(count_ost_writes)
4585 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4586 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4588 BEFOREWRITES=$(count_ost_writes)
4589 sync || error "sync: $?"
4590 AFTERWRITES=$(count_ost_writes)
4591 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4592 error "$BEFOREWRITES < $AFTERWRITES on sync"
4594 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4598 run_test 42b "test destroy of file with cached dirty data ======"
4600 # if these tests just want to test the effect of truncation,
4601 # they have to be very careful. consider:
4602 # - the first open gets a {0,EOF}PR lock
4603 # - the first write conflicts and gets a {0, count-1}PW
4604 # - the rest of the writes are under {count,EOF}PW
4605 # - the open for truncate tries to match a {0,EOF}PR
4606 # for the filesize and cancels the PWs.
4607 # any number of fixes (don't get {0,EOF} on open, match
4608 # composite locks, do smarter file size management) fix
4609 # this, but for now we want these tests to verify that
4610 # the cancellation with truncate intent works, so we
4611 # start the file with a full-file pw lock to match against
4612 # until the truncate.
4617 cancel_lru_locks $OSC
4619 # prime the file with 0,EOF PW to match
4623 # now the real test..
4624 dd if=/dev/zero of=$file bs=1024 count=100
4625 BEFOREWRITES=`count_ost_writes`
4626 $TRUNCATE $file $offset
4627 cancel_lru_locks $OSC
4628 AFTERWRITES=`count_ost_writes`
4633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4636 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4637 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4640 run_test 42c "test partial truncate of file with cached dirty data"
4643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4646 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4647 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4650 run_test 42d "test complete truncate of file with cached dirty data"
4652 test_42e() { # bug22074
4653 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4655 local TDIR=$DIR/${tdir}e
4656 local pages=16 # hardcoded 16 pages, don't change it.
4657 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4658 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4662 test_mkdir $DIR/${tdir}e
4663 $LFS setstripe -c 1 $TDIR
4664 createmany -o $TDIR/f $files
4666 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4668 # we assume that with $OSTCOUNT files, at least one of them will
4669 # be allocated on OST0.
4670 warmup_files=$((OSTCOUNT * max_dirty_mb))
4671 createmany -o $TDIR/w $warmup_files
4673 # write a large amount of data into one file and sync, to get good
4674 # avail_grant number from OST.
4675 for ((i=0; i<$warmup_files; i++)); do
4676 idx=$($LFS getstripe -i $TDIR/w$i)
4677 [ $idx -ne 0 ] && continue
4678 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4681 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4683 $LCTL get_param $proc_osc0/cur_dirty_bytes
4684 $LCTL get_param $proc_osc0/cur_grant_bytes
4686 # create as much dirty pages as we can while not to trigger the actual
4687 # RPCs directly. but depends on the env, VFS may trigger flush during this
4688 # period, hopefully we are good.
4689 for ((i=0; i<$warmup_files; i++)); do
4690 idx=$($LFS getstripe -i $TDIR/w$i)
4691 [ $idx -ne 0 ] && continue
4692 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4694 $LCTL get_param $proc_osc0/cur_dirty_bytes
4695 $LCTL get_param $proc_osc0/cur_grant_bytes
4697 # perform the real test
4698 $LCTL set_param $proc_osc0/rpc_stats 0
4699 for ((;i<$files; i++)); do
4700 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
4701 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4704 $LCTL get_param $proc_osc0/rpc_stats
4707 local have_ppr=false
4708 $LCTL get_param $proc_osc0/rpc_stats |
4709 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4710 # skip lines until we are at the RPC histogram data
4711 [ "$PPR" == "pages" ] && have_ppr=true && continue
4712 $have_ppr || continue
4714 # we only want the percent stat for < 16 pages
4715 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4717 percent=$((percent + WPCT))
4718 if [[ $percent -gt 15 ]]; then
4719 error "less than 16-pages write RPCs" \
4726 run_test 42e "verify sub-RPC writes are not done synchronously"
4728 test_43A() { # was test_43
4729 test_mkdir $DIR/$tdir
4730 cp -p /bin/ls $DIR/$tdir/$tfile
4731 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4733 # give multiop a chance to open
4736 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4739 run_test 43A "execution of file opened for write should return -ETXTBSY"
4742 test_mkdir $DIR/$tdir
4743 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4744 $DIR/$tdir/sleep 60 &
4746 # Make sure exec of $tdir/sleep wins race with truncate
4748 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4751 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4756 test_mkdir $DIR/$tdir
4757 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4758 $DIR/$tdir/sleep 60 &
4760 # Make sure exec of $tdir/sleep wins race with truncate
4762 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4765 run_test 43b "truncate of file being executed should return -ETXTBSY"
4768 local testdir="$DIR/$tdir"
4771 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4772 ( cd $testdir && md5sum -c )
4774 run_test 43c "md5sum of copy into lustre"
4776 test_44A() { # was test_44
4777 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4779 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4780 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4782 run_test 44A "zero length read from a sparse stripe"
4785 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4787 [ -z "$nstripe" ] && skip "can't get stripe info"
4788 [[ $nstripe -gt $OSTCOUNT ]] &&
4789 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4791 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4793 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4794 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4798 OFFSETS="0 $((stride/2)) $((stride-1))"
4799 for offset in $OFFSETS; do
4800 for i in $(seq 0 $((nstripe-1))); do
4801 local GLOBALOFFSETS=""
4803 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4804 local myfn=$DIR/d44a-$size
4805 echo "--------writing $myfn at $size"
4806 ll_sparseness_write $myfn $size ||
4807 error "ll_sparseness_write"
4808 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4809 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4810 error "ll_sparseness_verify $GLOBALOFFSETS"
4812 for j in $(seq 0 $((nstripe-1))); do
4814 size=$((((j + $nstripe )*$stride + $offset)))
4815 ll_sparseness_write $myfn $size ||
4816 error "ll_sparseness_write"
4817 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4819 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4820 error "ll_sparseness_verify $GLOBALOFFSETS"
4825 run_test 44a "test sparse pwrite ==============================="
4829 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4835 before=`dirty_osc_total`
4836 echo executing "\"$*\""
4838 after=`dirty_osc_total`
4839 echo before $before, after $after
4842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4845 # Obtain grants from OST if it supports it
4846 echo blah > ${f}_grant
4849 do_dirty_record "echo blah > $f"
4850 [[ $before -eq $after ]] && error "write wasn't cached"
4851 do_dirty_record "> $f"
4852 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4853 do_dirty_record "echo blah > $f"
4854 [[ $before -eq $after ]] && error "write wasn't cached"
4855 do_dirty_record "sync"
4856 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4857 do_dirty_record "echo blah > $f"
4858 [[ $before -eq $after ]] && error "write wasn't cached"
4859 do_dirty_record "cancel_lru_locks osc"
4860 [[ $before -gt $after ]] ||
4861 error "lock cancellation didn't lower dirty count"
4864 run_test 45 "osc io page accounting ============================"
4866 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4867 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4868 # objects offset and an assert hit when an rpc was built with 1023's mapped
4869 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4876 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4878 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4879 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4883 run_test 46 "dirtying a previously written page ================"
4885 # test_47 is removed "Device nodes check" is moved to test_28
4887 test_48a() { # bug 2399
4888 [ "$mds1_FSTYPE" = "zfs" ] &&
4889 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4890 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4892 test_mkdir $DIR/$tdir
4894 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4895 test_mkdir $DIR/$tdir
4896 touch foo || error "'touch foo' failed after recreating cwd"
4898 touch .foo || error "'touch .foo' failed after recreating cwd"
4900 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4901 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4902 cd . || error "'cd .' failed after recreating cwd"
4903 mkdir . && error "'mkdir .' worked after recreating cwd"
4904 rmdir . && error "'rmdir .' worked after recreating cwd"
4905 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4906 cd .. || error "'cd ..' failed after recreating cwd"
4908 run_test 48a "Access renamed working dir (should return errors)="
4910 test_48b() { # bug 2399
4912 test_mkdir $DIR/$tdir
4914 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4915 touch foo && error "'touch foo' worked after removing cwd"
4916 mkdir foo && error "'mkdir foo' worked after removing cwd"
4917 touch .foo && error "'touch .foo' worked after removing cwd"
4918 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4919 ls . > /dev/null && error "'ls .' worked after removing cwd"
4920 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4921 mkdir . && error "'mkdir .' worked after removing cwd"
4922 rmdir . && error "'rmdir .' worked after removing cwd"
4923 ln -s . foo && error "'ln -s .' worked after removing cwd"
4924 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4926 run_test 48b "Access removed working dir (should return errors)="
4928 test_48c() { # bug 2350
4929 #lctl set_param debug=-1
4932 test_mkdir -p $DIR/$tdir/dir
4934 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4935 $TRACE touch foo && error "touch foo worked after removing cwd"
4936 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4937 touch .foo && error "touch .foo worked after removing cwd"
4938 mkdir .foo && error "mkdir .foo worked after removing cwd"
4939 $TRACE ls . && error "'ls .' worked after removing cwd"
4940 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4941 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4942 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4943 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4944 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4946 run_test 48c "Access removed working subdir (should return errors)"
4948 test_48d() { # bug 2350
4949 #lctl set_param debug=-1
4952 test_mkdir -p $DIR/$tdir/dir
4954 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4955 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4956 $TRACE touch foo && error "'touch foo' worked after removing parent"
4957 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4958 touch .foo && error "'touch .foo' worked after removing parent"
4959 mkdir .foo && error "mkdir .foo worked after removing parent"
4960 $TRACE ls . && error "'ls .' worked after removing parent"
4961 $TRACE ls .. && error "'ls ..' worked after removing parent"
4962 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4963 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4964 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4967 run_test 48d "Access removed parent subdir (should return errors)"
4969 test_48e() { # bug 4134
4970 #lctl set_param debug=-1
4973 test_mkdir -p $DIR/$tdir/dir
4975 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4976 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4977 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4978 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4979 # On a buggy kernel addition of "touch foo" after cd .. will
4980 # produce kernel oops in lookup_hash_it
4981 touch ../foo && error "'cd ..' worked after recreate parent"
4983 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4985 run_test 48e "Access to recreated parent subdir (should return errors)"
4987 test_49() { # LU-1030
4988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4989 remote_ost_nodsh && skip "remote OST with nodsh"
4991 # get ost1 size - $FSNAME-OST0000
4992 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4994 # write 800M at maximum
4995 [[ $ost1_size -lt 2 ]] && ost1_size=2
4996 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4998 $LFS setstripe -c 1 -i 0 $DIR/$tfile
4999 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5002 # change max_pages_per_rpc while writing the file
5003 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5004 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5005 # loop until dd process exits
5006 while ps ax -opid | grep -wq $dd_pid; do
5007 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5008 sleep $((RANDOM % 5 + 1))
5010 # restore original max_pages_per_rpc
5011 $LCTL set_param $osc1_mppc=$orig_mppc
5012 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5014 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5018 test_mkdir $DIR/$tdir
5020 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5022 run_test 50 "special situations: /proc symlinks ==============="
5024 test_51a() { # was test_51
5025 # bug 1516 - create an empty entry right after ".." then split dir
5026 test_mkdir -c1 $DIR/$tdir
5027 touch $DIR/$tdir/foo
5028 $MCREATE $DIR/$tdir/bar
5030 createmany -m $DIR/$tdir/longfile 201
5032 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5033 $MCREATE $DIR/$tdir/longfile$FNUM
5038 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5040 run_test 51a "special situations: split htree with empty entry =="
5042 cleanup_print_lfs_df () {
5049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5051 local dir=$DIR/$tdir
5052 local nrdirs=$((65536 + 100))
5054 # cleanup the directory
5061 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5062 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5063 [[ $numfree -lt $nrdirs ]] &&
5064 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5066 # need to check free space for the directories as well
5067 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5068 numfree=$(( blkfree / $(fs_inode_ksize) ))
5069 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5071 trap cleanup_print_lfs_df EXIT
5074 createmany -d $dir/d $nrdirs || {
5075 unlinkmany $dir/d $nrdirs
5076 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5080 nrdirs=$(ls -U $dir | wc -l)
5082 # unlink all but 100 subdirectories, then check it still works
5084 local delete=$((nrdirs - left))
5089 # for ldiskfs the nlink count should be 1, but this is OSD specific
5090 # and so this is listed for informational purposes only
5091 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5092 unlinkmany -d $dir/d $delete ||
5093 error "unlink of first $delete subdirs failed"
5095 echo "nlink between: $(stat -c %h $dir)"
5096 local found=$(ls -U $dir | wc -l)
5097 [ $found -ne $left ] &&
5098 error "can't find subdirs: found only $found, expected $left"
5100 unlinkmany -d $dir/d $delete $left ||
5101 error "unlink of second $left subdirs failed"
5102 # regardless of whether the backing filesystem tracks nlink accurately
5103 # or not, the nlink count shouldn't be more than "." and ".." here
5104 local after=$(stat -c %h $dir)
5105 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5106 echo "nlink after: $after"
5108 cleanup_print_lfs_df
5110 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5113 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5114 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5116 test_mkdir $DIR/$tdir
5117 createmany -o $DIR/$tdir/t- 1000
5118 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5119 for N in $(seq 0 $((OSTCOUNT - 1))); do
5120 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
5121 END { printf("%0.0f", objs) }' $TMP/$tfile)
5122 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5123 '($1 == '$N') { objs += 1 } \
5124 END { printf("%0.0f", objs) }')
5125 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
5127 unlinkmany $DIR/$tdir/t- 1000
5130 for N in $(seq 1 $((OSTCOUNT - 1))); do
5131 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
5132 error "OST $N has less objects vs OST $NLAST" \
5133 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5134 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
5135 error "OST $N has less objects vs OST $NLAST" \
5136 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5138 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
5139 error "OST $N has less #0 objects vs OST $NLAST" \
5140 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5141 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
5142 error "OST $N has less #0 objects vs OST $NLAST" \
5143 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5148 run_test 51d "check object distribution"
5151 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5152 skip_env "ldiskfs only test"
5155 test_mkdir -c1 $DIR/$tdir
5156 test_mkdir -c1 $DIR/$tdir/d0
5158 touch $DIR/$tdir/d0/foo
5159 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5160 error "file exceed 65000 nlink limit!"
5161 unlinkmany $DIR/$tdir/d0/f- 65001
5164 run_test 51e "check file nlink limit"
5167 test_mkdir $DIR/$tdir
5170 local ulimit_old=$(ulimit -n)
5171 local spare=20 # number of spare fd's for scripts/libraries, etc.
5172 local mdt=$($LFS getstripe -m $DIR/$tdir)
5173 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5175 echo "MDT$mdt numfree=$numfree, max=$max"
5176 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5177 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5178 while ! ulimit -n $((numfree + spare)); do
5179 numfree=$((numfree * 3 / 4))
5181 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5183 echo "left ulimit at $ulimit_old"
5186 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5187 unlinkmany $DIR/$tdir/f $numfree
5188 error "create+open $numfree files in $DIR/$tdir failed"
5190 ulimit -n $ulimit_old
5192 # if createmany exits at 120s there will be fewer than $numfree files
5193 unlinkmany $DIR/$tdir/f $numfree || true
5195 run_test 51f "check many open files limit"
5198 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5199 test_mkdir $DIR/$tdir
5200 touch $DIR/$tdir/foo
5201 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5202 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5203 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5204 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5205 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5207 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5208 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5209 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5211 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5212 cp -r $DIR/$tdir $TMP/
5213 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5215 run_test 52a "append-only flag test (should return errors)"
5218 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5219 test_mkdir $DIR/$tdir
5220 touch $DIR/$tdir/foo
5221 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5222 cat test > $DIR/$tdir/foo && error "cat test worked"
5223 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5224 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5225 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5227 echo foo >> $DIR/$tdir/foo && error "echo worked"
5228 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5229 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5230 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5231 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5233 chattr -i $DIR/$tdir/foo || error "chattr failed"
5235 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5237 run_test 52b "immutable flag test (should return errors) ======="
5240 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5241 remote_mds_nodsh && skip "remote MDS with nodsh"
5242 remote_ost_nodsh && skip "remote OST with nodsh"
5255 local support_last_seq=true
5257 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5258 support_last_seq=false
5261 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5263 for value in $(do_facet $SINGLEMDS \
5264 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5265 param=$(echo ${value[0]} | cut -d "=" -f1)
5266 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5268 if $support_last_seq; then
5269 param_seq=$(echo $param |
5270 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5271 mds_last_seq=$(do_facet $SINGLEMDS \
5272 $LCTL get_param -n $param_seq)
5274 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5276 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5277 node=$(facet_active_host ost$((ostnum+1)))
5278 param="obdfilter.$ostname.last_id"
5279 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5280 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5281 ost_last_id=$ost_last
5283 if $support_last_seq; then
5284 ost_last_id=$(echo $ost_last |
5285 awk -F':' '{print $2}' |
5287 ost_last_seq=$(echo $ost_last |
5288 awk -F':' '{print $1}')
5289 [[ $ost_last_seq = $mds_last_seq ]] || continue
5292 if [[ $ost_last_id != $mds_last ]]; then
5293 error "$ost_last_id != $mds_last"
5300 $found || error "can not match last_seq/last_id for $mdtosc"
5303 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5306 perl -MSocket -e ';' || skip "no Socket perl module installed"
5308 $SOCKETSERVER $DIR/socket ||
5309 error "$SOCKETSERVER $DIR/socket failed: $?"
5310 $SOCKETCLIENT $DIR/socket ||
5311 error "$SOCKETCLIENT $DIR/socket failed: $?"
5312 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5314 run_test 54a "unix domain socket test =========================="
5320 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5322 run_test 54b "char device works in lustre ======================"
5325 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5326 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5327 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5329 for i in $(seq 3 7); do
5330 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5339 loopdev="$DIR/loop54c"
5342 $UMOUNT $DIR/$tdir || rc=$?
5343 losetup -d $loopdev || true
5344 losetup -d $LOOPDEV || true
5345 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5352 loopdev="$DIR/loop54c"
5355 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5356 trap cleanup_54c EXIT
5357 mknod $loopdev b 7 $LOOPNUM
5358 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5359 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5360 losetup $loopdev $DIR/$tfile ||
5361 error "can't set up $loopdev for $DIR/$tfile"
5362 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5363 test_mkdir $DIR/$tdir
5364 mount -t ext2 $loopdev $DIR/$tdir ||
5365 error "error mounting $loopdev on $DIR/$tdir"
5366 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
5369 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
5373 run_test 54c "block device works in lustre ====================="
5379 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
5381 run_test 54d "fifo device works in lustre ======================"
5386 cp -aL /dev/console $f
5387 echo $string > $f || error "echo $string to $f failed"
5389 run_test 54e "console/tty device works in lustre ======================"
5393 local dir=$DIR/$tdir
5396 test_mkdir -p $dir/dir
5397 for i in $(seq $numfiles); do
5399 touch $dir/dir/file$i
5402 local numcomp=$($LFS getstripe --component-count $dir)
5404 [[ $numcomp == 0 ]] && numcomp=1
5406 # test lfs getstripe with --recursive
5407 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5409 [[ $filenum -eq $((numfiles * 2)) ]] ||
5410 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5411 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5412 [[ $filenum -eq $numfiles ]] ||
5413 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5414 echo "$LFS getstripe showed obdidx or l_ost_idx"
5416 # test lfs getstripe with file instead of dir
5417 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5418 [[ $filenum -eq 1 ]] ||
5419 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5420 echo "$LFS getstripe file1 passed"
5422 #test lfs getstripe with --verbose
5423 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5424 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5425 error "$LFS getstripe --verbose $dir: "\
5426 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5427 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5428 error "$LFS getstripe $dir: showed lmm_magic"
5430 #test lfs getstripe with -v prints lmm_fid
5431 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5432 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5433 error "$LFS getstripe -v $dir: "\
5434 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5435 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5436 error "$LFS getstripe $dir: showed lmm_fid by default"
5437 echo "$LFS getstripe --verbose passed"
5439 #check for FID information
5440 local fid1=$($LFS getstripe --fid $dir/file1)
5441 local fid2=$($LFS getstripe --verbose $dir/file1 |
5442 awk '/lmm_fid: / { print $2; exit; }')
5443 local fid3=$($LFS path2fid $dir/file1)
5445 [ "$fid1" != "$fid2" ] &&
5446 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5447 [ "$fid1" != "$fid3" ] &&
5448 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5449 echo "$LFS getstripe --fid passed"
5451 #test lfs getstripe with --obd
5452 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5453 error "$LFS getstripe --obd wrong_uuid: should return error"
5455 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5458 local obduuid=$(ostuuid_from_index $ostidx)
5459 local found=$($LFS getstripe -r --obd $obduuid $dir |
5460 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5462 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5463 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5465 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5468 [[ $found -eq $filenum ]] ||
5469 error "$LFS getstripe --obd: found $found expect $filenum"
5470 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5471 sed '/^[ ]*'${ostidx}'[ ]/d' |
5472 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5473 error "$LFS getstripe --obd: should not show file on other obd"
5474 echo "$LFS getstripe --obd passed"
5476 run_test 56a "check $LFS getstripe"
5479 local dir=$DIR/$tdir
5483 for i in $(seq $numdirs); do
5484 test_mkdir $dir/dir$i
5487 # test lfs getdirstripe default mode is non-recursion, which is
5488 # different from lfs getstripe
5489 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5491 [[ $dircnt -eq 1 ]] ||
5492 error "$LFS getdirstripe: found $dircnt, not 1"
5493 dircnt=$($LFS getdirstripe --recursive $dir |
5494 grep -c lmv_stripe_count)
5495 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5496 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5498 run_test 56b "check $LFS getdirstripe"
5501 remote_ost_nodsh && skip "remote OST with nodsh"
5504 local ost_name=$(ostname_from_index $ost_idx)
5505 local old_status=$(ost_dev_status $ost_idx)
5507 [[ -z "$old_status" ]] ||
5508 skip_env "OST $ost_name is in $old_status status"
5510 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5511 [[ $OST1_VERSION -ge $(version_code 2.12.55) ]] && do_facet ost1 \
5512 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
5515 local new_status=$(ost_dev_status $ost_idx)
5517 [[ "$new_status" =~ "D" ]] ||
5518 error "$ost_name status is '$new_status', missing 'D'"
5519 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
5520 [[ "$new_status" =~ "N" ]] ||
5521 error "$ost_name status is '$new_status', missing 'N'"
5524 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5525 [[ $OST1_VERSION -ge $(version_code 2.12.55) ]] && do_facet ost1 \
5526 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
5529 new_status=$(ost_dev_status $ost_idx)
5530 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
5531 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
5533 run_test 56c "check 'lfs df' showing device status"
5538 local local_tdir="$1"
5539 local local_numfiles="$2"
5540 local local_numdirs="$3"
5541 local dir_params="$4"
5542 local dir_stripe_params="$5"
5544 if [ ! -d "$local_tdir" ] ; then
5545 test_mkdir -p $dir_stripe_params $local_tdir
5546 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5547 for i in $(seq $local_numfiles) ; do
5548 touch $local_tdir/file$i
5550 for i in $(seq $local_numdirs) ; do
5551 test_mkdir $dir_stripe_params $local_tdir/dir$i
5552 for j in $(seq $local_numfiles) ; do
5553 touch $local_tdir/dir$i/file$j
5559 setup_56_special() {
5561 local local_numfiles=$2
5562 local local_numdirs=$3
5564 setup_56 $local_tdir $local_numfiles $local_numdirs
5566 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5567 for i in $(seq $local_numfiles) ; do
5568 mknod $local_tdir/loop${i}b b 7 $i
5569 mknod $local_tdir/null${i}c c 1 3
5570 ln -s $local_tdir/file1 $local_tdir/link${i}
5572 for i in $(seq $local_numdirs) ; do
5573 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5574 mknod $local_tdir/dir$i/null${i}c c 1 3
5575 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5581 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5582 local expected=$(($NUMDIRS + 2))
5584 setup_56 $dir $NUMFILES $NUMDIRS
5586 # test lfs find with -name
5587 for i in $(seq $NUMFILES) ; do
5588 local nums=$($LFS find -name "*$i" $dir | wc -l)
5590 [ $nums -eq $expected ] ||
5591 error "lfs find -name '*$i' $dir wrong: "\
5592 "found $nums, expected $expected"
5595 run_test 56g "check lfs find -name"
5598 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5599 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5601 setup_56 $dir $NUMFILES $NUMDIRS
5603 # test lfs find with ! -name
5604 for i in $(seq $NUMFILES) ; do
5605 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5607 [ $nums -eq $expected ] ||
5608 error "lfs find ! -name '*$i' $dir wrong: "\
5609 "found $nums, expected $expected"
5612 run_test 56h "check lfs find ! -name"
5615 local dir=$DIR/$tdir
5619 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5622 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5624 run_test 56i "check 'lfs find -ost UUID' skips directories"
5627 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5629 setup_56_special $dir $NUMFILES $NUMDIRS
5631 local expected=$((NUMDIRS + 1))
5632 local cmd="$LFS find -type d $dir"
5633 local nums=$($cmd | wc -l)
5635 [ $nums -eq $expected ] ||
5636 error "'$cmd' wrong: found $nums, expected $expected"
5638 run_test 56j "check lfs find -type d"
5641 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5643 setup_56_special $dir $NUMFILES $NUMDIRS
5645 local expected=$(((NUMDIRS + 1) * NUMFILES))
5646 local cmd="$LFS find -type f $dir"
5647 local nums=$($cmd | wc -l)
5649 [ $nums -eq $expected ] ||
5650 error "'$cmd' wrong: found $nums, expected $expected"
5652 run_test 56k "check lfs find -type f"
5655 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5657 setup_56_special $dir $NUMFILES $NUMDIRS
5659 local expected=$((NUMDIRS + NUMFILES))
5660 local cmd="$LFS find -type b $dir"
5661 local nums=$($cmd | wc -l)
5663 [ $nums -eq $expected ] ||
5664 error "'$cmd' wrong: found $nums, expected $expected"
5666 run_test 56l "check lfs find -type b"
5669 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5671 setup_56_special $dir $NUMFILES $NUMDIRS
5673 local expected=$((NUMDIRS + NUMFILES))
5674 local cmd="$LFS find -type c $dir"
5675 local nums=$($cmd | wc -l)
5676 [ $nums -eq $expected ] ||
5677 error "'$cmd' wrong: found $nums, expected $expected"
5679 run_test 56m "check lfs find -type c"
5682 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5683 setup_56_special $dir $NUMFILES $NUMDIRS
5685 local expected=$((NUMDIRS + NUMFILES))
5686 local cmd="$LFS find -type l $dir"
5687 local nums=$($cmd | wc -l)
5689 [ $nums -eq $expected ] ||
5690 error "'$cmd' wrong: found $nums, expected $expected"
5692 run_test 56n "check lfs find -type l"
5695 local dir=$DIR/$tdir
5697 setup_56 $dir $NUMFILES $NUMDIRS
5698 utime $dir/file1 > /dev/null || error "utime (1)"
5699 utime $dir/file2 > /dev/null || error "utime (2)"
5700 utime $dir/dir1 > /dev/null || error "utime (3)"
5701 utime $dir/dir2 > /dev/null || error "utime (4)"
5702 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5703 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5706 local nums=$($LFS find -mtime +0 $dir | wc -l)
5708 [ $nums -eq $expected ] ||
5709 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5712 cmd="$LFS find -mtime 0 $dir"
5713 nums=$($cmd | wc -l)
5714 [ $nums -eq $expected ] ||
5715 error "'$cmd' wrong: found $nums, expected $expected"
5717 run_test 56o "check lfs find -mtime for old files"
5720 local dir=$DIR/$tdir
5724 # just to make sure there is something that won't be found
5726 touch $dir/$tfile.now
5728 for age in year week day hour min; do
5729 count=$((count + 1))
5731 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
5732 touch --date="$count $age ago" -a $dir/$tfile-a.$age
5733 touch --date="$count $age ago" -m $dir/$tfile-m.$age
5735 local cmd="$LFS find $dir -mtime $count${age:0:1}"
5736 local nums=$($cmd | wc -l)
5737 [ $nums -eq $expected ] ||
5738 error "'$cmd' wrong: found $nums, expected $expected"
5740 cmd="$LFS find $dir -atime $count${age:0:1}"
5741 nums=$($cmd | wc -l)
5742 [ $nums -eq $expected ] ||
5743 error "'$cmd' wrong: found $nums, expected $expected"
5747 cmd="$LFS find $dir -ctime +1s -type f"
5748 nums=$($cmd | wc -l)
5749 (( $nums == $count * 2 + 1)) ||
5750 error "'$cmd' wrong: found $nums, expected $((expected*2+1))"
5752 run_test 56ob "check lfs find -atime -mtime -ctime with units"
5754 test_newerXY_base() {
5757 local dir=$DIR/$tdir
5761 if [ $y == "t" ]; then
5762 ref="\"$(date +"%Y-%m-%d %H:%M:%S")\""
5764 ref=$DIR/$tfile.newer
5765 touch $ref || error "touch $ref failed"
5768 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
5770 if [ $y == "t" ]; then
5771 negref="\"$(date +"%Y-%m-%d %H:%M:%S")\""
5773 negref=$DIR/$tfile.newerneg
5774 touch $negref || error "touch $negref failed"
5777 local cmd="$LFS find $dir -newer$x$y $ref"
5778 local nums=$(eval $cmd | wc -l)
5779 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
5781 [ $nums -eq $expected ] ||
5782 error "'$cmd' wrong: found $nums, expected $expected"
5784 cmd="$LFS find $dir ! -newer$x$y $negref"
5785 nums=$(eval $cmd | wc -l)
5786 [ $nums -eq $expected ] ||
5787 error "'$cmd' wrong: found $nums, expected $expected"
5789 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
5790 nums=$(eval $cmd | wc -l)
5791 [ $nums -eq $expected ] ||
5792 error "'$cmd' wrong: found $nums, expected $expected"
5798 test_newerXY_base "a" "a"
5799 test_newerXY_base "a" "m"
5800 test_newerXY_base "a" "c"
5801 test_newerXY_base "m" "a"
5802 test_newerXY_base "m" "m"
5803 test_newerXY_base "m" "c"
5804 test_newerXY_base "c" "a"
5805 test_newerXY_base "c" "m"
5806 test_newerXY_base "c" "c"
5807 test_newerXY_base "a" "t"
5808 test_newerXY_base "m" "t"
5809 test_newerXY_base "c" "t"
5811 run_test 56oc "check lfs find -newerXY work"
5814 [ $RUNAS_ID -eq $UID ] &&
5815 skip_env "RUNAS_ID = UID = $UID -- skipping"
5817 local dir=$DIR/$tdir
5819 setup_56 $dir $NUMFILES $NUMDIRS
5820 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5822 local expected=$NUMFILES
5823 local cmd="$LFS find -uid $RUNAS_ID $dir"
5824 local nums=$($cmd | wc -l)
5826 [ $nums -eq $expected ] ||
5827 error "'$cmd' wrong: found $nums, expected $expected"
5829 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5830 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5831 nums=$($cmd | wc -l)
5832 [ $nums -eq $expected ] ||
5833 error "'$cmd' wrong: found $nums, expected $expected"
5835 run_test 56p "check lfs find -uid and ! -uid"
5838 [ $RUNAS_ID -eq $UID ] &&
5839 skip_env "RUNAS_ID = UID = $UID -- skipping"
5841 local dir=$DIR/$tdir
5843 setup_56 $dir $NUMFILES $NUMDIRS
5844 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5846 local expected=$NUMFILES
5847 local cmd="$LFS find -gid $RUNAS_GID $dir"
5848 local nums=$($cmd | wc -l)
5850 [ $nums -eq $expected ] ||
5851 error "'$cmd' wrong: found $nums, expected $expected"
5853 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5854 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5855 nums=$($cmd | wc -l)
5856 [ $nums -eq $expected ] ||
5857 error "'$cmd' wrong: found $nums, expected $expected"
5859 run_test 56q "check lfs find -gid and ! -gid"
5862 local dir=$DIR/$tdir
5864 setup_56 $dir $NUMFILES $NUMDIRS
5867 local cmd="$LFS find -size 0 -type f -lazy $dir"
5868 local nums=$($cmd | wc -l)
5870 [ $nums -eq $expected ] ||
5871 error "'$cmd' wrong: found $nums, expected $expected"
5872 cmd="$LFS find -size 0 -type f $dir"
5873 nums=$($cmd | wc -l)
5874 [ $nums -eq $expected ] ||
5875 error "'$cmd' wrong: found $nums, expected $expected"
5878 cmd="$LFS find ! -size 0 -type f -lazy $dir"
5879 nums=$($cmd | wc -l)
5880 [ $nums -eq $expected ] ||
5881 error "'$cmd' wrong: found $nums, expected $expected"
5882 cmd="$LFS find ! -size 0 -type f $dir"
5883 nums=$($cmd | wc -l)
5884 [ $nums -eq $expected ] ||
5885 error "'$cmd' wrong: found $nums, expected $expected"
5887 echo "test" > $dir/$tfile
5888 echo "test2" > $dir/$tfile.2 && sync
5890 cmd="$LFS find -size 5 -type f -lazy $dir"
5891 nums=$($cmd | wc -l)
5892 [ $nums -eq $expected ] ||
5893 error "'$cmd' wrong: found $nums, expected $expected"
5894 cmd="$LFS find -size 5 -type f $dir"
5895 nums=$($cmd | wc -l)
5896 [ $nums -eq $expected ] ||
5897 error "'$cmd' wrong: found $nums, expected $expected"
5900 cmd="$LFS find -size +5 -type f -lazy $dir"
5901 nums=$($cmd | wc -l)
5902 [ $nums -eq $expected ] ||
5903 error "'$cmd' wrong: found $nums, expected $expected"
5904 cmd="$LFS find -size +5 -type f $dir"
5905 nums=$($cmd | wc -l)
5906 [ $nums -eq $expected ] ||
5907 error "'$cmd' wrong: found $nums, expected $expected"
5910 cmd="$LFS find -size +0 -type f -lazy $dir"
5911 nums=$($cmd | wc -l)
5912 [ $nums -eq $expected ] ||
5913 error "'$cmd' wrong: found $nums, expected $expected"
5914 cmd="$LFS find -size +0 -type f $dir"
5915 nums=$($cmd | wc -l)
5916 [ $nums -eq $expected ] ||
5917 error "'$cmd' wrong: found $nums, expected $expected"
5920 cmd="$LFS find ! -size -5 -type f -lazy $dir"
5921 nums=$($cmd | wc -l)
5922 [ $nums -eq $expected ] ||
5923 error "'$cmd' wrong: found $nums, expected $expected"
5924 cmd="$LFS find ! -size -5 -type f $dir"
5925 nums=$($cmd | wc -l)
5926 [ $nums -eq $expected ] ||
5927 error "'$cmd' wrong: found $nums, expected $expected"
5930 cmd="$LFS find -size -5 -type f -lazy $dir"
5931 nums=$($cmd | wc -l)
5932 [ $nums -eq $expected ] ||
5933 error "'$cmd' wrong: found $nums, expected $expected"
5934 cmd="$LFS find -size -5 -type f $dir"
5935 nums=$($cmd | wc -l)
5936 [ $nums -eq $expected ] ||
5937 error "'$cmd' wrong: found $nums, expected $expected"
5939 run_test 56r "check lfs find -size works"
5942 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
5943 skip "MDS < 2.12.58 doesn't return LSOM data"
5944 local dir=$DIR/$tdir
5946 [[ $OSC == "mdc" ]] && skip "DoM files" && return
5948 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5950 cancel_lru_locks $OSC
5952 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5954 local cmd="$LFS find -size 0 -type f -lazy $dir"
5955 local nums=$($cmd | wc -l)
5957 [ $nums -eq $expected ] ||
5958 error "'$cmd' wrong: found $nums, expected $expected"
5960 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5961 [ $rpcs_before -eq $rpcs_after ] ||
5962 error "'$cmd' should not send glimpse RPCs to OST"
5963 cmd="$LFS find -size 0 -type f $dir"
5964 nums=$($cmd | wc -l)
5965 [ $nums -eq $expected ] ||
5966 error "'$cmd' wrong: found $nums, expected $expected"
5967 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5968 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5969 $LCTL get_param osc.*.stats
5970 [ $rpcs_after -eq $((rpcs_before + 12)) ] ||
5971 error "'$cmd' should send 12 glimpse RPCs to OST"
5973 cancel_lru_locks $OSC
5974 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5976 cmd="$LFS find ! -size 0 -type f -lazy $dir"
5977 nums=$($cmd | wc -l)
5978 [ $nums -eq $expected ] ||
5979 error "'$cmd' wrong: found $nums, expected $expected"
5980 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5981 $LCTL get_param mdc.*.stats
5982 [ $rpcs_before -eq $rpcs_after ] ||
5983 error "'$cmd' should not send glimpse RPCs to OST"
5984 cmd="$LFS find ! -size 0 -type f $dir"
5985 nums=$($cmd | wc -l)
5986 [ $nums -eq $expected ] ||
5987 error "'$cmd' wrong: found $nums, expected $expected"
5988 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5989 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5990 [ $rpcs_after -eq $((rpcs_before + 12)) ] ||
5991 error "'$cmd' should send 12 glimpse RPCs to OST"
5993 echo "test" > $dir/$tfile
5994 echo "test2" > $dir/$tfile.2 && sync
5995 cancel_lru_locks $OSC
5996 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5998 cmd="$LFS find -size 5 -type f -lazy $dir"
5999 nums=$($cmd | wc -l)
6000 [ $nums -eq $expected ] ||
6001 error "'$cmd' wrong: found $nums, expected $expected"
6002 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6003 [ $rpcs_before -eq $rpcs_after ] ||
6004 error "'$cmd' should not send glimpse RPCs to OST"
6005 cmd="$LFS find -size 5 -type f $dir"
6006 nums=$($cmd | wc -l)
6007 [ $nums -eq $expected ] ||
6008 error "'$cmd' wrong: found $nums, expected $expected"
6009 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6010 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6011 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6012 error "'$cmd' should send 14 glimpse RPCs to OST"
6014 cancel_lru_locks $OSC
6015 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6017 cmd="$LFS find -size +5 -type f -lazy $dir"
6018 nums=$($cmd | wc -l)
6019 [ $nums -eq $expected ] ||
6020 error "'$cmd' wrong: found $nums, expected $expected"
6021 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6022 [ $rpcs_before -eq $rpcs_after ] ||
6023 error "'$cmd' should not send glimpse RPCs to OST"
6024 cmd="$LFS find -size +5 -type f $dir"
6025 nums=$($cmd | wc -l)
6026 [ $nums -eq $expected ] ||
6027 error "'$cmd' wrong: found $nums, expected $expected"
6028 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6029 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6030 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6031 error "'$cmd' should send 14 glimpse RPCs to OST"
6033 cancel_lru_locks $OSC
6034 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6036 cmd="$LFS find -size +0 -type f -lazy $dir"
6037 nums=$($cmd | wc -l)
6038 [ $nums -eq $expected ] ||
6039 error "'$cmd' wrong: found $nums, expected $expected"
6040 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6041 [ $rpcs_before -eq $rpcs_after ] ||
6042 error "'$cmd' should not send glimpse RPCs to OST"
6043 cmd="$LFS find -size +0 -type f $dir"
6044 nums=$($cmd | wc -l)
6045 [ $nums -eq $expected ] ||
6046 error "'$cmd' wrong: found $nums, expected $expected"
6047 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6048 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6049 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6050 error "'$cmd' should send 14 glimpse RPCs to OST"
6052 cancel_lru_locks $OSC
6053 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6055 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6056 nums=$($cmd | wc -l)
6057 [ $nums -eq $expected ] ||
6058 error "'$cmd' wrong: found $nums, expected $expected"
6059 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6060 [ $rpcs_before -eq $rpcs_after ] ||
6061 error "'$cmd' should not send glimpse RPCs to OST"
6062 cmd="$LFS find ! -size -5 -type f $dir"
6063 nums=$($cmd | wc -l)
6064 [ $nums -eq $expected ] ||
6065 error "'$cmd' wrong: found $nums, expected $expected"
6066 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6067 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6068 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6069 error "'$cmd' should send 14 glimpse RPCs to OST"
6071 cancel_lru_locks $OSC
6072 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6074 cmd="$LFS find -size -5 -type f -lazy $dir"
6075 nums=$($cmd | wc -l)
6076 [ $nums -eq $expected ] ||
6077 error "'$cmd' wrong: found $nums, expected $expected"
6078 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6079 [ $rpcs_before -eq $rpcs_after ] ||
6080 error "'$cmd' should not send glimpse RPCs to OST"
6081 cmd="$LFS find -size -5 -type f $dir"
6082 nums=$($cmd | wc -l)
6083 [ $nums -eq $expected ] ||
6084 error "'$cmd' wrong: found $nums, expected $expected"
6085 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6086 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6087 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6088 error "'$cmd' should send 14 glimpse RPCs to OST"
6090 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6092 test_56s() { # LU-611 #LU-9369
6093 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
6095 local dir=$DIR/$tdir
6096 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
6098 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6099 for i in $(seq $NUMDIRS); do
6100 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
6103 local expected=$NUMDIRS
6104 local cmd="$LFS find -c $OSTCOUNT $dir"
6105 local nums=$($cmd | wc -l)
6107 [ $nums -eq $expected ] || {
6108 $LFS getstripe -R $dir
6109 error "'$cmd' wrong: found $nums, expected $expected"
6112 expected=$((NUMDIRS + onestripe))
6113 cmd="$LFS find -stripe-count +0 -type f $dir"
6114 nums=$($cmd | wc -l)
6115 [ $nums -eq $expected ] || {
6116 $LFS getstripe -R $dir
6117 error "'$cmd' wrong: found $nums, expected $expected"
6121 cmd="$LFS find -stripe-count 1 -type f $dir"
6122 nums=$($cmd | wc -l)
6123 [ $nums -eq $expected ] || {
6124 $LFS getstripe -R $dir
6125 error "'$cmd' wrong: found $nums, expected $expected"
6128 cmd="$LFS find -stripe-count -2 -type f $dir"
6129 nums=$($cmd | wc -l)
6130 [ $nums -eq $expected ] || {
6131 $LFS getstripe -R $dir
6132 error "'$cmd' wrong: found $nums, expected $expected"
6136 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
6137 nums=$($cmd | wc -l)
6138 [ $nums -eq $expected ] || {
6139 $LFS getstripe -R $dir
6140 error "'$cmd' wrong: found $nums, expected $expected"
6143 run_test 56s "check lfs find -stripe-count works"
6145 test_56t() { # LU-611 #LU-9369
6146 local dir=$DIR/$tdir
6148 setup_56 $dir 0 $NUMDIRS
6149 for i in $(seq $NUMDIRS); do
6150 $LFS setstripe -S 8M $dir/dir$i/$tfile
6153 local expected=$NUMDIRS
6154 local cmd="$LFS find -S 8M $dir"
6155 local nums=$($cmd | wc -l)
6157 [ $nums -eq $expected ] || {
6158 $LFS getstripe -R $dir
6159 error "'$cmd' wrong: found $nums, expected $expected"
6163 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
6165 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
6167 expected=$(((NUMDIRS + 1) * NUMFILES))
6168 cmd="$LFS find -stripe-size 512k -type f $dir"
6169 nums=$($cmd | wc -l)
6170 [ $nums -eq $expected ] ||
6171 error "'$cmd' wrong: found $nums, expected $expected"
6173 cmd="$LFS find -stripe-size +320k -type f $dir"
6174 nums=$($cmd | wc -l)
6175 [ $nums -eq $expected ] ||
6176 error "'$cmd' wrong: found $nums, expected $expected"
6178 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
6179 cmd="$LFS find -stripe-size +200k -type f $dir"
6180 nums=$($cmd | wc -l)
6181 [ $nums -eq $expected ] ||
6182 error "'$cmd' wrong: found $nums, expected $expected"
6184 cmd="$LFS find -stripe-size -640k -type f $dir"
6185 nums=$($cmd | wc -l)
6186 [ $nums -eq $expected ] ||
6187 error "'$cmd' wrong: found $nums, expected $expected"
6190 cmd="$LFS find -stripe-size 256k -type f $dir"
6191 nums=$($cmd | wc -l)
6192 [ $nums -eq $expected ] ||
6193 error "'$cmd' wrong: found $nums, expected $expected"
6195 cmd="$LFS find -stripe-size -320k -type f $dir"
6196 nums=$($cmd | wc -l)
6197 [ $nums -eq $expected ] ||
6198 error "'$cmd' wrong: found $nums, expected $expected"
6201 cmd="$LFS find -stripe-size 1024k -type f $dir"
6202 nums=$($cmd | wc -l)
6203 [ $nums -eq $expected ] ||
6204 error "'$cmd' wrong: found $nums, expected $expected"
6206 run_test 56t "check lfs find -stripe-size works"
6208 test_56u() { # LU-611
6209 local dir=$DIR/$tdir
6211 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
6213 if [[ $OSTCOUNT -gt 1 ]]; then
6214 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
6220 local expected=$(((NUMDIRS + 1) * NUMFILES))
6221 local cmd="$LFS find -stripe-index 0 -type f $dir"
6222 local nums=$($cmd | wc -l)
6224 [ $nums -eq $expected ] ||
6225 error "'$cmd' wrong: found $nums, expected $expected"
6228 cmd="$LFS find -stripe-index 1 -type f $dir"
6229 nums=$($cmd | wc -l)
6230 [ $nums -eq $expected ] ||
6231 error "'$cmd' wrong: found $nums, expected $expected"
6233 cmd="$LFS find ! -stripe-index 0 -type f $dir"
6234 nums=$($cmd | wc -l)
6235 [ $nums -eq $expected ] ||
6236 error "'$cmd' wrong: found $nums, expected $expected"
6239 # This should produce an error and not return any files
6240 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
6241 nums=$($cmd 2>/dev/null | wc -l)
6242 [ $nums -eq $expected ] ||
6243 error "'$cmd' wrong: found $nums, expected $expected"
6245 if [[ $OSTCOUNT -gt 1 ]]; then
6246 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
6247 cmd="$LFS find -stripe-index 0,1 -type f $dir"
6248 nums=$($cmd | wc -l)
6249 [ $nums -eq $expected ] ||
6250 error "'$cmd' wrong: found $nums, expected $expected"
6253 run_test 56u "check lfs find -stripe-index works"
6257 local dir=$DIR/$tdir
6259 setup_56 $dir $NUMFILES $NUMDIRS
6261 UUID=$(mdtuuid_from_index $mdt_idx $dir)
6262 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
6264 for file in $($LFS find -m $UUID $dir); do
6265 file_midx=$($LFS getstripe -m $file)
6266 [ $file_midx -eq $mdt_idx ] ||
6267 error "lfs find -m $UUID != getstripe -m $file_midx"
6270 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
6273 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6276 local dir=$DIR/$tdir
6278 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
6280 local stripe_size=$($LFS getstripe -S -d $dir) ||
6281 error "$LFS getstripe -S -d $dir failed"
6282 stripe_size=${stripe_size%% *}
6284 local file_size=$((stripe_size * OSTCOUNT))
6285 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
6286 local required_space=$((file_num * file_size))
6287 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
6289 [[ $free_space -le $((required_space / 1024)) ]] &&
6290 skip_env "need $required_space, have $free_space kbytes"
6293 local dd_count=$((file_size / dd_bs))
6295 # write data into the files
6300 for i in $(seq $NUMFILES); do
6302 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6303 error "write data into $file failed"
6305 for i in $(seq $NUMDIRS); do
6306 for j in $(seq $NUMFILES); do
6307 file=$dir/dir$i/file$j
6308 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6309 error "write data into $file failed"
6313 # $LFS_MIGRATE will fail if hard link migration is unsupported
6314 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
6315 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
6316 error "creating links to $dir/dir1/file1 failed"
6321 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
6324 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
6327 eval $cmd || error "$cmd failed"
6329 check_stripe_count $dir/file1 $expected
6331 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
6333 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
6334 # OST 1 if it is on OST 0. This file is small enough to
6335 # be on only one stripe.
6336 file=$dir/migr_1_ost
6337 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
6338 error "write data into $file failed"
6339 local obdidx=$($LFS getstripe -i $file)
6340 local oldmd5=$(md5sum $file)
6343 [[ $obdidx -eq 0 ]] && newobdidx=1
6344 cmd="$LFS migrate -i $newobdidx $file"
6346 eval $cmd || error "$cmd failed"
6348 local realobdix=$($LFS getstripe -i $file)
6349 local newmd5=$(md5sum $file)
6351 [[ $newobdidx -ne $realobdix ]] &&
6352 error "new OST is different (was=$obdidx, "\
6353 "wanted=$newobdidx, got=$realobdix)"
6354 [[ "$oldmd5" != "$newmd5" ]] &&
6355 error "md5sum differ: $oldmd5, $newmd5"
6359 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
6361 eval $cmd || error "$cmd failed"
6363 for j in $(seq $NUMFILES); do
6364 check_stripe_count $dir/dir1/file$j $expected
6367 # lfs_migrate works with lfs find
6368 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
6369 $LFS_MIGRATE -y -c $expected"
6371 eval $cmd || error "$cmd failed"
6373 for i in $(seq 2 $NUMFILES); do
6374 check_stripe_count $dir/file$i $expected
6376 for i in $(seq 2 $NUMDIRS); do
6377 for j in $(seq $NUMFILES); do
6378 check_stripe_count $dir/dir$i/file$j $expected
6382 run_test 56w "check lfs_migrate -c stripe_count works"
6385 local file1=$DIR/$tdir/file1
6386 local create_pool=false
6387 local initial_pool=$($LFS getstripe -p $DIR)
6391 echo -n "Creating test dir..."
6392 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6395 echo -n "Creating test file..."
6396 touch $file1 || error "cannot create file"
6399 echo -n "Detecting existing pools..."
6400 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
6402 if [ ${#pool_list[@]} -gt 0 ]; then
6403 echo "${pool_list[@]}"
6404 for thispool in "${pool_list[@]}"; do
6405 if [[ -z "$initial_pool" ||
6406 "$initial_pool" != "$thispool" ]]; then
6408 echo "Using existing pool '$pool'"
6413 echo "none detected."
6415 if [ -z "$pool" ]; then
6416 pool=${POOL:-testpool}
6417 [ "$initial_pool" = "$pool" ] && pool="testpool2"
6418 echo -n "Creating pool '$pool'..."
6420 pool_add $pool &> /dev/null ||
6421 error "pool_add failed"
6424 echo -n "Adding target to pool..."
6425 pool_add_targets $pool 0 0 1 &> /dev/null ||
6426 error "pool_add_targets failed"
6430 echo -n "Setting pool using -p option..."
6431 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
6432 error "migrate failed rc = $?"
6435 echo -n "Verifying test file is in pool after migrating..."
6436 [ "$($LFS getstripe -p $file1)" = $pool ] ||
6437 error "file was not migrated to pool $pool"
6440 echo -n "Removing test file from pool '$pool'..."
6441 # "lfs migrate $file" won't remove the file from the pool
6442 # until some striping information is changed.
6443 $LFS migrate -c 1 $file1 &> /dev/null ||
6444 error "cannot remove from pool"
6445 [ "$($LFS getstripe -p $file1)" ] &&
6446 error "pool still set"
6449 echo -n "Setting pool using --pool option..."
6450 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
6451 error "migrate failed rc = $?"
6456 if $create_pool; then
6457 destroy_test_pools 2> /dev/null ||
6458 error "destroy test pools failed"
6461 run_test 56wb "check lfs_migrate pool support"
6464 local file1="$DIR/$tdir/file1"
6471 echo -n "Creating test dir..."
6472 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6473 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
6474 error "cannot set stripe by '-S 1M -c 1'"
6477 echo -n "Setting initial stripe for test file..."
6478 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
6479 error "cannot set stripe"
6480 cur_ssize=$($LFS getstripe -S "$file1")
6481 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
6484 # File currently set to -S 512K -c 1
6486 # Ensure -c and -S options are rejected when -R is set
6487 echo -n "Verifying incompatible options are detected..."
6488 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
6489 error "incompatible -c and -R options not detected"
6490 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
6491 error "incompatible -S and -R options not detected"
6494 # Ensure unrecognized options are passed through to 'lfs migrate'
6495 echo -n "Verifying -S option is passed through to lfs migrate..."
6496 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
6497 error "migration failed"
6498 cur_ssize=$($LFS getstripe -S "$file1")
6499 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
6502 # File currently set to -S 1M -c 1
6504 # Ensure long options are supported
6505 echo -n "Verifying long options supported..."
6506 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
6507 error "long option without argument not supported"
6508 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
6509 error "long option with argument not supported"
6510 cur_ssize=$($LFS getstripe -S "$file1")
6511 [ $cur_ssize -eq 524288 ] ||
6512 error "migrate --stripe-size $cur_ssize != 524288"
6515 # File currently set to -S 512K -c 1
6517 if [ "$OSTCOUNT" -gt 1 ]; then
6518 echo -n "Verifying explicit stripe count can be set..."
6519 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
6520 error "migrate failed"
6521 cur_scount=$($LFS getstripe -c "$file1")
6522 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
6526 # File currently set to -S 512K -c 1 or -S 512K -c 2
6528 # Ensure parent striping is used if -R is set, and no stripe
6529 # count or size is specified
6530 echo -n "Setting stripe for parent directory..."
6531 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6532 error "cannot set stripe '-S 2M -c 1'"
6535 echo -n "Verifying restripe option uses parent stripe settings..."
6536 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
6537 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
6538 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
6539 error "migrate failed"
6540 cur_ssize=$($LFS getstripe -S "$file1")
6541 [ $cur_ssize -eq $parent_ssize ] ||
6542 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
6543 cur_scount=$($LFS getstripe -c "$file1")
6544 [ $cur_scount -eq $parent_scount ] ||
6545 error "migrate -R stripe_count $cur_scount != $parent_scount"
6548 # File currently set to -S 1M -c 1
6550 # Ensure striping is preserved if -R is not set, and no stripe
6551 # count or size is specified
6552 echo -n "Verifying striping size preserved when not specified..."
6553 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
6554 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6555 error "cannot set stripe on parent directory"
6556 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6557 error "migrate failed"
6558 cur_ssize=$($LFS getstripe -S "$file1")
6559 [ $cur_ssize -eq $orig_ssize ] ||
6560 error "migrate by default $cur_ssize != $orig_ssize"
6563 # Ensure file name properly detected when final option has no argument
6564 echo -n "Verifying file name properly detected..."
6565 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6566 error "file name interpreted as option argument"
6572 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
6575 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6577 local file1=$DIR/$tdir/file1
6579 echo -n "Creating test dir..."
6580 test_mkdir $DIR/$tdir || error "cannot create dir"
6583 echo -n "Creating test file..."
6587 # Ensure 'lfs migrate' will fail by using a non-existent option,
6588 # and make sure rsync is not called to recover
6589 echo -n "Make sure --no-rsync option works..."
6590 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
6591 grep -q 'refusing to fall back to rsync' ||
6592 error "rsync was called with --no-rsync set"
6595 # Ensure rsync is called without trying 'lfs migrate' first
6596 echo -n "Make sure --rsync option works..."
6597 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
6598 grep -q 'falling back to rsync' &&
6599 error "lfs migrate was called with --rsync set"
6602 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
6603 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
6604 grep -q 'at the same time' ||
6605 error "--rsync and --no-rsync accepted concurrently"
6611 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
6614 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6615 check_swap_layouts_support
6617 local dir=$DIR/$tdir
6618 local ref1=/etc/passwd
6619 local file1=$dir/file1
6621 test_mkdir $dir || error "creating dir $dir"
6622 $LFS setstripe -c 2 $file1
6624 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
6625 stripe=$($LFS getstripe -c $file1)
6626 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6627 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6632 run_test 56x "lfs migration support"
6635 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6636 check_swap_layouts_support
6638 local dir=$DIR/$tdir/$testnum
6642 local ref1=/etc/passwd
6643 local file1=$dir/file1
6645 $LFS setstripe -c 2 $file1
6647 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6649 local stripe=$($LFS getstripe -c $file1)
6651 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6652 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6657 run_test 56xa "lfs migration --block support"
6659 check_migrate_links() {
6661 local file1="$dir/file1"
6665 local total_count=$(($begin + $count - 1))
6666 local symlink_count=10
6669 if [ ! -f "$file1" ]; then
6670 echo -n "creating initial file..."
6671 $LFS setstripe -c 1 -S "512k" "$file1" ||
6672 error "cannot setstripe initial file"
6675 echo -n "creating symlinks..."
6676 for s in $(seq 1 $symlink_count); do
6677 ln -s "$file1" "$dir/slink$s" ||
6678 error "cannot create symlinks"
6682 echo -n "creating nonlinked files..."
6683 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6684 error "cannot create nonlinked files"
6689 if [ ! -f "$dir/file$total_count" ]; then
6690 echo -n "creating hard links $begin:$total_count..."
6691 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6692 /dev/null || error "cannot create hard links"
6696 echo -n "checking number of hard links listed in xattrs..."
6697 local fid=$($LFS getstripe -F "$file1")
6698 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6701 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6702 skip "hard link list has unexpected size, skipping test"
6704 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6705 error "link names should exceed xattrs size"
6708 echo -n "migrating files..."
6709 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
6711 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6714 # make sure all links have been properly migrated
6715 echo -n "verifying files..."
6716 fid=$($LFS getstripe -F "$file1") ||
6717 error "cannot get fid for file $file1"
6718 for i in $(seq 2 $total_count); do
6719 local fid2=$($LFS getstripe -F $dir/file$i)
6721 [ "$fid2" == "$fid" ] ||
6722 error "migrated hard link has mismatched FID"
6725 # make sure hard links were properly detected, and migration was
6726 # performed only once for the entire link set; nonlinked files should
6728 local actual=$(grep -c 'done' <<< "$migrate_out")
6729 local expected=$(($uniq_count + 1))
6731 [ "$actual" -eq "$expected" ] ||
6732 error "hard links individually migrated ($actual != $expected)"
6734 # make sure the correct number of hard links are present
6735 local hardlinks=$(stat -c '%h' "$file1")
6737 [ $hardlinks -eq $total_count ] ||
6738 error "num hard links $hardlinks != $total_count"
6745 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6746 skip "Need MDS version at least 2.10.55"
6748 local dir="$DIR/$tdir"
6750 test_mkdir "$dir" || error "cannot create dir $dir"
6752 echo "testing lfs migrate mode when all links fit within xattrs"
6753 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6755 echo "testing rsync mode when all links fit within xattrs"
6756 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6758 echo "testing lfs migrate mode when all links do not fit within xattrs"
6759 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6761 echo "testing rsync mode when all links do not fit within xattrs"
6762 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6764 chown -R $RUNAS_ID $dir
6765 echo "testing non-root lfs migrate mode when not all links are in xattr"
6766 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
6771 run_test 56xb "lfs migration hard link support"
6774 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6776 local dir="$DIR/$tdir"
6778 test_mkdir "$dir" || error "cannot create dir $dir"
6780 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6781 echo -n "Setting initial stripe for 20MB test file..."
6782 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
6783 error "cannot setstripe 20MB file"
6785 echo -n "Sizing 20MB test file..."
6786 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6788 echo -n "Verifying small file autostripe count is 1..."
6789 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
6790 error "cannot migrate 20MB file"
6791 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
6792 error "cannot get stripe for $dir/20mb"
6793 [ $stripe_count -eq 1 ] ||
6794 error "unexpected stripe count $stripe_count for 20MB file"
6798 # Test 2: File is small enough to fit within the available space on
6799 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
6800 # have at least an additional 1KB for each desired stripe for test 3
6801 echo -n "Setting stripe for 1GB test file..."
6802 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
6804 echo -n "Sizing 1GB test file..."
6805 # File size is 1GB + 3KB
6806 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
6809 # need at least 512MB per OST for 1GB file to fit in 2 stripes
6810 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
6811 if (( avail > 524288 * OSTCOUNT )); then
6812 echo -n "Migrating 1GB file..."
6813 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
6814 error "cannot migrate 1GB file"
6816 echo -n "Verifying autostripe count is sqrt(n) + 1..."
6817 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
6818 error "cannot getstripe for 1GB file"
6819 [ $stripe_count -eq 2 ] ||
6820 error "unexpected stripe count $stripe_count != 2"
6824 # Test 3: File is too large to fit within the available space on
6825 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
6826 if [ $OSTCOUNT -ge 3 ]; then
6827 # The required available space is calculated as
6828 # file size (1GB + 3KB) / OST count (3).
6829 local kb_per_ost=349526
6831 echo -n "Migrating 1GB file with limit..."
6832 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
6833 error "cannot migrate 1GB file with limit"
6836 stripe_count=$($LFS getstripe -c "$dir/1gb")
6837 echo -n "Verifying 1GB autostripe count with limited space..."
6838 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
6839 error "unexpected stripe count $stripe_count (min 3)"
6846 run_test 56xc "lfs migration autostripe"
6849 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6851 local dir=$DIR/$tdir
6852 local f_mgrt=$dir/$tfile.mgrt
6853 local f_yaml=$dir/$tfile.yaml
6854 local f_copy=$dir/$tfile.copy
6855 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6856 local layout_copy="-c 2 -S 2M -i 1"
6857 local yamlfile=$dir/yamlfile
6858 local layout_before;
6861 test_mkdir "$dir" || error "cannot create dir $dir"
6862 $LFS setstripe $layout_yaml $f_yaml ||
6863 error "cannot setstripe $f_yaml with layout $layout_yaml"
6864 $LFS getstripe --yaml $f_yaml > $yamlfile
6865 $LFS setstripe $layout_copy $f_copy ||
6866 error "cannot setstripe $f_copy with layout $layout_copy"
6868 dd if=/dev/zero of=$f_mgrt bs=1M count=4
6870 # 1. test option --yaml
6871 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
6872 error "cannot migrate $f_mgrt with --yaml $yamlfile"
6873 layout_before=$(get_layout_param $f_yaml)
6874 layout_after=$(get_layout_param $f_mgrt)
6875 [ "$layout_after" == "$layout_before" ] ||
6876 error "lfs_migrate --yaml: $layout_after != $layout_before"
6878 # 2. test option --copy
6879 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
6880 error "cannot migrate $f_mgrt with --copy $f_copy"
6881 layout_before=$(get_layout_param $f_copy)
6882 layout_after=$(get_layout_param $f_mgrt)
6883 [ "$layout_after" == "$layout_before" ] ||
6884 error "lfs_migrate --copy: $layout_after != $layout_before"
6886 run_test 56xd "check lfs_migrate --yaml and --copy support"
6889 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6891 local dir=$DIR/$tdir
6892 local f_comp=$dir/$tfile
6893 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6894 local layout_before=""
6895 local layout_after=""
6897 test_mkdir "$dir" || error "cannot create dir $dir"
6898 $LFS setstripe $layout $f_comp ||
6899 error "cannot setstripe $f_comp with layout $layout"
6900 layout_before=$(get_layout_param $f_comp)
6901 dd if=/dev/zero of=$f_comp bs=1M count=4
6903 # 1. migrate a comp layout file by lfs_migrate
6904 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
6905 layout_after=$(get_layout_param $f_comp)
6906 [ "$layout_before" == "$layout_after" ] ||
6907 error "lfs_migrate: $layout_before != $layout_after"
6909 # 2. migrate a comp layout file by lfs migrate
6910 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
6911 layout_after=$(get_layout_param $f_comp)
6912 [ "$layout_before" == "$layout_after" ] ||
6913 error "lfs migrate: $layout_before != $layout_after"
6915 run_test 56xe "migrate a composite layout file"
6918 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
6919 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
6922 local dir=$DIR/$tdir
6926 test_mkdir -p $dir || error "creating dir $dir"
6927 touch $f1 || error "creating std file $f1"
6928 $MULTIOP $f2 H2c || error "creating released file $f2"
6930 # a directory can be raid0, so ask only for files
6931 res=$($LFS find $dir -L raid0 -type f | wc -l)
6932 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
6934 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
6935 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
6937 # only files can be released, so no need to force file search
6938 res=$($LFS find $dir -L released)
6939 [[ $res == $f2 ]] || error "search released: found $res != $f2"
6941 res=$($LFS find $dir -type f \! -L released)
6942 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
6944 run_test 56y "lfs find -L raid0|released"
6946 test_56z() { # LU-4824
6947 # This checks to make sure 'lfs find' continues after errors
6948 # There are two classes of errors that should be caught:
6949 # - If multiple paths are provided, all should be searched even if one
6951 # - If errors are encountered during the search, it should not terminate
6953 local dir=$DIR/$tdir
6957 for i in d{0..9}; do
6959 touch $dir/$i/$tfile
6961 $LFS find $DIR/non_existent_dir $dir &&
6962 error "$LFS find did not return an error"
6963 # Make a directory unsearchable. This should NOT be the last entry in
6964 # directory order. Arbitrarily pick the 6th entry
6965 chmod 700 $($LFS find $dir -type d | sed '6!d')
6967 $RUNAS $LFS find $DIR/non_existent $dir
6968 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
6970 # The user should be able to see 10 directories and 9 files
6971 (( count == 19 )) ||
6972 error "$LFS find found $count != 19 entries after error"
6974 run_test 56z "lfs find should continue after an error"
6976 test_56aa() { # LU-5937
6977 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
6979 local dir=$DIR/$tdir
6982 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
6984 createmany -o $dir/striped_dir/${tfile}- 1024
6985 local dirs=$($LFS find --size +8k $dir/)
6987 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
6989 run_test 56aa "lfs find --size under striped dir"
6991 test_56ab() { # LU-10705
6992 test_mkdir $DIR/$tdir
6993 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
6994 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
6995 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
6996 # Flush writes to ensure valid blocks. Need to be more thorough for
6997 # ZFS, since blocks are not allocated/returned to client immediately.
6999 wait_zfs_commit ost1 2
7000 cancel_lru_locks osc
7003 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
7005 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
7007 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
7008 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
7010 rm -f $DIR/$tdir/$tfile.[123]
7012 run_test 56ab "lfs find --blocks"
7015 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
7016 skip "Need MDS version at least 2.10.50"
7018 # Create composite files with one component
7019 local dir=$DIR/$tdir
7021 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
7022 # Create composite files with three components
7023 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
7024 # Create non-composite files
7025 createmany -o $dir/${tfile}- 10
7027 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
7029 [[ $nfiles == 10 ]] ||
7030 error "lfs find -E 1M found $nfiles != 10 files"
7032 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
7033 [[ $nfiles == 25 ]] ||
7034 error "lfs find ! -E 1M found $nfiles != 25 files"
7036 # All files have a component that starts at 0
7037 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
7038 [[ $nfiles == 35 ]] ||
7039 error "lfs find --component-start 0 - $nfiles != 35 files"
7041 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
7042 [[ $nfiles == 15 ]] ||
7043 error "lfs find --component-start 2M - $nfiles != 15 files"
7045 # All files created here have a componenet that does not starts at 2M
7046 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
7047 [[ $nfiles == 35 ]] ||
7048 error "lfs find ! --component-start 2M - $nfiles != 35 files"
7050 # Find files with a specified number of components
7051 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
7052 [[ $nfiles == 15 ]] ||
7053 error "lfs find --component-count 3 - $nfiles != 15 files"
7055 # Remember non-composite files have a component count of zero
7056 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
7057 [[ $nfiles == 10 ]] ||
7058 error "lfs find --component-count 0 - $nfiles != 10 files"
7060 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
7061 [[ $nfiles == 20 ]] ||
7062 error "lfs find ! --component-count 3 - $nfiles != 20 files"
7064 # All files have a flag called "init"
7065 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
7066 [[ $nfiles == 35 ]] ||
7067 error "lfs find --component-flags init - $nfiles != 35 files"
7069 # Multi-component files will have a component not initialized
7070 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
7071 [[ $nfiles == 15 ]] ||
7072 error "lfs find !--component-flags init - $nfiles != 15 files"
7077 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
7080 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
7081 skip "Need MDS version at least 2.10.57"
7091 # create mirrored directories and mirrored files
7092 mkdir $td || error "mkdir $td failed"
7093 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
7094 createmany -o $tf- 10 || error "create $tf- failed"
7096 for i in $(seq 2); do
7098 mkdir $dir || error "mkdir $dir failed"
7099 $LFS mirror create -N$((3 + i)) $dir ||
7100 error "create mirrored dir $dir failed"
7101 createmany -o $dir/$tfile- 10 ||
7102 error "create $dir/$tfile- failed"
7105 # change the states of some mirrored files
7107 for i in $(seq 2); do
7109 for j in $(seq 4 9); do
7110 echo foo > $dir/$tfile-$j
7114 # find mirrored files with specific mirror count
7115 cmd="$LFS find --mirror-count 3 --type f $td"
7116 nfiles=$($cmd | wc -l)
7117 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
7119 cmd="$LFS find ! --mirror-count 3 --type f $td"
7120 nfiles=$($cmd | wc -l)
7121 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
7123 cmd="$LFS find --mirror-count +2 --type f $td"
7124 nfiles=$($cmd | wc -l)
7125 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7127 cmd="$LFS find --mirror-count -6 --type f $td"
7128 nfiles=$($cmd | wc -l)
7129 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7131 # find mirrored files with specific file state
7132 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
7133 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
7135 cmd="$LFS find --mirror-state=ro --type f $td"
7136 nfiles=$($cmd | wc -l)
7137 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
7139 cmd="$LFS find ! --mirror-state=ro --type f $td"
7140 nfiles=$($cmd | wc -l)
7141 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7143 cmd="$LFS find --mirror-state=wp --type f $td"
7144 nfiles=$($cmd | wc -l)
7145 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7147 cmd="$LFS find ! --mirror-state=sp --type f $td"
7148 nfiles=$($cmd | wc -l)
7149 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7151 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
7154 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7155 # note test will not do anything if MDS is not local
7156 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7157 skip_env "ldiskfs only test"
7159 remote_mds_nodsh && skip "remote MDS with nodsh"
7161 local MNTDEV="osd*.*MDT*.mntdev"
7162 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
7163 [ -z "$DEV" ] && error "can't access $MNTDEV"
7164 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
7165 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
7166 error "can't access $DEV"
7167 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
7168 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
7172 run_test 57a "verify MDS filesystem created with large inodes =="
7175 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7176 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7177 skip_env "ldiskfs only test"
7179 remote_mds_nodsh && skip "remote MDS with nodsh"
7181 local dir=$DIR/$tdir
7184 local fileN=$dir/f$filecount
7186 rm -rf $dir || error "removing $dir"
7188 local mdtidx=$($LFS getstripe -m $dir)
7189 local mdtname=MDT$(printf %04x $mdtidx)
7190 local facet=mds$((mdtidx + 1))
7192 echo "mcreating $filecount files"
7193 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
7195 # verify that files do not have EAs yet
7196 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
7197 error "$file1 has an EA"
7198 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
7199 error "$fileN has an EA"
7203 df $dir #make sure we get new statfs data
7204 local mdsfree=$(do_facet $facet \
7205 lctl get_param -n osd*.*$mdtname.kbytesfree)
7206 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7209 echo "opening files to create objects/EAs"
7210 for file in $(seq -f $dir/f%g 1 $filecount); do
7211 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
7212 error "opening $file"
7215 # verify that files have EAs now
7216 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
7217 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
7219 sleep 1 #make sure we get new statfs data
7221 local mdsfree2=$(do_facet $facet \
7222 lctl get_param -n osd*.*$mdtname.kbytesfree)
7223 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7225 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
7226 if [ "$mdsfree" != "$mdsfree2" ]; then
7227 error "MDC before $mdcfree != after $mdcfree2"
7229 echo "MDC before $mdcfree != after $mdcfree2"
7230 echo "unable to confirm if MDS has large inodes"
7235 run_test 57b "default LOV EAs are stored inside large inodes ==="
7238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7239 [ -z "$(which wiretest 2>/dev/null)" ] &&
7240 skip_env "could not find wiretest"
7244 run_test 58 "verify cross-platform wire constants =============="
7247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7249 echo "touch 130 files"
7250 createmany -o $DIR/f59- 130
7252 unlinkmany $DIR/f59- 130
7254 # wait for commitment of removal
7255 wait_delete_completed
7257 run_test 59 "verify cancellation of llog records async ========="
7259 TEST60_HEAD="test_60 run $RANDOM"
7261 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7262 remote_mgs_nodsh && skip "remote MGS with nodsh"
7263 do_facet mgs "! which run-llog.sh &> /dev/null" &&
7264 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
7265 skip_env "missing subtest run-llog.sh"
7267 log "$TEST60_HEAD - from kernel mode"
7268 do_facet mgs "$LCTL dk > /dev/null"
7269 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
7270 do_facet mgs $LCTL dk > $TMP/$tfile
7272 # LU-6388: test llog_reader
7273 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
7274 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
7275 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
7276 skip_env "missing llog_reader"
7277 local fstype=$(facet_fstype mgs)
7278 [ $fstype != ldiskfs -a $fstype != zfs ] &&
7279 skip_env "Only for ldiskfs or zfs type mgs"
7281 local mntpt=$(facet_mntpt mgs)
7282 local mgsdev=$(mgsdevname 1)
7294 #get fid and record list
7295 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
7297 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
7299 #remount mgs as ldiskfs or zfs type
7300 stop mgs || error "stop mgs failed"
7301 mount_fstype mgs || error "remount mgs failed"
7302 for ((i = 0; i < ${#fid_list[@]}; i++)); do
7305 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
7306 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
7311 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
7313 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
7315 echo "obj_file is $obj_file"
7316 do_facet mgs $llog_reader $obj_file
7318 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
7319 awk '{ print $3 }' | sed -e "s/^type=//g")
7320 if [ $rec_type != $rec ]; then
7321 echo "FAILED test_60a wrong record type $rec_type," \
7327 #check obj path if record type is LLOG_LOGID_MAGIC
7328 if [ "$rec" == "1064553b" ]; then
7329 path=$(do_facet mgs $llog_reader $obj_file |
7330 grep "path=" | awk '{ print $NF }' |
7331 sed -e "s/^path=//g")
7332 if [ $obj_file != $mntpt/$path ]; then
7333 echo "FAILED test_60a wrong obj path" \
7334 "$montpt/$path, should be $obj_file"
7341 #restart mgs before "error", otherwise it will block the next test
7342 stop mgs || error "stop mgs failed"
7343 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
7344 $pass || error "test failed, see FAILED test_60a messages for specifics"
7346 run_test 60a "llog_test run from kernel module and test llog_reader"
7348 test_60b() { # bug 6411
7349 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7352 LLOG_COUNT=$(do_facet mgs dmesg |
7353 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
7354 /llog_[a-z]*.c:[0-9]/ {
7366 [[ $LLOG_COUNT -gt 120 ]] &&
7367 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
7369 run_test 60b "limit repeated messages from CERROR/CWARN"
7372 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7374 echo "create 5000 files"
7375 createmany -o $DIR/f60c- 5000
7376 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
7377 lctl set_param fail_loc=0x80000137
7378 unlinkmany $DIR/f60c- 5000
7379 lctl set_param fail_loc=0
7381 run_test 60c "unlink file when mds full"
7384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7386 SAVEPRINTK=$(lctl get_param -n printk)
7387 # verify "lctl mark" is even working"
7388 MESSAGE="test message ID $RANDOM $$"
7389 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7390 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
7392 lctl set_param printk=0 || error "set lnet.printk failed"
7393 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
7394 MESSAGE="new test message ID $RANDOM $$"
7395 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
7396 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7397 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
7399 lctl set_param -n printk="$SAVEPRINTK"
7401 run_test 60d "test printk console message masking"
7404 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7405 remote_mds_nodsh && skip "remote MDS with nodsh"
7408 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
7409 do_facet mds1 lctl set_param fail_loc=0x15b
7412 run_test 60e "no space while new llog is being created"
7418 test_mkdir -c $MDSCOUNT $DIR/$tdir
7423 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
7424 -c $MDSCOUNT $DIR/$tdir/subdir$index \
7426 mkdir $DIR/$tdir/subdir$index 2>/dev/null
7427 rmdir $DIR/$tdir/subdir$index 2>/dev/null
7428 index=$((index + 1))
7434 for i in {0..100}; do
7435 # define OBD_FAIL_OSD_TXN_START 0x19a
7436 local index=$((i % MDSCOUNT + 1))
7438 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
7445 for i in $(seq $MDSCOUNT); do
7446 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
7449 mkdir $DIR/$tdir/new || error "mkdir failed"
7450 rmdir $DIR/$tdir/new || error "rmdir failed"
7452 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
7454 for i in $(seq $MDSCOUNT); do
7455 wait_update_facet mds$i "$LCTL get_param -n \
7456 mdd.$(facet_svc mds$i).lfsck_namespace |
7457 awk '/^status/ { print \\\$2 }'" "completed"
7460 ls -R $DIR/$tdir || error "ls failed"
7461 rm -rf $DIR/$tdir || error "rmdir failed"
7463 run_test 60g "transaction abort won't cause MDT hung"
7466 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
7467 skip "Need MDS version at least 2.12.52"
7468 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
7472 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
7473 #define OBD_FAIL_MDS_STRIPE_FID 0x189
7474 for fail_loc in 0x80000188 0x80000189; do
7475 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
7476 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
7477 error "mkdir $dir-$fail_loc failed"
7478 for i in {0..10}; do
7479 # create may fail on missing stripe
7480 echo $i > $DIR/$tdir-$fail_loc/$i
7482 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7483 error "getdirstripe $tdir-$fail_loc failed"
7484 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
7485 error "migrate $tdir-$fail_loc failed"
7486 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7487 error "getdirstripe $tdir-$fail_loc failed"
7488 pushd $DIR/$tdir-$fail_loc
7490 echo $f | cmp $f - || error "$f data mismatch"
7493 rm -rf $DIR/$tdir-$fail_loc
7496 run_test 60h "striped directory with missing stripes can be accessed"
7499 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7502 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
7503 cancel_lru_locks osc
7504 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
7507 run_test 61a "mmap() writes don't make sync hang ================"
7510 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
7512 run_test 61b "mmap() of unstriped file is successful"
7514 # bug 2330 - insufficient obd_match error checking causes LBUG
7516 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7520 cancel_lru_locks osc
7521 lctl set_param fail_loc=0x405
7522 cat $f && error "cat succeeded, expect -EIO"
7523 lctl set_param fail_loc=0
7525 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
7526 # match every page all of the time.
7527 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
7529 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
7530 # Though this test is irrelevant anymore, it helped to reveal some
7531 # other grant bugs (LU-4482), let's keep it.
7532 test_63a() { # was test_63
7533 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7535 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
7537 for i in `seq 10` ; do
7538 dd if=/dev/zero of=$DIR/f63 bs=8k &
7544 rm -f $DIR/f63 || true
7546 run_test 63a "Verify oig_wait interruption does not crash ======="
7548 # bug 2248 - async write errors didn't return to application on sync
7549 # bug 3677 - async write errors left page locked
7551 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7554 lctl set_param debug=-1
7556 # ensure we have a grant to do async writes
7557 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
7560 sync # sync lest earlier test intercept the fail_loc
7562 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7563 lctl set_param fail_loc=0x80000406
7564 $MULTIOP $DIR/$tfile Owy && \
7565 error "sync didn't return ENOMEM"
7566 sync; sleep 2; sync # do a real sync this time to flush page
7567 lctl get_param -n llite.*.dump_page_cache | grep locked && \
7568 error "locked page left in cache after async error" || true
7571 run_test 63b "async write errors should be returned to fsync ==="
7574 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7577 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
7579 run_test 64a "verify filter grant calculations (in kernel) ====="
7582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7584 sh oos.sh $MOUNT || error "oos.sh failed: $?"
7586 run_test 64b "check out-of-space detection on client"
7589 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
7591 run_test 64c "verify grant shrink"
7593 # this does exactly what osc_request.c:osc_announce_cached() does in
7594 # order to calculate max amount of grants to ask from server
7598 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
7599 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
7601 ((rpc_in_flight ++));
7602 nrpages=$((nrpages * rpc_in_flight))
7604 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
7606 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
7608 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
7609 local undirty=$((nrpages * PAGE_SIZE))
7611 local max_extent_pages
7612 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
7613 grep grant_max_extent_size | awk '{print $2}')
7614 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
7615 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
7616 local grant_extent_tax
7617 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7618 grep grant_extent_tax | awk '{print $2}')
7620 undirty=$((undirty + nrextents * grant_extent_tax))
7625 # this is size of unit for grant allocation. It should be equal to
7626 # what tgt_grant.c:tgt_grant_chunk() calculates
7630 local grant_extent_tax
7632 max_brw_size=$($LCTL get_param osc.${tgt}.import |
7633 grep max_brw_size | awk '{print $2}')
7635 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7636 grep grant_extent_tax | awk '{print $2}')
7638 echo $(((max_brw_size + grant_extent_tax) * 2))
7642 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
7643 skip "OST < 2.10.55 doesn't limit grants enough"
7645 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
7646 local file=$DIR/$tfile
7648 [[ $($LCTL get_param osc.${tgt}.import |
7649 grep "connect_flags:.*grant_param") ]] ||
7650 skip "no grant_param connect flag"
7652 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
7654 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
7656 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
7657 stack_trap "rm -f $file" EXIT
7659 $LFS setstripe $file -i 0 -c 1
7660 dd if=/dev/zero of=$file bs=1M count=1000 &
7665 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
7666 if [[ $cur_grant -gt $max_cur_granted ]]
7669 error "cur_grant $cur_grant > $max_cur_granted"
7672 [[ $? -ne 0 ]] && break;
7677 wait_delete_completed
7678 $LCTL set_param debug="$olddebug" 2> /dev/null || true
7680 run_test 64d "check grant limit exceed"
7682 # bug 1414 - set/get directories' stripe info
7684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7686 test_mkdir $DIR/$tdir
7688 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7690 run_test 65a "directory with no stripe info"
7693 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7695 test_mkdir $DIR/$tdir
7696 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7698 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7701 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
7703 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
7706 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7707 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
7709 test_mkdir $DIR/$tdir
7710 local stripesize=$($LFS getstripe -S $DIR/$tdir)
7712 $LFS setstripe -S $((stripesize * 4)) -i 1 \
7713 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
7715 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
7717 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
7720 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7722 test_mkdir $DIR/$tdir
7723 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
7724 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7726 if [[ $STRIPECOUNT -le 0 ]]; then
7728 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
7729 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
7730 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
7732 sc=$(($STRIPECOUNT - 1))
7734 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
7735 touch $DIR/$tdir/f4 $DIR/$tdir/f5
7736 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
7737 error "lverify failed"
7739 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
7742 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7744 test_mkdir $DIR/$tdir
7746 $LFS setstripe $DIR/$tdir || error "setstripe"
7747 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7748 error "no stripe info failed"
7750 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
7752 run_test 65e "directory setstripe defaults"
7755 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7757 test_mkdir $DIR/${tdir}f
7758 $RUNAS $LFS setstripe $DIR/${tdir}f &&
7759 error "setstripe succeeded" || true
7761 run_test 65f "dir setstripe permission (should return error) ==="
7764 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7766 test_mkdir $DIR/$tdir
7767 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7769 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7770 error "setstripe -S failed"
7771 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
7772 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7773 error "delete default stripe failed"
7775 run_test 65g "directory setstripe -d"
7778 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7780 test_mkdir $DIR/$tdir
7781 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7783 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7784 error "setstripe -S failed"
7785 test_mkdir $DIR/$tdir/dd1
7786 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
7787 error "stripe info inherit failed"
7789 run_test 65h "directory stripe info inherit ===================="
7792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7794 save_layout_restore_at_exit $MOUNT
7796 # bug6367: set non-default striping on root directory
7797 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
7799 # bug12836: getstripe on -1 default directory striping
7800 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
7802 # bug12836: getstripe -v on -1 default directory striping
7803 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
7805 # bug12836: new find on -1 default directory striping
7806 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
7808 run_test 65i "various tests to set root directory striping"
7810 test_65j() { # bug6367
7811 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7815 # if we aren't already remounting for each test, do so for this test
7816 if [ "$I_MOUNTED" = "yes" ]; then
7817 cleanup || error "failed to unmount"
7821 save_layout_restore_at_exit $MOUNT
7823 $LFS setstripe -d $MOUNT || error "setstripe failed"
7825 run_test 65j "set default striping on root directory (bug 6367)="
7829 wait_delete_completed
7830 do_facet $SINGLEMDS "lctl set_param -n \
7831 osp.$ost*MDT0000.max_create_count=$max_count"
7832 do_facet $SINGLEMDS "lctl set_param -n \
7833 osp.$ost*MDT0000.create_count=$count"
7834 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7835 echo $INACTIVE_OSC "is Activate"
7837 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7840 test_65k() { # bug11679
7841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7842 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7843 remote_mds_nodsh && skip "remote MDS with nodsh"
7845 local disable_precreate=true
7846 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
7847 disable_precreate=false
7849 echo "Check OST status: "
7850 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
7851 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
7853 for OSC in $MDS_OSCS; do
7854 echo $OSC "is active"
7855 do_facet $SINGLEMDS lctl --device %$OSC activate
7858 for INACTIVE_OSC in $MDS_OSCS; do
7859 local ost=$(osc_to_ost $INACTIVE_OSC)
7860 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
7861 lov.*md*.target_obd |
7862 awk -F: /$ost/'{ print $1 }' | head -n 1)
7865 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
7866 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
7868 echo "Deactivate: " $INACTIVE_OSC
7869 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
7871 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
7872 osp.$ost*MDT0000.create_count")
7873 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
7874 osp.$ost*MDT0000.max_create_count")
7875 $disable_precreate &&
7876 do_facet $SINGLEMDS "lctl set_param -n \
7877 osp.$ost*MDT0000.max_create_count=0"
7879 for idx in $(seq 0 $((OSTCOUNT - 1))); do
7880 [ -f $DIR/$tdir/$idx ] && continue
7881 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
7882 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
7884 error "setstripe $idx should succeed"; }
7885 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
7887 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
7890 do_facet $SINGLEMDS "lctl set_param -n \
7891 osp.$ost*MDT0000.max_create_count=$max_count"
7892 do_facet $SINGLEMDS "lctl set_param -n \
7893 osp.$ost*MDT0000.create_count=$count"
7894 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7895 echo $INACTIVE_OSC "is Activate"
7897 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7900 run_test 65k "validate manual striping works properly with deactivated OSCs"
7902 test_65l() { # bug 12836
7903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7905 test_mkdir -p $DIR/$tdir/test_dir
7906 $LFS setstripe -c -1 $DIR/$tdir/test_dir
7907 $LFS find -mtime -1 $DIR/$tdir >/dev/null
7909 run_test 65l "lfs find on -1 stripe dir ========================"
7912 local layout=$(save_layout $MOUNT)
7913 $RUNAS $LFS setstripe -c 2 $MOUNT && {
7914 restore_layout $MOUNT $layout
7915 error "setstripe should fail by non-root users"
7919 run_test 65m "normal user can't set filesystem default stripe"
7922 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
7923 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
7924 skip "Need MDS version at least 2.12.50"
7925 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7927 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7928 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
7929 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
7931 local root_layout=$(save_layout $MOUNT)
7932 stack_trap "restore_layout $MOUNT $root_layout" EXIT
7934 # new subdirectory under root directory should not inherit
7935 # the default layout from root
7936 local dir1=$MOUNT/$tdir-1
7937 mkdir $dir1 || error "mkdir $dir1 failed"
7938 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
7939 error "$dir1 shouldn't have LOV EA"
7941 # delete the default layout on root directory
7942 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
7944 local dir2=$MOUNT/$tdir-2
7945 mkdir $dir2 || error "mkdir $dir2 failed"
7946 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
7947 error "$dir2 shouldn't have LOV EA"
7949 # set a new striping pattern on root directory
7950 local def_stripe_size=$($LFS getstripe -S $MOUNT)
7951 local new_def_stripe_size=$((def_stripe_size * 2))
7952 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
7953 error "set stripe size on $MOUNT failed"
7955 # new file created in $dir2 should inherit the new stripe size from
7956 # the filesystem default
7957 local file2=$dir2/$tfile-2
7958 touch $file2 || error "touch $file2 failed"
7960 local file2_stripe_size=$($LFS getstripe -S $file2)
7961 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
7962 error "$file2 didn't inherit stripe size $new_def_stripe_size"
7964 local dir3=$MOUNT/$tdir-3
7965 mkdir $dir3 || error "mkdir $dir3 failed"
7966 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
7967 # the root layout, which is the actual default layout that will be used
7968 # when new files are created in $dir3.
7969 local dir3_layout=$(get_layout_param $dir3)
7970 local root_dir_layout=$(get_layout_param $MOUNT)
7971 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
7972 error "$dir3 should show the default layout from $MOUNT"
7974 # set OST pool on root directory
7975 local pool=$TESTNAME
7976 pool_add $pool || error "add $pool failed"
7977 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
7978 error "add targets to $pool failed"
7980 $LFS setstripe -p $pool $MOUNT ||
7981 error "set OST pool on $MOUNT failed"
7983 # new file created in $dir3 should inherit the pool from
7984 # the filesystem default
7985 local file3=$dir3/$tfile-3
7986 touch $file3 || error "touch $file3 failed"
7988 local file3_pool=$($LFS getstripe -p $file3)
7989 [[ "$file3_pool" = "$pool" ]] ||
7990 error "$file3 didn't inherit OST pool $pool"
7992 local dir4=$MOUNT/$tdir-4
7993 mkdir $dir4 || error "mkdir $dir4 failed"
7994 local dir4_layout=$(get_layout_param $dir4)
7995 root_dir_layout=$(get_layout_param $MOUNT)
7996 echo "$LFS getstripe -d $dir4"
7997 $LFS getstripe -d $dir4
7998 echo "$LFS getstripe -d $MOUNT"
7999 $LFS getstripe -d $MOUNT
8000 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
8001 error "$dir4 should show the default layout from $MOUNT"
8003 # new file created in $dir4 should inherit the pool from
8004 # the filesystem default
8005 local file4=$dir4/$tfile-4
8006 touch $file4 || error "touch $file4 failed"
8008 local file4_pool=$($LFS getstripe -p $file4)
8009 [[ "$file4_pool" = "$pool" ]] ||
8010 error "$file4 didn't inherit OST pool $pool"
8012 # new subdirectory under non-root directory should inherit
8013 # the default layout from its parent directory
8014 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
8015 error "set directory layout on $dir4 failed"
8017 local dir5=$dir4/$tdir-5
8018 mkdir $dir5 || error "mkdir $dir5 failed"
8020 dir4_layout=$(get_layout_param $dir4)
8021 local dir5_layout=$(get_layout_param $dir5)
8022 [[ "$dir4_layout" = "$dir5_layout" ]] ||
8023 error "$dir5 should inherit the default layout from $dir4"
8025 # though subdir under ROOT doesn't inherit default layout, but
8026 # its sub dir/file should be created with default layout.
8027 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
8028 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
8029 skip "Need MDS version at least 2.12.59"
8031 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
8032 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
8033 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
8035 if [ $default_lmv_hash == "none" ]; then
8036 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
8038 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
8039 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
8042 $LFS setdirstripe -D -c 2 $MOUNT ||
8043 error "setdirstripe -D -c 2 failed"
8044 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
8045 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
8046 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
8048 run_test 65n "don't inherit default layout from root for new subdirectories"
8050 # bug 2543 - update blocks count on client
8052 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8055 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
8056 sync; sync_all_data; sync; sync_all_data
8057 cancel_lru_locks osc
8058 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
8059 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
8061 run_test 66 "update inode blocks count on client ==============="
8064 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
8068 swapon -s | awk '($1 == "'$1'") { print $4 }'
8071 # bug5265, obdfilter oa2dentry return -ENOENT
8072 # #define OBD_FAIL_SRV_ENOENT 0x217
8074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8075 remote_ost_nodsh && skip "remote OST with nodsh"
8078 $LFS setstripe -c 1 -i 0 $f
8080 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
8082 do_facet ost1 lctl set_param fail_loc=0x217
8083 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
8084 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
8086 do_facet ost1 lctl set_param fail_loc=0
8087 $DIRECTIO write $f 0 2 || error "write error"
8089 cancel_lru_locks osc
8090 $DIRECTIO read $f 0 1 || error "read error"
8092 do_facet ost1 lctl set_param fail_loc=0x217
8093 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
8095 do_facet ost1 lctl set_param fail_loc=0
8098 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
8101 test_mkdir $DIR/$tdir
8102 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
8103 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
8105 run_test 71 "Running dbench on lustre (don't segment fault) ===="
8107 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
8108 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8109 [ "$RUNAS_ID" = "$UID" ] &&
8110 skip_env "RUNAS_ID = UID = $UID -- skipping"
8111 # Check that testing environment is properly set up. Skip if not
8112 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
8113 skip_env "User $RUNAS_ID does not exist - skipping"
8116 chmod 777 $DIR/$tfile
8117 chmod ug+s $DIR/$tfile
8118 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
8119 error "$RUNAS dd $DIR/$tfile failed"
8120 # See if we are still setuid/sgid
8121 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
8122 error "S/gid is not dropped on write"
8123 # Now test that MDS is updated too
8124 cancel_lru_locks mdc
8125 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
8126 error "S/gid is not dropped on MDS"
8129 run_test 72a "Test that remove suid works properly (bug5695) ===="
8131 test_72b() { # bug 24226 -- keep mode setting when size is not changing
8134 [ "$RUNAS_ID" = "$UID" ] &&
8135 skip_env "RUNAS_ID = UID = $UID -- skipping"
8136 [ "$RUNAS_ID" -eq 0 ] &&
8137 skip_env "RUNAS_ID = 0 -- skipping"
8138 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8139 # Check that testing environment is properly set up. Skip if not
8140 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
8141 skip_env "User $RUNAS_ID does not exist - skipping"
8143 touch $DIR/${tfile}-f{g,u}
8144 test_mkdir $DIR/${tfile}-dg
8145 test_mkdir $DIR/${tfile}-du
8146 chmod 770 $DIR/${tfile}-{f,d}{g,u}
8147 chmod g+s $DIR/${tfile}-{f,d}g
8148 chmod u+s $DIR/${tfile}-{f,d}u
8149 for perm in 777 2777 4777; do
8150 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
8151 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
8152 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
8153 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
8157 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
8159 # bug 3462 - multiple simultaneous MDC requests
8161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8163 test_mkdir $DIR/d73-1
8164 test_mkdir $DIR/d73-2
8165 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
8168 lctl set_param fail_loc=0x80000129
8169 $MULTIOP $DIR/d73-1/f73-2 Oc &
8171 lctl set_param fail_loc=0
8173 $MULTIOP $DIR/d73-2/f73-3 Oc &
8177 wait $pid1 || return 1
8181 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
8182 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
8183 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
8187 run_test 73 "multiple MDC requests (should not deadlock)"
8189 test_74a() { # bug 6149, 6184
8190 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8193 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8195 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8196 # will spin in a tight reconnection loop
8197 $LCTL set_param fail_loc=0x8000030e
8198 # get any lock that won't be difficult - lookup works.
8200 $LCTL set_param fail_loc=0
8204 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
8206 test_74b() { # bug 13310
8207 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8209 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8211 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8212 # will spin in a tight reconnection loop
8213 $LCTL set_param fail_loc=0x8000030e
8214 # get a "difficult" lock
8216 $LCTL set_param fail_loc=0
8220 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
8223 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8225 #define OBD_FAIL_LDLM_NEW_LOCK
8226 $LCTL set_param fail_loc=0x319
8227 touch $DIR/$tfile && error "touch successful"
8228 $LCTL set_param fail_loc=0
8231 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
8234 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
8237 test_76() { # Now for bug 20433, added originally in bug 1443
8238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8240 cancel_lru_locks osc
8241 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
8242 local before=$(num_inodes)
8243 local count=$((512 * cpus))
8244 [ "$SLOW" = "no" ] && count=$((64 * cpus))
8246 echo "before inodes: $before"
8247 for i in $(seq $count); do
8251 cancel_lru_locks osc
8252 local after=$(num_inodes)
8253 echo "after inodes: $after"
8254 while (( after > before + 8 * ${cpus:-1} )); do
8258 (( wait % 5 == 0 )) && echo "wait $wait seconds inodes: $after"
8259 if (( wait > 30 )); then
8260 error "inode slab grew from $before to $after"
8264 run_test 76 "confirm clients recycle inodes properly ===="
8270 # Note: in sptlrpc modes which enable its own bulk checksum, the
8271 # original crc32_le bulk checksum will be automatically disabled,
8272 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
8273 # will be checked by sptlrpc code against sptlrpc bulk checksum.
8274 # In this case set_checksums() will not be no-op, because sptlrpc
8275 # bulk checksum will be enabled all through the test.
8277 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
8278 lctl set_param -n osc.*.checksums $1
8282 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8283 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
8284 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8285 tr -d [] | head -n1)}
8288 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
8290 log "set checksum type to $1, rc = $rc"
8294 get_osc_checksum_type()
8296 # arugment 1: OST name, like OST0000
8298 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
8299 sed 's/.*\[\(.*\)\].*/\1/g')
8301 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
8305 F77_TMP=$TMP/f77-temp
8308 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
8309 error "error writing to $F77_TMP"
8312 test_77a() { # bug 10889
8313 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8314 $GSS && skip_env "could not run with gss"
8316 [ ! -f $F77_TMP ] && setup_f77
8318 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
8322 run_test 77a "normal checksum read/write operation"
8324 test_77b() { # bug 10889
8325 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8326 $GSS && skip_env "could not run with gss"
8328 [ ! -f $F77_TMP ] && setup_f77
8329 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8330 $LCTL set_param fail_loc=0x80000409
8333 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8334 error "dd error: $?"
8335 $LCTL set_param fail_loc=0
8337 for algo in $CKSUM_TYPES; do
8338 cancel_lru_locks osc
8339 set_checksum_type $algo
8340 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8341 $LCTL set_param fail_loc=0x80000408
8342 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
8343 $LCTL set_param fail_loc=0
8346 set_checksum_type $ORIG_CSUM_TYPE
8349 run_test 77b "checksum error on client write, read"
8354 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
8356 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
8357 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
8358 $check_ost && [ -n "$ost_file_prefix" ] &&
8359 do_facet ost1 rm -f ${ost_file_prefix}\*
8363 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8364 $GSS && skip_env "could not run with gss"
8365 remote_ost_nodsh && skip "remote OST with nodsh"
8368 local osc_file_prefix
8370 local check_ost=false
8371 local ost_file_prefix
8377 # ensure corruption will occur on first OSS/OST
8378 $LFS setstripe -i 0 $DIR/$tfile
8380 [ ! -f $F77_TMP ] && setup_f77
8381 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8382 error "dd write error: $?"
8383 fid=$($LFS path2fid $DIR/$tfile)
8385 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
8388 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
8389 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
8391 echo "OSS do not support bulk pages dump upon error"
8394 osc_file_prefix=$($LCTL get_param -n debug_path)
8395 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
8397 trap cleanup_77c EXIT
8400 # enable bulk pages dump upon error on Client
8401 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
8402 # enable bulk pages dump upon error on OSS
8404 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
8406 # flush Client cache to allow next read to reach OSS
8407 cancel_lru_locks osc
8409 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8410 $LCTL set_param fail_loc=0x80000408
8411 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
8412 $LCTL set_param fail_loc=0
8416 # check cksum dump on Client
8417 osc_file=$(ls ${osc_file_prefix}*)
8418 [ -n "$osc_file" ] || error "no checksum dump file on Client"
8419 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
8420 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
8421 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
8422 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
8424 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
8425 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8426 error "dump content does not match on Client"
8428 $check_ost || skip "No need to check cksum dump on OSS"
8430 # check cksum dump on OSS
8431 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
8432 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
8433 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
8434 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
8435 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8436 error "dump content does not match on OSS"
8440 run_test 77c "checksum error on client read with debug"
8442 test_77d() { # bug 10889
8443 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8444 $GSS && skip_env "could not run with gss"
8446 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8447 $LCTL set_param fail_loc=0x80000409
8449 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8450 error "direct write: rc=$?"
8451 $LCTL set_param fail_loc=0
8454 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8455 $LCTL set_param fail_loc=0x80000408
8457 cancel_lru_locks osc
8458 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8459 error "direct read: rc=$?"
8460 $LCTL set_param fail_loc=0
8463 run_test 77d "checksum error on OST direct write, read"
8465 test_77f() { # bug 10889
8466 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8467 $GSS && skip_env "could not run with gss"
8470 for algo in $CKSUM_TYPES; do
8471 cancel_lru_locks osc
8472 set_checksum_type $algo
8473 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8474 $LCTL set_param fail_loc=0x409
8475 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
8476 error "direct write succeeded"
8477 $LCTL set_param fail_loc=0
8479 set_checksum_type $ORIG_CSUM_TYPE
8482 run_test 77f "repeat checksum error on write (expect error)"
8484 test_77g() { # bug 10889
8485 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8486 $GSS && skip_env "could not run with gss"
8487 remote_ost_nodsh && skip "remote OST with nodsh"
8489 [ ! -f $F77_TMP ] && setup_f77
8491 local file=$DIR/$tfile
8492 stack_trap "rm -f $file" EXIT
8494 $LFS setstripe -c 1 -i 0 $file
8495 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
8496 do_facet ost1 lctl set_param fail_loc=0x8000021a
8498 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
8499 error "write error: rc=$?"
8500 do_facet ost1 lctl set_param fail_loc=0
8503 cancel_lru_locks osc
8504 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
8505 do_facet ost1 lctl set_param fail_loc=0x8000021b
8507 cmp $F77_TMP $file || error "file compare failed"
8508 do_facet ost1 lctl set_param fail_loc=0
8511 run_test 77g "checksum error on OST write, read"
8513 test_77k() { # LU-10906
8514 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8515 $GSS && skip_env "could not run with gss"
8517 local cksum_param="osc.$FSNAME*.checksums"
8518 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
8522 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
8523 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
8524 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
8528 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
8529 error "failed to set checksum=$i on MGS"
8530 wait_update $HOSTNAME "$get_checksum" $i
8532 echo "remount client, checksum should be $i"
8533 remount_client $MOUNT || error "failed to remount client"
8534 checksum=$(eval $get_checksum)
8535 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8537 # remove persistent param to avoid races with checksum mountopt below
8538 do_facet mgs $LCTL set_param -P -d $cksum_param ||
8539 error "failed to delete checksum on MGS"
8541 for opt in "checksum" "nochecksum"; do
8542 #remount with mount option
8543 echo "remount client with option $opt, checksum should be $i"
8544 umount_client $MOUNT || error "failed to umount client"
8545 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
8546 error "failed to mount client with option '$opt'"
8547 checksum=$(eval $get_checksum)
8548 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8552 remount_client $MOUNT || error "failed to remount client"
8554 run_test 77k "enable/disable checksum correctly"
8557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8558 $GSS && skip_env "could not run with gss"
8561 stack_trap "set_checksums $ORIG_CSUM" EXIT
8562 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
8564 set_checksum_type invalid && error "unexpected success of invalid checksum type"
8566 $LFS setstripe -c 1 -i 0 $DIR/$tfile
8567 for algo in $CKSUM_TYPES; do
8568 set_checksum_type $algo || error "fail to set checksum type $algo"
8569 osc_algo=$(get_osc_checksum_type OST0000)
8570 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
8572 # no locks, no reqs to let the connection idle
8573 cancel_lru_locks osc
8574 lru_resize_disable osc
8575 wait_osc_import_state client ost1 IDLE
8577 # ensure ost1 is connected
8578 stat $DIR/$tfile >/dev/null || error "can't stat"
8579 wait_osc_import_state client ost1 FULL
8581 osc_algo=$(get_osc_checksum_type OST0000)
8582 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
8586 run_test 77l "preferred checksum type is remembered after reconnected"
8588 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
8597 test_78() { # bug 10901
8598 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8599 remote_ost || skip_env "local OST"
8602 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
8603 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
8604 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
8605 echo "MemTotal: $MEMTOTAL"
8607 # reserve 256MB of memory for the kernel and other running processes,
8608 # and then take 1/2 of the remaining memory for the read/write buffers.
8609 if [ $MEMTOTAL -gt 512 ] ;then
8610 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
8612 # for those poor memory-starved high-end clusters...
8613 MEMTOTAL=$((MEMTOTAL / 2))
8615 echo "Mem to use for directio: $MEMTOTAL"
8617 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
8618 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
8619 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
8620 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
8622 echo "Smallest OST: $SMALLESTOST"
8623 [[ $SMALLESTOST -lt 10240 ]] &&
8624 skip "too small OSTSIZE, useless to run large O_DIRECT test"
8626 trap cleanup_test_78 EXIT
8628 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
8629 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
8631 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
8632 echo "File size: $F78SIZE"
8633 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
8634 for i in $(seq 1 $NSEQ); do
8635 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
8636 echo directIO rdwr round $i of $NSEQ
8637 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
8642 run_test 78 "handle large O_DIRECT writes correctly ============"
8644 test_79() { # bug 12743
8645 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8647 wait_delete_completed
8649 BKTOTAL=$(calc_osc_kbytes kbytestotal)
8650 BKFREE=$(calc_osc_kbytes kbytesfree)
8651 BKAVAIL=$(calc_osc_kbytes kbytesavail)
8653 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
8654 DFTOTAL=`echo $STRING | cut -d, -f1`
8655 DFUSED=`echo $STRING | cut -d, -f2`
8656 DFAVAIL=`echo $STRING | cut -d, -f3`
8657 DFFREE=$(($DFTOTAL - $DFUSED))
8659 ALLOWANCE=$((64 * $OSTCOUNT))
8661 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
8662 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
8663 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
8665 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
8666 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
8667 error "df free($DFFREE) mismatch OST free($BKFREE)"
8669 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
8670 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
8671 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
8674 run_test 79 "df report consistency check ======================="
8676 test_80() { # bug 10718
8677 remote_ost_nodsh && skip "remote OST with nodsh"
8678 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8680 # relax strong synchronous semantics for slow backends like ZFS
8681 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
8682 local soc="obdfilter.*.sync_lock_cancel"
8683 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8685 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
8686 if [ -z "$save" ]; then
8687 soc="obdfilter.*.sync_on_lock_cancel"
8688 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8691 if [ "$save" != "never" ]; then
8692 local hosts=$(comma_list $(osts_nodes))
8694 do_nodes $hosts $LCTL set_param $soc=never
8695 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
8699 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
8701 local before=$(date +%s)
8702 cancel_lru_locks osc
8703 local after=$(date +%s)
8704 local diff=$((after - before))
8705 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
8709 run_test 80 "Page eviction is equally fast at high offsets too"
8711 test_81a() { # LU-456
8712 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8713 remote_ost_nodsh && skip "remote OST with nodsh"
8715 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8716 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
8717 do_facet ost1 lctl set_param fail_loc=0x80000228
8719 # write should trigger a retry and success
8720 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8721 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8723 if [ $RC -ne 0 ] ; then
8724 error "write should success, but failed for $RC"
8727 run_test 81a "OST should retry write when get -ENOSPC ==============="
8729 test_81b() { # LU-456
8730 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8731 remote_ost_nodsh && skip "remote OST with nodsh"
8733 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8734 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
8735 do_facet ost1 lctl set_param fail_loc=0x228
8737 # write should retry several times and return -ENOSPC finally
8738 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8739 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8742 if [ $RC -ne $ENOSPC ] ; then
8743 error "dd should fail for -ENOSPC, but succeed."
8746 run_test 81b "OST should return -ENOSPC when retry still fails ======="
8748 test_82() { # LU-1031
8749 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
8753 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
8755 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
8757 kill -USR1 $MULTIPID2
8759 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
8760 error "First grouplock does not block second one"
8762 echo "Second grouplock blocks first one"
8764 kill -USR1 $MULTIPID1
8768 run_test 82 "Basic grouplock test"
8771 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
8773 test_mkdir $DIR/$tdir.cvsroot
8774 chown $RUNAS_ID $DIR/$tdir.cvsroot
8777 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
8780 # some versions of cvs import exit(1) when asked to import links or
8781 # files they can't read. ignore those files.
8782 local toignore=$(find . -type l -printf '-I %f\n' -o \
8783 ! -perm /4 -printf '-I %f\n')
8784 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
8785 $tdir.reposname vtag rtag
8788 test_mkdir $DIR/$tdir.reposname
8789 chown $RUNAS_ID $DIR/$tdir.reposname
8790 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
8792 cd $DIR/$tdir.reposname
8794 $RUNAS cvs add -m 'addmsg' foo99
8796 $RUNAS cvs commit -m 'nomsg' foo99
8797 rm -fr $DIR/$tdir.cvsroot
8799 run_test 99 "cvs strange file/directory operations"
8802 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8803 [[ "$NETTYPE" =~ tcp ]] ||
8804 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
8805 remote_ost_nodsh && skip "remote OST with nodsh"
8806 remote_mds_nodsh && skip "remote MDS with nodsh"
8808 skip "useless for local single node setup"
8810 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
8811 [ "$PROT" != "tcp" ] && continue
8812 RPORT=$(echo $REMOTE | cut -d: -f2)
8813 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
8816 LPORT=`echo $LOCAL | cut -d: -f2`
8817 if [ $LPORT -ge 1024 ]; then
8818 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
8820 error_exit "local: $LPORT > 1024, remote: $RPORT"
8823 [ "$rc" = 0 ] || error_exit "privileged port not found" )
8825 run_test 100 "check local port using privileged port ==========="
8827 function get_named_value()
8836 echo $line | sed "s/^$tag[ ]*//"
8843 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
8844 awk '/^max_cached_mb/ { print $2 }')
8847 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
8852 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8857 local cache_limit=32
8859 $LCTL set_param -n osc.*-osc*.rpc_stats 0
8860 trap cleanup_101a EXIT
8861 $LCTL set_param -n llite.*.read_ahead_stats 0
8862 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
8865 # randomly read 10000 of 64K chunks from file 3x 32MB in size
8867 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
8868 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
8871 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
8872 get_named_value 'read but discarded' | cut -d" " -f1); do
8873 discard=$(($discard + $s))
8877 $LCTL get_param osc.*-osc*.rpc_stats
8878 $LCTL get_param llite.*.read_ahead_stats
8880 # Discard is generally zero, but sometimes a few random reads line up
8881 # and trigger larger readahead, which is wasted & leads to discards.
8882 if [[ $(($discard)) -gt $nreads ]]; then
8883 error "too many ($discard) discarded pages"
8885 rm -f $DIR/$tfile || true
8887 run_test 101a "check read-ahead for random reads"
8890 test_mkdir $DIR/$tdir
8892 local FILE_LENGTH=$2
8895 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
8897 local list=$(comma_list $(osts_nodes))
8898 set_osd_param $list '' read_cache_enable 0
8899 set_osd_param $list '' writethrough_cache_enable 0
8901 trap cleanup_test101bc EXIT
8902 # prepare the read-ahead file
8903 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
8905 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
8906 count=$FILE_SIZE_MB 2> /dev/null
8910 cleanup_test101bc() {
8915 local list=$(comma_list $(osts_nodes))
8916 set_osd_param $list '' read_cache_enable 1
8917 set_osd_param $list '' writethrough_cache_enable 1
8921 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
8926 local STRIPE_SIZE=$2
8927 local FILE_LENGTH=$3
8928 local RA_INC=1048576
8929 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
8930 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
8931 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
8932 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
8933 get_named_value 'read but discarded' |
8934 cut -d" " -f1 | calc_total)
8935 if [[ $DISCARD -gt $discard_limit ]]; then
8936 $LCTL get_param llite.*.read_ahead_stats
8937 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
8939 echo "Read-ahead success for size ${READ_SIZE}"
8944 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8945 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8947 local STRIPE_SIZE=1048576
8948 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
8950 if [ $SLOW == "yes" ]; then
8951 local FILE_LENGTH=$((STRIDE_SIZE * 64))
8953 local FILE_LENGTH=$((STRIDE_SIZE * 8))
8956 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
8958 # prepare the read-ahead file
8959 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8960 cancel_lru_locks osc
8961 for BIDX in 2 4 8 16 32 64 128 256
8963 local BSIZE=$((BIDX*4096))
8964 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
8965 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
8966 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
8967 $LCTL set_param -n llite.*.read_ahead_stats 0
8968 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
8969 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
8970 cancel_lru_locks osc
8971 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
8976 run_test 101b "check stride-io mode read-ahead ================="
8979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8981 local STRIPE_SIZE=1048576
8982 local FILE_LENGTH=$((STRIPE_SIZE*100))
8987 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8989 cancel_lru_locks osc
8990 $LCTL set_param osc.*.rpc_stats 0
8991 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
8992 $LCTL get_param osc.*.rpc_stats
8993 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
8994 local stats=$($LCTL get_param -n $osc_rpc_stats)
8995 local lines=$(echo "$stats" | awk 'END {print NR;}')
8998 if [ $lines -le 20 ]; then
8999 echo "continue debug"
9002 for size in 1 2 4 8; do
9003 local rpc=$(echo "$stats" |
9004 awk '($1 == "'$size':") {print $2; exit; }')
9005 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
9006 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
9008 echo "$osc_rpc_stats check passed!"
9013 run_test 101c "check stripe_size aligned read-ahead ================="
9016 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9018 local file=$DIR/$tfile
9019 local sz_MB=${FILESIZE_101d:-500}
9020 local ra_MB=${READAHEAD_MB:-40}
9022 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
9023 [ $free_MB -lt $sz_MB ] &&
9024 skip "Need free space ${sz_MB}M, have ${free_MB}M"
9026 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
9027 $LFS setstripe -c -1 $file || error "setstripe failed"
9029 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
9030 echo Cancel LRU locks on lustre client to flush the client cache
9031 cancel_lru_locks osc
9033 echo Disable read-ahead
9034 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
9035 $LCTL set_param -n llite.*.max_read_ahead_mb=0
9036 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_RA" EXIT
9037 $LCTL get_param -n llite.*.max_read_ahead_mb
9039 echo Reading the test file $file with read-ahead disabled
9040 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
9042 echo Cancel LRU locks on lustre client to flush the client cache
9043 cancel_lru_locks osc
9044 echo Enable read-ahead with ${ra_MB}MB
9045 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
9047 echo Reading the test file $file with read-ahead enabled
9048 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
9050 echo "read-ahead disabled time read $raOFF"
9051 echo "read-ahead enabled time read $raON"
9054 wait_delete_completed
9056 [ $raOFF -le 1 ] || [ $raON -lt $raOFF ] ||
9057 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
9059 run_test 101d "file read with and without read-ahead enabled"
9062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9064 local file=$DIR/$tfile
9065 local size_KB=500 #KB
9069 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
9070 local need_KB=$((count * size_KB))
9071 [[ $free_KB -le $need_KB ]] &&
9072 skip_env "Need free space $need_KB, have $free_KB"
9074 echo "Creating $count ${size_KB}K test files"
9075 for ((i = 0; i < $count; i++)); do
9076 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
9079 echo "Cancel LRU locks on lustre client to flush the client cache"
9080 cancel_lru_locks $OSC
9082 echo "Reset readahead stats"
9083 $LCTL set_param -n llite.*.read_ahead_stats 0
9085 for ((i = 0; i < $count; i++)); do
9086 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
9089 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9090 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9092 for ((i = 0; i < $count; i++)); do
9093 rm -rf $file.$i 2>/dev/null
9096 #10000 means 20% reads are missing in readahead
9097 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
9099 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
9102 which iozone || skip_env "no iozone installed"
9104 local old_debug=$($LCTL get_param debug)
9105 old_debug=${old_debug#*=}
9106 $LCTL set_param debug="reada mmap"
9108 # create a test file
9109 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
9111 echo Cancel LRU locks on lustre client to flush the client cache
9112 cancel_lru_locks osc
9114 echo Reset readahead stats
9115 $LCTL set_param -n llite.*.read_ahead_stats 0
9117 echo mmap read the file with small block size
9118 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
9121 echo checking missing pages
9122 $LCTL get_param llite.*.read_ahead_stats
9123 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9124 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9126 $LCTL set_param debug="$old_debug"
9127 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
9130 run_test 101f "check mmap read performance"
9132 test_101g_brw_size_test() {
9134 local pages=$((mb * 1048576 / PAGE_SIZE))
9135 local file=$DIR/$tfile
9137 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
9138 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
9139 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
9140 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
9144 stack_trap "rm -f $file" EXIT
9145 $LCTL set_param -n osc.*.rpc_stats=0
9147 # 10 RPCs should be enough for the test
9149 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
9150 { error "dd write ${mb} MB blocks failed"; return 3; }
9151 cancel_lru_locks osc
9152 dd of=/dev/null if=$file bs=${mb}M count=$count ||
9153 { error "dd write ${mb} MB blocks failed"; return 4; }
9155 # calculate number of full-sized read and write RPCs
9156 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
9157 sed -n '/pages per rpc/,/^$/p' |
9158 awk '/'$pages':/ { reads += $2; writes += $6 }; \
9159 END { print reads,writes }'))
9160 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
9162 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
9169 remote_ost_nodsh && skip "remote OST with nodsh"
9172 local osts=$(get_facets OST)
9173 local list=$(comma_list $(osts_nodes))
9174 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9175 local brw_size="obdfilter.*.brw_size"
9177 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9179 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
9181 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
9182 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
9183 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
9184 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
9185 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
9186 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
9188 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
9191 if [[ $orig_mb -lt 16 ]]; then
9192 save_lustre_params $osts "$brw_size" > $p
9193 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
9194 error "set 16MB RPC size failed"
9196 echo "remount client to enable new RPC size"
9197 remount_client $MOUNT || error "remount_client failed"
9200 test_101g_brw_size_test 16 || error "16MB RPC test failed"
9201 # should be able to set brw_size=12, but no rpc_stats for that
9202 test_101g_brw_size_test 8 || error "8MB RPC test failed"
9205 test_101g_brw_size_test 4 || error "4MB RPC test failed"
9207 if [[ $orig_mb -lt 16 ]]; then
9208 restore_lustre_params < $p
9209 remount_client $MOUNT || error "remount_client restore failed"
9212 rm -f $p $DIR/$tfile
9214 run_test 101g "Big bulk(4/16 MiB) readahead"
9217 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9219 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
9220 error "dd 70M file failed"
9221 echo Cancel LRU locks on lustre client to flush the client cache
9222 cancel_lru_locks osc
9224 echo "Reset readahead stats"
9225 $LCTL set_param -n llite.*.read_ahead_stats 0
9227 echo "Read 10M of data but cross 64M bundary"
9228 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
9229 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9230 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9231 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
9232 rm -f $p $DIR/$tfile
9234 run_test 101h "Readahead should cover current read window"
9237 test_mkdir $DIR/$tdir
9238 chown $RUNAS_ID $DIR/$tdir
9241 STRIPE_COUNT=$OSTCOUNT
9242 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
9244 trap cleanup_test102 EXIT
9246 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
9248 for num in 1 2 3 4; do
9249 for count in $(seq 1 $STRIPE_COUNT); do
9250 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
9251 local size=`expr $STRIPE_SIZE \* $num`
9252 local file=file"$num-$idx-$count"
9253 $1 $LFS setstripe -S $size -i $idx -c $count $file
9259 $1 tar cf $TMP/f102.tar $tdir --xattrs
9265 rm -rf $DIR/d0.sanity/d102
9269 [ "$UID" != 0 ] && skip "must run as root"
9270 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
9271 skip_env "must have user_xattr"
9273 [ -z "$(which setfattr 2>/dev/null)" ] &&
9274 skip_env "could not find setfattr"
9276 local testfile=$DIR/$tfile
9279 echo "set/get xattr..."
9280 setfattr -n trusted.name1 -v value1 $testfile ||
9281 error "setfattr -n trusted.name1=value1 $testfile failed"
9282 getfattr -n trusted.name1 $testfile 2> /dev/null |
9283 grep "trusted.name1=.value1" ||
9284 error "$testfile missing trusted.name1=value1"
9286 setfattr -n user.author1 -v author1 $testfile ||
9287 error "setfattr -n user.author1=author1 $testfile failed"
9288 getfattr -n user.author1 $testfile 2> /dev/null |
9289 grep "user.author1=.author1" ||
9290 error "$testfile missing trusted.author1=author1"
9293 setfattr -n trusted.name2 -v value2 $testfile ||
9294 error "$testfile unable to set trusted.name2"
9295 setfattr -n trusted.name3 -v value3 $testfile ||
9296 error "$testfile unable to set trusted.name3"
9297 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
9298 grep "trusted.name" | wc -l) -eq 3 ] ||
9299 error "$testfile missing 3 trusted.name xattrs"
9301 setfattr -n user.author2 -v author2 $testfile ||
9302 error "$testfile unable to set user.author2"
9303 setfattr -n user.author3 -v author3 $testfile ||
9304 error "$testfile unable to set user.author3"
9305 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
9306 grep "user.author" | wc -l) -eq 3 ] ||
9307 error "$testfile missing 3 user.author xattrs"
9309 echo "remove xattr..."
9310 setfattr -x trusted.name1 $testfile ||
9311 error "$testfile error deleting trusted.name1"
9312 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
9313 error "$testfile did not delete trusted.name1 xattr"
9315 setfattr -x user.author1 $testfile ||
9316 error "$testfile error deleting user.author1"
9317 echo "set lustre special xattr ..."
9318 $LFS setstripe -c1 $testfile
9319 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
9320 awk -F "=" '/trusted.lov/ { print $2 }' )
9321 setfattr -n "trusted.lov" -v $lovea $testfile ||
9322 error "$testfile doesn't ignore setting trusted.lov again"
9323 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
9324 error "$testfile allow setting invalid trusted.lov"
9327 run_test 102a "user xattr test =================================="
9330 [ -z "$(which setfattr 2>/dev/null)" ] &&
9331 skip_env "could not find setfattr"
9332 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9334 # b10930: get/set/list trusted.lov xattr
9335 echo "get/set/list trusted.lov xattr ..."
9336 local testfile=$DIR/$tfile
9337 $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
9338 error "setstripe failed"
9339 local STRIPECOUNT=$($LFS getstripe -c $testfile) ||
9340 error "getstripe failed"
9341 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
9342 error "can't get trusted.lov from $testfile"
9344 local testfile2=${testfile}2
9345 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
9346 grep "trusted.lov" | sed -e 's/[^=]\+=//')
9349 setfattr -n trusted.lov -v $value $testfile2
9350 local stripe_size=$($LFS getstripe -S $testfile2)
9351 local stripe_count=$($LFS getstripe -c $testfile2)
9352 [[ $stripe_size -eq 65536 ]] ||
9353 error "stripe size $stripe_size != 65536"
9354 [[ $stripe_count -eq $STRIPECOUNT ]] ||
9355 error "stripe count $stripe_count != $STRIPECOUNT"
9358 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
9361 [ -z "$(which setfattr 2>/dev/null)" ] &&
9362 skip_env "could not find setfattr"
9363 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9365 # b10930: get/set/list lustre.lov xattr
9366 echo "get/set/list lustre.lov xattr ..."
9367 test_mkdir $DIR/$tdir
9368 chown $RUNAS_ID $DIR/$tdir
9369 local testfile=$DIR/$tdir/$tfile
9370 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
9371 error "setstripe failed"
9372 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
9373 error "getstripe failed"
9374 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
9375 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
9377 local testfile2=${testfile}2
9378 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
9379 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
9381 $RUNAS $MCREATE $testfile2
9382 $RUNAS setfattr -n lustre.lov -v $value $testfile2
9383 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
9384 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
9385 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
9386 [ $stripe_count -eq $STRIPECOUNT ] ||
9387 error "stripe count $stripe_count != $STRIPECOUNT"
9389 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
9391 compare_stripe_info1() {
9392 local stripe_index_all_zero=true
9394 for num in 1 2 3 4; do
9395 for count in $(seq 1 $STRIPE_COUNT); do
9396 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
9397 local size=$((STRIPE_SIZE * num))
9398 local file=file"$num-$offset-$count"
9399 stripe_size=$($LFS getstripe -S $PWD/$file)
9400 [[ $stripe_size -ne $size ]] &&
9401 error "$file: size $stripe_size != $size"
9402 stripe_count=$($LFS getstripe -c $PWD/$file)
9403 # allow fewer stripes to be created, ORI-601
9404 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
9405 error "$file: count $stripe_count != $count"
9406 stripe_index=$($LFS getstripe -i $PWD/$file)
9407 [[ $stripe_index -ne 0 ]] &&
9408 stripe_index_all_zero=false
9412 $stripe_index_all_zero &&
9413 error "all files are being extracted starting from OST index 0"
9417 have_xattrs_include() {
9418 tar --help | grep -q xattrs-include &&
9419 echo --xattrs-include="lustre.*"
9423 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9424 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9426 XINC=$(have_xattrs_include)
9428 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9430 compare_stripe_info1
9432 run_test 102d "tar restore stripe info from tarfile,not keep osts"
9435 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9436 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9438 XINC=$(have_xattrs_include)
9440 test_mkdir $DIR/$tdir.restore
9442 tar cf - --xattrs $tdir | tar xf - \
9443 -C $DIR/$tdir.restore --xattrs $XINC
9444 cd $DIR/$tdir.restore/$tdir
9445 compare_stripe_info1
9447 run_test 102f "tar copy files, not keep osts"
9450 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
9451 skip "must have user_xattr"
9452 [ -z "$(which setfattr 2>/dev/null)" ] &&
9453 skip_env "could not find setfattr"
9454 [ -z "$(which getfattr 2>/dev/null)" ] &&
9455 skip_env "could not find getfattr"
9457 local xsize=${1:-1024} # in bytes
9458 local file=$DIR/$tfile
9459 local value="$(generate_string $xsize)"
9460 local xbig=trusted.big
9464 log "save $xbig on $file"
9467 setfattr -n $xbig -v $value $file ||
9468 error "saving $xbig on $file failed"
9470 setfattr -n $xbig -v $value $file &&
9471 error "saving $xbig on $file succeeded"
9475 local orig=$(get_xattr_value $xbig $file)
9476 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
9478 local xsml=trusted.sml
9479 log "save $xsml on $file"
9480 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
9482 local new=$(get_xattr_value $xbig $file)
9483 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
9485 log "grow $xsml on $file"
9486 setfattr -n $xsml -v "$value" $file ||
9487 error "growing $xsml on $file failed"
9489 new=$(get_xattr_value $xbig $file)
9490 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
9491 log "$xbig still valid after growing $xsml"
9496 test_102h() { # bug 15777
9499 run_test 102h "grow xattr from inside inode to external block"
9502 large_xattr_enabled || skip_env "ea_inode feature disabled"
9504 echo "setting xattr of max xattr size: $(max_xattr_size)"
9505 grow_xattr $(max_xattr_size)
9507 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
9508 echo "This should fail:"
9509 grow_xattr $(($(max_xattr_size) + 10)) 1
9511 run_test 102ha "grow xattr from inside inode to external inode"
9513 test_102i() { # bug 17038
9514 [ -z "$(which getfattr 2>/dev/null)" ] &&
9515 skip "could not find getfattr"
9518 ln -s $DIR/$tfile $DIR/${tfile}link
9519 getfattr -n trusted.lov $DIR/$tfile ||
9520 error "lgetxattr on $DIR/$tfile failed"
9521 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
9522 grep -i "no such attr" ||
9523 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
9524 rm -f $DIR/$tfile $DIR/${tfile}link
9526 run_test 102i "lgetxattr test on symbolic link ============"
9529 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9530 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9532 XINC=$(have_xattrs_include)
9533 setup_test102 "$RUNAS"
9534 chown $RUNAS_ID $DIR/$tdir
9535 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9537 compare_stripe_info1 "$RUNAS"
9539 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
9542 [ -z "$(which setfattr 2>/dev/null)" ] &&
9543 skip "could not find setfattr"
9546 # b22187 just check that does not crash for regular file.
9547 setfattr -n trusted.lov $DIR/$tfile
9548 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
9549 local test_kdir=$DIR/$tdir
9550 test_mkdir $test_kdir
9551 local default_size=$($LFS getstripe -S $test_kdir)
9552 local default_count=$($LFS getstripe -c $test_kdir)
9553 local default_offset=$($LFS getstripe -i $test_kdir)
9554 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
9555 error 'dir setstripe failed'
9556 setfattr -n trusted.lov $test_kdir
9557 local stripe_size=$($LFS getstripe -S $test_kdir)
9558 local stripe_count=$($LFS getstripe -c $test_kdir)
9559 local stripe_offset=$($LFS getstripe -i $test_kdir)
9560 [ $stripe_size -eq $default_size ] ||
9561 error "stripe size $stripe_size != $default_size"
9562 [ $stripe_count -eq $default_count ] ||
9563 error "stripe count $stripe_count != $default_count"
9564 [ $stripe_offset -eq $default_offset ] ||
9565 error "stripe offset $stripe_offset != $default_offset"
9566 rm -rf $DIR/$tfile $test_kdir
9568 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
9571 [ -z "$(which getfattr 2>/dev/null)" ] &&
9572 skip "could not find getfattr"
9574 # LU-532 trusted. xattr is invisible to non-root
9575 local testfile=$DIR/$tfile
9579 echo "listxattr as user..."
9580 chown $RUNAS_ID $testfile
9581 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
9582 grep -q "trusted" &&
9583 error "$testfile trusted xattrs are user visible"
9587 run_test 102l "listxattr size test =================================="
9589 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
9590 local path=$DIR/$tfile
9593 listxattr_size_check $path || error "listattr_size_check $path failed"
9595 run_test 102m "Ensure listxattr fails on small bufffer ========"
9599 getxattr() { # getxattr path name
9600 # Return the base64 encoding of the value of xattr name on path.
9604 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
9606 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9608 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9610 getfattr --absolute-names --encoding=base64 --name=$name $path |
9611 awk -F= -v name=$name '$1 == name {
9612 print substr($0, index($0, "=") + 1);
9616 test_102n() { # LU-4101 mdt: protect internal xattrs
9617 [ -z "$(which setfattr 2>/dev/null)" ] &&
9618 skip "could not find setfattr"
9619 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
9621 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
9624 local file0=$DIR/$tfile.0
9625 local file1=$DIR/$tfile.1
9626 local xattr0=$TMP/$tfile.0
9627 local xattr1=$TMP/$tfile.1
9628 local namelist="lov lma lmv link fid version som hsm"
9632 rm -rf $file0 $file1 $xattr0 $xattr1
9635 # Get 'before' xattrs of $file1.
9636 getfattr --absolute-names --dump --match=- $file1 > $xattr0
9638 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
9639 namelist+=" lfsck_namespace"
9640 for name in $namelist; do
9641 # Try to copy xattr from $file0 to $file1.
9642 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9644 setfattr --name=trusted.$name --value="$value" $file1 ||
9645 error "setxattr 'trusted.$name' failed"
9647 # Try to set a garbage xattr.
9648 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9650 if [[ x$name == "xlov" ]]; then
9651 setfattr --name=trusted.lov --value="$value" $file1 &&
9652 error "setxattr invalid 'trusted.lov' success"
9654 setfattr --name=trusted.$name --value="$value" $file1 ||
9655 error "setxattr invalid 'trusted.$name' failed"
9658 # Try to remove the xattr from $file1. We don't care if this
9659 # appears to succeed or fail, we just don't want there to be
9660 # any changes or crashes.
9661 setfattr --remove=$trusted.$name $file1 2> /dev/null
9664 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
9667 # Try to copy xattr from $file0 to $file1.
9668 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9670 setfattr --name=trusted.$name --value="$value" $file1 ||
9671 error "setxattr 'trusted.$name' failed"
9673 # Try to set a garbage xattr.
9674 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9676 setfattr --name=trusted.$name --value="$value" $file1 ||
9677 error "setxattr 'trusted.$name' failed"
9679 # Try to remove the xattr from $file1. We don't care if this
9680 # appears to succeed or fail, we just don't want there to be
9681 # any changes or crashes.
9682 setfattr --remove=$trusted.$name $file1 2> /dev/null
9685 # Get 'after' xattrs of file1.
9686 getfattr --absolute-names --dump --match=- $file1 > $xattr1
9688 if ! diff $xattr0 $xattr1; then
9689 error "before and after xattrs of '$file1' differ"
9692 rm -rf $file0 $file1 $xattr0 $xattr1
9696 run_test 102n "silently ignore setxattr on internal trusted xattrs"
9698 test_102p() { # LU-4703 setxattr did not check ownership
9699 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
9700 skip "MDS needs to be at least 2.5.56"
9702 local testfile=$DIR/$tfile
9706 echo "setfacl as user..."
9707 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
9708 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
9710 echo "setfattr as user..."
9711 setfacl -m "u:$RUNAS_ID:---" $testfile
9712 $RUNAS setfattr -x system.posix_acl_access $testfile
9713 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
9715 run_test 102p "check setxattr(2) correctly fails without permission"
9718 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
9719 skip "MDS needs to be at least 2.6.92"
9721 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
9723 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
9726 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
9727 skip "MDS needs to be at least 2.6.93"
9729 touch $DIR/$tfile || error "touch"
9730 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
9731 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
9732 rm $DIR/$tfile || error "rm"
9735 mkdir -p $DIR/$tdir || error "mkdir"
9736 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9737 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9738 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9739 error "$testfile error deleting user.author1"
9740 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9741 grep "user.$(basename $tdir)" &&
9742 error "$tdir did not delete user.$(basename $tdir)"
9743 rmdir $DIR/$tdir || error "rmdir"
9746 test_mkdir $DIR/$tdir
9747 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9748 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9749 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9750 error "$testfile error deleting user.author1"
9751 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9752 grep "user.$(basename $tdir)" &&
9753 error "$tdir did not delete user.$(basename $tdir)"
9754 rmdir $DIR/$tdir || error "rm striped dir"
9756 run_test 102r "set EAs with empty values"
9759 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9760 skip "MDS needs to be at least 2.11.52"
9762 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9764 save_lustre_params client "llite.*.xattr_cache" > $save
9766 for cache in 0 1; do
9767 lctl set_param llite.*.xattr_cache=$cache
9770 touch $DIR/$tfile || error "touch"
9771 for prefix in lustre security system trusted user; do
9772 # Note getxattr() may fail with 'Operation not
9773 # supported' or 'No such attribute' depending
9774 # on prefix and cache.
9775 getfattr -n $prefix.n102s $DIR/$tfile &&
9776 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
9780 restore_lustre_params < $save
9782 run_test 102s "getting nonexistent xattrs should fail"
9785 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9786 skip "MDS needs to be at least 2.11.52"
9788 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9790 save_lustre_params client "llite.*.xattr_cache" > $save
9792 for cache in 0 1; do
9793 lctl set_param llite.*.xattr_cache=$cache
9795 for buf_size in 0 256; do
9797 touch $DIR/$tfile || error "touch"
9798 setfattr -n user.multiop $DIR/$tfile
9799 $MULTIOP $DIR/$tfile oa$buf_size ||
9800 error "cannot get zero length xattr value (buf_size = $buf_size)"
9804 restore_lustre_params < $save
9806 run_test 102t "zero length xattr values handled correctly"
9810 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
9815 [ "$UID" != 0 ] && skip "must run as root"
9816 $GSS && skip_env "could not run under gss"
9817 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
9818 skip_env "must have acl enabled"
9819 [ -z "$(which setfacl 2>/dev/null)" ] &&
9820 skip_env "could not find setfacl"
9821 remote_mds_nodsh && skip "remote MDS with nodsh"
9823 gpasswd -a daemon bin # LU-5641
9824 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
9826 declare -a identity_old
9828 for num in $(seq $MDSCOUNT); do
9829 switch_identity $num true || identity_old[$num]=$?
9837 echo "performing cp ..."
9838 run_acl_subtest cp || error "run_acl_subtest cp failed"
9839 echo "performing getfacl-noacl..."
9840 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
9841 echo "performing misc..."
9842 run_acl_subtest misc || error "misc test failed"
9843 echo "performing permissions..."
9844 run_acl_subtest permissions || error "permissions failed"
9845 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
9846 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
9847 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
9848 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
9850 echo "performing permissions xattr..."
9851 run_acl_subtest permissions_xattr ||
9852 error "permissions_xattr failed"
9854 echo "performing setfacl..."
9855 run_acl_subtest setfacl || error "setfacl test failed"
9857 # inheritance test got from HP
9858 echo "performing inheritance..."
9859 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
9860 chmod +x make-tree || error "chmod +x failed"
9861 run_acl_subtest inheritance || error "inheritance test failed"
9864 echo "LU-974 ignore umask when acl is enabled..."
9865 run_acl_subtest 974 || error "LU-974 umask test failed"
9866 if [ $MDSCOUNT -ge 2 ]; then
9867 run_acl_subtest 974_remote ||
9868 error "LU-974 umask test failed under remote dir"
9871 echo "LU-2561 newly created file is same size as directory..."
9872 if [ "$mds1_FSTYPE" != "zfs" ]; then
9873 run_acl_subtest 2561 || error "LU-2561 test failed"
9875 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
9878 run_acl_subtest 4924 || error "LU-4924 test failed"
9883 for num in $(seq $MDSCOUNT); do
9884 if [ "${identity_old[$num]}" = 1 ]; then
9885 switch_identity $num false || identity_old[$num]=$?
9889 run_test 103a "acl test"
9895 for U in {0..511}; do
9897 local O=$(printf "%04o" $U)
9899 umask $(printf "%04o" $((511 ^ $O)))
9900 $LFS setstripe -c 1 $DIR/$tfile.s$O
9901 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
9903 (( $S == ($O & 0666) )) ||
9904 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
9906 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
9907 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
9908 (( $S == ($O & 0666) )) ||
9909 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
9911 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
9912 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
9913 (( $S == ($O & 0666) )) ||
9914 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
9915 rm -f $DIR/$tfile.[smp]$0
9919 # limit the concurrently running threads to 64. LU-11878
9920 local idx=$((U % 64))
9921 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
9926 run_test 103b "umask lfs setstripe"
9930 cp -rp $DIR/$tdir $DIR/$tdir.bak
9932 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
9933 error "$DIR/$tdir shouldn't contain default ACL"
9934 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
9935 error "$DIR/$tdir.bak shouldn't contain default ACL"
9938 run_test 103c "'cp -rp' won't set empty acl"
9941 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9944 lfs df || error "lfs df failed"
9945 lfs df -ih || error "lfs df -ih failed"
9946 lfs df -h $DIR || error "lfs df -h $DIR failed"
9947 lfs df -i $DIR || error "lfs df -i $DIR failed"
9948 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
9949 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
9951 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
9952 lctl --device %$OSC deactivate
9953 lfs df || error "lfs df with deactivated OSC failed"
9954 lctl --device %$OSC activate
9955 # wait the osc back to normal
9956 wait_osc_import_ready client ost
9958 lfs df || error "lfs df with reactivated OSC failed"
9961 run_test 104a "lfs df [-ih] [path] test ========================="
9964 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9965 [ $RUNAS_ID -eq $UID ] &&
9966 skip_env "RUNAS_ID = UID = $UID -- skipping"
9968 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
9969 grep "Permission denied" | wc -l)))
9970 if [ $denied_cnt -ne 0 ]; then
9971 error "lfs check servers test failed"
9974 run_test 104b "$RUNAS lfs check servers test ===================="
9977 # doesn't work on 2.4 kernels
9979 if $(flock_is_enabled); then
9980 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
9982 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
9986 run_test 105a "flock when mounted without -o flock test ========"
9990 if $(flock_is_enabled); then
9991 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
9993 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
9997 run_test 105b "fcntl when mounted without -o flock test ========"
10001 if $(flock_is_enabled); then
10002 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
10004 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
10008 run_test 105c "lockf when mounted without -o flock test"
10010 test_105d() { # bug 15924
10011 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10013 test_mkdir $DIR/$tdir
10014 flock_is_enabled || skip_env "mount w/o flock enabled"
10015 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
10016 $LCTL set_param fail_loc=0x80000315
10017 flocks_test 2 $DIR/$tdir
10019 run_test 105d "flock race (should not freeze) ========"
10021 test_105e() { # bug 22660 && 22040
10022 flock_is_enabled || skip_env "mount w/o flock enabled"
10025 flocks_test 3 $DIR/$tfile
10027 run_test 105e "Two conflicting flocks from same process"
10029 test_106() { #bug 10921
10030 test_mkdir $DIR/$tdir
10031 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
10032 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
10034 run_test 106 "attempt exec of dir followed by chown of that dir"
10037 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10045 local save_pattern=$(sysctl -n kernel.core_pattern)
10046 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
10047 sysctl -w kernel.core_pattern=$file
10048 sysctl -w kernel.core_uses_pid=0
10050 ulimit -c unlimited
10056 kill -s 11 $SLEEPPID
10058 if [ -e $file ]; then
10059 size=`stat -c%s $file`
10060 [ $size -eq 0 ] && error "Fail to create core file $file"
10062 error "Fail to create core file $file"
10065 sysctl -w kernel.core_pattern=$save_pattern
10066 sysctl -w kernel.core_uses_pid=$save_uses_pid
10069 run_test 107 "Coredump on SIG"
10072 test_mkdir $DIR/$tdir
10073 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
10074 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
10075 error "mkdir with 256 char should fail, but did not"
10076 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
10077 error "create with 255 char failed"
10078 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
10079 error "create with 256 char should fail, but did not"
10084 run_test 110 "filename length checking"
10087 # Purpose: To verify dynamic thread (OSS) creation.
10090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10091 remote_ost_nodsh && skip "remote OST with nodsh"
10093 # Lustre does not stop service threads once they are started.
10094 # Reset number of running threads to default.
10099 local save_params="$TMP/sanity-$TESTNAME.parameters"
10101 # Get ll_ost_io count before I/O
10102 OSTIO_pre=$(do_facet ost1 \
10103 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
10104 # Exit if lustre is not running (ll_ost_io not running).
10105 [ -z "$OSTIO_pre" ] && error "no OSS threads"
10107 echo "Starting with $OSTIO_pre threads"
10108 local thread_max=$((OSTIO_pre * 2))
10109 local rpc_in_flight=$((thread_max * 2))
10110 # Number of I/O Process proposed to be started.
10112 local facets=$(get_facets OST)
10114 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
10115 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
10117 # Set in_flight to $rpc_in_flight
10118 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
10119 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
10120 nfiles=${rpc_in_flight}
10121 # Set ost thread_max to $thread_max
10122 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
10124 # 5 Minutes should be sufficient for max number of OSS
10125 # threads(thread_max) to be created.
10129 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
10130 test_mkdir $DIR/$tdir
10131 for i in $(seq $nfiles); do
10132 local file=$DIR/$tdir/${tfile}-$i
10133 $LFS setstripe -c -1 -i 0 $file
10134 ($WTL $file $timeout)&
10137 # I/O Started - Wait for thread_started to reach thread_max or report
10138 # error if thread_started is more than thread_max.
10139 echo "Waiting for thread_started to reach thread_max"
10140 local thread_started=0
10141 local end_time=$((SECONDS + timeout))
10143 while [ $SECONDS -le $end_time ] ; do
10145 # Get ost i/o thread_started count.
10146 thread_started=$(do_facet ost1 \
10148 ost.OSS.ost_io.threads_started | cut -d= -f2")
10149 # Break out if thread_started is equal/greater than thread_max
10150 if [[ $thread_started -ge $thread_max ]]; then
10151 echo ll_ost_io thread_started $thread_started, \
10152 equal/greater than thread_max $thread_max
10158 # Cleanup - We have the numbers, Kill i/o jobs if running.
10159 jobcount=($(jobs -p))
10160 for i in $(seq 0 $((${#jobcount[@]}-1)))
10162 kill -9 ${jobcount[$i]}
10163 if [ $? -ne 0 ] ; then
10165 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
10169 # Cleanup files left by WTL binary.
10170 for i in $(seq $nfiles); do
10171 local file=$DIR/$tdir/${tfile}-$i
10173 if [ $? -ne 0 ] ; then
10174 echo "Warning: Failed to delete file $file"
10178 restore_lustre_params <$save_params
10179 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
10181 # Error out if no new thread has started or Thread started is greater
10183 if [[ $thread_started -le $OSTIO_pre ||
10184 $thread_started -gt $thread_max ]]; then
10185 error "ll_ost_io: thread_started $thread_started" \
10186 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
10187 "No new thread started or thread started greater " \
10191 run_test 115 "verify dynamic thread creation===================="
10194 wait_delete_completed
10195 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
10196 echo "OST kbytes available: ${AVAIL[@]}"
10201 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
10202 #echo OST $i: ${AVAIL[i]}kb
10203 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
10207 if [[ ${AVAIL[i]} -lt $MINV ]]; then
10212 echo "Min free space: OST $MINI: $MINV"
10213 echo "Max free space: OST $MAXI: $MAXV"
10216 test_116a() { # was previously test_116()
10217 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10218 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10219 remote_mds_nodsh && skip "remote MDS with nodsh"
10221 echo -n "Free space priority "
10222 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
10227 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
10228 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
10229 trap simple_cleanup_common EXIT
10231 # Check if we need to generate uneven OSTs
10232 test_mkdir -p $DIR/$tdir/OST${MINI}
10233 local FILL=$((MINV / 4))
10234 local DIFF=$((MAXV - MINV))
10235 local DIFF2=$((DIFF * 100 / MINV))
10237 local threshold=$(do_facet $SINGLEMDS \
10238 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
10239 threshold=${threshold%%%}
10240 echo -n "Check for uneven OSTs: "
10241 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
10243 if [[ $DIFF2 -gt $threshold ]]; then
10245 echo "Don't need to fill OST$MINI"
10247 # generate uneven OSTs. Write 2% over the QOS threshold value
10249 DIFF=$((threshold - DIFF2 + 2))
10250 DIFF2=$((MINV * DIFF / 100))
10251 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
10252 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
10253 error "setstripe failed"
10254 DIFF=$((DIFF2 / 2048))
10256 while [ $i -lt $DIFF ]; do
10258 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
10259 bs=2M count=1 2>/dev/null
10268 DIFF=$((MAXV - MINV))
10269 DIFF2=$((DIFF * 100 / MINV))
10270 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
10271 if [ $DIFF2 -gt $threshold ]; then
10274 echo "failed - QOS mode won't be used"
10275 simple_cleanup_common
10276 skip "QOS imbalance criteria not met"
10284 # now fill using QOS
10285 $LFS setstripe -c 1 $DIR/$tdir
10286 FILL=$((FILL / 200))
10287 if [ $FILL -gt 600 ]; then
10290 echo "writing $FILL files to QOS-assigned OSTs"
10292 while [ $i -lt $FILL ]; do
10294 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
10295 count=1 2>/dev/null
10298 echo "wrote $i 200k files"
10302 echo "Note: free space may not be updated, so measurements might be off"
10304 DIFF2=$((MAXV - MINV))
10305 echo "free space delta: orig $DIFF final $DIFF2"
10306 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
10307 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
10308 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
10309 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
10310 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
10311 if [[ $DIFF -gt 0 ]]; then
10312 FILL=$((DIFF2 * 100 / DIFF - 100))
10313 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
10316 # Figure out which files were written where
10317 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10318 awk '/'$MINI1': / {print $2; exit}')
10320 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10321 echo "$MINC files created on smaller OST $MINI1"
10322 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10323 awk '/'$MAXI1': / {print $2; exit}')
10325 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10326 echo "$MAXC files created on larger OST $MAXI1"
10327 if [[ $MINC -gt 0 ]]; then
10328 FILL=$((MAXC * 100 / MINC - 100))
10329 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
10331 [[ $MAXC -gt $MINC ]] ||
10332 error_ignore LU-9 "stripe QOS didn't balance free space"
10333 simple_cleanup_common
10335 run_test 116a "stripe QOS: free space balance ==================="
10337 test_116b() { # LU-2093
10338 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10339 remote_mds_nodsh && skip "remote MDS with nodsh"
10341 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
10342 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
10343 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
10344 [ -z "$old_rr" ] && skip "no QOS"
10345 do_facet $SINGLEMDS lctl set_param \
10346 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
10347 mkdir -p $DIR/$tdir
10348 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
10349 createmany -o $DIR/$tdir/f- 20 || error "can't create"
10350 do_facet $SINGLEMDS lctl set_param fail_loc=0
10352 do_facet $SINGLEMDS lctl set_param \
10353 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
10355 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
10357 test_117() # bug 10891
10359 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10361 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
10362 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
10363 lctl set_param fail_loc=0x21e
10364 > $DIR/$tfile || error "truncate failed"
10365 lctl set_param fail_loc=0
10366 echo "Truncate succeeded."
10369 run_test 117 "verify osd extend =========="
10371 NO_SLOW_RESENDCOUNT=4
10372 export OLD_RESENDCOUNT=""
10373 set_resend_count () {
10374 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
10375 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
10376 lctl set_param -n $PROC_RESENDCOUNT $1
10377 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
10380 # for reduce test_118* time (b=14842)
10381 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10383 # Reset async IO behavior after error case
10385 FILE=$DIR/reset_async
10387 # Ensure all OSCs are cleared
10388 $LFS setstripe -c -1 $FILE
10389 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
10394 test_118a() #bug 11710
10396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10400 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10401 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10402 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10404 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10405 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10410 run_test 118a "verify O_SYNC works =========="
10414 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10415 remote_ost_nodsh && skip "remote OST with nodsh"
10419 #define OBD_FAIL_SRV_ENOENT 0x217
10420 set_nodes_failloc "$(osts_nodes)" 0x217
10421 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10423 set_nodes_failloc "$(osts_nodes)" 0
10424 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10425 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10428 if [[ $RC -eq 0 ]]; then
10429 error "Must return error due to dropped pages, rc=$RC"
10433 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10434 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10438 echo "Dirty pages not leaked on ENOENT"
10440 # Due to the above error the OSC will issue all RPCs syncronously
10441 # until a subsequent RPC completes successfully without error.
10442 $MULTIOP $DIR/$tfile Ow4096yc
10447 run_test 118b "Reclaim dirty pages on fatal error =========="
10451 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10453 # for 118c, restore the original resend count, LU-1940
10454 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
10455 set_resend_count $OLD_RESENDCOUNT
10456 remote_ost_nodsh && skip "remote OST with nodsh"
10460 #define OBD_FAIL_OST_EROFS 0x216
10461 set_nodes_failloc "$(osts_nodes)" 0x216
10463 # multiop should block due to fsync until pages are written
10464 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10468 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10469 error "Multiop failed to block on fsync, pid=$MULTIPID"
10472 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10474 if [[ $WRITEBACK -eq 0 ]]; then
10475 error "No page in writeback, writeback=$WRITEBACK"
10478 set_nodes_failloc "$(osts_nodes)" 0
10481 if [[ $RC -ne 0 ]]; then
10482 error "Multiop fsync failed, rc=$RC"
10485 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10486 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10488 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10489 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10493 echo "Dirty pages flushed via fsync on EROFS"
10496 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
10498 # continue to use small resend count to reduce test_118* time (b=14842)
10499 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10503 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10504 remote_ost_nodsh && skip "remote OST with nodsh"
10508 #define OBD_FAIL_OST_BRW_PAUSE_BULK
10509 set_nodes_failloc "$(osts_nodes)" 0x214
10510 # multiop should block due to fsync until pages are written
10511 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10515 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10516 error "Multiop failed to block on fsync, pid=$MULTIPID"
10519 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10521 if [[ $WRITEBACK -eq 0 ]]; then
10522 error "No page in writeback, writeback=$WRITEBACK"
10525 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
10526 set_nodes_failloc "$(osts_nodes)" 0
10528 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10529 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10531 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10532 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10536 echo "Dirty pages gaurenteed flushed via fsync"
10539 run_test 118d "Fsync validation inject a delay of the bulk =========="
10542 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10546 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
10547 lctl set_param fail_loc=0x8000040a
10549 # Should simulate EINVAL error which is fatal
10550 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10552 if [[ $RC -eq 0 ]]; then
10553 error "Must return error due to dropped pages, rc=$RC"
10556 lctl set_param fail_loc=0x0
10558 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10559 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10560 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10562 if [[ $LOCKED -ne 0 ]]; then
10563 error "Locked pages remain in cache, locked=$LOCKED"
10566 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10567 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10571 echo "No pages locked after fsync"
10576 run_test 118f "Simulate unrecoverable OSC side error =========="
10579 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10583 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
10584 lctl set_param fail_loc=0x406
10586 # simulate local -ENOMEM
10587 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10590 lctl set_param fail_loc=0
10591 if [[ $RC -eq 0 ]]; then
10592 error "Must return error due to dropped pages, rc=$RC"
10595 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10596 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10597 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10599 if [[ $LOCKED -ne 0 ]]; then
10600 error "Locked pages remain in cache, locked=$LOCKED"
10603 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10604 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10608 echo "No pages locked after fsync"
10613 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
10616 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10617 remote_ost_nodsh && skip "remote OST with nodsh"
10621 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10622 set_nodes_failloc "$(osts_nodes)" 0x20e
10623 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10624 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10627 set_nodes_failloc "$(osts_nodes)" 0
10628 if [[ $RC -eq 0 ]]; then
10629 error "Must return error due to dropped pages, rc=$RC"
10632 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10633 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10634 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10636 if [[ $LOCKED -ne 0 ]]; then
10637 error "Locked pages remain in cache, locked=$LOCKED"
10640 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10641 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10645 echo "No pages locked after fsync"
10649 run_test 118h "Verify timeout in handling recoverables errors =========="
10651 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10654 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10655 remote_ost_nodsh && skip "remote OST with nodsh"
10659 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10660 set_nodes_failloc "$(osts_nodes)" 0x20e
10662 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10663 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10666 set_nodes_failloc "$(osts_nodes)" 0
10670 if [[ $RC -ne 0 ]]; then
10671 error "got error, but should be not, rc=$RC"
10674 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10675 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10676 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10677 if [[ $LOCKED -ne 0 ]]; then
10678 error "Locked pages remain in cache, locked=$LOCKED"
10681 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10682 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10686 echo "No pages locked after fsync"
10690 run_test 118i "Fix error before timeout in recoverable error =========="
10692 [ "$SLOW" = "no" ] && set_resend_count 4
10695 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10696 remote_ost_nodsh && skip "remote OST with nodsh"
10700 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
10701 set_nodes_failloc "$(osts_nodes)" 0x220
10703 # return -EIO from OST
10704 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10706 set_nodes_failloc "$(osts_nodes)" 0x0
10707 if [[ $RC -eq 0 ]]; then
10708 error "Must return error due to dropped pages, rc=$RC"
10711 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10712 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10713 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10714 if [[ $LOCKED -ne 0 ]]; then
10715 error "Locked pages remain in cache, locked=$LOCKED"
10718 # in recoverable error on OST we want resend and stay until it finished
10719 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10720 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10724 echo "No pages locked after fsync"
10728 run_test 118j "Simulate unrecoverable OST side error =========="
10732 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10733 remote_ost_nodsh && skip "remote OSTs with nodsh"
10735 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10736 set_nodes_failloc "$(osts_nodes)" 0x20e
10737 test_mkdir $DIR/$tdir
10739 for ((i=0;i<10;i++)); do
10740 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
10741 error "dd to $DIR/$tdir/$tfile-$i failed" )&
10748 set_nodes_failloc "$(osts_nodes)" 0
10751 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
10753 test_118l() # LU-646
10755 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10757 test_mkdir $DIR/$tdir
10758 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
10761 run_test 118l "fsync dir"
10763 test_118m() # LU-3066
10765 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10767 test_mkdir $DIR/$tdir
10768 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
10771 run_test 118m "fdatasync dir ========="
10773 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10780 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10781 remote_ost_nodsh && skip "remote OSTs with nodsh"
10783 # Sleep to avoid a cached response.
10784 #define OBD_STATFS_CACHE_SECONDS 1
10787 # Inject a 10 second delay in the OST_STATFS handler.
10788 #define OBD_FAIL_OST_STATFS_DELAY 0x242
10789 set_nodes_failloc "$(osts_nodes)" 0x242
10792 stat --file-system $MOUNT > /dev/null
10795 set_nodes_failloc "$(osts_nodes)" 0
10797 if ((end - begin > 20)); then
10798 error "statfs took $((end - begin)) seconds, expected 10"
10801 run_test 118n "statfs() sends OST_STATFS requests in parallel"
10803 test_119a() # bug 11737
10805 BSIZE=$((512 * 1024))
10806 directio write $DIR/$tfile 0 1 $BSIZE
10807 # We ask to read two blocks, which is more than a file size.
10808 # directio will indicate an error when requested and actual
10809 # sizes aren't equeal (a normal situation in this case) and
10810 # print actual read amount.
10811 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
10812 if [ "$NOB" != "$BSIZE" ]; then
10813 error "read $NOB bytes instead of $BSIZE"
10817 run_test 119a "Short directIO read must return actual read amount"
10819 test_119b() # bug 11737
10821 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10823 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
10824 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
10826 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
10827 error "direct read failed"
10830 run_test 119b "Sparse directIO read must return actual read amount"
10832 test_119c() # bug 13099
10835 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
10836 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
10839 run_test 119c "Testing for direct read hitting hole"
10841 test_119d() # bug 15950
10843 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10845 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
10846 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
10848 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
10849 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
10850 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
10851 lctl set_param fail_loc=0x40d
10852 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
10855 cat $DIR/$tfile > /dev/null &
10856 lctl set_param fail_loc=0
10859 log "the DIO writes have completed, now wait for the reads (should not block very long)"
10861 [ -n "`ps h -p $pid_reads -o comm`" ] && \
10862 error "the read rpcs have not completed in 2s"
10864 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
10866 run_test 119d "The DIO path should try to send a new rpc once one is completed"
10869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10870 remote_mds_nodsh && skip "remote MDS with nodsh"
10871 test_mkdir -i0 -c1 $DIR/$tdir
10872 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10873 skip_env "no early lock cancel on server"
10875 lru_resize_disable mdc
10876 lru_resize_disable osc
10877 cancel_lru_locks mdc
10878 # asynchronous object destroy at MDT could cause bl ast to client
10879 cancel_lru_locks osc
10881 stat $DIR/$tdir > /dev/null
10882 can1=$(do_facet mds1 \
10883 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10884 awk '/ldlm_cancel/ {print $2}')
10885 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10886 awk '/ldlm_bl_callback/ {print $2}')
10887 test_mkdir -i0 -c1 $DIR/$tdir/d1
10888 can2=$(do_facet mds1 \
10889 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10890 awk '/ldlm_cancel/ {print $2}')
10891 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10892 awk '/ldlm_bl_callback/ {print $2}')
10893 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10894 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10895 lru_resize_enable mdc
10896 lru_resize_enable osc
10898 run_test 120a "Early Lock Cancel: mkdir test"
10901 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10902 remote_mds_nodsh && skip "remote MDS with nodsh"
10903 test_mkdir $DIR/$tdir
10904 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10905 skip_env "no early lock cancel on server"
10907 lru_resize_disable mdc
10908 lru_resize_disable osc
10909 cancel_lru_locks mdc
10910 stat $DIR/$tdir > /dev/null
10911 can1=$(do_facet $SINGLEMDS \
10912 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10913 awk '/ldlm_cancel/ {print $2}')
10914 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10915 awk '/ldlm_bl_callback/ {print $2}')
10916 touch $DIR/$tdir/f1
10917 can2=$(do_facet $SINGLEMDS \
10918 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10919 awk '/ldlm_cancel/ {print $2}')
10920 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10921 awk '/ldlm_bl_callback/ {print $2}')
10922 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10923 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10924 lru_resize_enable mdc
10925 lru_resize_enable osc
10927 run_test 120b "Early Lock Cancel: create test"
10930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10931 remote_mds_nodsh && skip "remote MDS with nodsh"
10932 test_mkdir -i0 -c1 $DIR/$tdir
10933 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10934 skip "no early lock cancel on server"
10936 lru_resize_disable mdc
10937 lru_resize_disable osc
10938 test_mkdir -i0 -c1 $DIR/$tdir/d1
10939 test_mkdir -i0 -c1 $DIR/$tdir/d2
10940 touch $DIR/$tdir/d1/f1
10941 cancel_lru_locks mdc
10942 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
10943 can1=$(do_facet mds1 \
10944 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10945 awk '/ldlm_cancel/ {print $2}')
10946 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10947 awk '/ldlm_bl_callback/ {print $2}')
10948 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10949 can2=$(do_facet mds1 \
10950 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10951 awk '/ldlm_cancel/ {print $2}')
10952 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10953 awk '/ldlm_bl_callback/ {print $2}')
10954 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10955 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10956 lru_resize_enable mdc
10957 lru_resize_enable osc
10959 run_test 120c "Early Lock Cancel: link test"
10962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10963 remote_mds_nodsh && skip "remote MDS with nodsh"
10964 test_mkdir -i0 -c1 $DIR/$tdir
10965 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10966 skip_env "no early lock cancel on server"
10968 lru_resize_disable mdc
10969 lru_resize_disable osc
10971 cancel_lru_locks mdc
10972 stat $DIR/$tdir > /dev/null
10973 can1=$(do_facet mds1 \
10974 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10975 awk '/ldlm_cancel/ {print $2}')
10976 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10977 awk '/ldlm_bl_callback/ {print $2}')
10978 chmod a+x $DIR/$tdir
10979 can2=$(do_facet mds1 \
10980 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10981 awk '/ldlm_cancel/ {print $2}')
10982 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10983 awk '/ldlm_bl_callback/ {print $2}')
10984 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10985 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10986 lru_resize_enable mdc
10987 lru_resize_enable osc
10989 run_test 120d "Early Lock Cancel: setattr test"
10992 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10993 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10994 skip_env "no early lock cancel on server"
10995 remote_mds_nodsh && skip "remote MDS with nodsh"
10997 local dlmtrace_set=false
10999 test_mkdir -i0 -c1 $DIR/$tdir
11000 lru_resize_disable mdc
11001 lru_resize_disable osc
11002 ! $LCTL get_param debug | grep -q dlmtrace &&
11003 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
11004 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
11005 cancel_lru_locks mdc
11006 cancel_lru_locks osc
11007 dd if=$DIR/$tdir/f1 of=/dev/null
11008 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
11009 # XXX client can not do early lock cancel of OST lock
11010 # during unlink (LU-4206), so cancel osc lock now.
11012 cancel_lru_locks osc
11013 can1=$(do_facet mds1 \
11014 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11015 awk '/ldlm_cancel/ {print $2}')
11016 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11017 awk '/ldlm_bl_callback/ {print $2}')
11018 unlink $DIR/$tdir/f1
11020 can2=$(do_facet mds1 \
11021 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11022 awk '/ldlm_cancel/ {print $2}')
11023 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11024 awk '/ldlm_bl_callback/ {print $2}')
11025 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
11026 $LCTL dk $TMP/cancel.debug.txt
11027 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
11028 $LCTL dk $TMP/blocking.debug.txt
11029 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
11030 lru_resize_enable mdc
11031 lru_resize_enable osc
11033 run_test 120e "Early Lock Cancel: unlink test"
11036 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11037 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11038 skip_env "no early lock cancel on server"
11039 remote_mds_nodsh && skip "remote MDS with nodsh"
11041 test_mkdir -i0 -c1 $DIR/$tdir
11042 lru_resize_disable mdc
11043 lru_resize_disable osc
11044 test_mkdir -i0 -c1 $DIR/$tdir/d1
11045 test_mkdir -i0 -c1 $DIR/$tdir/d2
11046 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
11047 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
11048 cancel_lru_locks mdc
11049 cancel_lru_locks osc
11050 dd if=$DIR/$tdir/d1/f1 of=/dev/null
11051 dd if=$DIR/$tdir/d2/f2 of=/dev/null
11052 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
11053 # XXX client can not do early lock cancel of OST lock
11054 # during rename (LU-4206), so cancel osc lock now.
11056 cancel_lru_locks osc
11057 can1=$(do_facet mds1 \
11058 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11059 awk '/ldlm_cancel/ {print $2}')
11060 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11061 awk '/ldlm_bl_callback/ {print $2}')
11062 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
11064 can2=$(do_facet mds1 \
11065 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11066 awk '/ldlm_cancel/ {print $2}')
11067 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11068 awk '/ldlm_bl_callback/ {print $2}')
11069 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11070 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11071 lru_resize_enable mdc
11072 lru_resize_enable osc
11074 run_test 120f "Early Lock Cancel: rename test"
11077 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11078 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11079 skip_env "no early lock cancel on server"
11080 remote_mds_nodsh && skip "remote MDS with nodsh"
11082 lru_resize_disable mdc
11083 lru_resize_disable osc
11085 echo create $count files
11086 test_mkdir $DIR/$tdir
11087 cancel_lru_locks mdc
11088 cancel_lru_locks osc
11091 can0=$(do_facet $SINGLEMDS \
11092 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11093 awk '/ldlm_cancel/ {print $2}')
11094 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11095 awk '/ldlm_bl_callback/ {print $2}')
11096 createmany -o $DIR/$tdir/f $count
11098 can1=$(do_facet $SINGLEMDS \
11099 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11100 awk '/ldlm_cancel/ {print $2}')
11101 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11102 awk '/ldlm_bl_callback/ {print $2}')
11104 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
11105 echo rm $count files
11108 can2=$(do_facet $SINGLEMDS \
11109 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11110 awk '/ldlm_cancel/ {print $2}')
11111 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11112 awk '/ldlm_bl_callback/ {print $2}')
11114 echo total: $count removes in $((t2-t1))
11115 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
11117 # wait for commitment of removal
11118 lru_resize_enable mdc
11119 lru_resize_enable osc
11121 run_test 120g "Early Lock Cancel: performance test"
11123 test_121() { #bug #10589
11124 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11127 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
11128 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
11129 lctl set_param fail_loc=0x310
11130 cancel_lru_locks osc > /dev/null
11131 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
11132 lctl set_param fail_loc=0
11133 [[ $reads -eq $writes ]] ||
11134 error "read $reads blocks, must be $writes blocks"
11136 run_test 121 "read cancel race ========="
11138 test_123a() { # was test 123, statahead(bug 11401)
11139 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11142 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
11143 log "testing UP system. Performance may be lower than expected."
11148 test_mkdir $DIR/$tdir
11149 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
11150 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
11152 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
11153 createmany -o $DIR/$tdir/$tfile $j $((i - j))
11155 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
11156 lctl set_param -n llite.*.statahead_max 0
11157 lctl get_param llite.*.statahead_max
11158 cancel_lru_locks mdc
11159 cancel_lru_locks osc
11161 time ls -l $DIR/$tdir | wc -l
11163 delta=$((etime - stime))
11164 log "ls $i files without statahead: $delta sec"
11165 lctl set_param llite.*.statahead_max=$max
11167 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
11168 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
11169 cancel_lru_locks mdc
11170 cancel_lru_locks osc
11172 time ls -l $DIR/$tdir | wc -l
11174 delta_sa=$((etime - stime))
11175 log "ls $i files with statahead: $delta_sa sec"
11176 lctl get_param -n llite.*.statahead_stats
11177 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
11179 [[ $swrong -lt $ewrong ]] &&
11180 log "statahead was stopped, maybe too many locks held!"
11181 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
11183 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
11184 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
11185 lctl set_param -n llite.*.statahead_max 0
11186 lctl get_param llite.*.statahead_max
11187 cancel_lru_locks mdc
11188 cancel_lru_locks osc
11190 time ls -l $DIR/$tdir | wc -l
11192 delta=$((etime - stime))
11193 log "ls $i files again without statahead: $delta sec"
11194 lctl set_param llite.*.statahead_max=$max
11195 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
11196 if [ $SLOWOK -eq 0 ]; then
11197 error "ls $i files is slower with statahead!"
11199 log "ls $i files is slower with statahead!"
11205 [ $delta -gt 20 ] && break
11206 [ $delta -gt 8 ] && MULT=$((50 / delta))
11207 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
11215 delta=$((etime - stime))
11216 log "rm -r $DIR/$tdir/: $delta seconds"
11218 lctl get_param -n llite.*.statahead_stats
11220 run_test 123a "verify statahead work"
11222 test_123b () { # statahead(bug 15027)
11223 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11225 test_mkdir $DIR/$tdir
11226 createmany -o $DIR/$tdir/$tfile-%d 1000
11228 cancel_lru_locks mdc
11229 cancel_lru_locks osc
11231 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
11232 lctl set_param fail_loc=0x80000803
11233 ls -lR $DIR/$tdir > /dev/null
11235 lctl set_param fail_loc=0x0
11236 lctl get_param -n llite.*.statahead_stats
11241 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
11244 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
11246 test_mkdir -i 0 -c 1 $DIR/$tdir.0
11247 test_mkdir -i 1 -c 1 $DIR/$tdir.1
11248 touch $DIR/$tdir.1/{1..3}
11249 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
11251 remount_client $MOUNT
11253 $MULTIOP $DIR/$tdir.0 Q
11255 # let statahead to complete
11256 ls -l $DIR/$tdir.0 > /dev/null
11258 testid=$(echo $TESTNAME | tr '_' ' ')
11259 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
11260 error "statahead warning" || true
11262 run_test 123c "Can not initialize inode warning on DNE statahead"
11265 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11266 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11267 skip_env "no lru resize on server"
11271 test_mkdir $DIR/$tdir
11273 log "create $NR files at $DIR/$tdir"
11274 createmany -o $DIR/$tdir/f $NR ||
11275 error "failed to create $NR files in $DIR/$tdir"
11277 cancel_lru_locks mdc
11278 ls -l $DIR/$tdir > /dev/null
11282 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
11283 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
11284 LRU_SIZE=$($LCTL get_param -n $PARAM)
11285 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
11286 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
11288 log "NS=$(basename $NSDIR)"
11293 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
11294 skip "Not enough cached locks created!"
11296 log "LRU=$LRU_SIZE"
11300 # We know that lru resize allows one client to hold $LIMIT locks
11301 # for 10h. After that locks begin to be killed by client.
11303 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
11305 if [ $LIMIT -lt $LRU_SIZE ]; then
11306 skip "Limit is too small $LIMIT"
11309 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
11310 # killing locks. Some time was spent for creating locks. This means
11311 # that up to the moment of sleep finish we must have killed some of
11312 # them (10-100 locks). This depends on how fast ther were created.
11313 # Many of them were touched in almost the same moment and thus will
11314 # be killed in groups.
11315 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
11317 # Use $LRU_SIZE_B here to take into account real number of locks
11318 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
11319 local LRU_SIZE_B=$LRU_SIZE
11321 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
11322 log "OLD_LVF=$OLD_LVF"
11323 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
11325 # Let's make sure that we really have some margin. Client checks
11326 # cached locks every 10 sec.
11327 SLEEP=$((SLEEP+20))
11328 log "Sleep ${SLEEP} sec"
11330 while ((SEC<$SLEEP)); do
11334 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
11335 echo -n "$LRU_SIZE"
11338 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
11339 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
11341 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
11342 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
11343 unlinkmany $DIR/$tdir/f $NR
11347 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
11348 log "unlink $NR files at $DIR/$tdir"
11349 unlinkmany $DIR/$tdir/f $NR
11351 run_test 124a "lru resize ======================================="
11353 get_max_pool_limit()
11355 local limit=$($LCTL get_param \
11356 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
11358 for l in $limit; do
11359 if [[ $l -gt $max ]]; then
11367 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11368 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11369 skip_env "no lru resize on server"
11371 LIMIT=$(get_max_pool_limit)
11373 NR=$(($(default_lru_size)*20))
11374 if [[ $NR -gt $LIMIT ]]; then
11375 log "Limit lock number by $LIMIT locks"
11379 IFree=$(mdsrate_inodes_available)
11380 if [ $IFree -lt $NR ]; then
11381 log "Limit lock number by $IFree inodes"
11385 lru_resize_disable mdc
11386 test_mkdir -p $DIR/$tdir/disable_lru_resize
11388 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
11389 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
11390 cancel_lru_locks mdc
11393 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11396 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11399 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11403 nolruresize_delta=$((etime-stime))
11404 log "ls -la time: $nolruresize_delta seconds"
11405 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11406 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
11408 lru_resize_enable mdc
11409 test_mkdir -p $DIR/$tdir/enable_lru_resize
11411 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
11412 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
11413 cancel_lru_locks mdc
11416 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11419 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11422 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11426 lruresize_delta=$((etime-stime))
11427 log "ls -la time: $lruresize_delta seconds"
11428 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11430 if [ $lruresize_delta -gt $nolruresize_delta ]; then
11431 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
11432 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
11433 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
11435 log "lru resize performs the same with no lru resize"
11437 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
11439 run_test 124b "lru resize (performance test) ======================="
11442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11443 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11444 skip_env "no lru resize on server"
11446 # cache ununsed locks on client
11448 cancel_lru_locks mdc
11449 test_mkdir $DIR/$tdir
11450 createmany -o $DIR/$tdir/f $nr ||
11451 error "failed to create $nr files in $DIR/$tdir"
11452 ls -l $DIR/$tdir > /dev/null
11454 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11455 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11456 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11457 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11458 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11460 # set lru_max_age to 1 sec
11461 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11462 echo "sleep $((recalc_p * 2)) seconds..."
11463 sleep $((recalc_p * 2))
11465 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11466 # restore lru_max_age
11467 $LCTL set_param -n $nsdir.lru_max_age $max_age
11468 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11469 unlinkmany $DIR/$tdir/f $nr
11471 run_test 124c "LRUR cancel very aged locks"
11474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11475 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11476 skip_env "no lru resize on server"
11478 # cache ununsed locks on client
11481 lru_resize_disable mdc
11482 stack_trap "lru_resize_enable mdc" EXIT
11484 cancel_lru_locks mdc
11486 # asynchronous object destroy at MDT could cause bl ast to client
11487 test_mkdir $DIR/$tdir
11488 createmany -o $DIR/$tdir/f $nr ||
11489 error "failed to create $nr files in $DIR/$tdir"
11490 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
11492 ls -l $DIR/$tdir > /dev/null
11494 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11495 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11496 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11497 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11499 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11501 # set lru_max_age to 1 sec
11502 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11503 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
11505 echo "sleep $((recalc_p * 2)) seconds..."
11506 sleep $((recalc_p * 2))
11508 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11510 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11512 run_test 124d "cancel very aged locks if lru-resize diasbaled"
11514 test_125() { # 13358
11515 $LCTL get_param -n llite.*.client_type | grep -q local ||
11516 skip "must run as local client"
11517 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
11518 skip_env "must have acl enabled"
11519 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11521 test_mkdir $DIR/$tdir
11522 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
11523 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
11524 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
11526 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
11528 test_126() { # bug 12829/13455
11529 $GSS && skip_env "must run as gss disabled"
11530 $LCTL get_param -n llite.*.client_type | grep -q local ||
11531 skip "must run as local client"
11532 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
11534 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
11535 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
11537 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
11539 run_test 126 "check that the fsgid provided by the client is taken into account"
11541 test_127a() { # bug 15521
11542 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11543 local name count samp unit min max sum sumsq
11545 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
11546 echo "stats before reset"
11547 $LCTL get_param osc.*.stats
11548 $LCTL set_param osc.*.stats=0
11549 local fsize=$((2048 * 1024))
11551 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
11552 cancel_lru_locks osc
11553 dd if=$DIR/$tfile of=/dev/null bs=$fsize
11555 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
11556 stack_trap "rm -f $TMP/$tfile.tmp"
11557 while read name count samp unit min max sum sumsq; do
11558 echo "got name=$name count=$count unit=$unit min=$min max=$max"
11559 [ ! $min ] && error "Missing min value for $name proc entry"
11560 eval $name=$count || error "Wrong proc format"
11563 read_bytes|write_bytes)
11564 [[ "$unit" =~ "bytes" ]] ||
11565 error "unit is not 'bytes': $unit"
11566 (( $min >= 4096 )) || error "min is too small: $min"
11567 (( $min <= $fsize )) || error "min is too big: $min"
11568 (( $max >= 4096 )) || error "max is too small: $max"
11569 (( $max <= $fsize )) || error "max is too big: $max"
11570 (( $sum == $fsize )) || error "sum is wrong: $sum"
11571 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
11572 error "sumsquare is too small: $sumsq"
11573 (( $sumsq <= $fsize * $fsize )) ||
11574 error "sumsquare is too big: $sumsq"
11576 ost_read|ost_write)
11577 [[ "$unit" =~ "usec" ]] ||
11578 error "unit is not 'usec': $unit"
11582 done < $DIR/$tfile.tmp
11584 #check that we actually got some stats
11585 [ "$read_bytes" ] || error "Missing read_bytes stats"
11586 [ "$write_bytes" ] || error "Missing write_bytes stats"
11587 [ "$read_bytes" != 0 ] || error "no read done"
11588 [ "$write_bytes" != 0 ] || error "no write done"
11590 run_test 127a "verify the client stats are sane"
11592 test_127b() { # bug LU-333
11593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11594 local name count samp unit min max sum sumsq
11596 echo "stats before reset"
11597 $LCTL get_param llite.*.stats
11598 $LCTL set_param llite.*.stats=0
11600 # perform 2 reads and writes so MAX is different from SUM.
11601 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11602 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11603 cancel_lru_locks osc
11604 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11605 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11607 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
11608 stack_trap "rm -f $TMP/$tfile.tmp"
11609 while read name count samp unit min max sum sumsq; do
11610 echo "got name=$name count=$count unit=$unit min=$min max=$max"
11611 eval $name=$count || error "Wrong proc format"
11614 read_bytes|write_bytes)
11615 [[ "$unit" =~ "bytes" ]] ||
11616 error "unit is not 'bytes': $unit"
11617 (( $count == 2 )) || error "count is not 2: $count"
11618 (( $min == $PAGE_SIZE )) ||
11619 error "min is not $PAGE_SIZE: $min"
11620 (( $max == $PAGE_SIZE )) ||
11621 error "max is not $PAGE_SIZE: $max"
11622 (( $sum == $PAGE_SIZE * 2 )) ||
11623 error "sum is not $((PAGE_SIZE * 2)): $sum"
11626 [[ "$unit" =~ "usec" ]] ||
11627 error "unit is not 'usec': $unit"
11631 done < $TMP/$tfile.tmp
11633 #check that we actually got some stats
11634 [ "$read_bytes" ] || error "Missing read_bytes stats"
11635 [ "$write_bytes" ] || error "Missing write_bytes stats"
11636 [ "$read_bytes" != 0 ] || error "no read done"
11637 [ "$write_bytes" != 0 ] || error "no write done"
11639 run_test 127b "verify the llite client stats are sane"
11641 test_127c() { # LU-12394
11642 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11649 $LCTL set_param llite.*.extents_stats=1
11650 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
11652 # Use two stripes so there is enough space in default config
11653 $LFS setstripe -c 2 $DIR/$tfile
11655 # Extent stats start at 0-4K and go in power of two buckets
11656 # LL_HIST_START = 12 --> 2^12 = 4K
11657 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
11658 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
11660 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
11662 # Write and read, 2x each, second time at a non-zero offset
11663 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
11664 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
11665 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
11666 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
11670 $LCTL get_param llite.*.extents_stats
11673 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
11675 local bucket=$($LCTL get_param -n llite.*.extents_stats |
11677 reads=$(echo $bucket | awk '{print $5}')
11678 writes=$(echo $bucket | awk '{print $9}')
11679 [ "$reads" -eq $count ] ||
11680 error "$reads reads in < $bsize bucket, expect $count"
11681 [ "$writes" -eq $count ] ||
11682 error "$writes writes in < $bsize bucket, expect $count"
11685 # Test mmap write and read
11686 $LCTL set_param llite.*.extents_stats=c
11688 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
11689 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
11690 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
11692 $LCTL get_param llite.*.extents_stats
11694 count=$(((size*1024) / PAGE_SIZE))
11696 bsize=$((2 * PAGE_SIZE / 1024))K
11698 bucket=$($LCTL get_param -n llite.*.extents_stats |
11700 reads=$(echo $bucket | awk '{print $5}')
11701 writes=$(echo $bucket | awk '{print $9}')
11702 # mmap writes fault in the page first, creating an additonal read
11703 [ "$reads" -eq $((2 * count)) ] ||
11704 error "$reads reads in < $bsize bucket, expect $count"
11705 [ "$writes" -eq $count ] ||
11706 error "$writes writes in < $bsize bucket, expect $count"
11708 run_test 127c "test llite extent stats with regular & mmap i/o"
11710 test_128() { # bug 15212
11712 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
11717 result=$(grep error $TMP/$tfile.log)
11718 rm -f $DIR/$tfile $TMP/$tfile.log
11719 [ -z "$result" ] ||
11720 error "consecutive find's under interactive lfs failed"
11722 run_test 128 "interactive lfs for 2 consecutive find's"
11724 set_dir_limits () {
11729 local ldproc=/proc/fs/ldiskfs
11730 local facets=$(get_facets MDS)
11732 for facet in ${facets//,/ }; do
11733 canondev=$(ldiskfs_canon \
11734 *.$(convert_facet2label $facet).mntdev $facet)
11735 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
11736 ldproc=/sys/fs/ldiskfs
11737 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
11738 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
11742 check_mds_dmesg() {
11743 local facets=$(get_facets MDS)
11744 for facet in ${facets//,/ }; do
11745 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
11751 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11752 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
11753 skip "Need MDS version with at least 2.5.56"
11754 if [ "$mds1_FSTYPE" != ldiskfs ]; then
11755 skip_env "ldiskfs only test"
11757 remote_mds_nodsh && skip "remote MDS with nodsh"
11761 local has_warning=false
11764 mkdir -p $DIR/$tdir
11766 # block size of mds1
11767 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
11768 set_dir_limits $maxsize $maxsize
11769 local dirsize=$(stat -c%s "$DIR/$tdir")
11771 while [[ $dirsize -le $maxsize ]]; do
11772 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
11774 if ! $has_warning; then
11775 check_mds_dmesg '"is approaching"' && has_warning=true
11777 # check two errors:
11778 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
11779 # EFBIG for previous versions included in ldiskfs series
11780 if [ $rc -eq $EFBIG ] || [ $rc -eq $ENOSPC ]; then
11782 echo "return code $rc received as expected"
11784 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
11785 error_exit "create failed w/o dir size limit"
11787 check_mds_dmesg '"has reached"' ||
11788 error_exit "reached message should be output"
11790 [ $has_warning = "false" ] &&
11791 error_exit "warning message should be output"
11793 dirsize=$(stat -c%s "$DIR/$tdir")
11795 [[ $dirsize -ge $maxsize ]] && return 0
11796 error_exit "current dir size $dirsize, " \
11797 "previous limit $maxsize"
11798 elif [ $rc -ne 0 ]; then
11800 error_exit "return $rc received instead of expected " \
11801 "$EFBIG or $ENOSPC, files in dir $dirsize"
11803 nfiles=$((nfiles + 1))
11804 dirsize=$(stat -c%s "$DIR/$tdir")
11808 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
11810 run_test 129 "test directory size limit ========================"
11819 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11820 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11822 trap cleanup_130 EXIT RETURN
11824 local fm_file=$DIR/$tfile
11825 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
11826 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
11827 error "dd failed for $fm_file"
11829 # LU-1795: test filefrag/FIEMAP once, even if unsupported
11830 filefrag -ves $fm_file
11832 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11833 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11834 [ $RC != 0 ] && error "filefrag $fm_file failed"
11836 filefrag_op=$(filefrag -ve -k $fm_file |
11837 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11838 lun=$($LFS getstripe -i $fm_file)
11840 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
11843 for line in $filefrag_op
11845 frag_lun=`echo $line | cut -d: -f5`
11846 ext_len=`echo $line | cut -d: -f4`
11847 if (( $frag_lun != $lun )); then
11849 error "FIEMAP on 1-stripe file($fm_file) failed"
11852 (( tot_len += ext_len ))
11855 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
11857 error "FIEMAP on 1-stripe file($fm_file) failed;"
11863 echo "FIEMAP on single striped file succeeded"
11865 run_test 130a "FIEMAP (1-stripe file)"
11868 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11870 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11871 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11873 trap cleanup_130 EXIT RETURN
11875 local fm_file=$DIR/$tfile
11876 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
11877 error "setstripe on $fm_file"
11878 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11879 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11881 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
11882 error "dd failed on $fm_file"
11884 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11885 filefrag_op=$(filefrag -ve -k $fm_file |
11886 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11888 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11889 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11894 for line in $filefrag_op
11896 frag_lun=$(echo $line | cut -d: -f5 |
11897 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11898 ext_len=$(echo $line | cut -d: -f4)
11899 if (( $frag_lun != $last_lun )); then
11900 if (( tot_len != 1024 )); then
11902 error "FIEMAP on $fm_file failed; returned " \
11903 "len $tot_len for OST $last_lun instead of 1024"
11906 (( num_luns += 1 ))
11910 (( tot_len += ext_len ))
11913 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
11915 error "FIEMAP on $fm_file failed; returned wrong number of " \
11916 "luns or wrong len for OST $last_lun"
11922 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
11924 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
11927 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11929 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11930 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11932 trap cleanup_130 EXIT RETURN
11934 local fm_file=$DIR/$tfile
11935 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
11936 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11937 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11939 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
11940 error "dd failed on $fm_file"
11942 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11943 filefrag_op=$(filefrag -ve -k $fm_file |
11944 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11946 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11947 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11952 for line in $filefrag_op
11954 frag_lun=$(echo $line | cut -d: -f5 |
11955 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11956 ext_len=$(echo $line | cut -d: -f4)
11957 if (( $frag_lun != $last_lun )); then
11958 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
11959 if (( logical != 512 )); then
11961 error "FIEMAP on $fm_file failed; returned " \
11962 "logical start for lun $logical instead of 512"
11965 if (( tot_len != 512 )); then
11967 error "FIEMAP on $fm_file failed; returned " \
11968 "len $tot_len for OST $last_lun instead of 1024"
11971 (( num_luns += 1 ))
11975 (( tot_len += ext_len ))
11978 if (( num_luns != 2 || tot_len != 512 )); then
11980 error "FIEMAP on $fm_file failed; returned wrong number of " \
11981 "luns or wrong len for OST $last_lun"
11987 echo "FIEMAP on 2-stripe file with hole succeeded"
11989 run_test 130c "FIEMAP (2-stripe file with hole)"
11992 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
11994 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11995 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11997 trap cleanup_130 EXIT RETURN
11999 local fm_file=$DIR/$tfile
12000 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
12001 error "setstripe on $fm_file"
12002 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12003 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12005 local actual_stripe_count=$($LFS getstripe -c $fm_file)
12006 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
12007 error "dd failed on $fm_file"
12009 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12010 filefrag_op=$(filefrag -ve -k $fm_file |
12011 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12013 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12014 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12019 for line in $filefrag_op
12021 frag_lun=$(echo $line | cut -d: -f5 |
12022 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12023 ext_len=$(echo $line | cut -d: -f4)
12024 if (( $frag_lun != $last_lun )); then
12025 if (( tot_len != 1024 )); then
12027 error "FIEMAP on $fm_file failed; returned " \
12028 "len $tot_len for OST $last_lun instead of 1024"
12031 (( num_luns += 1 ))
12035 (( tot_len += ext_len ))
12038 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
12040 error "FIEMAP on $fm_file failed; returned wrong number of " \
12041 "luns or wrong len for OST $last_lun"
12047 echo "FIEMAP on N-stripe file succeeded"
12049 run_test 130d "FIEMAP (N-stripe file)"
12052 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12054 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12055 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12057 trap cleanup_130 EXIT RETURN
12059 local fm_file=$DIR/$tfile
12060 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
12061 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12062 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12065 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
12066 for ((i = 0; i < $NUM_BLKS; i++))
12068 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
12071 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12072 filefrag_op=$(filefrag -ve -k $fm_file |
12073 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12075 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12076 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12081 for line in $filefrag_op
12083 frag_lun=$(echo $line | cut -d: -f5 |
12084 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12085 ext_len=$(echo $line | cut -d: -f4)
12086 if (( $frag_lun != $last_lun )); then
12087 if (( tot_len != $EXPECTED_LEN )); then
12089 error "FIEMAP on $fm_file failed; returned " \
12090 "len $tot_len for OST $last_lun instead " \
12094 (( num_luns += 1 ))
12098 (( tot_len += ext_len ))
12101 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
12103 error "FIEMAP on $fm_file failed; returned wrong number " \
12104 "of luns or wrong len for OST $last_lun"
12110 echo "FIEMAP with continuation calls succeeded"
12112 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
12115 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12116 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12118 local fm_file=$DIR/$tfile
12119 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
12120 error "multiop create with lov_delay_create on $fm_file"
12122 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12123 filefrag_extents=$(filefrag -vek $fm_file |
12124 awk '/extents? found/ { print $2 }')
12125 if [[ "$filefrag_extents" != "0" ]]; then
12126 error "FIEMAP on $fm_file failed; " \
12127 "returned $filefrag_extents expected 0"
12132 run_test 130f "FIEMAP (unstriped file)"
12134 # Test for writev/readv
12136 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
12137 error "writev test failed"
12138 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
12139 error "readv failed"
12142 run_test 131a "test iov's crossing stripe boundary for writev/readv"
12145 local fsize=$((524288 + 1048576 + 1572864))
12146 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
12147 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
12148 error "append writev test failed"
12150 ((fsize += 1572864 + 1048576))
12151 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
12152 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
12153 error "append writev test failed"
12156 run_test 131b "test append writev"
12159 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
12162 run_test 131c "test read/write on file w/o objects"
12165 rwv -f $DIR/$tfile -w -n 1 1572864
12166 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
12167 if [ "$NOB" != 1572864 ]; then
12168 error "Short read filed: read $NOB bytes instead of 1572864"
12172 run_test 131d "test short read"
12175 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
12176 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
12177 error "read hitting hole failed"
12180 run_test 131e "test read hitting hole"
12189 mds*) res=$(do_facet $facet \
12190 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
12192 ost*) res=$(do_facet $facet \
12193 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
12195 *) error "Wrong facet '$facet'" ;;
12197 [ "$res" ] || error "The counter for $op on $facet was not incremented"
12198 # if the argument $3 is zero, it means any stat increment is ok.
12199 if [[ $want -gt 0 ]]; then
12200 local count=$(echo $res | awk '{ print $2 }')
12201 [[ $count -ne $want ]] &&
12202 error "The $op counter on $facet is $count, not $want"
12207 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12208 remote_ost_nodsh && skip "remote OST with nodsh"
12209 remote_mds_nodsh && skip "remote MDS with nodsh"
12210 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12211 skip_env "MDS doesn't support rename stats"
12213 local testdir=$DIR/${tdir}/stats_testdir
12215 mkdir -p $DIR/${tdir}
12218 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12219 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12221 # verify mdt stats first.
12222 mkdir ${testdir} || error "mkdir failed"
12223 check_stats $SINGLEMDS "mkdir" 1
12224 touch ${testdir}/${tfile} || error "touch failed"
12225 check_stats $SINGLEMDS "open" 1
12226 check_stats $SINGLEMDS "close" 1
12227 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
12228 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
12229 check_stats $SINGLEMDS "mknod" 2
12231 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
12232 check_stats $SINGLEMDS "unlink" 1
12233 rm -f ${testdir}/${tfile} || error "file remove failed"
12234 check_stats $SINGLEMDS "unlink" 2
12236 # remove working dir and check mdt stats again.
12237 rmdir ${testdir} || error "rmdir failed"
12238 check_stats $SINGLEMDS "rmdir" 1
12240 local testdir1=$DIR/${tdir}/stats_testdir1
12241 mkdir -p ${testdir}
12242 mkdir -p ${testdir1}
12243 touch ${testdir1}/test1
12244 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
12245 check_stats $SINGLEMDS "crossdir_rename" 1
12247 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
12248 check_stats $SINGLEMDS "samedir_rename" 1
12250 rm -rf $DIR/${tdir}
12252 run_test 133a "Verifying MDT stats ========================================"
12257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12258 remote_ost_nodsh && skip "remote OST with nodsh"
12259 remote_mds_nodsh && skip "remote MDS with nodsh"
12261 local testdir=$DIR/${tdir}/stats_testdir
12263 mkdir -p ${testdir} || error "mkdir failed"
12264 touch ${testdir}/${tfile} || error "touch failed"
12265 cancel_lru_locks mdc
12268 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12269 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12271 # extra mdt stats verification.
12272 chmod 444 ${testdir}/${tfile} || error "chmod failed"
12273 check_stats $SINGLEMDS "setattr" 1
12274 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12275 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
12277 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
12278 check_stats $SINGLEMDS "getattr" 1
12280 rm -rf $DIR/${tdir}
12282 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
12283 # so the check below is not reliable
12284 [ $MDSCOUNT -eq 1 ] || return 0
12286 # Sleep to avoid a cached response.
12287 #define OBD_STATFS_CACHE_SECONDS 1
12289 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12290 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12291 $LFS df || error "lfs failed"
12292 check_stats $SINGLEMDS "statfs" 1
12294 # check aggregated statfs (LU-10018)
12295 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
12297 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
12300 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12301 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12303 check_stats $SINGLEMDS "statfs" 1
12305 # We want to check that the client didn't send OST_STATFS to
12306 # ost1 but the MDT also uses OST_STATFS for precreate. So some
12307 # extra care is needed here.
12308 if remote_mds; then
12309 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
12310 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
12312 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
12313 [ "$res" ] && error "OST got STATFS"
12318 run_test 133b "Verifying extra MDT stats =================================="
12321 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12322 remote_ost_nodsh && skip "remote OST with nodsh"
12323 remote_mds_nodsh && skip "remote MDS with nodsh"
12325 local testdir=$DIR/$tdir/stats_testdir
12327 test_mkdir -p $testdir
12329 # verify obdfilter stats.
12330 $LFS setstripe -c 1 -i 0 $testdir/$tfile
12332 cancel_lru_locks osc
12333 wait_delete_completed
12336 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12337 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12339 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
12342 cancel_lru_locks osc
12343 check_stats ost1 "write" 1
12345 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
12346 check_stats ost1 "read" 1
12348 > $testdir/$tfile || error "truncate failed"
12349 check_stats ost1 "punch" 1
12351 rm -f $testdir/$tfile || error "file remove failed"
12352 wait_delete_completed
12353 check_stats ost1 "destroy" 1
12357 run_test 133c "Verifying OST stats ========================================"
12364 while [ $value -ge 2 ]; do
12369 if [ $orig -gt $order ]; then
12377 local size=('K' 'M' 'G' 'T');
12379 local size_string=$value
12381 while [ $value -ge 1024 ]; do
12382 if [ $i -gt 3 ]; then
12383 #T is the biggest unit we get here, if that is bigger,
12385 size_string=${value}T
12388 value=$((value >> 10))
12389 if [ $value -lt 1024 ]; then
12390 size_string=${value}${size[$i]}
12399 get_rename_size() {
12401 local context=${2:-.}
12402 local sample=$(do_facet $SINGLEMDS $LCTL \
12403 get_param mdt.$FSNAME-MDT0000.rename_stats |
12404 grep -A1 $context |
12405 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
12410 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12411 remote_ost_nodsh && skip "remote OST with nodsh"
12412 remote_mds_nodsh && skip "remote MDS with nodsh"
12413 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12414 skip_env "MDS doesn't support rename stats"
12416 local testdir1=$DIR/${tdir}/stats_testdir1
12417 local testdir2=$DIR/${tdir}/stats_testdir2
12418 mkdir -p $DIR/${tdir}
12420 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12422 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
12423 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
12425 createmany -o $testdir1/test 512 || error "createmany failed"
12427 # check samedir rename size
12428 mv ${testdir1}/test0 ${testdir1}/test_0
12430 local testdir1_size=$(ls -l $DIR/${tdir} |
12431 awk '/stats_testdir1/ {print $5}')
12432 local testdir2_size=$(ls -l $DIR/${tdir} |
12433 awk '/stats_testdir2/ {print $5}')
12435 testdir1_size=$(order_2 $testdir1_size)
12436 testdir2_size=$(order_2 $testdir2_size)
12438 testdir1_size=$(size_in_KMGT $testdir1_size)
12439 testdir2_size=$(size_in_KMGT $testdir2_size)
12441 echo "source rename dir size: ${testdir1_size}"
12442 echo "target rename dir size: ${testdir2_size}"
12444 local cmd="do_facet $SINGLEMDS $LCTL "
12445 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
12447 eval $cmd || error "$cmd failed"
12448 local samedir=$($cmd | grep 'same_dir')
12449 local same_sample=$(get_rename_size $testdir1_size)
12450 [ -z "$samedir" ] && error "samedir_rename_size count error"
12451 [[ $same_sample -eq 1 ]] ||
12452 error "samedir_rename_size error $same_sample"
12453 echo "Check same dir rename stats success"
12455 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12457 # check crossdir rename size
12458 mv ${testdir1}/test_0 ${testdir2}/test_0
12460 testdir1_size=$(ls -l $DIR/${tdir} |
12461 awk '/stats_testdir1/ {print $5}')
12462 testdir2_size=$(ls -l $DIR/${tdir} |
12463 awk '/stats_testdir2/ {print $5}')
12465 testdir1_size=$(order_2 $testdir1_size)
12466 testdir2_size=$(order_2 $testdir2_size)
12468 testdir1_size=$(size_in_KMGT $testdir1_size)
12469 testdir2_size=$(size_in_KMGT $testdir2_size)
12471 echo "source rename dir size: ${testdir1_size}"
12472 echo "target rename dir size: ${testdir2_size}"
12474 eval $cmd || error "$cmd failed"
12475 local crossdir=$($cmd | grep 'crossdir')
12476 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
12477 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
12478 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
12479 [[ $src_sample -eq 1 ]] ||
12480 error "crossdir_rename_size error $src_sample"
12481 [[ $tgt_sample -eq 1 ]] ||
12482 error "crossdir_rename_size error $tgt_sample"
12483 echo "Check cross dir rename stats success"
12484 rm -rf $DIR/${tdir}
12486 run_test 133d "Verifying rename_stats ========================================"
12489 remote_mds_nodsh && skip "remote MDS with nodsh"
12490 remote_ost_nodsh && skip "remote OST with nodsh"
12491 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12493 local testdir=$DIR/${tdir}/stats_testdir
12494 local ctr f0 f1 bs=32768 count=42 sum
12496 mkdir -p ${testdir} || error "mkdir failed"
12498 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
12500 for ctr in {write,read}_bytes; do
12502 cancel_lru_locks osc
12504 do_facet ost1 $LCTL set_param -n \
12505 "obdfilter.*.exports.clear=clear"
12507 if [ $ctr = write_bytes ]; then
12509 f1=${testdir}/${tfile}
12511 f0=${testdir}/${tfile}
12515 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
12518 cancel_lru_locks osc
12520 sum=$(do_facet ost1 $LCTL get_param \
12521 "obdfilter.*.exports.*.stats" |
12522 awk -v ctr=$ctr 'BEGIN { sum = 0 }
12523 $1 == ctr { sum += $7 }
12524 END { printf("%0.0f", sum) }')
12526 if ((sum != bs * count)); then
12527 error "Bad $ctr sum, expected $((bs * count)), got $sum"
12531 rm -rf $DIR/${tdir}
12533 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
12535 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
12537 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
12538 # not honor the -ignore_readdir_race option correctly. So we call
12539 # error_ignore() rather than error() in these cases. See LU-11152.
12541 if (find --version; do_facet mds1 find --version) |
12542 grep -q '\b4\.5\.1[1-4]\b'; then
12543 error_ignore LU-11152 "$@"
12550 # First without trusting modes.
12551 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
12552 echo "proc_dirs='$proc_dirs'"
12553 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
12554 find $proc_dirs -exec cat '{}' \; &> /dev/null
12556 # Second verifying readability.
12557 $LCTL get_param -R '*' &> /dev/null
12559 # Verifing writability with badarea_io.
12561 -ignore_readdir_race \
12563 -not -name force_lbug \
12564 -not -name changelog_mask \
12565 -exec badarea_io '{}' \; ||
12566 error_133 "find $proc_dirs failed"
12568 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
12571 remote_mds_nodsh && skip "remote MDS with nodsh"
12572 remote_ost_nodsh && skip "remote OST with nodsh"
12575 for facet in mds1 ost1; do
12576 local facet_ver=$(lustre_version_code $facet)
12577 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
12578 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
12580 log "$facet: too old lustre for get_param -R"
12582 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
12583 do_facet $facet "$LCTL list_param -R '*' | grep '=' |
12584 tr -d= | egrep -v 'force_lbug|changelog_mask' |
12585 xargs badarea_io" ||
12586 error_133 "$facet badarea_io failed"
12588 skip_noexit "$facet: too old lustre for get_param -R"
12592 # remount the FS in case writes/reads /proc break the FS
12593 cleanup || error "failed to unmount"
12594 setup || error "failed to setup"
12597 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
12600 remote_mds_nodsh && skip "remote MDS with nodsh"
12601 remote_ost_nodsh && skip "remote OST with nodsh"
12602 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
12603 skip "Need MDS version at least 2.9.54"
12607 for facet in client mds1 ost1; do
12608 local facet_proc_dirs=$(do_facet $facet \
12609 \\\ls -d $proc_regexp 2> /dev/null)
12610 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12611 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12612 # Get the list of files that are missing the terminating newline
12613 local missing=($(do_facet $facet \
12614 find ${facet_proc_dirs} -type f \| \
12615 while read F\; do \
12616 awk -v FS='\v' -v RS='\v\v' \
12617 "'END { if(NR>0 && \
12618 \\\$NF !~ /.*\\\n\$/) \
12619 print FILENAME}'" \
12622 [ ${#missing[*]} -eq 0 ] ||
12623 error "files do not end with newline: ${missing[*]}"
12626 run_test 133h "Proc files should end with newlines"
12629 remote_mds_nodsh && skip "remote MDS with nodsh"
12630 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12631 skip "Need MDS version at least 2.7.54"
12633 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12634 cancel_lru_locks mdc
12636 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12637 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12638 [ $unused -eq 0 ] || error "$unused locks are not cleared"
12641 createmany -o $DIR/$tdir/f $nr ||
12642 error "failed to create $nr files in $DIR/$tdir"
12643 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12645 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
12646 do_facet mds1 $LCTL set_param fail_loc=0x327
12647 do_facet mds1 $LCTL set_param fail_val=500
12650 echo "sleep 10 seconds ..."
12652 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
12654 do_facet mds1 $LCTL set_param fail_loc=0
12655 do_facet mds1 $LCTL set_param fail_val=0
12656 [ $lck_cnt -lt $unused ] ||
12657 error "No locks reclaimed, before:$unused, after:$lck_cnt"
12660 unlinkmany $DIR/$tdir/f $nr
12662 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
12665 remote_mds_nodsh && skip "remote MDS with nodsh"
12666 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12667 skip "Need MDS version at least 2.7.54"
12669 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12670 cancel_lru_locks mdc
12672 local low_wm=$(do_facet mds1 $LCTL get_param -n \
12673 ldlm.lock_reclaim_threshold_mb)
12674 # disable reclaim temporarily
12675 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
12677 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
12678 do_facet mds1 $LCTL set_param fail_loc=0x328
12679 do_facet mds1 $LCTL set_param fail_val=500
12681 $LCTL set_param debug=+trace
12684 createmany -o $DIR/$tdir/f $nr &
12685 local create_pid=$!
12687 echo "Sleep $TIMEOUT seconds ..."
12689 if ! ps -p $create_pid > /dev/null 2>&1; then
12690 do_facet mds1 $LCTL set_param fail_loc=0
12691 do_facet mds1 $LCTL set_param fail_val=0
12692 do_facet mds1 $LCTL set_param \
12693 ldlm.lock_reclaim_threshold_mb=${low_wm}m
12694 error "createmany finished incorrectly!"
12696 do_facet mds1 $LCTL set_param fail_loc=0
12697 do_facet mds1 $LCTL set_param fail_val=0
12698 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
12699 wait $create_pid || return 1
12701 unlinkmany $DIR/$tdir/f $nr
12703 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
12706 remote_mds_nodsh && skip "remote MDS with nodsh"
12707 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
12708 skip "Need MDS version at least 2.13.50"
12711 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12713 #define OBD_FAIL_PLAIN_RECORDS 0x1319
12714 #set only one record at plain llog
12715 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
12717 #fill already existed plain llog each 64767
12718 #wrapping whole catalog
12719 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
12721 createmany -o $DIR/$tdir/$tfile_ 64700
12722 for (( i = 0; i < 64700; i = i + 2 ))
12724 rm $DIR/$tdir/$tfile_$i &
12725 rm $DIR/$tdir/$tfile_$((i + 1)) &
12730 #waiting osp synchronization
12731 wait_delete_completed
12733 run_test 135 "Race catalog processing"
12736 remote_mds_nodsh && skip "remote MDS with nodsh"
12737 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
12738 skip "Need MDS version at least 2.13.50"
12741 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12742 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
12743 #set only one record at plain llog
12744 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
12745 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
12747 #fill already existed 2 plain llogs each 64767
12748 #wrapping whole catalog
12749 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
12750 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
12751 wait_delete_completed
12753 createmany -o $DIR/$tdir/$tfile_ 10
12756 do_facet $SINGLEMDS $LCTL set_param fail_val=3
12757 for (( i = 0; i < 10; i = i + 3 ))
12759 rm $DIR/$tdir/$tfile_$i &
12760 rm $DIR/$tdir/$tfile_$((i + 1)) &
12764 rm $DIR/$tdir/$tfile_$((i + 2)) &
12767 #waiting osp synchronization
12768 wait_delete_completed
12770 run_test 136 "Race catalog processing 2"
12772 test_140() { #bug-17379
12773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12775 test_mkdir $DIR/$tdir
12776 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
12777 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
12779 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
12780 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
12782 while i=$((i + 1)); do
12784 cd $i || error "Changing to $i"
12785 ln -s ../stat stat || error "Creating stat symlink"
12786 # Read the symlink until ELOOP present,
12787 # not LBUGing the system is considered success,
12788 # we didn't overrun the stack.
12789 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
12790 if [ $ret -ne 0 ]; then
12791 if [ $ret -eq 40 ]; then
12794 error "Open stat symlink"
12800 echo "The symlink depth = $i"
12801 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
12802 error "Invalid symlink depth"
12804 # Test recursive symlink
12805 ln -s symlink_self symlink_self
12806 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
12807 echo "open symlink_self returns $ret"
12808 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
12810 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
12813 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12815 local TF="$TMP/$tfile"
12817 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12819 cancel_lru_locks $OSC
12820 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
12821 remount_client $MOUNT
12823 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
12826 $TRUNCATE $DIR/$tfile 6000
12827 cancel_lru_locks $OSC
12828 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
12831 echo "12345" >>$DIR/$tfile
12832 cancel_lru_locks $OSC
12833 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
12836 echo "12345" >>$DIR/$tfile
12837 cancel_lru_locks $OSC
12838 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
12843 run_test 150 "truncate/append tests"
12845 #LU-2902 roc_hit was not able to read all values from lproc
12846 function roc_hit_init() {
12847 local list=$(comma_list $(osts_nodes))
12848 local dir=$DIR/$tdir-check
12849 local file=$dir/$tfile
12855 #use setstripe to do a write to every ost
12856 for i in $(seq 0 $((OSTCOUNT-1))); do
12857 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
12858 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
12859 idx=$(printf %04x $i)
12860 BEFORE=$(get_osd_param $list *OST*$idx stats |
12861 awk '$1 == "cache_access" {sum += $7}
12862 END { printf("%0.0f", sum) }')
12864 cancel_lru_locks osc
12865 cat $file >/dev/null
12867 AFTER=$(get_osd_param $list *OST*$idx stats |
12868 awk '$1 == "cache_access" {sum += $7}
12869 END { printf("%0.0f", sum) }')
12871 echo BEFORE:$BEFORE AFTER:$AFTER
12872 if ! let "AFTER - BEFORE == 4"; then
12874 error "roc_hit is not safe to use"
12882 function roc_hit() {
12883 local list=$(comma_list $(osts_nodes))
12884 echo $(get_osd_param $list '' stats |
12885 awk '$1 == "cache_hit" {sum += $7}
12886 END { printf("%0.0f", sum) }')
12889 function set_cache() {
12892 if [ "$2" == "off" ]; then
12895 local list=$(comma_list $(osts_nodes))
12896 set_osd_param $list '' $1_cache_enable $on
12898 cancel_lru_locks osc
12902 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12903 remote_ost_nodsh && skip "remote OST with nodsh"
12906 local list=$(comma_list $(osts_nodes))
12908 # check whether obdfilter is cache capable at all
12909 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
12910 skip "not cache-capable obdfilter"
12913 # check cache is enabled on all obdfilters
12914 if get_osd_param $list '' read_cache_enable | grep 0; then
12915 skip "oss cache is disabled"
12918 set_osd_param $list '' writethrough_cache_enable 1
12920 # check write cache is enabled on all obdfilters
12921 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
12922 skip "oss write cache is NOT enabled"
12927 #define OBD_FAIL_OBD_NO_LRU 0x609
12928 do_nodes $list $LCTL set_param fail_loc=0x609
12930 # pages should be in the case right after write
12931 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
12934 local BEFORE=$(roc_hit)
12935 cancel_lru_locks osc
12936 cat $DIR/$tfile >/dev/null
12937 local AFTER=$(roc_hit)
12939 do_nodes $list $LCTL set_param fail_loc=0
12941 if ! let "AFTER - BEFORE == CPAGES"; then
12942 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12945 cancel_lru_locks osc
12946 # invalidates OST cache
12947 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
12948 set_osd_param $list '' read_cache_enable 0
12949 cat $DIR/$tfile >/dev/null
12951 # now data shouldn't be found in the cache
12953 cancel_lru_locks osc
12954 cat $DIR/$tfile >/dev/null
12956 if let "AFTER - BEFORE != 0"; then
12957 error "IN CACHE: before: $BEFORE, after: $AFTER"
12960 set_osd_param $list '' read_cache_enable 1
12963 run_test 151 "test cache on oss and controls ==============================="
12966 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12968 local TF="$TMP/$tfile"
12970 # simulate ENOMEM during write
12971 #define OBD_FAIL_OST_NOMEM 0x226
12972 lctl set_param fail_loc=0x80000226
12973 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12975 sync || error "sync failed"
12976 lctl set_param fail_loc=0
12978 # discard client's cache
12979 cancel_lru_locks osc
12981 # simulate ENOMEM during read
12982 lctl set_param fail_loc=0x80000226
12983 cmp $TF $DIR/$tfile || error "cmp failed"
12984 lctl set_param fail_loc=0
12988 run_test 152 "test read/write with enomem ============================"
12991 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
12993 run_test 153 "test if fdatasync does not crash ======================="
12995 dot_lustre_fid_permission_check() {
12997 local ffid=$MOUNT/.lustre/fid/$fid
13000 echo "stat fid $fid"
13001 stat $ffid > /dev/null || error "stat $ffid failed."
13002 echo "touch fid $fid"
13003 touch $ffid || error "touch $ffid failed."
13004 echo "write to fid $fid"
13005 cat /etc/hosts > $ffid || error "write $ffid failed."
13006 echo "read fid $fid"
13007 diff /etc/hosts $ffid || error "read $ffid failed."
13008 echo "append write to fid $fid"
13009 cat /etc/hosts >> $ffid || error "append write $ffid failed."
13010 echo "rename fid $fid"
13011 mv $ffid $test_dir/$tfile.1 &&
13012 error "rename $ffid to $tfile.1 should fail."
13013 touch $test_dir/$tfile.1
13014 mv $test_dir/$tfile.1 $ffid &&
13015 error "rename $tfile.1 to $ffid should fail."
13016 rm -f $test_dir/$tfile.1
13017 echo "truncate fid $fid"
13018 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
13019 echo "link fid $fid"
13020 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
13021 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
13022 echo "setfacl fid $fid"
13023 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
13024 echo "getfacl fid $fid"
13025 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
13027 echo "unlink fid $fid"
13028 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
13029 echo "mknod fid $fid"
13030 mknod $ffid c 1 3 && error "mknod $ffid should fail."
13032 fid=[0xf00000400:0x1:0x0]
13033 ffid=$MOUNT/.lustre/fid/$fid
13035 echo "stat non-exist fid $fid"
13036 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
13037 echo "write to non-exist fid $fid"
13038 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
13039 echo "link new fid $fid"
13040 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
13042 mkdir -p $test_dir/$tdir
13043 touch $test_dir/$tdir/$tfile
13044 fid=$($LFS path2fid $test_dir/$tdir)
13047 error "error: could not get fid for $test_dir/$dir/$tfile."
13049 ffid=$MOUNT/.lustre/fid/$fid
13052 ls $ffid > /dev/null || error "ls $ffid failed."
13053 echo "touch $fid/$tfile.1"
13054 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
13056 echo "touch $MOUNT/.lustre/fid/$tfile"
13057 touch $MOUNT/.lustre/fid/$tfile && \
13058 error "touch $MOUNT/.lustre/fid/$tfile should fail."
13060 echo "setxattr to $MOUNT/.lustre/fid"
13061 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
13063 echo "listxattr for $MOUNT/.lustre/fid"
13064 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
13066 echo "delxattr from $MOUNT/.lustre/fid"
13067 setfattr -x trusted.name1 $MOUNT/.lustre/fid
13069 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
13070 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
13071 error "touch invalid fid should fail."
13073 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
13074 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
13075 error "touch non-normal fid should fail."
13077 echo "rename $tdir to $MOUNT/.lustre/fid"
13078 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
13079 error "rename to $MOUNT/.lustre/fid should fail."
13081 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
13083 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
13084 local new_obf_mode=777
13086 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
13087 chmod $new_obf_mode $DIR/.lustre/fid ||
13088 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
13090 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
13091 [ $obf_mode -eq $new_obf_mode ] ||
13092 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
13094 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
13095 chmod $old_obf_mode $DIR/.lustre/fid ||
13096 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
13099 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
13100 fid=$($LFS path2fid $test_dir/$tfile-2)
13102 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
13104 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
13105 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
13106 error "create lov data thru .lustre failed"
13108 echo "cp /etc/passwd $test_dir/$tfile-2"
13109 cp /etc/passwd $test_dir/$tfile-2 ||
13110 error "copy to $test_dir/$tfile-2 failed."
13111 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
13112 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
13113 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
13115 rm -rf $test_dir/tfile.lnk
13116 rm -rf $test_dir/$tfile-2
13120 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13121 skip "Need MDS version at least 2.4.1"
13123 local tf=$DIR/$tfile
13126 local fid=$($LFS path2fid $tf)
13127 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
13129 # check that we get the same pathname back
13130 local found=$($LFS fid2path $MOUNT "$fid")
13131 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
13132 [ "$found" == "$tf" ] ||
13133 error "fid2path($fid=path2fid($tf)) = $found != $tf"
13135 run_test 154A "lfs path2fid and fid2path basic checks"
13138 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13139 skip "Need MDS version at least 2.4.1"
13141 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
13142 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
13143 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
13144 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
13146 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
13147 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
13149 # check that we get the same pathname
13150 echo "PFID: $PFID, name: $name"
13151 local FOUND=$($LFS fid2path $MOUNT "$PFID")
13152 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
13153 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
13154 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
13156 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
13158 run_test 154B "verify the ll_decode_linkea tool"
13161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13162 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13163 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
13164 skip "Need MDS version at least 2.2.51"
13165 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13167 cp /etc/hosts $DIR/$tfile
13169 fid=$($LFS path2fid $DIR/$tfile)
13171 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
13173 dot_lustre_fid_permission_check "$fid" $DIR ||
13174 error "dot lustre permission check $fid failed"
13176 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
13178 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
13180 touch $MOUNT/.lustre/file &&
13181 error "creation is not allowed under .lustre"
13183 mkdir $MOUNT/.lustre/dir &&
13184 error "mkdir is not allowed under .lustre"
13188 run_test 154a "Open-by-FID"
13191 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13192 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13193 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13194 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
13195 skip "Need MDS version at least 2.2.51"
13197 local remote_dir=$DIR/$tdir/remote_dir
13201 mkdir -p $DIR/$tdir
13202 $LFS mkdir -i $MDTIDX $remote_dir ||
13203 error "create remote directory failed"
13205 cp /etc/hosts $remote_dir/$tfile
13207 fid=$($LFS path2fid $remote_dir/$tfile)
13209 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
13211 dot_lustre_fid_permission_check "$fid" $remote_dir ||
13212 error "dot lustre permission check $fid failed"
13215 run_test 154b "Open-by-FID for remote directory"
13218 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13219 skip "Need MDS version at least 2.4.1"
13221 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
13222 local FID1=$($LFS path2fid $DIR/$tfile.1)
13223 local FID2=$($LFS path2fid $DIR/$tfile.2)
13224 local FID3=$($LFS path2fid $DIR/$tfile.3)
13227 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
13228 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
13229 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
13231 [ "$FID" = "${!want}" ] ||
13232 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
13236 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
13238 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
13239 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
13243 run_test 154c "lfs path2fid and fid2path multiple arguments"
13246 remote_mds_nodsh && skip "remote MDS with nodsh"
13247 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
13248 skip "Need MDS version at least 2.5.53"
13250 if remote_mds; then
13251 nid=$($LCTL list_nids | sed "s/\./\\\./g")
13255 local proc_ofile="mdt.*.exports.'$nid'.open_files"
13262 local fid=$($LFS path2fid $DIR/$tfile)
13265 cmd="exec $fd<$DIR/$tfile"
13267 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
13268 echo "$fid_list" | grep "$fid"
13271 cmd="exec $fd>/dev/null"
13273 if [ $rc -ne 0 ]; then
13274 error "FID $fid not found in open files list $fid_list"
13277 run_test 154d "Verify open file fid"
13281 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
13282 skip "Need MDS version at least 2.6.50"
13284 if ls -a $MOUNT | grep -q '^\.lustre$'; then
13285 error ".lustre returned by readdir"
13288 run_test 154e ".lustre is not returned by readdir"
13291 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13293 # create parent directory on a single MDT to avoid cross-MDT hardlinks
13294 test_mkdir -p -c1 $DIR/$tdir/d
13295 # test dirs inherit from its stripe
13296 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
13297 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
13298 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
13299 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
13302 # get fid of parents
13303 local FID0=$($LFS path2fid $DIR/$tdir/d)
13304 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
13305 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
13306 local FID3=$($LFS path2fid $DIR)
13308 # check that path2fid --parents returns expected <parent_fid>/name
13309 # 1) test for a directory (single parent)
13310 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
13311 [ "$parent" == "$FID0/foo1" ] ||
13312 error "expected parent: $FID0/foo1, got: $parent"
13314 # 2) test for a file with nlink > 1 (multiple parents)
13315 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
13316 echo "$parent" | grep -F "$FID1/$tfile" ||
13317 error "$FID1/$tfile not returned in parent list"
13318 echo "$parent" | grep -F "$FID2/link" ||
13319 error "$FID2/link not returned in parent list"
13321 # 3) get parent by fid
13322 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
13323 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13324 echo "$parent" | grep -F "$FID1/$tfile" ||
13325 error "$FID1/$tfile not returned in parent list (by fid)"
13326 echo "$parent" | grep -F "$FID2/link" ||
13327 error "$FID2/link not returned in parent list (by fid)"
13329 # 4) test for entry in root directory
13330 parent=$($LFS path2fid --parents $DIR/f)
13331 echo "$parent" | grep -F "$FID3/f" ||
13332 error "$FID3/f not returned in parent list"
13334 # 5) test it on root directory
13335 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
13336 error "$MOUNT should not have parents"
13338 # enable xattr caching and check that linkea is correctly updated
13339 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
13340 save_lustre_params client "llite.*.xattr_cache" > $save
13341 lctl set_param llite.*.xattr_cache 1
13343 # 6.1) linkea update on rename
13344 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
13346 # get parents by fid
13347 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13348 # foo1 should no longer be returned in parent list
13349 echo "$parent" | grep -F "$FID1" &&
13350 error "$FID1 should no longer be in parent list"
13351 # the new path should appear
13352 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
13353 error "$FID2/$tfile.moved is not in parent list"
13355 # 6.2) linkea update on unlink
13356 rm -f $DIR/$tdir/d/foo2/link
13357 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13358 # foo2/link should no longer be returned in parent list
13359 echo "$parent" | grep -F "$FID2/link" &&
13360 error "$FID2/link should no longer be in parent list"
13364 restore_lustre_params < $save
13367 run_test 154f "get parent fids by reading link ea"
13371 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13372 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
13373 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
13374 skip "Need MDS version at least 2.6.92"
13376 mkdir -p $DIR/$tdir
13377 llapi_fid_test -d $DIR/$tdir
13379 run_test 154g "various llapi FID tests"
13381 test_155_small_load() {
13382 local temp=$TMP/$tfile
13383 local file=$DIR/$tfile
13385 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
13386 error "dd of=$temp bs=6096 count=1 failed"
13388 cancel_lru_locks $OSC
13389 cmp $temp $file || error "$temp $file differ"
13391 $TRUNCATE $temp 6000
13392 $TRUNCATE $file 6000
13393 cmp $temp $file || error "$temp $file differ (truncate1)"
13395 echo "12345" >>$temp
13396 echo "12345" >>$file
13397 cmp $temp $file || error "$temp $file differ (append1)"
13399 echo "12345" >>$temp
13400 echo "12345" >>$file
13401 cmp $temp $file || error "$temp $file differ (append2)"
13407 test_155_big_load() {
13408 remote_ost_nodsh && skip "remote OST with nodsh"
13410 local temp=$TMP/$tfile
13411 local file=$DIR/$tfile
13414 local cache_size=$(do_facet ost$((MAXI+1)) \
13415 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
13416 local large_file_size=$((cache_size * 2))
13418 echo "OSS cache size: $cache_size KB"
13419 echo "Large file size: $large_file_size KB"
13421 [ $MAXV -le $large_file_size ] &&
13422 skip_env "max available OST size needs > $large_file_size KB"
13424 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
13426 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
13427 error "dd of=$temp bs=$large_file_size count=1k failed"
13430 cancel_lru_locks osc
13431 cmp $temp $file || error "$temp $file differ"
13437 save_writethrough() {
13438 local facets=$(get_facets OST)
13440 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
13444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13446 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13448 save_writethrough $p
13451 set_cache writethrough on
13452 test_155_small_load
13453 restore_lustre_params < $p
13456 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
13459 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13461 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13463 save_writethrough $p
13466 set_cache writethrough off
13467 test_155_small_load
13468 restore_lustre_params < $p
13471 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
13474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13476 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13478 save_writethrough $p
13481 set_cache writethrough on
13482 test_155_small_load
13483 restore_lustre_params < $p
13486 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
13489 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13491 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13493 save_writethrough $p
13496 set_cache writethrough off
13497 test_155_small_load
13498 restore_lustre_params < $p
13501 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
13504 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13506 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13508 save_writethrough $p
13511 set_cache writethrough on
13513 restore_lustre_params < $p
13516 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
13519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13521 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13523 save_writethrough $p
13526 set_cache writethrough off
13528 restore_lustre_params < $p
13531 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
13534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13536 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13538 save_writethrough $p
13541 set_cache writethrough on
13543 restore_lustre_params < $p
13546 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
13549 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13551 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13553 save_writethrough $p
13556 set_cache writethrough off
13558 restore_lustre_params < $p
13561 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
13564 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13565 remote_ost_nodsh && skip "remote OST with nodsh"
13566 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
13567 skip "stats not implemented on old servers"
13568 [ "$ost1_FSTYPE" = "zfs" ] &&
13569 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
13574 local file="$DIR/$tfile"
13575 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13577 save_writethrough $p
13580 log "Turn on read and write cache"
13582 set_cache writethrough on
13584 log "Write data and read it back."
13585 log "Read should be satisfied from the cache."
13586 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13588 cancel_lru_locks osc
13589 cat $file >/dev/null
13591 if ! let "AFTER - BEFORE == CPAGES"; then
13592 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
13594 log "cache hits: before: $BEFORE, after: $AFTER"
13597 log "Read again; it should be satisfied from the cache."
13599 cancel_lru_locks osc
13600 cat $file >/dev/null
13602 if ! let "AFTER - BEFORE == CPAGES"; then
13603 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
13605 log "cache hits:: before: $BEFORE, after: $AFTER"
13608 log "Turn off the read cache and turn on the write cache"
13610 set_cache writethrough on
13612 log "Read again; it should be satisfied from the cache."
13614 cancel_lru_locks osc
13615 cat $file >/dev/null
13617 if ! let "AFTER - BEFORE == CPAGES"; then
13618 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
13620 log "cache hits:: before: $BEFORE, after: $AFTER"
13623 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
13624 # > 2.12.56 uses pagecache if cached
13625 log "Read again; it should not be satisfied from the cache."
13627 cancel_lru_locks osc
13628 cat $file >/dev/null
13630 if ! let "AFTER - BEFORE == 0"; then
13631 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
13633 log "cache hits:: before: $BEFORE, after: $AFTER"
13637 log "Write data and read it back."
13638 log "Read should be satisfied from the cache."
13639 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13641 cancel_lru_locks osc
13642 cat $file >/dev/null
13644 if ! let "AFTER - BEFORE == CPAGES"; then
13645 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
13647 log "cache hits:: before: $BEFORE, after: $AFTER"
13650 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
13651 # > 2.12.56 uses pagecache if cached
13652 log "Read again; it should not be satisfied from the cache."
13654 cancel_lru_locks osc
13655 cat $file >/dev/null
13657 if ! let "AFTER - BEFORE == 0"; then
13658 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
13660 log "cache hits:: before: $BEFORE, after: $AFTER"
13664 log "Turn off read and write cache"
13666 set_cache writethrough off
13668 log "Write data and read it back"
13669 log "It should not be satisfied from the cache."
13671 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13672 cancel_lru_locks osc
13674 cat $file >/dev/null
13676 if ! let "AFTER - BEFORE == 0"; then
13677 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
13679 log "cache hits:: before: $BEFORE, after: $AFTER"
13682 log "Turn on the read cache and turn off the write cache"
13684 set_cache writethrough off
13686 log "Write data and read it back"
13687 log "It should not be satisfied from the cache."
13689 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13691 cancel_lru_locks osc
13692 cat $file >/dev/null
13694 if ! let "AFTER - BEFORE == 0"; then
13695 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
13697 log "cache hits:: before: $BEFORE, after: $AFTER"
13700 log "Read again; it should be satisfied from the cache."
13702 cancel_lru_locks osc
13703 cat $file >/dev/null
13705 if ! let "AFTER - BEFORE == CPAGES"; then
13706 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
13708 log "cache hits:: before: $BEFORE, after: $AFTER"
13711 restore_lustre_params < $p
13714 run_test 156 "Verification of tunables"
13717 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13718 remote_mds_nodsh && skip "remote MDS with nodsh"
13719 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13720 skip "Need MDS version at least 2.2.0"
13722 changelog_register || error "changelog_register failed"
13723 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13724 changelog_users $SINGLEMDS | grep -q $cl_user ||
13725 error "User $cl_user not found in changelog_users"
13728 test_mkdir -p $DIR/$tdir/pics/2008/zachy
13729 changelog_clear 0 || error "changelog_clear failed"
13730 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
13731 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
13732 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
13733 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
13734 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
13735 rm $DIR/$tdir/pics/desktop.jpg
13737 changelog_dump | tail -10
13739 echo "verifying changelog mask"
13740 changelog_chmask "-MKDIR"
13741 changelog_chmask "-CLOSE"
13743 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
13744 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
13746 changelog_chmask "+MKDIR"
13747 changelog_chmask "+CLOSE"
13749 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
13750 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
13752 changelog_dump | tail -10
13753 MKDIRS=$(changelog_dump | grep -c "MKDIR")
13754 CLOSES=$(changelog_dump | grep -c "CLOSE")
13755 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
13756 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
13759 echo "verifying target fid"
13760 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
13761 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
13762 [ "$fidc" == "$fidf" ] ||
13763 error "changelog '$tfile' fid $fidc != file fid $fidf"
13764 echo "verifying parent fid"
13765 # The FID returned from the Changelog may be the directory shard on
13766 # a different MDT, and not the FID returned by path2fid on the parent.
13767 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
13768 # since this is what will matter when recreating this file in the tree.
13769 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
13770 local pathp=$($LFS fid2path $MOUNT "$fidp")
13771 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
13772 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
13774 echo "getting records for $cl_user"
13775 changelog_users $SINGLEMDS
13776 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
13778 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
13779 error "changelog_clear failed"
13780 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
13781 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
13782 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
13783 error "user index expect $user_rec1 + $nclr != $user_rec2"
13785 local min0_rec=$(changelog_users $SINGLEMDS |
13786 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
13787 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
13788 awk '{ print $1; exit; }')
13790 changelog_dump | tail -n 5
13791 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
13792 [ $first_rec == $((min0_rec + 1)) ] ||
13793 error "first index should be $min0_rec + 1 not $first_rec"
13795 # LU-3446 changelog index reset on MDT restart
13796 local cur_rec1=$(changelog_users $SINGLEMDS |
13797 awk '/^current.index:/ { print $NF }')
13798 changelog_clear 0 ||
13799 error "clear all changelog records for $cl_user failed"
13800 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
13801 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
13802 error "Fail to start $SINGLEMDS"
13803 local cur_rec2=$(changelog_users $SINGLEMDS |
13804 awk '/^current.index:/ { print $NF }')
13805 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
13806 [ $cur_rec1 == $cur_rec2 ] ||
13807 error "current index should be $cur_rec1 not $cur_rec2"
13809 echo "verifying users from this test are deregistered"
13810 changelog_deregister || error "changelog_deregister failed"
13811 changelog_users $SINGLEMDS | grep -q $cl_user &&
13812 error "User '$cl_user' still in changelog_users"
13814 # lctl get_param -n mdd.*.changelog_users
13815 # current index: 144
13816 # ID index (idle seconds)
13818 if ! changelog_users $SINGLEMDS | grep "^cl"; then
13819 # this is the normal case where all users were deregistered
13820 # make sure no new records are added when no users are present
13821 local last_rec1=$(changelog_users $SINGLEMDS |
13822 awk '/^current.index:/ { print $NF }')
13823 touch $DIR/$tdir/chloe
13824 local last_rec2=$(changelog_users $SINGLEMDS |
13825 awk '/^current.index:/ { print $NF }')
13826 echo "verify changelogs are off: $last_rec1 == $last_rec2"
13827 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
13829 # any changelog users must be leftovers from a previous test
13830 changelog_users $SINGLEMDS
13831 echo "other changelog users; can't verify off"
13834 run_test 160a "changelog sanity"
13836 test_160b() { # LU-3587
13837 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13838 remote_mds_nodsh && skip "remote MDS with nodsh"
13839 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13840 skip "Need MDS version at least 2.2.0"
13842 changelog_register || error "changelog_register failed"
13843 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13844 changelog_users $SINGLEMDS | grep -q $cl_user ||
13845 error "User '$cl_user' not found in changelog_users"
13847 local longname1=$(str_repeat a 255)
13848 local longname2=$(str_repeat b 255)
13851 echo "creating very long named file"
13852 touch $longname1 || error "create of '$longname1' failed"
13853 echo "renaming very long named file"
13854 mv $longname1 $longname2
13856 changelog_dump | grep RENME | tail -n 5
13859 run_test 160b "Verify that very long rename doesn't crash in changelog"
13862 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13863 remote_mds_nodsh && skip "remote MDS with nodsh"
13865 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
13866 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
13867 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
13868 skip "Need MDS version at least 2.5.58 or 2.5.2+"
13872 # Registration step
13873 changelog_register || error "changelog_register failed"
13876 mkdir -p $DIR/$tdir
13877 $MCREATE $DIR/$tdir/foo_160c
13878 changelog_chmask "-TRUNC"
13879 $TRUNCATE $DIR/$tdir/foo_160c 200
13880 changelog_chmask "+TRUNC"
13881 $TRUNCATE $DIR/$tdir/foo_160c 199
13882 changelog_dump | tail -n 5
13883 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
13884 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
13886 run_test 160c "verify that changelog log catch the truncate event"
13889 remote_mds_nodsh && skip "remote MDS with nodsh"
13890 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13892 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
13893 skip "Need MDS version at least 2.7.60"
13895 # Registration step
13896 changelog_register || error "changelog_register failed"
13898 mkdir -p $DIR/$tdir/migrate_dir
13899 changelog_clear 0 || error "changelog_clear failed"
13901 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
13902 changelog_dump | tail -n 5
13903 local migrates=$(changelog_dump | grep -c "MIGRT")
13904 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
13906 run_test 160d "verify that changelog log catch the migrate event"
13909 remote_mds_nodsh && skip "remote MDS with nodsh"
13912 changelog_register || error "changelog_register failed"
13914 # Delete a future user (expect fail)
13915 local MDT0=$(facet_svc $SINGLEMDS)
13916 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
13919 if [ $rc -eq 0 ]; then
13920 error "Deleted non-existant user cl77"
13921 elif [ $rc -ne 2 ]; then
13922 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
13925 # Clear to a bad index (1 billion should be safe)
13926 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
13929 if [ $rc -eq 0 ]; then
13930 error "Successfully cleared to invalid CL index"
13931 elif [ $rc -ne 22 ]; then
13932 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
13935 run_test 160e "changelog negative testing (should return errors)"
13938 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13939 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13940 skip "Need MDS version at least 2.10.56"
13942 local mdts=$(comma_list $(mdts_nodes))
13945 changelog_register || error "first changelog_register failed"
13946 changelog_register || error "second changelog_register failed"
13948 declare -A cl_user1
13949 declare -A cl_user2
13954 # generate some changelog records to accumulate on each MDT
13955 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13956 log "$(date +%s): creating first files"
13957 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13958 error "create $DIR/$tdir/$tfile failed"
13960 # check changelogs have been generated
13961 local start=$SECONDS
13962 local idle_time=$((MDSCOUNT * 5 + 5))
13963 local nbcl=$(changelog_dump | wc -l)
13964 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13966 for param in "changelog_max_idle_time=$idle_time" \
13968 "changelog_min_gc_interval=2" \
13969 "changelog_min_free_cat_entries=3"; do
13970 local MDT0=$(facet_svc $SINGLEMDS)
13971 local var="${param%=*}"
13972 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13974 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13975 do_nodes $mdts $LCTL set_param mdd.*.$param
13978 # force cl_user2 to be idle (1st part), but also cancel the
13979 # cl_user1 records so that it is not evicted later in the test.
13980 local sleep1=$((idle_time / 2))
13981 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
13984 # simulate changelog catalog almost full
13985 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13986 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13988 for i in $(seq $MDSCOUNT); do
13989 cl_users=(${CL_USERS[mds$i]})
13990 cl_user1[mds$i]="${cl_users[0]}"
13991 cl_user2[mds$i]="${cl_users[1]}"
13993 [ -n "${cl_user1[mds$i]}" ] ||
13994 error "mds$i: no user registered"
13995 [ -n "${cl_user2[mds$i]}" ] ||
13996 error "mds$i: only ${cl_user2[mds$i]} is registered"
13998 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13999 [ -n "$user_rec1" ] ||
14000 error "mds$i: User ${cl_user1[mds$i]} not registered"
14001 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14002 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14003 [ -n "$user_rec2" ] ||
14004 error "mds$i: User ${cl_user1[mds$i]} not registered"
14005 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14006 "$user_rec1 + 2 == $user_rec2"
14007 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14008 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14009 "$user_rec1 + 2, but is $user_rec2"
14010 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14011 [ -n "$user_rec2" ] ||
14012 error "mds$i: User ${cl_user2[mds$i]} not registered"
14013 [ $user_rec1 == $user_rec2 ] ||
14014 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14015 "$user_rec1, but is $user_rec2"
14018 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
14019 local sleep2=$((idle_time - (SECONDS - start) + 1))
14020 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
14023 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
14024 # cl_user1 should be OK because it recently processed records.
14025 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
14026 createmany -m $DIR/$tdir/${tfile}b $((MDSCOUNT * 2)) ||
14027 error "create $DIR/$tdir/${tfile}b failed"
14029 # ensure gc thread is done
14030 for i in $(mdts_nodes); do
14032 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
14033 error "$i: GC-thread not done"
14037 for i in $(seq $MDSCOUNT); do
14038 # check cl_user1 still registered
14039 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14040 error "mds$i: User ${cl_user1[mds$i]} not registered"
14041 # check cl_user2 unregistered
14042 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14043 error "mds$i: User ${cl_user2[mds$i]} still registered"
14045 # check changelogs are present and starting at $user_rec1 + 1
14046 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14047 [ -n "$user_rec1" ] ||
14048 error "mds$i: User ${cl_user1[mds$i]} not registered"
14049 first_rec=$($LFS changelog $(facet_svc mds$i) |
14050 awk '{ print $1; exit; }')
14052 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14053 [ $((user_rec1 + 1)) == $first_rec ] ||
14054 error "mds$i: first index should be $user_rec1 + 1, " \
14055 "but is $first_rec"
14058 run_test 160f "changelog garbage collect (timestamped users)"
14061 remote_mds_nodsh && skip "remote MDS with nodsh"
14062 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14063 skip "Need MDS version at least 2.10.56"
14065 local mdts=$(comma_list $(mdts_nodes))
14067 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
14068 do_nodes $mdts $LCTL set_param fail_loc=0x1314
14071 changelog_register || error "first changelog_register failed"
14072 changelog_register || error "second changelog_register failed"
14074 declare -A cl_user1
14075 declare -A cl_user2
14080 # generate some changelog records to accumulate on each MDT
14081 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
14082 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14083 error "create $DIR/$tdir/$tfile failed"
14085 # check changelogs have been generated
14086 local nbcl=$(changelog_dump | wc -l)
14087 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14089 # reduce the max_idle_indexes value to make sure we exceed it
14090 max_ndx=$((nbcl / 2 - 1))
14092 for param in "changelog_max_idle_indexes=$max_ndx" \
14094 "changelog_min_gc_interval=2" \
14095 "changelog_min_free_cat_entries=3"; do
14096 local MDT0=$(facet_svc $SINGLEMDS)
14097 local var="${param%=*}"
14098 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14100 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14101 do_nodes $mdts $LCTL set_param mdd.*.$param ||
14102 error "unable to set mdd.*.$param"
14105 # simulate changelog catalog almost full
14106 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
14107 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
14109 for i in $(seq $MDSCOUNT); do
14110 cl_users=(${CL_USERS[mds$i]})
14111 cl_user1[mds$i]="${cl_users[0]}"
14112 cl_user2[mds$i]="${cl_users[1]}"
14114 [ -n "${cl_user1[mds$i]}" ] ||
14115 error "mds$i: no user registered"
14116 [ -n "${cl_user2[mds$i]}" ] ||
14117 error "mds$i: only ${cl_user1[mds$i]} is registered"
14119 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14120 [ -n "$user_rec1" ] ||
14121 error "mds$i: User ${cl_user1[mds$i]} not registered"
14122 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14123 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14124 [ -n "$user_rec2" ] ||
14125 error "mds$i: User ${cl_user1[mds$i]} not registered"
14126 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14127 "$user_rec1 + 2 == $user_rec2"
14128 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14129 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14130 "$user_rec1 + 2, but is $user_rec2"
14131 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14132 [ -n "$user_rec2" ] ||
14133 error "mds$i: User ${cl_user2[mds$i]} not registered"
14134 [ $user_rec1 == $user_rec2 ] ||
14135 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14136 "$user_rec1, but is $user_rec2"
14139 # ensure we are past the previous changelog_min_gc_interval set above
14142 # generate one more changelog to trigger fail_loc
14143 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14144 error "create $DIR/$tdir/${tfile}bis failed"
14146 # ensure gc thread is done
14147 for i in $(mdts_nodes); do
14149 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
14150 error "$i: GC-thread not done"
14154 for i in $(seq $MDSCOUNT); do
14155 # check cl_user1 still registered
14156 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14157 error "mds$i: User ${cl_user1[mds$i]} not registered"
14158 # check cl_user2 unregistered
14159 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14160 error "mds$i: User ${cl_user2[mds$i]} still registered"
14162 # check changelogs are present and starting at $user_rec1 + 1
14163 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14164 [ -n "$user_rec1" ] ||
14165 error "mds$i: User ${cl_user1[mds$i]} not registered"
14166 first_rec=$($LFS changelog $(facet_svc mds$i) |
14167 awk '{ print $1; exit; }')
14169 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14170 [ $((user_rec1 + 1)) == $first_rec ] ||
14171 error "mds$i: first index should be $user_rec1 + 1, " \
14172 "but is $first_rec"
14175 run_test 160g "changelog garbage collect (old users)"
14178 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14179 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14180 skip "Need MDS version at least 2.10.56"
14182 local mdts=$(comma_list $(mdts_nodes))
14185 changelog_register || error "first changelog_register failed"
14186 changelog_register || error "second changelog_register failed"
14188 declare -A cl_user1
14189 declare -A cl_user2
14194 # generate some changelog records to accumulate on each MDT
14195 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
14196 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14197 error "create $DIR/$tdir/$tfile failed"
14199 # check changelogs have been generated
14200 local nbcl=$(changelog_dump | wc -l)
14201 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14203 for param in "changelog_max_idle_time=10" \
14205 "changelog_min_gc_interval=2"; do
14206 local MDT0=$(facet_svc $SINGLEMDS)
14207 local var="${param%=*}"
14208 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14210 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14211 do_nodes $mdts $LCTL set_param mdd.*.$param
14214 # force cl_user2 to be idle (1st part)
14217 for i in $(seq $MDSCOUNT); do
14218 cl_users=(${CL_USERS[mds$i]})
14219 cl_user1[mds$i]="${cl_users[0]}"
14220 cl_user2[mds$i]="${cl_users[1]}"
14222 [ -n "${cl_user1[mds$i]}" ] ||
14223 error "mds$i: no user registered"
14224 [ -n "${cl_user2[mds$i]}" ] ||
14225 error "mds$i: only ${cl_user2[mds$i]} is registered"
14227 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14228 [ -n "$user_rec1" ] ||
14229 error "mds$i: User ${cl_user1[mds$i]} not registered"
14230 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14231 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14232 [ -n "$user_rec2" ] ||
14233 error "mds$i: User ${cl_user1[mds$i]} not registered"
14234 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14235 "$user_rec1 + 2 == $user_rec2"
14236 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14237 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14238 "$user_rec1 + 2, but is $user_rec2"
14239 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14240 [ -n "$user_rec2" ] ||
14241 error "mds$i: User ${cl_user2[mds$i]} not registered"
14242 [ $user_rec1 == $user_rec2 ] ||
14243 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14244 "$user_rec1, but is $user_rec2"
14247 # force cl_user2 to be idle (2nd part) and to reach
14248 # changelog_max_idle_time
14251 # force each GC-thread start and block then
14252 # one per MDT/MDD, set fail_val accordingly
14253 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
14254 do_nodes $mdts $LCTL set_param fail_loc=0x1316
14256 # generate more changelogs to trigger fail_loc
14257 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14258 error "create $DIR/$tdir/${tfile}bis failed"
14260 # stop MDT to stop GC-thread, should be done in back-ground as it will
14261 # block waiting for the thread to be released and exit
14262 declare -A stop_pids
14263 for i in $(seq $MDSCOUNT); do
14265 stop_pids[mds$i]=$!
14268 for i in $(mdts_nodes); do
14271 local facets=$(facets_up_on_host $i)
14273 for facet in ${facets//,/ }; do
14274 if [[ $facet == mds* ]]; then
14278 # ensure each MDS's gc threads are still present and all in "R"
14279 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
14280 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
14281 error "$i: expected $nb GC-thread"
14283 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
14285 error "$i: GC-thread not found in R-state"
14286 # check umounts of each MDT on MDS have reached kthread_stop()
14287 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
14288 error "$i: expected $nb umount"
14290 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
14291 error "$i: umount not found in D-state"
14294 # release all GC-threads
14295 do_nodes $mdts $LCTL set_param fail_loc=0
14297 # wait for MDT stop to complete
14298 for i in $(seq $MDSCOUNT); do
14299 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
14303 # may try to check if any orphan changelog records are present
14304 # via ldiskfs/zfs and llog_reader...
14306 # re-start/mount MDTs
14307 for i in $(seq $MDSCOUNT); do
14308 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
14309 error "Fail to start mds$i"
14313 for i in $(seq $MDSCOUNT); do
14314 # check cl_user1 still registered
14315 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14316 error "mds$i: User ${cl_user1[mds$i]} not registered"
14317 # check cl_user2 unregistered
14318 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14319 error "mds$i: User ${cl_user2[mds$i]} still registered"
14321 # check changelogs are present and starting at $user_rec1 + 1
14322 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14323 [ -n "$user_rec1" ] ||
14324 error "mds$i: User ${cl_user1[mds$i]} not registered"
14325 first_rec=$($LFS changelog $(facet_svc mds$i) |
14326 awk '{ print $1; exit; }')
14328 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14329 [ $((user_rec1 + 1)) == $first_rec ] ||
14330 error "mds$i: first index should be $user_rec1 + 1, " \
14331 "but is $first_rec"
14334 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
14339 local mdts=$(comma_list $(mdts_nodes))
14341 changelog_register || error "first changelog_register failed"
14343 # generate some changelog records to accumulate on each MDT
14344 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
14345 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14346 error "create $DIR/$tdir/$tfile failed"
14348 # check changelogs have been generated
14349 local nbcl=$(changelog_dump | wc -l)
14350 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14352 # simulate race between register and unregister
14353 # XXX as fail_loc is set per-MDS, with DNE configs the race
14354 # simulation will only occur for one MDT per MDS and for the
14355 # others the normal race scenario will take place
14356 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
14357 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
14358 do_nodes $mdts $LCTL set_param fail_val=1
14360 # unregister 1st user
14361 changelog_deregister &
14363 # wait some time for deregister work to reach race rdv
14365 # register 2nd user
14366 changelog_register || error "2nd user register failed"
14368 wait $pid1 || error "1st user deregister failed"
14372 declare -A LAST_REC
14373 for i in $(seq $MDSCOUNT); do
14374 if changelog_users mds$i | grep "^cl"; then
14375 # make sure new records are added with one user present
14376 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
14377 awk '/^current.index:/ { print $NF }')
14379 error "mds$i has no user registered"
14383 # generate more changelog records to accumulate on each MDT
14384 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14385 error "create $DIR/$tdir/${tfile}bis failed"
14387 for i in $(seq $MDSCOUNT); do
14388 last_rec=$(changelog_users $SINGLEMDS |
14389 awk '/^current.index:/ { print $NF }')
14390 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
14391 [ $last_rec != ${LAST_REC[mds$i]} ] ||
14392 error "changelogs are off on mds$i"
14395 run_test 160i "changelog user register/unregister race"
14398 remote_mds_nodsh && skip "remote MDS with nodsh"
14399 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
14400 skip "Need MDS version at least 2.12.56"
14402 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
14403 stack_trap "umount $MOUNT2" EXIT
14405 changelog_register || error "first changelog_register failed"
14406 stack_trap "changelog_deregister" EXIT
14408 # generate some changelog
14409 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
14410 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14411 error "create $DIR/$tdir/${tfile}bis failed"
14413 # open the changelog device
14414 exec 3>/dev/changelog-$FSNAME-MDT0000
14415 stack_trap "exec 3>&-" EXIT
14416 exec 4</dev/changelog-$FSNAME-MDT0000
14417 stack_trap "exec 4<&-" EXIT
14419 # umount the first lustre mount
14421 stack_trap "mount_client $MOUNT" EXIT
14424 cat <&4 >/dev/null || error "read changelog failed"
14427 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14428 changelog_users $SINGLEMDS | grep -q $cl_user ||
14429 error "User $cl_user not found in changelog_users"
14431 printf 'clear:'$cl_user':0' >&3
14434 run_test 160j "client can be umounted while its chanangelog is being used"
14437 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14438 remote_mds_nodsh && skip "remote MDS with nodsh"
14440 mkdir -p $DIR/$tdir/1/1
14442 changelog_register || error "changelog_register failed"
14443 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14445 changelog_users $SINGLEMDS | grep -q $cl_user ||
14446 error "User '$cl_user' not found in changelog_users"
14447 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
14448 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
14449 rmdir $DIR/$tdir/1/1 & sleep 1
14451 touch $DIR/$tdir/2/2
14452 rm -rf $DIR/$tdir/2
14457 changelog_dump | grep rmdir || error "rmdir not recorded"
14460 changelog_deregister
14462 run_test 160k "Verify that changelog records are not lost"
14465 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14467 test_mkdir -c1 $DIR/$tdir
14468 cp /etc/hosts $DIR/$tdir/$tfile
14469 test_mkdir -c1 $DIR/$tdir/foo1
14470 test_mkdir -c1 $DIR/$tdir/foo2
14471 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
14472 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
14473 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
14474 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
14475 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
14476 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14477 $LFS fid2path $DIR $FID
14478 error "bad link ea"
14481 rm $DIR/$tdir/foo2/zachary
14483 rm $DIR/$tdir/foo2/thor
14485 rm $DIR/$tdir/$tfile
14487 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
14488 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
14489 { $LFS fid2path $DIR $FID; error "bad link rename"; }
14490 rm $DIR/$tdir/foo2/maggie
14493 local longname=$tfile.avg_len_is_thirty_two_
14494 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
14495 error_noexit 'failed to unlink many hardlinks'" EXIT
14496 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
14497 error "failed to hardlink many files"
14498 links=$($LFS fid2path $DIR $FID | wc -l)
14499 echo -n "${links}/1000 links in link EA"
14500 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
14502 run_test 161a "link ea sanity"
14505 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14506 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
14509 local remote_dir=$DIR/$tdir/remote_dir
14511 mkdir -p $DIR/$tdir
14512 $LFS mkdir -i $MDTIDX $remote_dir ||
14513 error "create remote directory failed"
14515 cp /etc/hosts $remote_dir/$tfile
14516 mkdir -p $remote_dir/foo1
14517 mkdir -p $remote_dir/foo2
14518 ln $remote_dir/$tfile $remote_dir/foo1/sofia
14519 ln $remote_dir/$tfile $remote_dir/foo2/zachary
14520 ln $remote_dir/$tfile $remote_dir/foo1/luna
14521 ln $remote_dir/$tfile $remote_dir/foo2/thor
14523 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
14525 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14526 $LFS fid2path $DIR $FID
14527 error "bad link ea"
14530 rm $remote_dir/foo2/zachary
14532 rm $remote_dir/foo2/thor
14534 rm $remote_dir/$tfile
14536 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
14537 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
14538 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
14539 $LFS fid2path $DIR $FID
14540 error "bad link rename"
14542 rm $remote_dir/foo2/maggie
14545 local longname=filename_avg_len_is_thirty_two_
14546 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
14547 error "failed to hardlink many files"
14548 links=$($LFS fid2path $DIR $FID | wc -l)
14549 echo -n "${links}/1000 links in link EA"
14550 [[ ${links} -gt 60 ]] ||
14551 error "expected at least 60 links in link EA"
14552 unlinkmany $remote_dir/foo2/$longname 1000 ||
14553 error "failed to unlink many hardlinks"
14555 run_test 161b "link ea sanity under remote directory"
14558 remote_mds_nodsh && skip "remote MDS with nodsh"
14559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14560 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
14561 skip "Need MDS version at least 2.1.5"
14563 # define CLF_RENAME_LAST 0x0001
14564 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
14565 changelog_register || error "changelog_register failed"
14568 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
14569 touch $DIR/$tdir/foo_161c
14570 touch $DIR/$tdir/bar_161c
14571 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14572 changelog_dump | grep RENME | tail -n 5
14573 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14574 changelog_clear 0 || error "changelog_clear failed"
14575 if [ x$flags != "x0x1" ]; then
14576 error "flag $flags is not 0x1"
14579 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
14580 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
14581 touch $DIR/$tdir/foo_161c
14582 touch $DIR/$tdir/bar_161c
14583 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14584 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14585 changelog_dump | grep RENME | tail -n 5
14586 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14587 changelog_clear 0 || error "changelog_clear failed"
14588 if [ x$flags != "x0x0" ]; then
14589 error "flag $flags is not 0x0"
14591 echo "rename overwrite a target having nlink > 1," \
14592 "changelog record has flags of $flags"
14594 # rename doesn't overwrite a target (changelog flag 0x0)
14595 touch $DIR/$tdir/foo_161c
14596 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
14597 changelog_dump | grep RENME | tail -n 5
14598 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
14599 changelog_clear 0 || error "changelog_clear failed"
14600 if [ x$flags != "x0x0" ]; then
14601 error "flag $flags is not 0x0"
14603 echo "rename doesn't overwrite a target," \
14604 "changelog record has flags of $flags"
14606 # define CLF_UNLINK_LAST 0x0001
14607 # unlink a file having nlink = 1 (changelog flag 0x1)
14608 rm -f $DIR/$tdir/foo2_161c
14609 changelog_dump | grep UNLNK | tail -n 5
14610 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14611 changelog_clear 0 || error "changelog_clear failed"
14612 if [ x$flags != "x0x1" ]; then
14613 error "flag $flags is not 0x1"
14615 echo "unlink a file having nlink = 1," \
14616 "changelog record has flags of $flags"
14618 # unlink a file having nlink > 1 (changelog flag 0x0)
14619 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14620 rm -f $DIR/$tdir/foobar_161c
14621 changelog_dump | grep UNLNK | tail -n 5
14622 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14623 changelog_clear 0 || error "changelog_clear failed"
14624 if [ x$flags != "x0x0" ]; then
14625 error "flag $flags is not 0x0"
14627 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
14629 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
14632 remote_mds_nodsh && skip "remote MDS with nodsh"
14633 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
14638 changelog_register || error "changelog_register failed"
14640 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
14641 # interfer with $MOUNT/.lustre/fid/ access
14643 [[ $? -eq 0 ]] || error "mkdir failed"
14645 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
14646 $LCTL set_param fail_loc=0x8000140c
14648 $LCTL set_param fail_val=5
14651 echo foofoo > $DIR/$tdir/$tfile &
14654 # wait for create to be delayed
14658 [[ $? -eq 0 ]] || error "create should be blocked"
14660 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
14661 stack_trap "rm -f $tempfile"
14662 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
14663 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
14664 # some delay may occur during ChangeLog publishing and file read just
14665 # above, that could allow file write to happen finally
14666 [[ -s $tempfile ]] && echo "file should be empty"
14668 $LCTL set_param fail_loc=0
14671 [[ $? -eq 0 ]] || error "create failed"
14673 run_test 161d "create with concurrent .lustre/fid access"
14676 local expected="$1"
14681 path=$($LFS fid2path "$@")
14684 if [ $rc -ne 0 ]; then
14685 error "path looked up of '$expected' failed: rc=$rc"
14686 elif [ "$path" != "$expected" ]; then
14687 error "path looked up '$path' instead of '$expected'"
14689 echo "FID '$fid' resolves to path '$path' as expected"
14693 test_162a() { # was test_162
14694 test_mkdir -p -c1 $DIR/$tdir/d2
14695 touch $DIR/$tdir/d2/$tfile
14696 touch $DIR/$tdir/d2/x1
14697 touch $DIR/$tdir/d2/x2
14698 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
14699 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
14701 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
14702 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
14705 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
14706 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
14707 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
14709 # softlink to wrong file
14710 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
14711 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
14712 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
14715 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
14716 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
14717 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
14718 # fid2path dir/fsname should both work
14719 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
14720 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
14722 # hardlink count: check that there are 2 links
14723 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
14724 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
14726 # hardlink indexing: remove the first link
14727 rm $DIR/$tdir/d2/p/q/r/hlink
14728 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
14730 run_test 162a "path lookup sanity"
14733 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14734 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14737 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
14738 error "create striped dir failed"
14740 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
14741 tail -n 1 | awk '{print $2}')
14742 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
14744 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
14745 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
14748 for ((i=0;i<5;i++)); do
14749 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
14750 error "get fid for f$i failed"
14751 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
14753 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
14754 error "get fid for d$i failed"
14755 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
14760 run_test 162b "striped directory path lookup sanity"
14762 # LU-4239: Verify fid2path works with paths 100 or more directories deep
14764 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
14765 skip "Need MDS version at least 2.7.51"
14767 local lpath=$tdir.local
14768 local rpath=$tdir.remote
14770 test_mkdir $DIR/$lpath
14771 test_mkdir $DIR/$rpath
14773 for ((i = 0; i <= 101; i++)); do
14776 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
14777 error "get fid for local directory $DIR/$lpath failed"
14778 check_path "$DIR/$lpath" $MOUNT $FID --link 0
14781 test_mkdir $DIR/$rpath
14782 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
14783 error "get fid for remote directory $DIR/$rpath failed"
14784 check_path "$DIR/$rpath" $MOUNT $FID --link 0
14789 run_test 162c "fid2path works with paths 100 or more directories deep"
14792 # do directio so as not to populate the page cache
14793 log "creating a 10 Mb file"
14794 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14795 log "starting reads"
14796 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14797 log "truncating the file"
14798 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14800 kill %+ || true # reads might have finished
14801 echo "wait until dd is finished"
14803 log "removing the temporary file"
14804 rm -rf $DIR/$tfile || error "tmp file removal failed"
14806 run_test 169 "parallel read and truncate should not deadlock"
14809 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14811 $LCTL clear # bug 18514
14812 $LCTL debug_daemon start $TMP/${tfile}_log_good
14814 $LCTL debug_daemon stop
14815 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
14816 error "sed failed to read log_good"
14818 $LCTL debug_daemon start $TMP/${tfile}_log_good
14820 $LCTL debug_daemon stop
14822 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
14823 error "lctl df log_bad failed"
14825 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14826 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14828 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
14829 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
14831 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
14832 error "bad_line good_line1 good_line2 are empty"
14834 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14835 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
14836 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14838 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
14839 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14840 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14842 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
14843 error "bad_line_new good_line_new are empty"
14845 local expected_good=$((good_line1 + good_line2*2))
14847 rm -f $TMP/${tfile}*
14848 # LU-231, short malformed line may not be counted into bad lines
14849 if [ $bad_line -ne $bad_line_new ] &&
14850 [ $bad_line -ne $((bad_line_new - 1)) ]; then
14851 error "expected $bad_line bad lines, but got $bad_line_new"
14855 if [ $expected_good -ne $good_line_new ]; then
14856 error "expected $expected_good good lines, but got $good_line_new"
14861 run_test 170 "test lctl df to handle corrupted log ====================="
14863 test_171() { # bug20592
14864 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14866 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
14867 $LCTL set_param fail_loc=0x50e
14868 $LCTL set_param fail_val=3000
14869 multiop_bg_pause $DIR/$tfile O_s || true
14871 kill -USR1 $MULTIPID
14875 if dmesg | grep "recursive fault"; then
14876 error "caught a recursive fault"
14878 $LCTL set_param fail_loc=0
14881 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
14883 # it would be good to share it with obdfilter-survey/iokit-libecho code
14884 setup_obdecho_osc () {
14887 local obdfilter_name=$2
14888 echo "Creating new osc for $obdfilter_name on $ost_nid"
14889 # make sure we can find loopback nid
14890 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
14892 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
14893 ${obdfilter_name}_osc_UUID || rc=2; }
14894 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
14895 ${obdfilter_name}_UUID $ost_nid || rc=3; }
14899 cleanup_obdecho_osc () {
14900 local obdfilter_name=$1
14901 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
14902 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
14909 local pages=${3:-64}
14914 local obd_size=$(get_obd_size $node $OBD)
14915 local page_size=$(get_page_size $node)
14916 if [[ -n "$obd_size" ]]; then
14917 local new_count=$((obd_size / (pages * page_size / 1024)))
14918 [[ $new_count -ge $count ]] || count=$new_count
14921 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
14922 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
14924 if [ $rc -eq 0 ]; then
14925 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
14926 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
14928 echo "New object id is $id"
14929 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
14931 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
14932 "test_brw $count w v $pages $id" || rc=4; }
14933 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
14935 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
14936 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
14937 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
14938 { do_facet $node "$LCTL --device ec detach" || rc=6; }
14939 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
14944 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14946 if ! module_loaded obdecho; then
14947 load_module obdecho/obdecho &&
14948 stack_trap "rmmod obdecho" EXIT ||
14949 error "unable to load obdecho on client"
14952 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
14953 local host=$($LCTL get_param -n osc.$osc.import |
14954 awk '/current_connection:/ { print $2 }' )
14955 local target=$($LCTL get_param -n osc.$osc.import |
14956 awk '/target:/ { print $2 }' )
14957 target=${target%_UUID}
14959 if [ -n "$target" ]; then
14960 setup_obdecho_osc $host $target &&
14961 stack_trap "cleanup_obdecho_osc $target" EXIT ||
14962 { error "obdecho setup failed with $?"; return; }
14964 obdecho_test ${target}_osc client ||
14965 error "obdecho_test failed on ${target}_osc"
14967 $LCTL get_param osc.$osc.import
14968 error "there is no osc.$osc.import target"
14971 run_test 180a "test obdecho on osc"
14974 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14975 remote_ost_nodsh && skip "remote OST with nodsh"
14977 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14978 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14979 error "failed to load module obdecho"
14981 local target=$(do_facet ost1 $LCTL dl |
14982 awk '/obdfilter/ { print $4; exit; }')
14984 if [ -n "$target" ]; then
14985 obdecho_test $target ost1 || error "obdecho_test failed with $?"
14987 do_facet ost1 $LCTL dl
14988 error "there is no obdfilter target on ost1"
14991 run_test 180b "test obdecho directly on obdfilter"
14993 test_180c() { # LU-2598
14994 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14995 remote_ost_nodsh && skip "remote OST with nodsh"
14996 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
14997 skip "Need MDS version at least 2.4.0"
14999 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
15000 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
15001 error "failed to load module obdecho"
15003 local target=$(do_facet ost1 $LCTL dl |
15004 awk '/obdfilter/ { print $4; exit; }')
15006 if [ -n "$target" ]; then
15007 local pages=16384 # 64MB bulk I/O RPC size
15009 obdecho_test "$target" ost1 "$pages" ||
15010 error "obdecho_test with pages=$pages failed with $?"
15012 do_facet ost1 $LCTL dl
15013 error "there is no obdfilter target on ost1"
15016 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
15018 test_181() { # bug 22177
15019 test_mkdir $DIR/$tdir
15020 # create enough files to index the directory
15021 createmany -o $DIR/$tdir/foobar 4000
15022 # print attributes for debug purpose
15025 multiop_bg_pause $DIR/$tdir D_Sc || return 1
15027 # remove the files & current working dir
15028 unlinkmany $DIR/$tdir/foobar 4000
15030 kill -USR1 $MULTIPID
15032 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
15035 run_test 181 "Test open-unlinked dir ========================"
15041 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15043 $LCTL set_param mdc.*.rpc_stats=clear
15045 for (( i = 0; i < $tcount; i++ )) ; do
15046 mkdir $DIR/$tdir/$i
15049 for (( i = 0; i < $tcount; i++ )) ; do
15050 createmany -o $DIR/$tdir/$i/f- $fcount &
15054 for (( i = 0; i < $tcount; i++ )) ; do
15055 unlinkmany $DIR/$tdir/$i/f- $fcount &
15059 $LCTL get_param mdc.*.rpc_stats
15063 run_test 182 "Test parallel modify metadata operations ================"
15065 test_183() { # LU-2275
15066 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15067 remote_mds_nodsh && skip "remote MDS with nodsh"
15068 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
15069 skip "Need MDS version at least 2.3.56"
15071 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15072 echo aaa > $DIR/$tdir/$tfile
15074 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
15075 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
15077 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
15078 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
15080 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
15082 # Flush negative dentry cache
15083 touch $DIR/$tdir/$tfile
15085 # We are not checking for any leaked references here, they'll
15086 # become evident next time we do cleanup with module unload.
15089 run_test 183 "No crash or request leak in case of strange dispositions ========"
15091 # test suite 184 is for LU-2016, LU-2017
15093 check_swap_layouts_support
15095 dir0=$DIR/$tdir/$testnum
15096 test_mkdir -p -c1 $dir0
15101 $LFS setstripe -c1 $file1
15103 $LFS setstripe -c2 $file2
15105 gen1=$($LFS getstripe -g $file1)
15106 gen2=$($LFS getstripe -g $file2)
15108 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
15109 gen=$($LFS getstripe -g $file1)
15110 [[ $gen1 != $gen ]] ||
15111 "Layout generation on $file1 does not change"
15112 gen=$($LFS getstripe -g $file2)
15113 [[ $gen2 != $gen ]] ||
15114 "Layout generation on $file2 does not change"
15116 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
15117 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
15119 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
15121 run_test 184a "Basic layout swap"
15124 check_swap_layouts_support
15126 dir0=$DIR/$tdir/$testnum
15127 mkdir -p $dir0 || error "creating dir $dir0"
15134 $LFS setstripe -c1 $file1
15135 $LFS setstripe -c2 $file2
15136 $LFS setstripe -c1 $file3
15137 chown $RUNAS_ID $file3
15138 gen1=$($LFS getstripe -g $file1)
15139 gen2=$($LFS getstripe -g $file2)
15141 $LFS swap_layouts $dir1 $dir2 &&
15142 error "swap of directories layouts should fail"
15143 $LFS swap_layouts $dir1 $file1 &&
15144 error "swap of directory and file layouts should fail"
15145 $RUNAS $LFS swap_layouts $file1 $file2 &&
15146 error "swap of file we cannot write should fail"
15147 $LFS swap_layouts $file1 $file3 &&
15148 error "swap of file with different owner should fail"
15149 /bin/true # to clear error code
15151 run_test 184b "Forbidden layout swap (will generate errors)"
15154 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
15155 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
15156 check_swap_layouts_support
15158 local dir0=$DIR/$tdir/$testnum
15159 mkdir -p $dir0 || error "creating dir $dir0"
15161 local ref1=$dir0/ref1
15162 local ref2=$dir0/ref2
15163 local file1=$dir0/file1
15164 local file2=$dir0/file2
15165 # create a file large enough for the concurrent test
15166 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
15167 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
15168 echo "ref file size: ref1($(stat -c %s $ref1))," \
15169 "ref2($(stat -c %s $ref2))"
15172 dd if=$ref1 of=$file1 bs=16k &
15175 # Make sure dd starts to copy file
15176 while [ ! -f $file1 ]; do sleep 0.1; done
15178 $LFS swap_layouts $file1 $file2
15181 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
15182 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
15184 # how many bytes copied before swapping layout
15185 local copied=$(stat -c %s $file2)
15186 local remaining=$(stat -c %s $ref1)
15187 remaining=$((remaining - copied))
15188 echo "Copied $copied bytes before swapping layout..."
15190 cmp -n $copied $file1 $ref2 | grep differ &&
15191 error "Content mismatch [0, $copied) of ref2 and file1"
15192 cmp -n $copied $file2 $ref1 ||
15193 error "Content mismatch [0, $copied) of ref1 and file2"
15194 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
15195 error "Content mismatch [$copied, EOF) of ref1 and file1"
15198 rm -f $ref1 $ref2 $file1 $file2
15200 run_test 184c "Concurrent write and layout swap"
15203 check_swap_layouts_support
15204 [ -z "$(which getfattr 2>/dev/null)" ] &&
15205 skip_env "no getfattr command"
15207 local file1=$DIR/$tdir/$tfile-1
15208 local file2=$DIR/$tdir/$tfile-2
15209 local file3=$DIR/$tdir/$tfile-3
15213 mkdir -p $DIR/$tdir
15214 touch $file1 || error "create $file1 failed"
15215 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
15216 error "create $file2 failed"
15217 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
15218 error "create $file3 failed"
15219 lovea1=$(get_layout_param $file1)
15221 $LFS swap_layouts $file2 $file3 ||
15222 error "swap $file2 $file3 layouts failed"
15223 $LFS swap_layouts $file1 $file2 ||
15224 error "swap $file1 $file2 layouts failed"
15226 lovea2=$(get_layout_param $file2)
15229 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
15231 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
15232 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
15234 run_test 184d "allow stripeless layouts swap"
15237 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
15238 skip "Need MDS version at least 2.6.94"
15239 check_swap_layouts_support
15240 [ -z "$(which getfattr 2>/dev/null)" ] &&
15241 skip_env "no getfattr command"
15243 local file1=$DIR/$tdir/$tfile-1
15244 local file2=$DIR/$tdir/$tfile-2
15245 local file3=$DIR/$tdir/$tfile-3
15248 mkdir -p $DIR/$tdir
15249 touch $file1 || error "create $file1 failed"
15250 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
15251 error "create $file2 failed"
15252 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
15253 error "create $file3 failed"
15255 $LFS swap_layouts $file1 $file2 ||
15256 error "swap $file1 $file2 layouts failed"
15258 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
15259 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
15261 echo 123 > $file1 || error "Should be able to write into $file1"
15263 $LFS swap_layouts $file1 $file3 ||
15264 error "swap $file1 $file3 layouts failed"
15266 echo 123 > $file1 || error "Should be able to write into $file1"
15268 rm -rf $file1 $file2 $file3
15270 run_test 184e "Recreate layout after stripeless layout swaps"
15273 # Create a file with name longer than sizeof(struct stat) ==
15274 # 144 to see if we can get chars from the file name to appear
15275 # in the returned striping. Note that 'f' == 0x66.
15276 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
15278 mkdir -p $DIR/$tdir
15279 mcreate $DIR/$tdir/$file
15280 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
15281 error "IOC_MDC_GETFILEINFO returned garbage striping"
15284 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
15286 test_185() { # LU-2441
15287 # LU-3553 - no volatile file support in old servers
15288 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
15289 skip "Need MDS version at least 2.3.60"
15291 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15292 touch $DIR/$tdir/spoo
15293 local mtime1=$(stat -c "%Y" $DIR/$tdir)
15294 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
15295 error "cannot create/write a volatile file"
15296 [ "$FILESET" == "" ] &&
15297 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
15298 error "FID is still valid after close"
15300 multiop_bg_pause $DIR/$tdir vVw4096_c
15307 # assume that the next FID for this client is sequential, since stdout
15308 # is unfortunately eaten by multiop_bg_pause
15309 local n=$((${fidv[1]} + 1))
15310 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
15311 if [ "$FILESET" == "" ]; then
15312 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
15313 error "FID is missing before close"
15315 kill -USR1 $multi_pid
15316 # 1 second delay, so if mtime change we will see it
15318 local mtime2=$(stat -c "%Y" $DIR/$tdir)
15319 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
15321 run_test 185 "Volatile file support"
15323 function create_check_volatile() {
15327 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
15330 local FID=$(cat /tmp/${tfile}.fid)
15331 [ "$FID" == "" ] && error "can't get FID for volatile"
15332 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
15333 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
15334 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
15338 cancel_lru_locks mdc # flush opencache
15339 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
15344 # LU-12516 - volatile creation via .lustre
15345 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
15346 skip "Need MDS version at least 2.3.55"
15348 create_check_volatile 0
15349 [ $MDSCOUNT -lt 2 ] && return 0
15352 create_check_volatile 1
15356 run_test 185a "Volatile file creation in .lustre/fid/"
15359 remote_mds_nodsh && skip "remote MDS with nodsh"
15360 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15361 skip "Need MDS version at least 2.3.0"
15363 local dir0=$DIR/$tdir/$testnum
15364 mkdir -p $dir0 || error "creating dir $dir0"
15366 local file=$dir0/file1
15367 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
15368 local dv1=$($LFS data_version $file)
15369 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
15370 local dv2=$($LFS data_version $file)
15371 [[ $dv1 != $dv2 ]] ||
15372 error "data version did not change on write $dv1 == $dv2"
15377 run_test 187a "Test data version change"
15380 remote_mds_nodsh && skip "remote MDS with nodsh"
15381 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15382 skip "Need MDS version at least 2.3.0"
15384 local dir0=$DIR/$tdir/$testnum
15385 mkdir -p $dir0 || error "creating dir $dir0"
15387 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
15388 [[ ${DV[0]} != ${DV[1]} ]] ||
15389 error "data version did not change on write"\
15390 " ${DV[0]} == ${DV[1]}"
15395 run_test 187b "Test data version change on volatile file"
15398 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15399 remote_mgs_nodsh && skip "remote MGS with nodsh"
15400 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15402 local POOL=${POOL:-cea1}
15403 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
15404 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
15407 local last_ost=$(($OSTCOUNT - 1))
15409 local ost_list=$(seq $first_ost $ost_step $last_ost)
15410 local ost_range="$first_ost $last_ost $ost_step"
15411 local test_path=$POOL_ROOT/$POOL_DIR_NAME
15412 local file_dir=$POOL_ROOT/file_tst
15413 local subdir=$test_path/subdir
15417 # former test_200a test_200b
15418 pool_add $POOL || { rc=$? ; break; }
15419 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
15420 # former test_200c test_200d
15421 mkdir -p $test_path
15422 pool_set_dir $POOL $test_path || { rc=$? ; break; }
15423 pool_check_dir $POOL $test_path || { rc=$? ; break; }
15425 pool_check_dir $POOL $subdir || { rc=$? ; break; }
15426 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
15427 || { rc=$? ; break; }
15428 # former test_200e test_200f
15429 local files=$((OSTCOUNT*3))
15430 pool_alloc_files $POOL $test_path $files "$ost_list" \
15431 || { rc=$? ; break; }
15432 pool_create_files $POOL $file_dir $files "$ost_list" \
15433 || { rc=$? ; break; }
15434 # former test_200g test_200h
15435 pool_lfs_df $POOL || { rc=$? ; break; }
15436 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
15438 # former test_201a test_201b test_201c
15439 pool_remove_first_target $POOL || { rc=$? ; break; }
15441 local f=$test_path/$tfile
15442 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
15443 pool_remove $POOL $f || { rc=$? ; break; }
15451 run_test 200 "OST pools"
15453 # usage: default_attr <count | size | offset>
15455 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
15458 # usage: check_default_stripe_attr
15459 check_default_stripe_attr() {
15460 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
15463 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
15465 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
15469 error "unknown getstripe attr '$1'"
15472 [ $ACTUAL == $EXPECTED ] ||
15473 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
15477 test_mkdir $DIR/$tdir
15478 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
15480 check_default_stripe_attr --stripe-count
15481 check_default_stripe_attr --stripe-size
15482 check_default_stripe_attr --stripe-index
15484 run_test 204a "Print default stripe attributes"
15487 test_mkdir $DIR/$tdir
15488 $LFS setstripe --stripe-count 1 $DIR/$tdir
15490 check_default_stripe_attr --stripe-size
15491 check_default_stripe_attr --stripe-index
15493 run_test 204b "Print default stripe size and offset"
15496 test_mkdir $DIR/$tdir
15497 $LFS setstripe --stripe-size 65536 $DIR/$tdir
15499 check_default_stripe_attr --stripe-count
15500 check_default_stripe_attr --stripe-index
15502 run_test 204c "Print default stripe count and offset"
15505 test_mkdir $DIR/$tdir
15506 $LFS setstripe --stripe-index 0 $DIR/$tdir
15508 check_default_stripe_attr --stripe-count
15509 check_default_stripe_attr --stripe-size
15511 run_test 204d "Print default stripe count and size"
15514 test_mkdir $DIR/$tdir
15515 $LFS setstripe -d $DIR/$tdir
15517 check_default_stripe_attr --stripe-count --raw
15518 check_default_stripe_attr --stripe-size --raw
15519 check_default_stripe_attr --stripe-index --raw
15521 run_test 204e "Print raw stripe attributes"
15524 test_mkdir $DIR/$tdir
15525 $LFS setstripe --stripe-count 1 $DIR/$tdir
15527 check_default_stripe_attr --stripe-size --raw
15528 check_default_stripe_attr --stripe-index --raw
15530 run_test 204f "Print raw stripe size and offset"
15533 test_mkdir $DIR/$tdir
15534 $LFS setstripe --stripe-size 65536 $DIR/$tdir
15536 check_default_stripe_attr --stripe-count --raw
15537 check_default_stripe_attr --stripe-index --raw
15539 run_test 204g "Print raw stripe count and offset"
15542 test_mkdir $DIR/$tdir
15543 $LFS setstripe --stripe-index 0 $DIR/$tdir
15545 check_default_stripe_attr --stripe-count --raw
15546 check_default_stripe_attr --stripe-size --raw
15548 run_test 204h "Print raw stripe count and size"
15550 # Figure out which job scheduler is being used, if any,
15551 # or use a fake one
15552 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
15553 JOBENV=SLURM_JOB_ID
15554 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
15556 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
15558 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
15559 JOBENV=LOADL_STEP_ID
15560 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
15563 $LCTL list_param jobid_name > /dev/null 2>&1
15564 if [ $? -eq 0 ]; then
15570 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
15572 verify_jobstats() {
15577 # we don't really need to clear the stats for this test to work, since each
15578 # command has a unique jobid, but it makes debugging easier if needed.
15579 # for facet in $facets; do
15580 # local dev=$(convert_facet2label $facet)
15581 # # clear old jobstats
15582 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
15585 # use a new JobID for each test, or we might see an old one
15586 [ "$JOBENV" = "FAKE_JOBID" ] &&
15587 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
15589 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
15591 [ "$JOBENV" = "nodelocal" ] && {
15592 FAKE_JOBID=id.$testnum.%e.$RANDOM
15593 $LCTL set_param jobid_name=$FAKE_JOBID
15594 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
15597 log "Test: ${cmd[*]}"
15598 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
15600 if [ $JOBENV = "FAKE_JOBID" ]; then
15601 FAKE_JOBID=$JOBVAL ${cmd[*]}
15606 # all files are created on OST0000
15607 for facet in $facets; do
15608 local stats="*.$(convert_facet2label $facet).job_stats"
15610 # strip out libtool wrappers for in-tree executables
15611 if [ $(do_facet $facet lctl get_param $stats |
15612 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
15613 do_facet $facet lctl get_param $stats
15614 error "No jobstats for $JOBVAL found on $facet::$stats"
15620 local new_jobenv=$1
15622 set_persistent_param_and_check client "jobid_var" \
15623 "$FSNAME.sys.jobid_var" $new_jobenv
15626 test_205a() { # Job stats
15627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15628 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
15629 skip "Need MDS version with at least 2.7.1"
15630 remote_mgs_nodsh && skip "remote MGS with nodsh"
15631 remote_mds_nodsh && skip "remote MDS with nodsh"
15632 remote_ost_nodsh && skip "remote OST with nodsh"
15633 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
15634 skip "Server doesn't support jobstats"
15635 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
15637 local old_jobenv=$($LCTL get_param -n jobid_var)
15638 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
15640 if [[ $PERM_CMD == *"set_param -P"* ]]; then
15641 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
15643 stack_trap "do_facet mgs $PERM_CMD \
15644 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
15648 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
15649 mdt.*.job_cleanup_interval | head -n 1)
15650 local new_interval=5
15651 do_facet $SINGLEMDS \
15652 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
15653 stack_trap "do_facet $SINGLEMDS \
15654 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
15655 local start=$SECONDS
15659 cmd="mkdir $DIR/$tdir"
15660 verify_jobstats "$cmd" "$SINGLEMDS"
15662 cmd="rmdir $DIR/$tdir"
15663 verify_jobstats "$cmd" "$SINGLEMDS"
15664 # mkdir on secondary MDT
15665 if [ $MDSCOUNT -gt 1 ]; then
15666 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
15667 verify_jobstats "$cmd" "mds2"
15670 cmd="mknod $DIR/$tfile c 1 3"
15671 verify_jobstats "$cmd" "$SINGLEMDS"
15673 cmd="rm -f $DIR/$tfile"
15674 verify_jobstats "$cmd" "$SINGLEMDS"
15675 # create all files on OST0000 so verify_jobstats can find OST stats
15677 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
15678 verify_jobstats "$cmd" "$SINGLEMDS"
15680 cmd="touch $DIR/$tfile"
15681 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15683 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
15684 verify_jobstats "$cmd" "ost1"
15686 cancel_lru_locks osc
15687 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
15688 verify_jobstats "$cmd" "ost1"
15690 cmd="$TRUNCATE $DIR/$tfile 0"
15691 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15693 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
15694 verify_jobstats "$cmd" "$SINGLEMDS"
15695 # jobstats expiry - sleep until old stats should be expired
15696 local left=$((new_interval + 5 - (SECONDS - start)))
15697 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
15698 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
15700 cmd="mkdir $DIR/$tdir.expire"
15701 verify_jobstats "$cmd" "$SINGLEMDS"
15702 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
15703 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
15705 # Ensure that jobid are present in changelog (if supported by MDS)
15706 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
15707 changelog_dump | tail -10
15708 jobids=$(changelog_dump | tail -9 | grep -c "j=")
15709 [ $jobids -eq 9 ] ||
15710 error "Wrong changelog jobid count $jobids != 9"
15714 jobstats_set $JOBENV
15716 changelog_dump | grep $tfile
15717 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
15718 [ $jobids -eq 0 ] ||
15719 error "Unexpected jobids when jobid_var=$JOBENV"
15722 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
15723 JOBENV="JOBCOMPLEX"
15724 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
15726 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
15728 run_test 205a "Verify job stats"
15732 $LCTL set_param jobid_var=USER jobid_name="%e.%u"
15733 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
15734 do_facet $SINGLEMDS $LCTL get_param mdt.*.job_stats |
15735 grep job_id: | grep foolish &&
15736 error "Unexpected jobid found"
15739 run_test 205b "Verify job stats jobid parsing"
15741 # LU-1480, LU-1773 and LU-1657
15743 mkdir -p $DIR/$tdir
15744 $LFS setstripe -c -1 $DIR/$tdir
15745 #define OBD_FAIL_LOV_INIT 0x1403
15746 $LCTL set_param fail_loc=0xa0001403
15747 $LCTL set_param fail_val=1
15748 touch $DIR/$tdir/$tfile || true
15750 run_test 206 "fail lov_init_raid0() doesn't lbug"
15753 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15754 local fsz=`stat -c %s $DIR/$tfile`
15755 cancel_lru_locks mdc
15757 # do not return layout in getattr intent
15758 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
15759 $LCTL set_param fail_loc=0x170
15760 local sz=`stat -c %s $DIR/$tfile`
15762 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
15766 run_test 207a "can refresh layout at glimpse"
15769 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15770 local cksum=`md5sum $DIR/$tfile`
15771 local fsz=`stat -c %s $DIR/$tfile`
15772 cancel_lru_locks mdc
15773 cancel_lru_locks osc
15775 # do not return layout in getattr intent
15776 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
15777 $LCTL set_param fail_loc=0x171
15779 # it will refresh layout after the file is opened but before read issues
15780 echo checksum is "$cksum"
15781 echo "$cksum" |md5sum -c --quiet || error "file differs"
15785 run_test 207b "can refresh layout at open"
15788 # FIXME: in this test suite, only RD lease is used. This is okay
15789 # for now as only exclusive open is supported. After generic lease
15790 # is done, this test suite should be revised. - Jinshan
15792 remote_mds_nodsh && skip "remote MDS with nodsh"
15793 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
15794 skip "Need MDS version at least 2.4.52"
15796 echo "==== test 1: verify get lease work"
15797 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
15799 echo "==== test 2: verify lease can be broken by upcoming open"
15800 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15804 $MULTIOP $DIR/$tfile oO_RDONLY:c
15805 kill -USR1 $PID && wait $PID || error "break lease error"
15807 echo "==== test 3: verify lease can't be granted if an open already exists"
15808 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
15812 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
15813 kill -USR1 $PID && wait $PID || error "open file error"
15815 echo "==== test 4: lease can sustain over recovery"
15816 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
15822 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
15824 echo "==== test 5: lease broken can't be regained by replay"
15825 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15829 # open file to break lease and then recovery
15830 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
15833 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
15837 run_test 208 "Exclusive open"
15840 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
15841 skip_env "must have disp_stripe"
15844 sync; sleep 5; sync;
15846 echo 3 > /proc/sys/vm/drop_caches
15847 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15849 # open/close 500 times
15850 for i in $(seq 500); do
15854 echo 3 > /proc/sys/vm/drop_caches
15855 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15857 echo "before: $req_before, after: $req_after"
15858 [ $((req_after - req_before)) -ge 300 ] &&
15859 error "open/close requests are not freed"
15862 run_test 209 "read-only open/close requests should be freed promptly"
15866 size=$((size % 8192 + 1))
15867 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
15868 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
15869 rm -f $DIR/f212 $DIR/f212.xyz
15871 run_test 212 "Sendfile test ============================================"
15874 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
15875 cancel_lru_locks osc
15876 lctl set_param fail_loc=0x8000040f
15877 # generate a read lock
15878 cat $DIR/$tfile > /dev/null
15879 # write to the file, it will try to cancel the above read lock.
15880 cat /etc/hosts >> $DIR/$tfile
15882 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
15884 test_214() { # for bug 20133
15885 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
15886 for (( i=0; i < 340; i++ )) ; do
15887 touch $DIR/$tdir/d214c/a$i
15890 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
15891 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
15892 ls $DIR/d214c || error "ls $DIR/d214c failed"
15893 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
15894 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
15896 run_test 214 "hash-indexed directory test - bug 20133"
15898 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
15899 create_lnet_proc_files() {
15900 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
15903 # counterpart of create_lnet_proc_files
15904 remove_lnet_proc_files() {
15905 rm -f $TMP/lnet_$1.sys
15908 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15909 # 3rd arg as regexp for body
15910 check_lnet_proc_stats() {
15911 local l=$(cat "$TMP/lnet_$1" |wc -l)
15912 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
15914 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
15917 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15918 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
15919 # optional and can be regexp for 2nd line (lnet.routes case)
15920 check_lnet_proc_entry() {
15921 local blp=2 # blp stands for 'position of 1st line of body'
15922 [ -z "$5" ] || blp=3 # lnet.routes case
15924 local l=$(cat "$TMP/lnet_$1" |wc -l)
15925 # subtracting one from $blp because the body can be empty
15926 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
15928 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
15929 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
15931 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
15932 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
15934 # bail out if any unexpected line happened
15935 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
15936 [ "$?" != 0 ] || error "$2 misformatted"
15939 test_215() { # for bugs 18102, 21079, 21517
15940 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15942 local N='(0|[1-9][0-9]*)' # non-negative numeric
15943 local P='[1-9][0-9]*' # positive numeric
15944 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
15945 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
15946 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
15947 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
15949 local L1 # regexp for 1st line
15950 local L2 # regexp for 2nd line (optional)
15951 local BR # regexp for the rest (body)
15953 # lnet.stats should look as 11 space-separated non-negative numerics
15954 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
15955 create_lnet_proc_files "stats"
15956 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
15957 remove_lnet_proc_files "stats"
15959 # lnet.routes should look like this:
15960 # Routing disabled/enabled
15961 # net hops priority state router
15962 # where net is a string like tcp0, hops > 0, priority >= 0,
15963 # state is up/down,
15964 # router is a string like 192.168.1.1@tcp2
15965 L1="^Routing (disabled|enabled)$"
15966 L2="^net +hops +priority +state +router$"
15967 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
15968 create_lnet_proc_files "routes"
15969 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
15970 remove_lnet_proc_files "routes"
15972 # lnet.routers should look like this:
15973 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
15974 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
15975 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
15976 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
15977 L1="^ref +rtr_ref +alive +router$"
15978 BR="^$P +$P +(up|down) +$NID$"
15979 create_lnet_proc_files "routers"
15980 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
15981 remove_lnet_proc_files "routers"
15983 # lnet.peers should look like this:
15984 # nid refs state last max rtr min tx min queue
15985 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
15986 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
15987 # numeric (0 or >0 or <0), queue >= 0.
15988 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
15989 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
15990 create_lnet_proc_files "peers"
15991 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
15992 remove_lnet_proc_files "peers"
15994 # lnet.buffers should look like this:
15995 # pages count credits min
15996 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
15997 L1="^pages +count +credits +min$"
15998 BR="^ +$N +$N +$I +$I$"
15999 create_lnet_proc_files "buffers"
16000 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
16001 remove_lnet_proc_files "buffers"
16003 # lnet.nis should look like this:
16004 # nid status alive refs peer rtr max tx min
16005 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
16006 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
16007 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
16008 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
16009 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
16010 create_lnet_proc_files "nis"
16011 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
16012 remove_lnet_proc_files "nis"
16014 # can we successfully write to lnet.stats?
16015 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
16017 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
16019 test_216() { # bug 20317
16020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16021 remote_ost_nodsh && skip "remote OST with nodsh"
16024 local facets=$(get_facets OST)
16025 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16027 save_lustre_params client "osc.*.contention_seconds" > $p
16028 save_lustre_params $facets \
16029 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
16030 save_lustre_params $facets \
16031 "ldlm.namespaces.filter-*.contended_locks" >> $p
16032 save_lustre_params $facets \
16033 "ldlm.namespaces.filter-*.contention_seconds" >> $p
16034 clear_stats osc.*.osc_stats
16036 # agressive lockless i/o settings
16037 do_nodes $(comma_list $(osts_nodes)) \
16038 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
16039 ldlm.namespaces.filter-*.contended_locks=0 \
16040 ldlm.namespaces.filter-*.contention_seconds=60"
16041 lctl set_param -n osc.*.contention_seconds=60
16043 $DIRECTIO write $DIR/$tfile 0 10 4096
16044 $CHECKSTAT -s 40960 $DIR/$tfile
16046 # disable lockless i/o
16047 do_nodes $(comma_list $(osts_nodes)) \
16048 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
16049 ldlm.namespaces.filter-*.contended_locks=32 \
16050 ldlm.namespaces.filter-*.contention_seconds=0"
16051 lctl set_param -n osc.*.contention_seconds=0
16052 clear_stats osc.*.osc_stats
16054 dd if=/dev/zero of=$DIR/$tfile count=0
16055 $CHECKSTAT -s 0 $DIR/$tfile
16057 restore_lustre_params <$p
16061 run_test 216 "check lockless direct write updates file size and kms correctly"
16063 test_217() { # bug 22430
16064 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16069 for node in $(nodes_list); do
16070 nid=$(host_nids_address $node $NETTYPE)
16071 if [[ $nid = *-* ]] ; then
16072 echo "lctl ping $(h2nettype $nid)"
16073 lctl ping $(h2nettype $nid)
16075 echo "skipping $node (no hyphen detected)"
16079 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
16082 # do directio so as not to populate the page cache
16083 log "creating a 10 Mb file"
16084 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
16085 log "starting reads"
16086 dd if=$DIR/$tfile of=/dev/null bs=4096 &
16087 log "truncating the file"
16088 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
16090 kill %+ || true # reads might have finished
16091 echo "wait until dd is finished"
16093 log "removing the temporary file"
16094 rm -rf $DIR/$tfile || error "tmp file removal failed"
16096 run_test 218 "parallel read and truncate should not deadlock"
16099 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16101 # write one partial page
16102 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
16103 # set no grant so vvp_io_commit_write will do sync write
16104 $LCTL set_param fail_loc=0x411
16105 # write a full page at the end of file
16106 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
16108 $LCTL set_param fail_loc=0
16109 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
16110 $LCTL set_param fail_loc=0x411
16111 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
16114 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
16115 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
16117 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
16119 test_220() { #LU-325
16120 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16121 remote_ost_nodsh && skip "remote OST with nodsh"
16122 remote_mds_nodsh && skip "remote MDS with nodsh"
16123 remote_mgs_nodsh && skip "remote MGS with nodsh"
16127 # create on MDT0000 so the last_id and next_id are correct
16129 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
16133 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
16134 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
16135 osp.$mdtosc_proc1.prealloc_last_id)
16136 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
16137 osp.$mdtosc_proc1.prealloc_next_id)
16141 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
16142 #define OBD_FAIL_OST_ENOINO 0x229
16143 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
16144 create_pool $FSNAME.$TESTNAME || return 1
16145 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
16147 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
16149 MDSOBJS=$((last_id - next_id))
16150 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
16152 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
16153 echo "OST still has $count kbytes free"
16155 echo "create $MDSOBJS files @next_id..."
16156 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
16158 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
16159 osp.$mdtosc_proc1.prealloc_last_id)
16160 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
16161 osp.$mdtosc_proc1.prealloc_next_id)
16163 echo "after creation, last_id=$last_id2, next_id=$next_id2"
16168 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
16169 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
16171 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
16172 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
16173 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
16174 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
16175 echo "unlink $MDSOBJS files @$next_id..."
16176 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
16178 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
16181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16183 dd if=`which date` of=$MOUNT/date oflag=sync
16184 chmod +x $MOUNT/date
16186 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
16187 $LCTL set_param fail_loc=0x80001401
16189 $MOUNT/date > /dev/null
16192 run_test 221 "make sure fault and truncate race to not cause OOM"
16195 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16198 test_mkdir $DIR/$tdir
16199 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16200 createmany -o $DIR/$tdir/$tfile 10
16201 cancel_lru_locks mdc
16202 cancel_lru_locks osc
16203 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
16204 $LCTL set_param fail_loc=0x31a
16205 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
16206 $LCTL set_param fail_loc=0
16209 run_test 222a "AGL for ls should not trigger CLIO lock failure"
16212 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16215 test_mkdir $DIR/$tdir
16216 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16217 createmany -o $DIR/$tdir/$tfile 10
16218 cancel_lru_locks mdc
16219 cancel_lru_locks osc
16220 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
16221 $LCTL set_param fail_loc=0x31a
16222 rm -r $DIR/$tdir || error "AGL for rmdir failed"
16223 $LCTL set_param fail_loc=0
16225 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
16228 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16231 test_mkdir $DIR/$tdir
16232 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16233 createmany -o $DIR/$tdir/$tfile 10
16234 cancel_lru_locks mdc
16235 cancel_lru_locks osc
16236 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
16237 $LCTL set_param fail_loc=0x31b
16238 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
16239 $LCTL set_param fail_loc=0
16242 run_test 223 "osc reenqueue if without AGL lock granted ======================="
16244 test_224a() { # LU-1039, MRP-303
16245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16247 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
16248 $LCTL set_param fail_loc=0x508
16249 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
16250 $LCTL set_param fail_loc=0
16253 run_test 224a "Don't panic on bulk IO failure"
16255 test_224b() { # LU-1039, MRP-303
16256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16258 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
16259 cancel_lru_locks osc
16260 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
16261 $LCTL set_param fail_loc=0x515
16262 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
16263 $LCTL set_param fail_loc=0
16266 run_test 224b "Don't panic on bulk IO failure"
16268 test_224c() { # LU-6441
16269 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16270 remote_mds_nodsh && skip "remote MDS with nodsh"
16272 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16273 save_writethrough $p
16274 set_cache writethrough on
16276 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
16277 local at_max=$($LCTL get_param -n at_max)
16278 local timeout=$($LCTL get_param -n timeout)
16279 local test_at="at_max"
16280 local param_at="$FSNAME.sys.at_max"
16281 local test_timeout="timeout"
16282 local param_timeout="$FSNAME.sys.timeout"
16284 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
16286 set_persistent_param_and_check client "$test_at" "$param_at" 0
16287 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
16289 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
16290 do_facet ost1 "$LCTL set_param fail_loc=0x520"
16291 $LFS setstripe -c 1 -i 0 $DIR/$tfile
16292 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
16294 do_facet ost1 "$LCTL set_param fail_loc=0"
16296 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
16297 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
16300 $LCTL set_param -n $pages_per_rpc
16301 restore_lustre_params < $p
16304 run_test 224c "Don't hang if one of md lost during large bulk RPC"
16306 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
16308 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16309 if [ -z ${MDSSURVEY} ]; then
16310 skip_env "mds-survey not found"
16312 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16313 skip "Need MDS version at least 2.2.51"
16315 local mds=$(facet_host $SINGLEMDS)
16316 local target=$(do_nodes $mds 'lctl dl' |
16317 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
16319 local cmd1="file_count=1000 thrhi=4"
16320 local cmd2="dir_count=2 layer=mdd stripe_count=0"
16321 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16322 local cmd="$cmd1 $cmd2 $cmd3"
16324 rm -f ${TMP}/mds_survey*
16326 eval $cmd || error "mds-survey with zero-stripe failed"
16327 cat ${TMP}/mds_survey*
16328 rm -f ${TMP}/mds_survey*
16330 run_test 225a "Metadata survey sanity with zero-stripe"
16333 if [ -z ${MDSSURVEY} ]; then
16334 skip_env "mds-survey not found"
16336 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16337 skip "Need MDS version at least 2.2.51"
16338 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16339 remote_mds_nodsh && skip "remote MDS with nodsh"
16340 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
16341 skip_env "Need to mount OST to test"
16344 local mds=$(facet_host $SINGLEMDS)
16345 local target=$(do_nodes $mds 'lctl dl' |
16346 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
16348 local cmd1="file_count=1000 thrhi=4"
16349 local cmd2="dir_count=2 layer=mdd stripe_count=1"
16350 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16351 local cmd="$cmd1 $cmd2 $cmd3"
16353 rm -f ${TMP}/mds_survey*
16355 eval $cmd || error "mds-survey with stripe_count failed"
16356 cat ${TMP}/mds_survey*
16357 rm -f ${TMP}/mds_survey*
16359 run_test 225b "Metadata survey sanity with stripe_count = 1"
16361 mcreate_path2fid () {
16367 local path=$DIR/$tdir/$name
16372 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
16373 error "cannot create $desc"
16375 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
16377 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
16379 fid_path=$($LFS fid2path $MOUNT $fid)
16381 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
16383 [ "$path" == "$fid_path" ] ||
16384 error "fid2path returned $fid_path, expected $path"
16386 echo "pass with $path and $fid"
16391 mkdir -p $DIR/$tdir
16393 mcreate_path2fid 0010666 0 0 fifo "FIFO"
16394 mcreate_path2fid 0020666 1 3 null "character special file (null)"
16395 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
16396 mcreate_path2fid 0040666 0 0 dir "directory"
16397 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
16398 mcreate_path2fid 0100666 0 0 file "regular file"
16399 mcreate_path2fid 0120666 0 0 link "symbolic link"
16400 mcreate_path2fid 0140666 0 0 sock "socket"
16402 run_test 226a "call path2fid and fid2path on files of all type"
16405 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16410 mkdir -p $DIR/$tdir
16411 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
16412 error "create remote directory failed"
16413 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
16414 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
16415 "character special file (null)"
16416 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
16417 "character special file (no device)"
16418 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
16419 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
16420 "block special file (loop)"
16421 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
16422 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
16423 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
16425 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
16427 # LU-1299 Executing or running ldd on a truncated executable does not
16428 # cause an out-of-memory condition.
16430 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16431 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
16433 dd if=$(which date) of=$MOUNT/date bs=1k count=1
16434 chmod +x $MOUNT/date
16436 $MOUNT/date > /dev/null
16437 ldd $MOUNT/date > /dev/null
16440 run_test 227 "running truncated executable does not cause OOM"
16442 # LU-1512 try to reuse idle OI blocks
16444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16445 remote_mds_nodsh && skip "remote MDS with nodsh"
16446 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16448 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16449 local myDIR=$DIR/$tdir
16452 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16453 $LCTL set_param fail_loc=0x80001002
16454 createmany -o $myDIR/t- 10000
16455 $LCTL set_param fail_loc=0
16456 # The guard is current the largest FID holder
16458 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16460 local IDX=$(($SEQ % 64))
16462 do_facet $SINGLEMDS sync
16463 # Make sure journal flushed.
16465 local blk1=$(do_facet $SINGLEMDS \
16466 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16467 grep Blockcount | awk '{print $4}')
16469 # Remove old files, some OI blocks will become idle.
16470 unlinkmany $myDIR/t- 10000
16471 # Create new files, idle OI blocks should be reused.
16472 createmany -o $myDIR/t- 2000
16473 do_facet $SINGLEMDS sync
16474 # Make sure journal flushed.
16476 local blk2=$(do_facet $SINGLEMDS \
16477 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16478 grep Blockcount | awk '{print $4}')
16480 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16482 run_test 228a "try to reuse idle OI blocks"
16485 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16486 remote_mds_nodsh && skip "remote MDS with nodsh"
16487 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16489 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16490 local myDIR=$DIR/$tdir
16493 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16494 $LCTL set_param fail_loc=0x80001002
16495 createmany -o $myDIR/t- 10000
16496 $LCTL set_param fail_loc=0
16497 # The guard is current the largest FID holder
16499 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16501 local IDX=$(($SEQ % 64))
16503 do_facet $SINGLEMDS sync
16504 # Make sure journal flushed.
16506 local blk1=$(do_facet $SINGLEMDS \
16507 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16508 grep Blockcount | awk '{print $4}')
16510 # Remove old files, some OI blocks will become idle.
16511 unlinkmany $myDIR/t- 10000
16514 stop $SINGLEMDS || error "Fail to stop MDT."
16516 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
16518 df $MOUNT || error "Fail to df."
16519 # Create new files, idle OI blocks should be reused.
16520 createmany -o $myDIR/t- 2000
16521 do_facet $SINGLEMDS sync
16522 # Make sure journal flushed.
16524 local blk2=$(do_facet $SINGLEMDS \
16525 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16526 grep Blockcount | awk '{print $4}')
16528 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16530 run_test 228b "idle OI blocks can be reused after MDT restart"
16534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16535 remote_mds_nodsh && skip "remote MDS with nodsh"
16536 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16538 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16539 local myDIR=$DIR/$tdir
16542 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16543 $LCTL set_param fail_loc=0x80001002
16544 # 20000 files can guarantee there are index nodes in the OI file
16545 createmany -o $myDIR/t- 20000
16546 $LCTL set_param fail_loc=0
16547 # The guard is current the largest FID holder
16549 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16551 local IDX=$(($SEQ % 64))
16553 do_facet $SINGLEMDS sync
16554 # Make sure journal flushed.
16556 local blk1=$(do_facet $SINGLEMDS \
16557 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16558 grep Blockcount | awk '{print $4}')
16560 # Remove old files, some OI blocks will become idle.
16561 unlinkmany $myDIR/t- 20000
16563 # The OI file should become empty now
16565 # Create new files, idle OI blocks should be reused.
16566 createmany -o $myDIR/t- 2000
16567 do_facet $SINGLEMDS sync
16568 # Make sure journal flushed.
16570 local blk2=$(do_facet $SINGLEMDS \
16571 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16572 grep Blockcount | awk '{print $4}')
16574 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16576 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
16578 test_229() { # LU-2482, LU-3448
16579 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16580 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
16581 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
16582 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
16586 # Create a file with a released layout and stripe count 2.
16587 $MULTIOP $DIR/$tfile H2c ||
16588 error "failed to create file with released layout"
16590 $LFS getstripe -v $DIR/$tfile
16592 local pattern=$($LFS getstripe -L $DIR/$tfile)
16593 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
16595 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
16597 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
16598 stat $DIR/$tfile || error "failed to stat released file"
16600 chown $RUNAS_ID $DIR/$tfile ||
16601 error "chown $RUNAS_ID $DIR/$tfile failed"
16603 chgrp $RUNAS_ID $DIR/$tfile ||
16604 error "chgrp $RUNAS_ID $DIR/$tfile failed"
16606 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
16607 rm $DIR/$tfile || error "failed to remove released file"
16609 run_test 229 "getstripe/stat/rm/attr changes work on released files"
16612 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16613 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16614 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16615 skip "Need MDS version at least 2.11.52"
16619 test_mkdir $DIR/$tdir
16620 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
16621 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
16622 [ $mdt_idx -ne 0 ] &&
16623 error "create local directory on wrong MDT $mdt_idx"
16625 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
16626 error "create remote directory failed"
16627 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
16628 [ $mdt_idx -ne $MDTIDX ] &&
16629 error "create remote directory on wrong MDT $mdt_idx"
16631 createmany -o $DIR/$tdir/test_230/t- 10 ||
16632 error "create files on remote directory failed"
16633 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
16634 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
16635 rm -r $DIR/$tdir || error "unlink remote directory failed"
16637 run_test 230a "Create remote directory and files under the remote directory"
16640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16641 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16642 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16643 skip "Need MDS version at least 2.11.52"
16651 local migrate_dir=$DIR/$tdir/migrate_dir
16652 local other_dir=$DIR/$tdir/other_dir
16654 test_mkdir $DIR/$tdir
16655 test_mkdir -i0 -c1 $migrate_dir
16656 test_mkdir -i0 -c1 $other_dir
16657 for ((i=0; i<10; i++)); do
16658 mkdir -p $migrate_dir/dir_${i}
16659 createmany -o $migrate_dir/dir_${i}/f 10 ||
16660 error "create files under remote dir failed $i"
16663 cp /etc/passwd $migrate_dir/$tfile
16664 cp /etc/passwd $other_dir/$tfile
16665 chattr +SAD $migrate_dir
16666 chattr +SAD $migrate_dir/$tfile
16668 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16669 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16670 local old_dir_mode=$(stat -c%f $migrate_dir)
16671 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
16673 mkdir -p $migrate_dir/dir_default_stripe2
16674 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
16675 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
16677 mkdir -p $other_dir
16678 ln $migrate_dir/$tfile $other_dir/luna
16679 ln $migrate_dir/$tfile $migrate_dir/sofia
16680 ln $other_dir/$tfile $migrate_dir/david
16681 ln -s $migrate_dir/$tfile $other_dir/zachary
16682 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
16683 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
16685 $LFS migrate -m $MDTIDX $migrate_dir ||
16686 error "fails on migrating remote dir to MDT1"
16688 echo "migratate to MDT1, then checking.."
16689 for ((i = 0; i < 10; i++)); do
16690 for file in $(find $migrate_dir/dir_${i}); do
16691 mdt_index=$($LFS getstripe -m $file)
16692 [ $mdt_index == $MDTIDX ] ||
16693 error "$file is not on MDT${MDTIDX}"
16697 # the multiple link file should still in MDT0
16698 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
16699 [ $mdt_index == 0 ] ||
16700 error "$file is not on MDT${MDTIDX}"
16702 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16703 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16704 error " expect $old_dir_flag get $new_dir_flag"
16706 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16707 [ "$old_file_flag" = "$new_file_flag" ] ||
16708 error " expect $old_file_flag get $new_file_flag"
16710 local new_dir_mode=$(stat -c%f $migrate_dir)
16711 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16712 error "expect mode $old_dir_mode get $new_dir_mode"
16714 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16715 [ "$old_file_mode" = "$new_file_mode" ] ||
16716 error "expect mode $old_file_mode get $new_file_mode"
16718 diff /etc/passwd $migrate_dir/$tfile ||
16719 error "$tfile different after migration"
16721 diff /etc/passwd $other_dir/luna ||
16722 error "luna different after migration"
16724 diff /etc/passwd $migrate_dir/sofia ||
16725 error "sofia different after migration"
16727 diff /etc/passwd $migrate_dir/david ||
16728 error "david different after migration"
16730 diff /etc/passwd $other_dir/zachary ||
16731 error "zachary different after migration"
16733 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16734 error "${tfile}_ln different after migration"
16736 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16737 error "${tfile}_ln_other different after migration"
16739 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
16740 [ $stripe_count = 2 ] ||
16741 error "dir strpe_count $d != 2 after migration."
16743 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
16744 [ $stripe_count = 2 ] ||
16745 error "file strpe_count $d != 2 after migration."
16747 #migrate back to MDT0
16750 $LFS migrate -m $MDTIDX $migrate_dir ||
16751 error "fails on migrating remote dir to MDT0"
16753 echo "migrate back to MDT0, checking.."
16754 for file in $(find $migrate_dir); do
16755 mdt_index=$($LFS getstripe -m $file)
16756 [ $mdt_index == $MDTIDX ] ||
16757 error "$file is not on MDT${MDTIDX}"
16760 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16761 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16762 error " expect $old_dir_flag get $new_dir_flag"
16764 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16765 [ "$old_file_flag" = "$new_file_flag" ] ||
16766 error " expect $old_file_flag get $new_file_flag"
16768 local new_dir_mode=$(stat -c%f $migrate_dir)
16769 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16770 error "expect mode $old_dir_mode get $new_dir_mode"
16772 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16773 [ "$old_file_mode" = "$new_file_mode" ] ||
16774 error "expect mode $old_file_mode get $new_file_mode"
16776 diff /etc/passwd ${migrate_dir}/$tfile ||
16777 error "$tfile different after migration"
16779 diff /etc/passwd ${other_dir}/luna ||
16780 error "luna different after migration"
16782 diff /etc/passwd ${migrate_dir}/sofia ||
16783 error "sofia different after migration"
16785 diff /etc/passwd ${other_dir}/zachary ||
16786 error "zachary different after migration"
16788 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16789 error "${tfile}_ln different after migration"
16791 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16792 error "${tfile}_ln_other different after migration"
16794 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
16795 [ $stripe_count = 2 ] ||
16796 error "dir strpe_count $d != 2 after migration."
16798 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
16799 [ $stripe_count = 2 ] ||
16800 error "file strpe_count $d != 2 after migration."
16802 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16804 run_test 230b "migrate directory"
16807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16808 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16809 remote_mds_nodsh && skip "remote MDS with nodsh"
16810 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16811 skip "Need MDS version at least 2.11.52"
16817 local migrate_dir=$DIR/$tdir/migrate_dir
16819 #If migrating directory fails in the middle, all entries of
16820 #the directory is still accessiable.
16821 test_mkdir $DIR/$tdir
16822 test_mkdir -i0 -c1 $migrate_dir
16823 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
16825 createmany -o $migrate_dir/f $total ||
16826 error "create files under ${migrate_dir} failed"
16828 # fail after migrating top dir, and this will fail only once, so the
16829 # first sub file migration will fail (currently f3), others succeed.
16830 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
16831 do_facet mds1 lctl set_param fail_loc=0x1801
16832 local t=$(ls $migrate_dir | wc -l)
16833 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
16834 error "migrate should fail"
16835 local u=$(ls $migrate_dir | wc -l)
16836 [ "$u" == "$t" ] || error "$u != $t during migration"
16838 # add new dir/file should succeed
16839 mkdir $migrate_dir/dir ||
16840 error "mkdir failed under migrating directory"
16841 touch $migrate_dir/file ||
16842 error "create file failed under migrating directory"
16844 # add file with existing name should fail
16845 for file in $migrate_dir/f*; do
16846 stat $file > /dev/null || error "stat $file failed"
16847 $OPENFILE -f O_CREAT:O_EXCL $file &&
16848 error "open(O_CREAT|O_EXCL) $file should fail"
16849 $MULTIOP $file m && error "create $file should fail"
16850 touch $DIR/$tdir/remote_dir/$tfile ||
16851 error "touch $tfile failed"
16852 ln $DIR/$tdir/remote_dir/$tfile $file &&
16853 error "link $file should fail"
16854 mdt_index=$($LFS getstripe -m $file)
16855 if [ $mdt_index == 0 ]; then
16856 # file failed to migrate is not allowed to rename to
16857 mv $DIR/$tdir/remote_dir/$tfile $file &&
16858 error "rename to $file should fail"
16860 mv $DIR/$tdir/remote_dir/$tfile $file ||
16861 error "rename to $file failed"
16863 echo hello >> $file || error "write $file failed"
16866 # resume migration with different options should fail
16867 $LFS migrate -m 0 $migrate_dir &&
16868 error "migrate -m 0 $migrate_dir should fail"
16870 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
16871 error "migrate -c 2 $migrate_dir should fail"
16873 # resume migration should succeed
16874 $LFS migrate -m $MDTIDX $migrate_dir ||
16875 error "migrate $migrate_dir failed"
16877 echo "Finish migration, then checking.."
16878 for file in $(find $migrate_dir); do
16879 mdt_index=$($LFS getstripe -m $file)
16880 [ $mdt_index == $MDTIDX ] ||
16881 error "$file is not on MDT${MDTIDX}"
16884 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16886 run_test 230c "check directory accessiblity if migration failed"
16889 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16890 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16891 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16892 skip "Need MDS version at least 2.11.52"
16894 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
16896 local migrate_dir=$DIR/$tdir/migrate_dir
16906 old_index=$((RANDOM % MDSCOUNT))
16907 old_count=$((MDSCOUNT - old_index))
16908 new_index=$((RANDOM % MDSCOUNT))
16909 new_count=$((MDSCOUNT - new_index))
16910 new_hash="all_char"
16912 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
16913 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
16915 test_mkdir $DIR/$tdir
16916 test_mkdir -i $old_index -c $old_count $migrate_dir
16918 for ((i=0; i<100; i++)); do
16919 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
16920 createmany -o $migrate_dir/dir_${i}/f 100 ||
16921 error "create files under remote dir failed $i"
16924 echo -n "Migrate from MDT$old_index "
16925 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
16926 echo -n "to MDT$new_index"
16927 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
16930 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
16931 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
16932 error "migrate remote dir error"
16934 echo "Finish migration, then checking.."
16935 for file in $(find $migrate_dir); do
16936 mdt_index=$($LFS getstripe -m $file)
16937 if [ $mdt_index -lt $new_index ] ||
16938 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
16939 error "$file is on MDT$mdt_index"
16943 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16945 run_test 230d "check migrate big directory"
16948 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16949 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16950 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16951 skip "Need MDS version at least 2.11.52"
16958 mkdir -p $DIR/$tdir
16959 mkdir $DIR/$tdir/migrate_dir
16960 mkdir $DIR/$tdir/other_dir
16961 touch $DIR/$tdir/migrate_dir/a
16962 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
16963 ls $DIR/$tdir/other_dir
16965 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16966 error "migrate dir fails"
16968 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16969 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16971 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16972 [ $mdt_index == 0 ] || error "a is not on MDT0"
16974 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
16975 error "migrate dir fails"
16977 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
16978 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
16980 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16981 [ $mdt_index == 1 ] || error "a is not on MDT1"
16983 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
16984 [ $mdt_index == 1 ] || error "b is not on MDT1"
16986 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16987 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
16989 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
16991 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16993 run_test 230e "migrate mulitple local link files"
16996 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16997 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16998 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16999 skip "Need MDS version at least 2.11.52"
17004 mkdir -p $DIR/$tdir
17005 mkdir $DIR/$tdir/migrate_dir
17006 $LFS mkdir -i1 $DIR/$tdir/other_dir
17007 touch $DIR/$tdir/migrate_dir/a
17008 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
17009 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
17010 ls $DIR/$tdir/other_dir
17012 # a should be migrated to MDT1, since no other links on MDT0
17013 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17014 error "#1 migrate dir fails"
17015 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
17016 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
17017 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17018 [ $mdt_index == 1 ] || error "a is not on MDT1"
17020 # a should stay on MDT1, because it is a mulitple link file
17021 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
17022 error "#2 migrate dir fails"
17023 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17024 [ $mdt_index == 1 ] || error "a is not on MDT1"
17026 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17027 error "#3 migrate dir fails"
17029 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
17030 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
17031 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
17033 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
17034 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
17036 # a should be migrated to MDT0, since no other links on MDT1
17037 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
17038 error "#4 migrate dir fails"
17039 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17040 [ $mdt_index == 0 ] || error "a is not on MDT0"
17042 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17044 run_test 230f "migrate mulitple remote link files"
17047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17048 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17049 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17050 skip "Need MDS version at least 2.11.52"
17052 mkdir -p $DIR/$tdir/migrate_dir
17054 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
17055 error "migrating dir to non-exist MDT succeeds"
17058 run_test 230g "migrate dir to non-exist MDT"
17061 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17062 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17063 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17064 skip "Need MDS version at least 2.11.52"
17068 mkdir -p $DIR/$tdir/migrate_dir
17070 $LFS migrate -m1 $DIR &&
17071 error "migrating mountpoint1 should fail"
17073 $LFS migrate -m1 $DIR/$tdir/.. &&
17074 error "migrating mountpoint2 should fail"
17077 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
17078 error "migrating $tdir/migrate_dir/.. should fail"
17082 run_test 230h "migrate .. and root"
17085 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17086 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17087 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17088 skip "Need MDS version at least 2.11.52"
17090 mkdir -p $DIR/$tdir/migrate_dir
17092 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
17093 error "migration fails with a tailing slash"
17095 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
17096 error "migration fails with two tailing slashes"
17098 run_test 230i "lfs migrate -m tolerates trailing slashes"
17101 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17102 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17103 skip "Need MDS version at least 2.11.52"
17105 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
17106 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
17107 error "create $tfile failed"
17108 cat /etc/passwd > $DIR/$tdir/$tfile
17110 $LFS migrate -m 1 $DIR/$tdir
17112 cmp /etc/passwd $DIR/$tdir/$tfile ||
17113 error "DoM file mismatch after migration"
17115 run_test 230j "DoM file data not changed after dir migration"
17118 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
17119 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17120 skip "Need MDS version at least 2.11.56"
17123 local files_on_starting_mdt=0
17125 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
17126 $LFS getdirstripe $DIR/$tdir
17127 for i in $(seq $total); do
17128 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
17129 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
17130 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17133 echo "$files_on_starting_mdt files on MDT0"
17135 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
17136 $LFS getdirstripe $DIR/$tdir
17138 files_on_starting_mdt=0
17139 for i in $(seq $total); do
17140 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
17141 error "file $tfile.$i mismatch after migration"
17142 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
17143 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17146 echo "$files_on_starting_mdt files on MDT1 after migration"
17147 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
17149 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
17150 $LFS getdirstripe $DIR/$tdir
17152 files_on_starting_mdt=0
17153 for i in $(seq $total); do
17154 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
17155 error "file $tfile.$i mismatch after 2nd migration"
17156 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
17157 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17160 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
17161 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
17165 run_test 230k "file data not changed after dir migration"
17168 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17169 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17170 skip "Need MDS version at least 2.11.56"
17172 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
17173 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
17174 error "create files under remote dir failed $i"
17175 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
17177 run_test 230l "readdir between MDTs won't crash"
17180 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17181 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17182 skip "Need MDS version at least 2.11.56"
17185 local mig_dir=$DIR/$tdir/migrate_dir
17186 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
17190 echo "Creating files and dirs with xattrs"
17191 test_mkdir $DIR/$tdir
17192 test_mkdir -i0 -c1 $mig_dir
17194 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
17195 error "cannot set xattr attr1 on dir"
17196 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
17197 error "cannot set xattr attr2 on dir"
17198 touch $mig_dir/dir/f0
17199 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
17200 error "cannot set xattr attr1 on file"
17201 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
17202 error "cannot set xattr attr2 on file"
17203 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
17204 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
17205 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
17206 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
17207 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
17208 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
17209 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
17210 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
17211 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
17213 echo "Migrating to MDT1"
17214 $LFS migrate -m $MDTIDX $mig_dir ||
17215 error "fails on migrating dir to MDT1"
17217 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
17218 echo "Checking xattrs"
17219 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
17220 [ "$val" = $longstr ] ||
17221 error "expecting xattr1 $longstr on dir, found $val"
17222 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
17223 [ "$val" = $shortstr ] ||
17224 error "expecting xattr2 $shortstr on dir, found $val"
17225 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
17226 [ "$val" = $longstr ] ||
17227 error "expecting xattr1 $longstr on file, found $val"
17228 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
17229 [ "$val" = $shortstr ] ||
17230 error "expecting xattr2 $shortstr on file, found $val"
17232 run_test 230m "xattrs not changed after dir migration"
17236 # For simplicity this test assumes that max_pages_per_rpc
17237 # is the same across all OSCs
17238 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
17239 local bulk_size=$((max_pages * PAGE_SIZE))
17240 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
17243 mkdir -p $DIR/$tdir
17244 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
17245 error "failed to set stripe with -S ${brw_size}M option"
17247 # clear the OSC stats
17248 $LCTL set_param osc.*.stats=0 &>/dev/null
17251 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
17252 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
17253 oflag=direct &>/dev/null || error "dd failed"
17255 sync; sleep 1; sync # just to be safe
17256 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
17257 if [ x$nrpcs != "x1" ]; then
17258 $LCTL get_param osc.*.stats
17259 error "found $nrpcs ost_write RPCs, not 1 as expected"
17263 # Drop the OSC cache, otherwise we will read from it
17264 cancel_lru_locks osc
17266 # clear the OSC stats
17267 $LCTL set_param osc.*.stats=0 &>/dev/null
17269 # Client reads $bulk_size.
17270 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
17271 iflag=direct &>/dev/null || error "dd failed"
17273 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
17274 if [ x$nrpcs != "x1" ]; then
17275 $LCTL get_param osc.*.stats
17276 error "found $nrpcs ost_read RPCs, not 1 as expected"
17279 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
17282 mkdir -p $DIR/$tdir
17284 for i in {0..1023}; do
17285 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
17286 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
17287 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
17291 run_test 231b "must not assert on fully utilized OST request buffer"
17294 mkdir -p $DIR/$tdir
17295 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
17297 #define OBD_FAIL_LDLM_OST_LVB 0x31c
17298 do_facet ost1 $LCTL set_param fail_loc=0x31c
17300 # ignore dd failure
17301 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
17303 do_facet ost1 $LCTL set_param fail_loc=0
17304 umount_client $MOUNT || error "umount failed"
17305 mount_client $MOUNT || error "mount failed"
17306 stop ost1 || error "cannot stop ost1"
17307 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
17309 run_test 232a "failed lock should not block umount"
17312 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
17313 skip "Need MDS version at least 2.10.58"
17315 mkdir -p $DIR/$tdir
17316 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
17317 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
17319 cancel_lru_locks osc
17321 #define OBD_FAIL_LDLM_OST_LVB 0x31c
17322 do_facet ost1 $LCTL set_param fail_loc=0x31c
17325 $LFS data_version $DIR/$tdir/$tfile || true
17327 do_facet ost1 $LCTL set_param fail_loc=0
17328 umount_client $MOUNT || error "umount failed"
17329 mount_client $MOUNT || error "mount failed"
17330 stop ost1 || error "cannot stop ost1"
17331 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
17333 run_test 232b "failed data version lock should not block umount"
17336 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
17337 skip "Need MDS version at least 2.3.64"
17338 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
17340 local fid=$($LFS path2fid $MOUNT)
17342 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17343 error "cannot access $MOUNT using its FID '$fid'"
17345 run_test 233a "checking that OBF of the FS root succeeds"
17348 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
17349 skip "Need MDS version at least 2.5.90"
17350 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
17352 local fid=$($LFS path2fid $MOUNT/.lustre)
17354 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17355 error "cannot access $MOUNT/.lustre using its FID '$fid'"
17357 fid=$($LFS path2fid $MOUNT/.lustre/fid)
17358 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17359 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
17361 run_test 233b "checking that OBF of the FS .lustre succeeds"
17364 local p="$TMP/sanityN-$TESTNAME.parameters"
17365 save_lustre_params client "llite.*.xattr_cache" > $p
17366 lctl set_param llite.*.xattr_cache 1 ||
17367 skip_env "xattr cache is not supported"
17369 mkdir -p $DIR/$tdir || error "mkdir failed"
17370 touch $DIR/$tdir/$tfile || error "touch failed"
17371 # OBD_FAIL_LLITE_XATTR_ENOMEM
17372 $LCTL set_param fail_loc=0x1405
17373 getfattr -n user.attr $DIR/$tdir/$tfile &&
17374 error "getfattr should have failed with ENOMEM"
17375 $LCTL set_param fail_loc=0x0
17378 restore_lustre_params < $p
17381 run_test 234 "xattr cache should not crash on ENOMEM"
17384 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
17385 skip "Need MDS version at least 2.4.52"
17387 flock_deadlock $DIR/$tfile
17392 124) error "process hangs on a deadlock"
17394 *) error "error executing flock_deadlock $DIR/$tfile"
17398 run_test 235 "LU-1715: flock deadlock detection does not work properly"
17402 check_swap_layouts_support
17404 local ref1=/etc/passwd
17405 local ref2=/etc/group
17406 local file1=$DIR/$tdir/f1
17407 local file2=$DIR/$tdir/f2
17409 test_mkdir -c1 $DIR/$tdir
17410 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
17411 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
17412 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
17413 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
17414 local fd=$(free_fd)
17415 local cmd="exec $fd<>$file2"
17418 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
17419 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
17422 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
17427 run_test 236 "Layout swap on open unlinked file"
17429 # LU-4659 linkea consistency
17431 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
17432 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
17433 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
17434 skip "Need MDS version at least 2.5.58 or 2.5.2+"
17437 ln $DIR/$tfile $DIR/$tfile.lnk
17438 touch $DIR/$tfile.new
17439 mv $DIR/$tfile.new $DIR/$tfile
17440 local fid1=$($LFS path2fid $DIR/$tfile)
17441 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
17442 local path1=$($LFS fid2path $FSNAME "$fid1")
17443 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
17444 local path2=$($LFS fid2path $FSNAME "$fid2")
17445 [ $tfile.lnk == $path2 ] ||
17446 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
17449 run_test 238 "Verify linkea consistency"
17451 test_239A() { # was test_239
17452 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
17453 skip "Need MDS version at least 2.5.60"
17455 local list=$(comma_list $(mdts_nodes))
17457 mkdir -p $DIR/$tdir
17458 createmany -o $DIR/$tdir/f- 5000
17459 unlinkmany $DIR/$tdir/f- 5000
17460 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
17461 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
17462 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
17463 osp.*MDT*.sync_in_flight" | calc_sum)
17464 [ "$changes" -eq 0 ] || error "$changes not synced"
17466 run_test 239A "osp_sync test"
17468 test_239a() { #LU-5297
17469 remote_mds_nodsh && skip "remote MDS with nodsh"
17472 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
17473 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
17474 chgrp $RUNAS_GID $DIR/$tfile
17475 wait_delete_completed
17477 run_test 239a "process invalid osp sync record correctly"
17479 test_239b() { #LU-5297
17480 remote_mds_nodsh && skip "remote MDS with nodsh"
17483 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
17484 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
17485 chgrp $RUNAS_GID $DIR/$tfile1
17486 wait_delete_completed
17487 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17489 chgrp $RUNAS_GID $DIR/$tfile2
17490 wait_delete_completed
17492 run_test 239b "process osp sync record with ENOMEM error correctly"
17495 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17496 remote_mds_nodsh && skip "remote MDS with nodsh"
17498 mkdir -p $DIR/$tdir
17500 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
17501 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
17502 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
17503 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
17505 umount_client $MOUNT || error "umount failed"
17506 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
17507 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
17508 mount_client $MOUNT || error "failed to mount client"
17510 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
17511 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
17513 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
17519 for LOOP in $(seq $count); do
17520 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
17521 cancel_lru_locks $OSC || true
17529 for LOOP in $(seq $1); do
17530 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
17535 test_241a() { # was test_241
17536 local bsize=$PAGE_SIZE
17538 (( bsize < 40960 )) && bsize=40960
17539 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17541 cancel_lru_locks $OSC
17542 test_241_bio 1000 $bsize &
17544 test_241_dio 1000 $bsize
17547 run_test 241a "bio vs dio"
17550 local bsize=$PAGE_SIZE
17552 (( bsize < 40960 )) && bsize=40960
17553 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17555 test_241_dio 1000 $bsize &
17557 test_241_dio 1000 $bsize
17560 run_test 241b "dio vs dio"
17563 remote_mds_nodsh && skip "remote MDS with nodsh"
17565 mkdir -p $DIR/$tdir
17566 touch $DIR/$tdir/$tfile
17568 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
17569 do_facet mds1 lctl set_param fail_loc=0x105
17570 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
17572 do_facet mds1 lctl set_param fail_loc=0
17573 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
17575 run_test 242 "mdt_readpage failure should not cause directory unreadable"
17579 test_mkdir $DIR/$tdir
17580 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
17582 run_test 243 "various group lock tests"
17586 test_mkdir $DIR/$tdir
17587 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
17588 sendfile_grouplock $DIR/$tdir/$tfile || \
17589 error "sendfile+grouplock failed"
17592 run_test 244a "sendfile with group lock tests"
17596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17599 local size=$((1024*1024))
17601 test_mkdir $DIR/$tdir
17602 for i in $(seq 1 $threads); do
17603 local file=$DIR/$tdir/file_$((i / 10))
17604 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
17607 for i in $(seq 1 $threads); do
17611 run_test 244b "multi-threaded write with group lock"
17614 local flagname="multi_mod_rpcs"
17615 local connect_data_name="max_mod_rpcs"
17618 # check if multiple modify RPCs flag is set
17619 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
17620 grep "connect_flags:")
17623 echo "$out" | grep -qw $flagname
17624 if [ $? -ne 0 ]; then
17625 echo "connect flag $flagname is not set"
17629 # check if multiple modify RPCs data is set
17630 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
17633 echo "$out" | grep -qw $connect_data_name ||
17634 error "import should have connect data $connect_data_name"
17636 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
17642 umount_client $submount
17647 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17649 skip_env "Fileset feature is not supported"
17651 local submount=${MOUNT}_$tdir
17654 mkdir -p $submount || error "mkdir $submount failed"
17655 FILESET="$FILESET/$tdir" mount_client $submount ||
17656 error "mount $submount failed"
17657 trap "cleanup_247 $submount" EXIT
17658 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
17659 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
17660 error "read $MOUNT/$tdir/$tfile failed"
17661 cleanup_247 $submount
17663 run_test 247a "mount subdir as fileset"
17666 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17667 skip_env "Fileset feature is not supported"
17669 local submount=${MOUNT}_$tdir
17671 rm -rf $MOUNT/$tdir
17672 mkdir -p $submount || error "mkdir $submount failed"
17674 FILESET="$FILESET/$tdir" mount_client $submount &&
17675 error "mount $submount should fail"
17678 run_test 247b "mount subdir that dose not exist"
17681 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17682 skip_env "Fileset feature is not supported"
17684 local submount=${MOUNT}_$tdir
17686 mkdir -p $MOUNT/$tdir/dir1
17687 mkdir -p $submount || error "mkdir $submount failed"
17688 trap "cleanup_247 $submount" EXIT
17689 FILESET="$FILESET/$tdir" mount_client $submount ||
17690 error "mount $submount failed"
17691 local fid=$($LFS path2fid $MOUNT/)
17692 $LFS fid2path $submount $fid && error "fid2path should fail"
17693 cleanup_247 $submount
17695 run_test 247c "running fid2path outside root"
17698 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17699 skip "Fileset feature is not supported"
17701 local submount=${MOUNT}_$tdir
17703 mkdir -p $MOUNT/$tdir/dir1
17704 mkdir -p $submount || error "mkdir $submount failed"
17705 FILESET="$FILESET/$tdir" mount_client $submount ||
17706 error "mount $submount failed"
17707 trap "cleanup_247 $submount" EXIT
17708 local fid=$($LFS path2fid $submount/dir1)
17709 $LFS fid2path $submount $fid || error "fid2path should succeed"
17710 cleanup_247 $submount
17712 run_test 247d "running fid2path inside root"
17716 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17718 skip "Fileset feature is not supported"
17720 local submount=${MOUNT}_$tdir
17723 mkdir -p $submount || error "mkdir $submount failed"
17724 FILESET="$FILESET/.." mount_client $submount &&
17725 error "mount $submount should fail"
17728 run_test 247e "mount .. as fileset"
17731 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
17732 [ -z "$fast_read_sav" ] && skip "no fast read support"
17734 # create a large file for fast read verification
17735 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
17737 # make sure the file is created correctly
17738 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
17739 { rm -f $DIR/$tfile; skip "file creation error"; }
17741 echo "Test 1: verify that fast read is 4 times faster on cache read"
17743 # small read with fast read enabled
17744 $LCTL set_param -n llite.*.fast_read=1
17745 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17746 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17747 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17748 # small read with fast read disabled
17749 $LCTL set_param -n llite.*.fast_read=0
17750 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17751 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17752 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17754 # verify that fast read is 4 times faster for cache read
17755 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
17756 error_not_in_vm "fast read was not 4 times faster: " \
17757 "$t_fast vs $t_slow"
17759 echo "Test 2: verify the performance between big and small read"
17760 $LCTL set_param -n llite.*.fast_read=1
17762 # 1k non-cache read
17763 cancel_lru_locks osc
17764 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17765 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17766 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17768 # 1M non-cache read
17769 cancel_lru_locks osc
17770 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17771 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17772 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17774 # verify that big IO is not 4 times faster than small IO
17775 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
17776 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
17778 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
17781 run_test 248a "fast read verification"
17784 # Default short_io_bytes=16384, try both smaller and larger sizes.
17785 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
17786 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
17787 echo "bs=53248 count=113 normal buffered write"
17788 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
17789 error "dd of initial data file failed"
17790 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
17792 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
17793 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
17794 error "dd with sync normal writes failed"
17795 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
17797 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
17798 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
17799 error "dd with sync small writes failed"
17800 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
17802 cancel_lru_locks osc
17804 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
17805 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
17806 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
17807 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
17808 iflag=direct || error "dd with O_DIRECT small read failed"
17809 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
17810 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
17811 error "compare $TMP/$tfile.1 failed"
17813 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
17814 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
17816 # just to see what the maximum tunable value is, and test parsing
17817 echo "test invalid parameter 2MB"
17818 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
17819 error "too-large short_io_bytes allowed"
17820 echo "test maximum parameter 512KB"
17821 # if we can set a larger short_io_bytes, run test regardless of version
17822 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
17823 # older clients may not allow setting it this large, that's OK
17824 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
17825 skip "Need at least client version 2.13.50"
17826 error "medium short_io_bytes failed"
17828 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
17829 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
17831 echo "test large parameter 64KB"
17832 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
17833 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
17835 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
17836 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
17837 error "dd with sync large writes failed"
17838 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
17840 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
17841 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
17842 num=$((113 * 4096 / PAGE_SIZE))
17843 echo "bs=$size count=$num oflag=direct large write $tfile.3"
17844 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
17845 error "dd with O_DIRECT large writes failed"
17846 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
17847 error "compare $DIR/$tfile.3 failed"
17849 cancel_lru_locks osc
17851 echo "bs=$size count=$num iflag=direct large read $tfile.2"
17852 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
17853 error "dd with O_DIRECT large read failed"
17854 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
17855 error "compare $TMP/$tfile.2 failed"
17857 echo "bs=$size count=$num iflag=direct large read $tfile.3"
17858 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
17859 error "dd with O_DIRECT large read failed"
17860 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
17861 error "compare $TMP/$tfile.3 failed"
17863 run_test 248b "test short_io read and write for both small and large sizes"
17865 test_249() { # LU-7890
17866 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
17867 skip "Need at least version 2.8.54"
17870 $LFS setstripe -c 1 $DIR/$tfile
17871 # Offset 2T == 4k * 512M
17872 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
17873 error "dd to 2T offset failed"
17875 run_test 249 "Write above 2T file size"
17878 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
17879 && skip "no 16TB file size limit on ZFS"
17881 $LFS setstripe -c 1 $DIR/$tfile
17882 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
17883 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
17884 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
17885 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
17886 conv=notrunc,fsync && error "append succeeded"
17889 run_test 250 "Write above 16T limit"
17892 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
17894 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
17895 #Skip once - writing the first stripe will succeed
17896 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17897 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
17898 error "short write happened"
17900 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17901 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
17902 error "short read happened"
17906 run_test 251 "Handling short read and write correctly"
17909 remote_mds_nodsh && skip "remote MDS with nodsh"
17910 remote_ost_nodsh && skip "remote OST with nodsh"
17911 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
17912 skip_env "ldiskfs only test"
17922 # check lr_reader on OST0000
17924 dev=$(facet_device $tgt)
17925 out=$(do_facet $tgt $LR_READER $dev)
17926 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17928 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
17929 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
17930 error "Invalid uuid returned by $LR_READER on target $tgt"
17931 echo -e "uuid returned by $LR_READER is '$uuid'\n"
17933 # check lr_reader -c on MDT0000
17935 dev=$(facet_device $tgt)
17936 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
17937 skip "$LR_READER does not support additional options"
17939 out=$(do_facet $tgt $LR_READER -c $dev)
17940 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17942 num=$(echo "$out" | grep -c "mdtlov")
17943 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
17944 error "Invalid number of mdtlov clients returned by $LR_READER"
17945 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
17947 # check lr_reader -cr on MDT0000
17948 out=$(do_facet $tgt $LR_READER -cr $dev)
17949 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17951 echo "$out" | grep -q "^reply_data:$" ||
17952 error "$LR_READER should have returned 'reply_data' section"
17953 num=$(echo "$out" | grep -c "client_generation")
17954 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
17956 run_test 252 "check lr_reader tool"
17959 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17960 remote_mds_nodsh && skip "remote MDS with nodsh"
17961 remote_mgs_nodsh && skip "remote MGS with nodsh"
17965 local ost_name=$(ostname_from_index $ostidx)
17968 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
17969 do_facet $SINGLEMDS $LCTL get_param -n \
17970 osp.$mdtosc_proc1.reserved_mb_high ||
17971 skip "remote MDS does not support reserved_mb_high"
17975 wait_delete_completed
17978 pool_add $TESTNAME || error "Pool creation failed"
17979 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
17981 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
17982 error "Setstripe failed"
17984 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
17986 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
17988 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
17990 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17991 osp.$mdtosc_proc1.prealloc_status)
17992 echo "prealloc_status $oa_status"
17994 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
17995 error "File creation should fail"
17997 #object allocation was stopped, but we still able to append files
17998 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
17999 oflag=append || error "Append failed"
18001 rm -f $DIR/$tdir/$tfile.0
18003 # For this test, we want to delete the files we created to go out of
18004 # space but leave the watermark, so we remain nearly out of space
18005 ost_watermarks_enospc_delete_files $tfile $ostidx
18007 wait_delete_completed
18011 for i in $(seq 10 12); do
18012 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
18013 2>/dev/null || error "File creation failed after rm"
18016 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
18017 osp.$mdtosc_proc1.prealloc_status)
18018 echo "prealloc_status $oa_status"
18020 if (( oa_status != 0 )); then
18021 error "Object allocation still disable after rm"
18024 run_test 253 "Check object allocation limit"
18027 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18028 remote_mds_nodsh && skip "remote MDS with nodsh"
18029 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
18030 skip "MDS does not support changelog_size"
18033 local MDT0=$(facet_svc $SINGLEMDS)
18035 changelog_register || error "changelog_register failed"
18037 changelog_clear 0 || error "changelog_clear failed"
18039 local size1=$(do_facet $SINGLEMDS \
18040 $LCTL get_param -n mdd.$MDT0.changelog_size)
18041 echo "Changelog size $size1"
18044 $LFS mkdir -i 0 $DIR/$tdir
18046 mkdir -p $DIR/$tdir/pics/2008/zachy
18047 touch $DIR/$tdir/pics/2008/zachy/timestamp
18048 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
18049 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
18050 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
18051 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
18052 rm $DIR/$tdir/pics/desktop.jpg
18054 local size2=$(do_facet $SINGLEMDS \
18055 $LCTL get_param -n mdd.$MDT0.changelog_size)
18056 echo "Changelog size after work $size2"
18058 (( $size2 > $size1 )) ||
18059 error "new Changelog size=$size2 less than old size=$size1"
18061 run_test 254 "Check changelog size"
18068 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
18069 awk -F: '{print $2}' | grep $type > /dev/null
18070 if [ $? -ne 0 ]; then
18080 lfs ladvise -a willread $file > /dev/null 2>&1
18081 if [ $? -eq 0 ]; then
18085 lfs ladvise -a willread $file 2>&1 |
18086 grep "Inappropriate ioctl for device" > /dev/null
18087 if [ $? -eq 0 ]; then
18094 bc <<<"scale=2; ($1 - $2) * 100 / $2"
18097 # run a random read IO workload
18098 # usage: random_read_iops <filename> <filesize> <iosize>
18099 random_read_iops() {
18102 local iosize=${3:-4096}
18104 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
18105 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
18108 drop_file_oss_cache() {
18112 $LFS ladvise -a dontneed $file 2>/dev/null ||
18113 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
18116 ladvise_willread_performance()
18119 local average_origin=0
18120 local average_cache=0
18121 local average_ladvise=0
18123 for ((i = 1; i <= $repeat; i++)); do
18124 echo "Iter $i/$repeat: reading without willread hint"
18125 cancel_lru_locks osc
18126 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
18127 local speed_origin=$(random_read_iops $DIR/$tfile $size)
18128 echo "Iter $i/$repeat: uncached speed: $speed_origin"
18129 average_origin=$(bc <<<"$average_origin + $speed_origin")
18131 cancel_lru_locks osc
18132 local speed_cache=$(random_read_iops $DIR/$tfile $size)
18133 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
18134 average_cache=$(bc <<<"$average_cache + $speed_cache")
18136 cancel_lru_locks osc
18137 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
18138 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
18139 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
18140 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
18141 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
18143 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
18144 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
18145 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
18147 speedup_cache=$(percent $average_cache $average_origin)
18148 speedup_ladvise=$(percent $average_ladvise $average_origin)
18150 echo "Average uncached read: $average_origin"
18151 echo "Average speedup with OSS cached read: " \
18152 "$average_cache = +$speedup_cache%"
18153 echo "Average speedup with ladvise willread: " \
18154 "$average_ladvise = +$speedup_ladvise%"
18156 local lowest_speedup=20
18157 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
18158 echo "Speedup with OSS cached read less than $lowest_speedup%," \
18159 "got $average_cache%. Skipping ladvise willread check."
18163 # the test won't work on ZFS until it supports 'ladvise dontneed', but
18164 # it is still good to run until then to exercise 'ladvise willread'
18165 ! $LFS ladvise -a dontneed $DIR/$tfile &&
18166 [ "$ost1_FSTYPE" = "zfs" ] &&
18167 echo "osd-zfs does not support dontneed or drop_caches" &&
18170 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
18171 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
18172 error_not_in_vm "Speedup with willread is less than " \
18173 "$lowest_speedup%, got $average_ladvise%"
18177 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
18178 skip "lustre < 2.8.54 does not support ladvise "
18179 remote_ost_nodsh && skip "remote OST with nodsh"
18181 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
18183 ladvise_no_type willread $DIR/$tfile &&
18184 skip "willread ladvise is not supported"
18186 ladvise_no_ioctl $DIR/$tfile &&
18187 skip "ladvise ioctl is not supported"
18190 local size=$((size_mb * 1048576))
18191 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
18192 error "dd to $DIR/$tfile failed"
18194 lfs ladvise -a willread $DIR/$tfile ||
18195 error "Ladvise failed with no range argument"
18197 lfs ladvise -a willread -s 0 $DIR/$tfile ||
18198 error "Ladvise failed with no -l or -e argument"
18200 lfs ladvise -a willread -e 1 $DIR/$tfile ||
18201 error "Ladvise failed with only -e argument"
18203 lfs ladvise -a willread -l 1 $DIR/$tfile ||
18204 error "Ladvise failed with only -l argument"
18206 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
18207 error "End offset should not be smaller than start offset"
18209 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
18210 error "End offset should not be equal to start offset"
18212 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
18213 error "Ladvise failed with overflowing -s argument"
18215 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
18216 error "Ladvise failed with overflowing -e argument"
18218 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
18219 error "Ladvise failed with overflowing -l argument"
18221 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
18222 error "Ladvise succeeded with conflicting -l and -e arguments"
18224 echo "Synchronous ladvise should wait"
18226 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
18227 do_nodes $(comma_list $(osts_nodes)) \
18228 $LCTL set_param fail_val=$delay fail_loc=0x237
18230 local start_ts=$SECONDS
18231 lfs ladvise -a willread $DIR/$tfile ||
18232 error "Ladvise failed with no range argument"
18233 local end_ts=$SECONDS
18234 local inteval_ts=$((end_ts - start_ts))
18236 if [ $inteval_ts -lt $(($delay - 1)) ]; then
18237 error "Synchronous advice didn't wait reply"
18240 echo "Asynchronous ladvise shouldn't wait"
18241 local start_ts=$SECONDS
18242 lfs ladvise -a willread -b $DIR/$tfile ||
18243 error "Ladvise failed with no range argument"
18244 local end_ts=$SECONDS
18245 local inteval_ts=$((end_ts - start_ts))
18247 if [ $inteval_ts -gt $(($delay / 2)) ]; then
18248 error "Asynchronous advice blocked"
18251 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
18252 ladvise_willread_performance
18254 run_test 255a "check 'lfs ladvise -a willread'"
18260 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
18264 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
18265 skip "lustre < 2.8.54 does not support ladvise "
18266 remote_ost_nodsh && skip "remote OST with nodsh"
18268 lfs setstripe -c 1 -i 0 $DIR/$tfile
18270 ladvise_no_type dontneed $DIR/$tfile &&
18271 skip "dontneed ladvise is not supported"
18273 ladvise_no_ioctl $DIR/$tfile &&
18274 skip "ladvise ioctl is not supported"
18276 ! $LFS ladvise -a dontneed $DIR/$tfile &&
18277 [ "$ost1_FSTYPE" = "zfs" ] &&
18278 skip "zfs-osd does not support 'ladvise dontneed'"
18281 local size=$((size_mb * 1048576))
18282 # In order to prevent disturbance of other processes, only check 3/4
18283 # of the memory usage
18284 local kibibytes=$((size_mb * 1024 * 3 / 4))
18286 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
18287 error "dd to $DIR/$tfile failed"
18289 #force write to complete before dropping OST cache & checking memory
18292 local total=$(facet_meminfo ost1 MemTotal)
18293 echo "Total memory: $total KiB"
18295 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
18296 local before_read=$(facet_meminfo ost1 Cached)
18297 echo "Cache used before read: $before_read KiB"
18299 lfs ladvise -a willread $DIR/$tfile ||
18300 error "Ladvise willread failed"
18301 local after_read=$(facet_meminfo ost1 Cached)
18302 echo "Cache used after read: $after_read KiB"
18304 lfs ladvise -a dontneed $DIR/$tfile ||
18305 error "Ladvise dontneed again failed"
18306 local no_read=$(facet_meminfo ost1 Cached)
18307 echo "Cache used after dontneed ladvise: $no_read KiB"
18309 if [ $total -lt $((before_read + kibibytes)) ]; then
18310 echo "Memory is too small, abort checking"
18314 if [ $((before_read + kibibytes)) -gt $after_read ]; then
18315 error "Ladvise willread should use more memory" \
18316 "than $kibibytes KiB"
18319 if [ $((no_read + kibibytes)) -gt $after_read ]; then
18320 error "Ladvise dontneed should release more memory" \
18321 "than $kibibytes KiB"
18324 run_test 255b "check 'lfs ladvise -a dontneed'"
18327 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
18328 skip "lustre < 2.10.50 does not support lockahead"
18336 test_mkdir -p $DIR/$tdir
18337 $LFS setstripe -i 0 -c 1 $DIR/$tdir
18339 #test 10 returns only success/failure
18341 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18343 if [ $rc -eq 255 ]; then
18344 error "Ladvise test${i} failed, ${rc}"
18347 #test 11 counts lock enqueue requests, all others count new locks
18349 count=$(do_facet ost1 \
18350 $LCTL get_param -n ost.OSS.ost.stats)
18351 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
18353 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18355 if [ $rc -eq 255 ]; then
18356 error "Ladvise test${i} failed, ${rc}"
18359 new_count=$(do_facet ost1 \
18360 $LCTL get_param -n ost.OSS.ost.stats)
18361 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
18362 awk '{ print $2 }')
18364 difference="$((new_count - count))"
18365 if [ $difference -ne $rc ]; then
18366 error "Ladvise test${i}, bad enqueue count, returned " \
18367 "${rc}, actual ${difference}"
18370 for i in $(seq 12 21); do
18371 # If we do not do this, we run the risk of having too many
18372 # locks and starting lock cancellation while we are checking
18374 cancel_lru_locks osc
18376 count=$($LCTL get_param -n \
18377 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
18379 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18381 if [ $rc -eq 255 ]; then
18382 error "Ladvise test ${i} failed, ${rc}"
18385 new_count=$($LCTL get_param -n \
18386 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
18387 difference="$((new_count - count))"
18389 # Test 15 output is divided by 100 to map down to valid return
18390 if [ $i -eq 15 ]; then
18394 if [ $difference -ne $rc ]; then
18395 error "Ladvise test ${i}, bad lock count, returned " \
18396 "${rc}, actual ${difference}"
18400 #test 22 returns only success/failure
18402 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18404 if [ $rc -eq 255 ]; then
18405 error "Ladvise test${i} failed, ${rc}"
18408 run_test 255c "suite of ladvise lockahead tests"
18411 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18412 remote_mds_nodsh && skip "remote MDS with nodsh"
18413 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18414 changelog_users $SINGLEMDS | grep "^cl" &&
18415 skip "active changelog user"
18421 mdt_dev=$(mdsdevname 1)
18424 changelog_register || error "changelog_register failed"
18427 mkdir -p $DIR/$tdir
18429 changelog_clear 0 || error "changelog_clear failed"
18432 touch $DIR/$tdir/{1..10}
18435 stop $SINGLEMDS || error "Fail to stop MDT"
18439 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
18441 #after mount new plainllog is used
18442 touch $DIR/$tdir/{11..19}
18443 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
18444 stack_trap "rm -f $tmpfile"
18445 cat_sl=$(do_facet $SINGLEMDS "sync; \
18446 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
18447 llog_reader $tmpfile | grep -c type=1064553b")
18448 do_facet $SINGLEMDS llog_reader $tmpfile
18450 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
18452 changelog_clear 0 || error "changelog_clear failed"
18454 cat_sl=$(do_facet $SINGLEMDS "sync; \
18455 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
18456 llog_reader $tmpfile | grep -c type=1064553b")
18458 if (( cat_sl == 2 )); then
18459 error "Empty plain llog was not deleted from changelog catalog"
18460 elif (( cat_sl != 1 )); then
18461 error "Active plain llog shouldn't be deleted from catalog"
18464 run_test 256 "Check llog delete for empty and not full state"
18467 remote_mds_nodsh && skip "remote MDS with nodsh"
18468 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
18469 skip "Need MDS version at least 2.8.55"
18471 test_mkdir $DIR/$tdir
18473 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
18474 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
18477 #define OBD_FAIL_MDS_XATTR_REP 0x161
18478 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18479 local facet=mds$((mdtidx + 1))
18480 set_nodes_failloc $(facet_active_host $facet) 0x80000161
18481 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
18483 stop $facet || error "stop MDS failed"
18484 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
18485 error "start MDS fail"
18486 wait_recovery_complete $facet
18488 run_test 257 "xattr locks are not lost"
18490 # Verify we take the i_mutex when security requires it
18492 #define OBD_FAIL_IMUTEX_SEC 0x141c
18493 $LCTL set_param fail_loc=0x141c
18495 chmod u+s $DIR/$tfile
18496 chmod a+rwx $DIR/$tfile
18497 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18499 if [ $RC -ne 0 ]; then
18500 error "error, failed to take i_mutex, rc=$?"
18504 run_test 258a "verify i_mutex security behavior when suid attributes is set"
18506 # Verify we do NOT take the i_mutex in the normal case
18508 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
18509 $LCTL set_param fail_loc=0x141d
18512 chmod a+rw $DIR/$tfile
18513 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18515 if [ $RC -ne 0 ]; then
18516 error "error, took i_mutex unnecessarily, rc=$?"
18521 run_test 258b "verify i_mutex security behavior"
18524 local file=$DIR/$tfile
18528 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18530 stack_trap "rm -f $file" EXIT
18532 wait_delete_completed
18533 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18534 echo "before: $before"
18536 $LFS setstripe -i 0 -c 1 $file
18537 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
18539 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18540 echo "after write: $after"
18542 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
18543 do_facet ost1 $LCTL set_param fail_loc=0x2301
18545 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18546 echo "after truncate: $after"
18549 do_facet ost1 $LCTL set_param fail_loc=0
18550 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18552 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18553 echo "after restart: $after"
18554 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
18555 error "missing truncate?"
18559 run_test 259 "crash at delayed truncate"
18562 #define OBD_FAIL_MDC_CLOSE 0x806
18563 $LCTL set_param fail_loc=0x80000806
18567 run_test 260 "Check mdc_close fail"
18569 ### Data-on-MDT sanity tests ###
18571 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18572 skip "Need MDS version at least 2.10.55 for DoM"
18575 local dom=$DIR/$tdir/dom_file
18576 local tmp=$DIR/$tdir/tmp_file
18578 mkdir -p $DIR/$tdir
18580 # basic checks for DoM component creation
18581 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
18582 error "Can set MDT layout to non-first entry"
18584 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
18585 error "Can define multiple entries as MDT layout"
18587 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
18589 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
18590 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
18591 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
18593 local mdtidx=$($LFS getstripe -m $dom)
18594 local mdtname=MDT$(printf %04x $mdtidx)
18595 local facet=mds$((mdtidx + 1))
18596 local space_check=1
18598 # Skip free space checks with ZFS
18599 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
18603 local size_tmp=$((65536 * 3))
18604 local mdtfree1=$(do_facet $facet \
18605 lctl get_param -n osd*.*$mdtname.kbytesfree)
18607 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18608 # check also direct IO along write
18609 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
18610 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18612 cmp $tmp $dom || error "file data is different"
18613 [ $(stat -c%s $dom) == $size_tmp ] ||
18614 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18615 if [ $space_check == 1 ]; then
18616 local mdtfree2=$(do_facet $facet \
18617 lctl get_param -n osd*.*$mdtname.kbytesfree)
18619 # increase in usage from by $size_tmp
18620 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18621 error "MDT free space wrong after write: " \
18622 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18626 local size_dom=10000
18628 $TRUNCATE $dom $size_dom
18629 [ $(stat -c%s $dom) == $size_dom ] ||
18630 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
18631 if [ $space_check == 1 ]; then
18632 mdtfree1=$(do_facet $facet \
18633 lctl get_param -n osd*.*$mdtname.kbytesfree)
18634 # decrease in usage from $size_tmp to new $size_dom
18635 [ $(($mdtfree1 - $mdtfree2)) -ge \
18636 $(((size_tmp - size_dom) / 1024)) ] ||
18637 error "MDT free space is wrong after truncate: " \
18638 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
18644 size_dom=$((size_dom + size_tmp))
18645 [ $(stat -c%s $dom) == $size_dom ] ||
18646 error "bad size after append: $(stat -c%s $dom) != $size_dom"
18647 if [ $space_check == 1 ]; then
18648 mdtfree2=$(do_facet $facet \
18649 lctl get_param -n osd*.*$mdtname.kbytesfree)
18650 # increase in usage by $size_tmp from previous
18651 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18652 error "MDT free space is wrong after append: " \
18653 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18658 if [ $space_check == 1 ]; then
18659 mdtfree1=$(do_facet $facet \
18660 lctl get_param -n osd*.*$mdtname.kbytesfree)
18661 # decrease in usage by $size_dom from previous
18662 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
18663 error "MDT free space is wrong after removal: " \
18664 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
18667 # combined striping
18668 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
18669 error "Can't create DoM + OST striping"
18671 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
18672 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18673 # check also direct IO along write
18674 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18676 cmp $tmp $dom || error "file data is different"
18677 [ $(stat -c%s $dom) == $size_tmp ] ||
18678 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18683 run_test 270a "DoM: basic functionality tests"
18686 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18687 skip "Need MDS version at least 2.10.55"
18689 local dom=$DIR/$tdir/dom_file
18690 local max_size=1048576
18692 mkdir -p $DIR/$tdir
18693 $LFS setstripe -E $max_size -L mdt $dom
18695 # truncate over the limit
18696 $TRUNCATE $dom $(($max_size + 1)) &&
18697 error "successful truncate over the maximum size"
18698 # write over the limit
18699 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
18700 error "successful write over the maximum size"
18701 # append over the limit
18702 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
18703 echo "12345" >> $dom && error "successful append over the maximum size"
18708 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
18711 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18712 skip "Need MDS version at least 2.10.55"
18714 mkdir -p $DIR/$tdir
18715 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18717 # check files inherit DoM EA
18718 touch $DIR/$tdir/first
18719 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
18720 error "bad pattern"
18721 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
18722 error "bad stripe count"
18723 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
18724 error "bad stripe size"
18726 # check directory inherits DoM EA and uses it as default
18727 mkdir $DIR/$tdir/subdir
18728 touch $DIR/$tdir/subdir/second
18729 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
18730 error "bad pattern in sub-directory"
18731 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
18732 error "bad stripe count in sub-directory"
18733 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
18734 error "bad stripe size in sub-directory"
18737 run_test 270c "DoM: DoM EA inheritance tests"
18740 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18741 skip "Need MDS version at least 2.10.55"
18743 mkdir -p $DIR/$tdir
18744 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18746 # inherit default DoM striping
18747 mkdir $DIR/$tdir/subdir
18748 touch $DIR/$tdir/subdir/f1
18750 # change default directory striping
18751 $LFS setstripe -c 1 $DIR/$tdir/subdir
18752 touch $DIR/$tdir/subdir/f2
18753 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
18754 error "wrong default striping in file 2"
18755 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
18756 error "bad pattern in file 2"
18759 run_test 270d "DoM: change striping from DoM to RAID0"
18762 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18763 skip "Need MDS version at least 2.10.55"
18765 mkdir -p $DIR/$tdir/dom
18766 mkdir -p $DIR/$tdir/norm
18769 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
18770 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
18772 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
18773 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
18775 # find DoM files by layout
18776 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
18777 [ $NUM -eq $DOMFILES ] ||
18778 error "lfs find -L: found $NUM, expected $DOMFILES"
18779 echo "Test 1: lfs find 20 DOM files by layout: OK"
18781 # there should be 1 dir with default DOM striping
18782 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
18784 error "lfs find -L: found $NUM, expected 1 dir"
18785 echo "Test 2: lfs find 1 DOM dir by layout: OK"
18787 # find DoM files by stripe size
18788 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
18789 [ $NUM -eq $DOMFILES ] ||
18790 error "lfs find -S: found $NUM, expected $DOMFILES"
18791 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
18793 # find files by stripe offset except DoM files
18794 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
18795 [ $NUM -eq $NORMFILES ] ||
18796 error "lfs find -i: found $NUM, expected $NORMFILES"
18797 echo "Test 5: lfs find no DOM files by stripe index: OK"
18800 run_test 270e "DoM: lfs find with DoM files test"
18803 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18804 skip "Need MDS version at least 2.10.55"
18806 local mdtname=${FSNAME}-MDT0000-mdtlov
18807 local dom=$DIR/$tdir/dom_file
18808 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
18809 lod.$mdtname.dom_stripesize)
18810 local dom_limit=131072
18812 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
18813 local dom_current=$(do_facet mds1 $LCTL get_param -n \
18814 lod.$mdtname.dom_stripesize)
18815 [ ${dom_limit} -eq ${dom_current} ] ||
18816 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
18818 $LFS mkdir -i 0 -c 1 $DIR/$tdir
18819 $LFS setstripe -d $DIR/$tdir
18820 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
18821 error "Can't set directory default striping"
18823 # exceed maximum stripe size
18824 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18825 error "Can't create file with $((dom_limit * 2)) DoM stripe"
18826 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
18827 error "Able to create DoM component size more than LOD limit"
18829 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
18830 dom_current=$(do_facet mds1 $LCTL get_param -n \
18831 lod.$mdtname.dom_stripesize)
18832 [ 0 -eq ${dom_current} ] ||
18833 error "Can't set zero DoM stripe limit"
18836 # attempt to create DoM file on server with disabled DoM should
18837 # remove DoM entry from layout and be succeed
18838 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
18839 error "Can't create DoM file (DoM is disabled)"
18840 [ $($LFS getstripe -L $dom) == "mdt" ] &&
18841 error "File has DoM component while DoM is disabled"
18844 # attempt to create DoM file with only DoM stripe should return error
18845 $LFS setstripe -E $dom_limit -L mdt $dom &&
18846 error "Able to create DoM-only file while DoM is disabled"
18848 # too low values to be aligned with smallest stripe size 64K
18849 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
18850 dom_current=$(do_facet mds1 $LCTL get_param -n \
18851 lod.$mdtname.dom_stripesize)
18852 [ 30000 -eq ${dom_current} ] &&
18853 error "Can set too small DoM stripe limit"
18855 # 64K is a minimal stripe size in Lustre, expect limit of that size
18856 [ 65536 -eq ${dom_current} ] ||
18857 error "Limit is not set to 64K but ${dom_current}"
18859 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
18860 dom_current=$(do_facet mds1 $LCTL get_param -n \
18861 lod.$mdtname.dom_stripesize)
18863 [ 2147483648 -eq ${dom_current} ] &&
18864 error "Can set too large DoM stripe limit"
18866 do_facet mds1 $LCTL set_param -n \
18867 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
18868 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18869 error "Can't create DoM component size after limit change"
18870 do_facet mds1 $LCTL set_param -n \
18871 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
18872 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
18873 error "Can't create DoM file after limit decrease"
18874 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
18875 error "Can create big DoM component after limit decrease"
18876 touch ${dom}_def ||
18877 error "Can't create file with old default layout"
18879 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
18882 run_test 270f "DoM: maximum DoM stripe size checks"
18885 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18886 skip "Need MDS version at least 2.10.55"
18888 local dom=$DIR/$tdir/dom
18890 mkdir -p $DIR/$tdir
18892 $LFS setstripe -E 1024K -L mdt $dom
18894 lctl set_param -n mdc.*.stats=clear
18895 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18896 cat $dom > /dev/null
18897 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
18898 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
18902 run_test 271a "DoM: data is cached for read after write"
18905 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18906 skip "Need MDS version at least 2.10.55"
18908 local dom=$DIR/$tdir/dom
18910 mkdir -p $DIR/$tdir
18912 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18914 lctl set_param -n mdc.*.stats=clear
18915 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18916 cancel_lru_locks mdc
18917 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
18918 # second stat to check size is cached on client
18919 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
18920 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18921 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
18924 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
18927 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18928 skip "Need MDS version at least 2.10.55"
18930 local dom=$DIR/$tdir/dom
18932 mkdir -p $DIR/$tdir
18934 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18936 lctl set_param -n mdc.*.stats=clear
18937 lctl set_param -n osc.*.stats=clear
18938 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
18939 cancel_lru_locks mdc
18940 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18941 # second stat to check size is cached on client
18942 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18943 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18944 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
18945 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
18946 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
18949 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
18955 local mdt=MDT$(printf %04x $mdtidx)
18957 if [ -z $param ]; then
18958 lctl get_param -n mdc.*$mdt*.stats
18960 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
18965 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18966 skip "Need MDS version at least 2.10.55"
18968 local dom=$DIR/$tdir/dom
18970 mkdir -p $DIR/$tdir
18972 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18974 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18975 local facet=mds$((mdtidx + 1))
18977 cancel_lru_locks mdc
18978 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
18979 createmany -o $dom 1000
18980 lctl set_param -n mdc.*.stats=clear
18981 smalliomany -w $dom 1000 200
18982 get_mdc_stats $mdtidx
18983 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18984 # Each file has 1 open, 1 IO enqueues, total 2000
18985 # but now we have also +1 getxattr for security.capability, total 3000
18986 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
18987 unlinkmany $dom 1000
18989 cancel_lru_locks mdc
18990 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
18991 createmany -o $dom 1000
18992 lctl set_param -n mdc.*.stats=clear
18993 smalliomany -w $dom 1000 200
18994 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18995 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
18996 # for OPEN and IO lock.
18997 [ $((enq - enq_2)) -ge 1000 ] ||
18998 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
18999 unlinkmany $dom 1000
19002 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
19004 cleanup_271def_tests() {
19010 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
19011 skip "Need MDS version at least 2.10.57"
19013 local dom=$DIR/$tdir/dom
19014 local tmp=$TMP/$tfile
19015 trap "cleanup_271def_tests $tmp" EXIT
19017 mkdir -p $DIR/$tdir
19019 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19021 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
19023 cancel_lru_locks mdc
19024 dd if=/dev/urandom of=$tmp bs=1000 count=1
19025 dd if=$tmp of=$dom bs=1000 count=1
19026 cancel_lru_locks mdc
19028 cat /etc/hosts >> $tmp
19029 lctl set_param -n mdc.*.stats=clear
19031 # append data to the same file it should update local page
19032 echo "Append to the same page"
19033 cat /etc/hosts >> $dom
19034 local num=$(get_mdc_stats $mdtidx ost_read)
19035 local ra=$(get_mdc_stats $mdtidx req_active)
19036 local rw=$(get_mdc_stats $mdtidx req_waittime)
19038 [ -z $num ] || error "$num READ RPC occured"
19039 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19043 cmp $tmp $dom || error "file miscompare"
19045 cancel_lru_locks mdc
19046 lctl set_param -n mdc.*.stats=clear
19048 echo "Open and read file"
19049 cat $dom > /dev/null
19050 local num=$(get_mdc_stats $mdtidx ost_read)
19051 local ra=$(get_mdc_stats $mdtidx req_active)
19052 local rw=$(get_mdc_stats $mdtidx req_waittime)
19054 [ -z $num ] || error "$num READ RPC occured"
19055 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19059 cmp $tmp $dom || error "file miscompare"
19063 run_test 271d "DoM: read on open (1K file in reply buffer)"
19066 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
19067 skip "Need MDS version at least 2.10.57"
19069 local dom=$DIR/$tdir/dom
19070 local tmp=$TMP/$tfile
19071 trap "cleanup_271def_tests $tmp" EXIT
19073 mkdir -p $DIR/$tdir
19075 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19077 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
19079 cancel_lru_locks mdc
19080 dd if=/dev/urandom of=$tmp bs=265000 count=1
19081 dd if=$tmp of=$dom bs=265000 count=1
19082 cancel_lru_locks mdc
19083 cat /etc/hosts >> $tmp
19084 lctl set_param -n mdc.*.stats=clear
19086 echo "Append to the same page"
19087 cat /etc/hosts >> $dom
19088 local num=$(get_mdc_stats $mdtidx ost_read)
19089 local ra=$(get_mdc_stats $mdtidx req_active)
19090 local rw=$(get_mdc_stats $mdtidx req_waittime)
19092 [ -z $num ] || error "$num READ RPC occured"
19093 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19097 cmp $tmp $dom || error "file miscompare"
19099 cancel_lru_locks mdc
19100 lctl set_param -n mdc.*.stats=clear
19102 echo "Open and read file"
19103 cat $dom > /dev/null
19104 local num=$(get_mdc_stats $mdtidx ost_read)
19105 local ra=$(get_mdc_stats $mdtidx req_active)
19106 local rw=$(get_mdc_stats $mdtidx req_waittime)
19108 [ -z $num ] && num=0
19109 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
19110 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19114 cmp $tmp $dom || error "file miscompare"
19118 run_test 271f "DoM: read on open (200K file and read tail)"
19121 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
19122 skip "Skipping due to old client or server version"
19124 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
19126 $CHECKSTAT -t file $DIR1/$tfile
19128 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
19131 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
19132 $LCTL set_param fail_loc=0x80000314
19133 rm $DIR1/$tfile || error "Unlink fails"
19135 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
19136 [ $RC -eq 0 ] || error "Failed write to stale object"
19138 run_test 271g "Discard DoM data vs client flush race"
19141 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19142 skip "Need MDS version at least 2.11.50"
19144 local dom=$DIR/$tdir/dom
19145 mkdir -p $DIR/$tdir
19147 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
19148 dd if=/dev/urandom of=$dom bs=512K count=1 ||
19149 error "failed to write data into $dom"
19150 local old_md5=$(md5sum $dom)
19152 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
19153 error "failed to migrate to the same DoM component"
19155 local new_md5=$(md5sum $dom)
19157 [ "$old_md5" == "$new_md5" ] ||
19158 error "md5sum differ: $old_md5, $new_md5"
19160 [ $($LFS getstripe -c $dom) -eq 2 ] ||
19161 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
19163 run_test 272a "DoM migration: new layout with the same DOM component"
19166 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19167 skip "Need MDS version at least 2.11.50"
19169 local dom=$DIR/$tdir/dom
19170 mkdir -p $DIR/$tdir
19171 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
19173 local mdtidx=$($LFS getstripe -m $dom)
19174 local mdtname=MDT$(printf %04x $mdtidx)
19175 local facet=mds$((mdtidx + 1))
19177 local mdtfree1=$(do_facet $facet \
19178 lctl get_param -n osd*.*$mdtname.kbytesfree)
19179 dd if=/dev/urandom of=$dom bs=2M count=1 ||
19180 error "failed to write data into $dom"
19181 local old_md5=$(md5sum $dom)
19182 cancel_lru_locks mdc
19183 local mdtfree1=$(do_facet $facet \
19184 lctl get_param -n osd*.*$mdtname.kbytesfree)
19186 $LFS migrate -c2 $dom ||
19187 error "failed to migrate to the new composite layout"
19188 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
19189 error "MDT stripe was not removed"
19191 cancel_lru_locks mdc
19192 local new_md5=$(md5sum $dom)
19193 [ "$old_md5" == "$new_md5" ] ||
19194 error "$old_md5 != $new_md5"
19196 # Skip free space checks with ZFS
19197 if [ "$(facet_fstype $facet)" != "zfs" ]; then
19198 local mdtfree2=$(do_facet $facet \
19199 lctl get_param -n osd*.*$mdtname.kbytesfree)
19200 [ $mdtfree2 -gt $mdtfree1 ] ||
19201 error "MDT space is not freed after migration"
19205 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
19208 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19209 skip "Need MDS version at least 2.11.50"
19211 local dom=$DIR/$tdir/$tfile
19212 mkdir -p $DIR/$tdir
19213 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
19215 local mdtidx=$($LFS getstripe -m $dom)
19216 local mdtname=MDT$(printf %04x $mdtidx)
19217 local facet=mds$((mdtidx + 1))
19219 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
19220 error "failed to write data into $dom"
19221 local old_md5=$(md5sum $dom)
19222 cancel_lru_locks mdc
19223 local mdtfree1=$(do_facet $facet \
19224 lctl get_param -n osd*.*$mdtname.kbytesfree)
19226 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
19227 error "failed to migrate to the new composite layout"
19228 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
19229 error "MDT stripe was not removed"
19231 cancel_lru_locks mdc
19232 local new_md5=$(md5sum $dom)
19233 [ "$old_md5" == "$new_md5" ] ||
19234 error "$old_md5 != $new_md5"
19236 # Skip free space checks with ZFS
19237 if [ "$(facet_fstype $facet)" != "zfs" ]; then
19238 local mdtfree2=$(do_facet $facet \
19239 lctl get_param -n osd*.*$mdtname.kbytesfree)
19240 [ $mdtfree2 -gt $mdtfree1 ] ||
19241 error "MDS space is not freed after migration"
19245 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
19248 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
19249 skip "Need MDS version at least 2.12.55"
19251 local dom=$DIR/$tdir/$tfile
19252 mkdir -p $DIR/$tdir
19253 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
19255 local mdtidx=$($LFS getstripe -m $dom)
19256 local mdtname=MDT$(printf %04x $mdtidx)
19257 local facet=mds$((mdtidx + 1))
19259 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
19260 error "failed to write data into $dom"
19261 local old_md5=$(md5sum $dom)
19262 cancel_lru_locks mdc
19263 local mdtfree1=$(do_facet $facet \
19264 lctl get_param -n osd*.*$mdtname.kbytesfree)
19266 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
19267 error "failed mirroring to the new composite layout"
19268 $LFS mirror resync $dom ||
19269 error "failed mirror resync"
19270 $LFS mirror split --mirror-id 1 -d $dom ||
19271 error "failed mirror split"
19273 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
19274 error "MDT stripe was not removed"
19276 cancel_lru_locks mdc
19277 local new_md5=$(md5sum $dom)
19278 [ "$old_md5" == "$new_md5" ] ||
19279 error "$old_md5 != $new_md5"
19281 # Skip free space checks with ZFS
19282 if [ "$(facet_fstype $facet)" != "zfs" ]; then
19283 local mdtfree2=$(do_facet $facet \
19284 lctl get_param -n osd*.*$mdtname.kbytesfree)
19285 [ $mdtfree2 -gt $mdtfree1 ] ||
19286 error "MDS space is not freed after DOM mirror deletion"
19290 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
19293 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
19294 skip "Need MDS version at least 2.12.55"
19296 local dom=$DIR/$tdir/$tfile
19297 mkdir -p $DIR/$tdir
19298 $LFS setstripe -c 2 $dom
19300 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
19301 error "failed to write data into $dom"
19302 local old_md5=$(md5sum $dom)
19303 cancel_lru_locks mdc
19305 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
19306 error "failed mirroring to the DOM layout"
19307 $LFS mirror resync $dom ||
19308 error "failed mirror resync"
19309 $LFS mirror split --mirror-id 1 -d $dom ||
19310 error "failed mirror split"
19312 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
19313 error "MDT stripe was not removed"
19315 cancel_lru_locks mdc
19316 local new_md5=$(md5sum $dom)
19317 [ "$old_md5" == "$new_md5" ] ||
19318 error "$old_md5 != $new_md5"
19322 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
19325 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
19326 skip "Need MDS version at least 2.12.55"
19328 local dom=$DIR/$tdir/$tfile
19329 mkdir -p $DIR/$tdir
19330 $LFS setstripe -c 2 $dom
19332 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
19333 error "failed to write data into $dom"
19334 local old_md5=$(md5sum $dom)
19335 cancel_lru_locks mdc
19337 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
19338 error "failed migrating to the DOM file"
19340 cancel_lru_locks mdc
19341 local new_md5=$(md5sum $dom)
19342 [ "$old_md5" != "$new_md5" ] &&
19343 error "$old_md5 != $new_md5"
19347 run_test 272f "DoM migration: OST-striped file to DOM file"
19350 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19351 skip "Need MDS version at least 2.11.50"
19353 # Layout swap cannot be done if either file has DOM component,
19354 # this will never be supported, migration should be used instead
19356 local dom=$DIR/$tdir/$tfile
19357 mkdir -p $DIR/$tdir
19359 $LFS setstripe -c2 ${dom}_plain
19360 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
19361 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
19362 error "can swap layout with DoM component"
19363 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
19364 error "can swap layout with DoM component"
19366 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
19367 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
19368 error "can swap layout with DoM component"
19369 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
19370 error "can swap layout with DoM component"
19373 run_test 273a "DoM: layout swapping should fail with DOM"
19376 remote_ost_nodsh && skip "remote OST with nodsh"
19377 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
19378 skip "Need OST version >= 2.10.57"
19380 local file=$DIR/$tfile
19383 oss=$(comma_list $(osts_nodes))
19385 dd if=/dev/urandom of=$file bs=1M count=2 ||
19386 error "failed to create a file"
19387 cancel_lru_locks osc
19390 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
19391 error "failed to read a file"
19393 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
19394 $LCTL set_param fail_loc=0x8000031f
19396 cancel_lru_locks osc &
19399 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
19400 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
19401 #IO takes another lock, but matches the PENDING one
19402 #and places it to the IO RPC
19403 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
19404 error "failed to read a file with PENDING lock"
19406 run_test 275 "Read on a canceled duplicate lock"
19409 remote_ost_nodsh && skip "remote OST with nodsh"
19412 do_facet ost1 "(while true; do \
19413 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
19414 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
19417 for LOOP in $(seq 20); do
19419 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
19422 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
19423 rm $TMP/sanity_276_pid"
19425 run_test 276 "Race between mount and obd_statfs"
19428 $LCTL set_param ldlm.namespaces.*.lru_size=0
19429 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
19430 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
19431 grep ^used_mb | awk '{print $2}')
19432 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
19433 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
19434 oflag=direct conv=notrunc
19435 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
19436 grep ^used_mb | awk '{print $2}')
19437 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
19439 run_test 277 "Direct IO shall drop page cache"
19442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
19443 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19444 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
19445 skip "needs the same host for mdt1 mdt2" && return
19450 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
19451 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
19457 echo "Starting MDTs"
19458 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
19460 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
19462 do_facet mds2 $LCTL set_param fail_loc=0
19464 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
19465 wait_recovery_complete mds2
19467 run_test 278 "Race starting MDS between MDTs stop/start"
19469 cleanup_test_300() {
19473 test_striped_dir() {
19478 mkdir -p $DIR/$tdir
19480 SAVE_UMASK=$(umask)
19481 trap cleanup_test_300 RETURN EXIT
19483 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
19484 $DIR/$tdir/striped_dir ||
19485 error "set striped dir error"
19487 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
19488 [ "$mode" = "755" ] || error "expect 755 got $mode"
19490 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
19491 error "getdirstripe failed"
19492 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
19493 if [ "$stripe_count" != "2" ]; then
19494 error "1:stripe_count is $stripe_count, expect 2"
19496 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
19497 if [ "$stripe_count" != "2" ]; then
19498 error "2:stripe_count is $stripe_count, expect 2"
19501 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
19502 if [ "$stripe_index" != "$mdt_index" ]; then
19503 error "stripe_index is $stripe_index, expect $mdt_index"
19506 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
19507 error "nlink error after create striped dir"
19509 mkdir $DIR/$tdir/striped_dir/a
19510 mkdir $DIR/$tdir/striped_dir/b
19512 stat $DIR/$tdir/striped_dir/a ||
19513 error "create dir under striped dir failed"
19514 stat $DIR/$tdir/striped_dir/b ||
19515 error "create dir under striped dir failed"
19517 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
19518 error "nlink error after mkdir"
19520 rmdir $DIR/$tdir/striped_dir/a
19521 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
19522 error "nlink error after rmdir"
19524 rmdir $DIR/$tdir/striped_dir/b
19525 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
19526 error "nlink error after rmdir"
19528 chattr +i $DIR/$tdir/striped_dir
19529 createmany -o $DIR/$tdir/striped_dir/f 10 &&
19530 error "immutable flags not working under striped dir!"
19531 chattr -i $DIR/$tdir/striped_dir
19533 rmdir $DIR/$tdir/striped_dir ||
19534 error "rmdir striped dir error"
19542 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19543 skip "skipped for lustre < 2.7.0"
19544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19545 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19547 test_striped_dir 0 || error "failed on striped dir on MDT0"
19548 test_striped_dir 1 || error "failed on striped dir on MDT0"
19550 run_test 300a "basic striped dir sanity test"
19553 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19554 skip "skipped for lustre < 2.7.0"
19555 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19556 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19563 test_mkdir $DIR/$tdir || error "mkdir fail"
19564 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19565 error "set striped dir error"
19566 for i in {0..9}; do
19567 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
19569 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
19570 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
19571 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
19573 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
19574 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
19575 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
19579 run_test 300b "check ctime/mtime for striped dir"
19582 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19583 skip "skipped for lustre < 2.7.0"
19584 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19585 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19589 mkdir -p $DIR/$tdir
19590 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
19591 error "set striped dir error"
19593 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
19594 error "chown striped dir failed"
19596 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
19597 error "create 5k files failed"
19599 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
19601 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
19605 run_test 300c "chown && check ls under striped directory"
19608 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19609 skip "skipped for lustre < 2.7.0"
19610 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19611 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19616 mkdir -p $DIR/$tdir
19617 $LFS setstripe -c 2 $DIR/$tdir
19619 #local striped directory
19620 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19621 error "set striped dir error"
19622 createmany -o $DIR/$tdir/striped_dir/f 10 ||
19623 error "create 10 files failed"
19625 #remote striped directory
19626 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
19627 error "set striped dir error"
19628 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
19629 error "create 10 files failed"
19631 for file in $(find $DIR/$tdir); do
19632 stripe_count=$($LFS getstripe -c $file)
19633 [ $stripe_count -eq 2 ] ||
19634 error "wrong stripe $stripe_count for $file"
19639 run_test 300d "check default stripe under striped directory"
19642 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19643 skip "Need MDS version at least 2.7.55"
19644 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19645 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19650 mkdir -p $DIR/$tdir
19652 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19653 error "set striped dir error"
19655 touch $DIR/$tdir/striped_dir/a
19656 touch $DIR/$tdir/striped_dir/b
19657 touch $DIR/$tdir/striped_dir/c
19659 mkdir $DIR/$tdir/striped_dir/dir_a
19660 mkdir $DIR/$tdir/striped_dir/dir_b
19661 mkdir $DIR/$tdir/striped_dir/dir_c
19663 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
19664 error "set striped adir under striped dir error"
19666 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
19667 error "set striped bdir under striped dir error"
19669 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
19670 error "set striped cdir under striped dir error"
19672 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
19673 error "rename dir under striped dir fails"
19675 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
19676 error "rename dir under different stripes fails"
19678 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
19679 error "rename file under striped dir should succeed"
19681 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
19682 error "rename dir under striped dir should succeed"
19686 run_test 300e "check rename under striped directory"
19689 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19690 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19691 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19692 skip "Need MDS version at least 2.7.55"
19698 mkdir -p $DIR/$tdir
19700 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19701 error "set striped dir error"
19703 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
19704 error "set striped dir error"
19706 touch $DIR/$tdir/striped_dir/a
19707 mkdir $DIR/$tdir/striped_dir/dir_a
19708 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
19709 error "create striped dir under striped dir fails"
19711 touch $DIR/$tdir/striped_dir1/b
19712 mkdir $DIR/$tdir/striped_dir1/dir_b
19713 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
19714 error "create striped dir under striped dir fails"
19716 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
19717 error "rename dir under different striped dir should fail"
19719 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
19720 error "rename striped dir under diff striped dir should fail"
19722 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
19723 error "rename file under diff striped dirs fails"
19727 run_test 300f "check rename cross striped directory"
19729 test_300_check_default_striped_dir()
19732 local default_count=$2
19733 local default_index=$3
19736 local dir_stripe_index
19739 echo "checking $dirname $default_count $default_index"
19740 $LFS setdirstripe -D -c $default_count -i $default_index \
19741 -t all_char $DIR/$tdir/$dirname ||
19742 error "set default stripe on striped dir error"
19743 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
19744 [ $stripe_count -eq $default_count ] ||
19745 error "expect $default_count get $stripe_count for $dirname"
19747 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
19748 [ $stripe_index -eq $default_index ] ||
19749 error "expect $default_index get $stripe_index for $dirname"
19751 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
19752 error "create dirs failed"
19754 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
19755 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
19756 for dir in $(find $DIR/$tdir/$dirname/*); do
19757 stripe_count=$($LFS getdirstripe -c $dir)
19758 [ $stripe_count -eq $default_count ] ||
19759 [ $stripe_count -eq 0 ] || [ $default_count -eq 1 ] ||
19760 error "stripe count $default_count != $stripe_count for $dir"
19762 stripe_index=$($LFS getdirstripe -i $dir)
19763 [ $default_index -eq -1 ] ||
19764 [ $stripe_index -eq $default_index ] ||
19765 error "$stripe_index != $default_index for $dir"
19767 #check default stripe
19768 stripe_count=$($LFS getdirstripe -D -c $dir)
19769 [ $stripe_count -eq $default_count ] ||
19770 error "default count $default_count != $stripe_count for $dir"
19772 stripe_index=$($LFS getdirstripe -D -i $dir)
19773 [ $stripe_index -eq $default_index ] ||
19774 error "default index $default_index != $stripe_index for $dir"
19776 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
19780 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19781 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19782 skip "Need MDS version at least 2.7.55"
19789 mkdir $DIR/$tdir/normal_dir
19791 #Checking when client cache stripe index
19792 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
19793 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
19794 error "create striped_dir failed"
19796 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
19797 error "create dir0 fails"
19798 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
19799 [ $stripe_index -eq 0 ] ||
19800 error "dir0 expect index 0 got $stripe_index"
19802 mkdir $DIR/$tdir/striped_dir/dir1 ||
19803 error "create dir1 fails"
19804 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
19805 [ $stripe_index -eq 1 ] ||
19806 error "dir1 expect index 1 got $stripe_index"
19808 #check default stripe count/stripe index
19809 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
19810 test_300_check_default_striped_dir normal_dir 1 0
19811 test_300_check_default_striped_dir normal_dir 2 1
19812 test_300_check_default_striped_dir normal_dir 2 -1
19814 #delete default stripe information
19815 echo "delete default stripeEA"
19816 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
19817 error "set default stripe on striped dir error"
19819 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
19820 for dir in $(find $DIR/$tdir/normal_dir/*); do
19821 stripe_count=$($LFS getdirstripe -c $dir)
19822 [ $stripe_count -eq 0 ] ||
19823 error "expect 1 get $stripe_count for $dir"
19824 stripe_index=$($LFS getdirstripe -i $dir)
19825 [ $stripe_index -eq 0 ] ||
19826 error "expect 0 get $stripe_index for $dir"
19829 run_test 300g "check default striped directory for normal directory"
19832 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19833 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19834 skip "Need MDS version at least 2.7.55"
19840 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19841 error "set striped dir error"
19843 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
19844 test_300_check_default_striped_dir striped_dir 1 0
19845 test_300_check_default_striped_dir striped_dir 2 1
19846 test_300_check_default_striped_dir striped_dir 2 -1
19848 #delete default stripe information
19849 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
19850 error "set default stripe on striped dir error"
19852 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
19853 for dir in $(find $DIR/$tdir/striped_dir/*); do
19854 stripe_count=$($LFS getdirstripe -c $dir)
19855 [ $stripe_count -eq 0 ] ||
19856 error "expect 1 get $stripe_count for $dir"
19859 run_test 300h "check default striped directory for striped directory"
19862 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19863 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19864 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19865 skip "Need MDS version at least 2.7.55"
19872 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19873 error "set striped dir error"
19875 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19876 error "create files under striped dir failed"
19878 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
19879 error "set striped hashdir error"
19881 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
19882 error "create dir0 under hash dir failed"
19883 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
19884 error "create dir1 under hash dir failed"
19886 # unfortunately, we need to umount to clear dir layout cache for now
19887 # once we fully implement dir layout, we can drop this
19888 umount_client $MOUNT || error "umount failed"
19889 mount_client $MOUNT || error "mount failed"
19891 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
19892 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
19893 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
19895 #set the stripe to be unknown hash type
19896 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
19897 $LCTL set_param fail_loc=0x1901
19898 for ((i = 0; i < 10; i++)); do
19899 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
19900 error "stat f-$i failed"
19901 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
19904 touch $DIR/$tdir/striped_dir/f0 &&
19905 error "create under striped dir with unknown hash should fail"
19907 $LCTL set_param fail_loc=0
19909 umount_client $MOUNT || error "umount failed"
19910 mount_client $MOUNT || error "mount failed"
19914 run_test 300i "client handle unknown hash type striped directory"
19917 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19918 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19919 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19920 skip "Need MDS version at least 2.7.55"
19927 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
19928 $LCTL set_param fail_loc=0x1702
19929 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19930 error "set striped dir error"
19932 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19933 error "create files under striped dir failed"
19935 $LCTL set_param fail_loc=0
19937 rm -rf $DIR/$tdir || error "unlink striped dir fails"
19941 run_test 300j "test large update record"
19944 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19945 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19946 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19947 skip "Need MDS version at least 2.7.55"
19949 # this test needs a huge transaction
19951 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19952 osd*.$FSNAME-MDT0000.kbytestotal")
19953 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
19960 #define OBD_FAIL_LARGE_STRIPE 0x1703
19961 $LCTL set_param fail_loc=0x1703
19962 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
19963 error "set striped dir error"
19964 $LCTL set_param fail_loc=0
19966 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19967 error "getstripeddir fails"
19968 rm -rf $DIR/$tdir/striped_dir ||
19969 error "unlink striped dir fails"
19973 run_test 300k "test large striped directory"
19976 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19977 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19978 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19979 skip "Need MDS version at least 2.7.55"
19983 test_mkdir -p $DIR/$tdir/striped_dir
19984 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
19985 error "chown $RUNAS_ID failed"
19986 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
19987 error "set default striped dir failed"
19989 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
19990 $LCTL set_param fail_loc=0x80000158
19991 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
19993 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
19994 [ $stripe_index -eq 1 ] ||
19995 error "expect 1 get $stripe_index for $dir"
19997 run_test 300l "non-root user to create dir under striped dir with stale layout"
20000 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20001 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
20002 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20003 skip "Need MDS version at least 2.7.55"
20005 mkdir -p $DIR/$tdir/striped_dir
20006 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
20007 error "set default stripes dir error"
20009 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
20011 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
20012 [ $stripe_count -eq 0 ] ||
20013 error "expect 0 get $stripe_count for a"
20015 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
20016 error "set default stripes dir error"
20018 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
20020 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
20021 [ $stripe_count -eq 0 ] ||
20022 error "expect 0 get $stripe_count for b"
20024 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
20025 error "set default stripes dir error"
20027 mkdir $DIR/$tdir/striped_dir/c &&
20028 error "default stripe_index is invalid, mkdir c should fails"
20030 rm -rf $DIR/$tdir || error "rmdir fails"
20032 run_test 300m "setstriped directory on single MDT FS"
20035 local list=$(comma_list $(mdts_nodes))
20038 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20042 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20043 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20044 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20045 skip "Need MDS version at least 2.7.55"
20046 remote_mds_nodsh && skip "remote MDS with nodsh"
20049 local list=$(comma_list $(mdts_nodes))
20051 trap cleanup_300n RETURN EXIT
20052 mkdir -p $DIR/$tdir
20053 chmod 777 $DIR/$tdir
20054 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
20055 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
20056 error "create striped dir succeeds with gid=0"
20058 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
20059 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
20060 error "create striped dir fails with gid=-1"
20062 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20063 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
20064 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
20065 error "set default striped dir succeeds with gid=0"
20068 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
20069 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
20070 error "set default striped dir fails with gid=-1"
20073 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20074 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
20075 error "create test_dir fails"
20076 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
20077 error "create test_dir1 fails"
20078 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
20079 error "create test_dir2 fails"
20082 run_test 300n "non-root user to create dir under striped dir with default EA"
20085 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20086 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20087 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20088 skip "Need MDS version at least 2.7.55"
20093 mkdir -p $DIR/$tdir
20095 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
20096 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
20097 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
20098 skip "not enough free inodes $numfree1 $numfree2"
20101 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
20102 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
20103 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
20104 skip "not enough free space $numfree1 $numfree2"
20107 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
20108 error "setdirstripe fails"
20110 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
20111 error "create dirs fails"
20113 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
20114 ls $DIR/$tdir/striped_dir > /dev/null ||
20115 error "ls striped dir fails"
20116 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
20117 error "unlink big striped dir fails"
20119 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
20122 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20123 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20124 remote_mds_nodsh && skip "remote MDS with nodsh"
20126 mkdir -p $DIR/$tdir
20128 #define OBD_FAIL_OUT_ENOSPC 0x1704
20129 do_facet mds2 lctl set_param fail_loc=0x80001704
20130 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
20131 && error "create striped directory should fail"
20133 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
20135 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
20138 run_test 300p "create striped directory without space"
20141 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20142 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20144 local fd=$(free_fd)
20145 local cmd="exec $fd<$tdir"
20147 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
20150 trap "eval $cmd" EXIT
20151 cd $tdir || error "cd $tdir fails"
20152 rmdir ../$tdir || error "rmdir $tdir fails"
20153 mkdir local_dir && error "create dir succeeds"
20154 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
20158 run_test 300q "create remote directory under orphan directory"
20161 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20162 skip "Need MDS version at least 2.7.55" && return
20163 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
20167 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
20168 error "set striped dir error"
20170 $LFS getdirstripe $DIR/$tdir/striped_dir ||
20171 error "getstripeddir fails"
20174 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
20175 awk '/lmv_stripe_count:/ { print $2 }')
20177 [ $MDSCOUNT -ne $stripe_count ] &&
20178 error "wrong stripe count $stripe_count expected $MDSCOUNT"
20180 rm -rf $DIR/$tdir/striped_dir ||
20181 error "unlink striped dir fails"
20183 run_test 300r "test -1 striped directory"
20185 prepare_remote_file() {
20186 mkdir $DIR/$tdir/src_dir ||
20187 error "create remote source failed"
20189 cp /etc/hosts $DIR/$tdir/src_dir/a ||
20190 error "cp to remote source failed"
20191 touch $DIR/$tdir/src_dir/a
20193 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
20194 error "create remote target dir failed"
20196 touch $DIR/$tdir/tgt_dir/b
20198 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
20199 error "rename dir cross MDT failed!"
20201 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
20202 error "src_child still exists after rename"
20204 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
20205 error "missing file(a) after rename"
20207 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
20208 error "diff after rename"
20212 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
20213 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20215 local remote_file=$DIR/$tdir/tgt_dir/b
20217 mkdir -p $DIR/$tdir
20219 prepare_remote_file || error "prepare remote file failed"
20222 $OPENUNLINK $remote_file $remote_file ||
20223 error "openunlink $remote_file failed"
20224 $CHECKSTAT -a $remote_file || error "$remote_file exists"
20226 run_test 310a "open unlink remote file"
20229 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
20230 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20232 local remote_file=$DIR/$tdir/tgt_dir/b
20234 mkdir -p $DIR/$tdir
20236 prepare_remote_file || error "prepare remote file failed"
20238 ln $remote_file $DIR/$tfile || error "link failed for remote file"
20239 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
20240 $CHECKSTAT -t file $remote_file || error "check file failed"
20242 run_test 310b "unlink remote file with multiple links while open"
20245 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20246 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
20248 local remote_file=$DIR/$tdir/tgt_dir/b
20250 mkdir -p $DIR/$tdir
20252 prepare_remote_file || error "prepare remote file failed"
20254 ln $remote_file $DIR/$tfile || error "link failed for remote file"
20255 multiop_bg_pause $remote_file O_uc ||
20256 error "mulitop failed for remote file"
20258 $MULTIOP $DIR/$tfile Ouc
20259 kill -USR1 $MULTIPID
20262 run_test 310c "open-unlink remote file with multiple links"
20266 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20267 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
20268 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
20269 skip "lustre < 2.8.54 does not contain LU-4825 fix"
20270 remote_mds_nodsh && skip "remote MDS with nodsh"
20272 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
20273 local mdts=$(comma_list $(mdts_nodes))
20275 mkdir -p $DIR/$tdir
20276 $LFS setstripe -i 0 -c 1 $DIR/$tdir
20277 createmany -o $DIR/$tdir/$tfile. 1000
20279 # statfs data is not real time, let's just calculate it
20280 old_iused=$((old_iused + 1000))
20282 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
20283 osp.*OST0000*MDT0000.create_count")
20284 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
20285 osp.*OST0000*MDT0000.max_create_count")
20286 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
20288 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
20289 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
20290 [ $index -ne 0 ] || error "$tfile stripe index is 0"
20292 unlinkmany $DIR/$tdir/$tfile. 1000
20294 do_nodes $mdts "$LCTL set_param -n \
20295 osp.*OST0000*.max_create_count=$max_count"
20296 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
20297 do_nodes $mdts "$LCTL set_param -n \
20298 osp.*OST0000*.create_count=$count"
20299 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
20300 grep "=0" && error "create_count is zero"
20303 for i in $(seq 120); do
20304 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
20305 # system may be too busy to destroy all objs in time, use
20306 # a somewhat small value to not fail autotest
20307 [ $((old_iused - new_iused)) -gt 400 ] && break
20311 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
20312 [ $((old_iused - new_iused)) -gt 400 ] ||
20313 error "objs not destroyed after unlink"
20315 run_test 311 "disable OSP precreate, and unlink should destroy objs"
20322 local vdevdir=$(dirname $(facet_vdevice $ost))
20323 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
20324 local zfs_zapid=$(do_facet $ost $cmd |
20325 grep -w "/O/0/d$((objid%32))" -C 5 |
20326 awk '/Object/{getline; print $1}')
20327 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
20328 awk "/$objid = /"'{printf $3}')
20333 zfs_object_blksz() {
20337 local vdevdir=$(dirname $(facet_vdevice $ost))
20338 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
20339 local blksz=$(do_facet $ost $cmd $objid |
20340 awk '/dblk/{getline; printf $4}')
20342 case "${blksz: -1}" in
20343 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
20344 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
20351 test_312() { # LU-4856
20352 remote_ost_nodsh && skip "remote OST with nodsh"
20353 [ "$ost1_FSTYPE" = "zfs" ] ||
20354 skip_env "the test only applies to zfs"
20356 local max_blksz=$(do_facet ost1 \
20357 $ZFS get -p recordsize $(facet_device ost1) |
20358 awk '!/VALUE/{print $3}')
20360 # to make life a little bit easier
20361 $LFS mkdir -c 1 -i 0 $DIR/$tdir
20362 $LFS setstripe -c 1 -i 0 $DIR/$tdir
20364 local tf=$DIR/$tdir/$tfile
20366 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
20368 # Get ZFS object id
20369 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
20370 # block size change by sequential overwrite
20373 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
20374 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
20376 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
20377 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
20381 # block size change by sequential append write
20382 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
20383 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
20384 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
20387 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
20388 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
20389 oflag=sync conv=notrunc
20391 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20392 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
20393 error "blksz error, actual $blksz, " \
20394 "expected: 2 * $count * $PAGE_SIZE"
20400 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
20401 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
20403 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
20404 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20405 [ $blksz -eq $PAGE_SIZE ] ||
20406 error "blksz error: $blksz, expected: $PAGE_SIZE"
20408 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
20409 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20410 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
20412 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
20413 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20414 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
20416 run_test 312 "make sure ZFS adjusts its block size by write pattern"
20419 remote_ost_nodsh && skip "remote OST with nodsh"
20421 local file=$DIR/$tfile
20424 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
20426 # define OBD_FAIL_TGT_RCVD_EIO 0x720
20427 do_facet ost1 "$LCTL set_param fail_loc=0x720"
20428 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
20429 error "write should failed"
20430 do_facet ost1 "$LCTL set_param fail_loc=0"
20433 run_test 313 "io should fail after last_rcvd update fail"
20436 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
20438 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
20439 do_facet ost1 "$LCTL set_param fail_loc=0x720"
20441 wait_delete_completed
20442 do_facet ost1 "$LCTL set_param fail_loc=0"
20444 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
20446 test_315() { # LU-618
20447 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
20449 local file=$DIR/$tfile
20452 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
20453 error "multiop file write failed"
20454 $MULTIOP $file oO_RDONLY:r4063232_c &
20459 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
20462 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
20465 run_test 315 "read should be accounted"
20468 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20469 large_xattr_enabled || skip_env "ea_inode feature disabled"
20471 rm -rf $DIR/$tdir/d
20472 mkdir -p $DIR/$tdir/d
20473 chown nobody $DIR/$tdir/d
20474 touch $DIR/$tdir/d/file
20476 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
20478 run_test 316 "lfs mv"
20481 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
20482 skip "Need MDS version at least 2.11.53"
20483 if [ "$ost1_FSTYPE" == "zfs" ]; then
20484 skip "LU-10370: no implementation for ZFS"
20488 local grant_blk_size
20490 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
20491 awk '/grant_block_size:/ { print $2; exit; }')
20493 # Create File of size 5M. Truncate it to below size's and verify
20496 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
20497 error "Create file $DIR/$tfile failed"
20498 stack_trap "rm -f $DIR/$tfile" EXIT
20500 for trunc_sz in 2097152 4097 4000 509 0; do
20501 $TRUNCATE $DIR/$tfile $trunc_sz ||
20502 error "truncate $tfile to $trunc_sz failed"
20503 local sz=$(stat --format=%s $DIR/$tfile)
20504 local blk=$(stat --format=%b $DIR/$tfile)
20505 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
20506 grant_blk_size) * 8))
20508 if [[ $blk -ne $trunc_blk ]]; then
20509 $(which stat) $DIR/$tfile
20510 error "Expected Block $trunc_blk got $blk for $tfile"
20513 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
20514 error "Expected Size $trunc_sz got $sz for $tfile"
20519 # Create file with a hole and write actual two blocks. Block count
20522 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
20523 conv=fsync || error "Create file : $DIR/$tfile"
20525 # Calculate the final truncate size.
20526 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
20529 # truncate to size $trunc_sz bytes. Strip the last block
20530 # The block count must drop to 8
20532 $TRUNCATE $DIR/$tfile $trunc_sz ||
20533 error "truncate $tfile to $trunc_sz failed"
20535 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
20536 sz=$(stat --format=%s $DIR/$tfile)
20537 blk=$(stat --format=%b $DIR/$tfile)
20539 if [[ $blk -ne $trunc_bsz ]]; then
20540 $(which stat) $DIR/$tfile
20541 error "Expected Block $trunc_bsz got $blk for $tfile"
20544 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
20545 error "Expected Size $trunc_sz got $sz for $tfile"
20547 run_test 317 "Verify blocks get correctly update after truncate"
20550 local old_max_active=$($LCTL get_param -n \
20551 llite.*.max_read_ahead_async_active 2>/dev/null)
20553 $LCTL set_param llite.*.max_read_ahead_async_active=256
20554 local max_active=$($LCTL get_param -n \
20555 llite.*.max_read_ahead_async_active 2>/dev/null)
20556 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
20558 # currently reset to 0 is unsupported, leave it 512 for now.
20559 $LCTL set_param llite.*.max_read_ahead_async_active=0 &&
20560 error "set max_read_ahead_async_active should fail"
20562 $LCTL set_param llite.*.max_read_ahead_async_active=512
20563 max_active=$($LCTL get_param -n \
20564 llite.*.max_read_ahead_async_active 2>/dev/null)
20565 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
20567 # restore @max_active
20568 [ $old_max_active -ne 0 ] && $LCTL set_param \
20569 llite.*.max_read_ahead_async_active=$old_max_active
20571 local old_threshold=$($LCTL get_param -n \
20572 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
20573 local max_per_file_mb=$($LCTL get_param -n \
20574 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
20576 local invalid=$(($max_per_file_mb + 1))
20578 llite.*.read_ahead_async_file_threshold_mb=$invalid\
20579 && error "set $invalid should fail"
20581 local valid=$(($invalid - 1))
20583 llite.*.read_ahead_async_file_threshold_mb=$valid ||
20584 error "set $valid should succeed"
20585 local threshold=$($LCTL get_param -n \
20586 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
20587 [ $threshold -eq $valid ] || error \
20588 "expect threshold $valid got $threshold"
20590 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
20592 run_test 318 "Verify async readahead tunables"
20595 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
20597 local before=$(date +%s)
20599 local mdir=$DIR/$tdir
20600 local file=$mdir/xxx
20602 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
20605 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
20606 $LCTL set_param fail_val=5 fail_loc=0x8000032c
20607 $LFS mv -m1 $file &
20610 dd if=$file of=/dev/null
20612 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
20613 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
20615 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
20617 run_test 319 "lost lease lock on migrate error"
20619 test_398a() { # LU-4198
20620 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20621 $LCTL set_param ldlm.namespaces.*.lru_size=clear
20623 # request a new lock on client
20624 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
20626 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
20627 local lock_count=$($LCTL get_param -n \
20628 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
20629 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
20631 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
20633 # no lock cached, should use lockless IO and not enqueue new lock
20634 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
20635 lock_count=$($LCTL get_param -n \
20636 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
20637 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
20639 run_test 398a "direct IO should cancel lock otherwise lockless"
20641 test_398b() { # LU-4198
20642 which fio || skip_env "no fio installed"
20643 $LFS setstripe -c -1 $DIR/$tfile
20646 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
20649 echo "mix direct rw ${size}M to OST0 by fio with $njobs jobs..."
20650 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
20651 --numjobs=$njobs --fallocate=none \
20652 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
20653 --filename=$DIR/$tfile &
20656 echo "mix buffer rw ${size}M to OST0 by fio with $njobs jobs..."
20657 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE \
20658 --numjobs=$njobs --fallocate=none \
20659 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
20660 --filename=$DIR/$tfile || true
20665 run_test 398b "DIO and buffer IO race"
20667 test_398c() { # LU-4198
20668 which fio || skip_env "no fio installed"
20670 saved_debug=$($LCTL get_param -n debug)
20671 $LCTL set_param debug=0
20673 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
20674 ((size /= 1024)) # by megabytes
20675 ((size /= 2)) # write half of the OST at most
20676 [ $size -gt 40 ] && size=40 #reduce test time anyway
20678 $LFS setstripe -c 1 $DIR/$tfile
20680 # it seems like ldiskfs reserves more space than necessary if the
20681 # writing blocks are not mapped, so it extends the file firstly
20682 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
20683 cancel_lru_locks osc
20685 # clear and verify rpc_stats later
20686 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
20689 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
20690 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
20691 --numjobs=$njobs --fallocate=none --ioengine=libaio \
20692 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
20693 --filename=$DIR/$tfile
20694 [ $? -eq 0 ] || error "fio write error"
20696 [ $($LCTL get_param -n \
20697 ldlm.namespaces.${FSNAME}-OST0000-osc-ffff*.lock_count) -eq 0 ] ||
20698 error "Locks were requested while doing AIO"
20700 # get the percentage of 1-page I/O
20701 pct=$($LCTL get_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats |
20702 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
20704 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
20706 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
20707 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
20708 --numjobs=$njobs --fallocate=none --ioengine=libaio \
20709 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
20710 --filename=$DIR/$tfile
20711 [ $? -eq 0 ] || error "fio mixed read write error"
20714 $LCTL set_param debug="$saved_debug"
20716 run_test 398c "run fio to test AIO"
20719 local read_write=$1
20720 if [ "$read_write" = "write" ]; then
20721 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
20722 elif [ "$read_write" = "read" ]; then
20723 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
20725 error "argument error"
20728 # turn off debug for performance testing
20729 local saved_debug=$($LCTL get_param -n debug)
20730 $LCTL set_param debug=0
20732 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20734 # get ost1 size - $FSNAME-OST0000
20735 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
20736 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
20737 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
20739 if [ "$read_write" = "read" ]; then
20740 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
20743 local start_time=$(date +%s.%N)
20744 $dd_cmd bs=1M count=$blocks oflag=sync ||
20745 error "real dd $read_write error"
20746 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
20748 if [ "$read_write" = "write" ]; then
20752 # define OBD_FAIL_OST_FAKE_RW 0x238
20753 do_facet ost1 $LCTL set_param fail_loc=0x238
20755 local start_time=$(date +%s.%N)
20756 $dd_cmd bs=1M count=$blocks oflag=sync ||
20757 error "fake dd $read_write error"
20758 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
20760 if [ "$read_write" = "write" ]; then
20762 cancel_lru_locks osc
20763 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
20764 error "$tfile size not $blocks MB"
20766 do_facet ost1 $LCTL set_param fail_loc=0
20768 echo "fake $read_write $duration_fake vs. normal $read_write" \
20769 "$duration in seconds"
20770 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
20771 error_not_in_vm "fake write is slower"
20773 $LCTL set_param -n debug="$saved_debug"
20776 test_399a() { # LU-7655 for OST fake write
20777 remote_ost_nodsh && skip "remote OST with nodsh"
20781 run_test 399a "fake write should not be slower than normal write"
20783 test_399b() { # LU-8726 for OST fake read
20784 remote_ost_nodsh && skip "remote OST with nodsh"
20785 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
20786 skip_env "ldiskfs only test"
20791 run_test 399b "fake read should not be slower than normal read"
20793 test_400a() { # LU-1606, was conf-sanity test_74
20794 if ! which $CC > /dev/null 2>&1; then
20795 skip_env "$CC is not installed"
20798 local extra_flags=''
20799 local out=$TMP/$tfile
20800 local prefix=/usr/include/lustre
20803 if ! [[ -d $prefix ]]; then
20804 # Assume we're running in tree and fixup the include path.
20805 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
20806 extra_flags+=" -L$LUSTRE/utils/.lib"
20809 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
20810 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
20811 error "client api broken"
20815 run_test 400a "Lustre client api program can compile and link"
20817 test_400b() { # LU-1606, LU-5011
20819 local out=$TMP/$tfile
20820 local prefix=/usr/include/linux/lustre
20822 # We use a hard coded prefix so that this test will not fail
20823 # when run in tree. There are headers in lustre/include/lustre/
20824 # that are not packaged (like lustre_idl.h) and have more
20825 # complicated include dependencies (like config.h and lnet/types.h).
20826 # Since this test about correct packaging we just skip them when
20827 # they don't exist (see below) rather than try to fixup cppflags.
20829 if ! which $CC > /dev/null 2>&1; then
20830 skip_env "$CC is not installed"
20833 for header in $prefix/*.h; do
20834 if ! [[ -f "$header" ]]; then
20838 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
20839 continue # lustre_ioctl.h is internal header
20842 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
20843 error "cannot compile '$header'"
20847 run_test 400b "packaged headers can be compiled"
20849 test_401a() { #LU-7437
20850 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
20851 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
20853 #count the number of parameters by "list_param -R"
20854 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
20855 #count the number of parameters by listing proc files
20856 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
20857 echo "proc_dirs='$proc_dirs'"
20858 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
20859 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
20862 [ $params -eq $procs ] ||
20863 error "found $params parameters vs. $procs proc files"
20865 # test the list_param -D option only returns directories
20866 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
20867 #count the number of parameters by listing proc directories
20868 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
20871 [ $params -eq $procs ] ||
20872 error "found $params parameters vs. $procs proc files"
20874 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
20877 local save=$($LCTL get_param -n jobid_var)
20880 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
20881 error "no error returned when setting bad parameters"
20883 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
20884 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
20886 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
20887 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
20888 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
20890 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
20893 local jobid_var_old=$($LCTL get_param -n jobid_var)
20894 local jobid_var_new
20896 $LCTL set_param jobid_var= &&
20897 error "no error returned for 'set_param a='"
20899 jobid_var_new=$($LCTL get_param -n jobid_var)
20900 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20901 error "jobid_var was changed by setting without value"
20903 $LCTL set_param jobid_var &&
20904 error "no error returned for 'set_param a'"
20906 jobid_var_new=$($LCTL get_param -n jobid_var)
20907 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20908 error "jobid_var was changed by setting without value"
20910 run_test 401c "Verify 'lctl set_param' without value fails in either format."
20913 local jobid_var_old=$($LCTL get_param -n jobid_var)
20914 local jobid_var_new
20915 local new_value="foo=bar"
20917 $LCTL set_param jobid_var=$new_value ||
20918 error "'set_param a=b' did not accept a value containing '='"
20920 jobid_var_new=$($LCTL get_param -n jobid_var)
20921 [[ "$jobid_var_new" == "$new_value" ]] ||
20922 error "'set_param a=b' failed on a value containing '='"
20924 # Reset the jobid_var to test the other format
20925 $LCTL set_param jobid_var=$jobid_var_old
20926 jobid_var_new=$($LCTL get_param -n jobid_var)
20927 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
20928 error "failed to reset jobid_var"
20930 $LCTL set_param jobid_var $new_value ||
20931 error "'set_param a b' did not accept a value containing '='"
20933 jobid_var_new=$($LCTL get_param -n jobid_var)
20934 [[ "$jobid_var_new" == "$new_value" ]] ||
20935 error "'set_param a b' failed on a value containing '='"
20937 $LCTL set_param jobid_var $jobid_var_old
20938 jobid_var_new=$($LCTL get_param -n jobid_var)
20939 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
20940 error "failed to reset jobid_var"
20942 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
20945 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
20946 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
20947 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
20948 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
20949 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
20950 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
20951 remote_mds_nodsh && skip "remote MDS with nodsh"
20953 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
20954 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
20955 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
20956 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
20957 echo "Touch failed - OK"
20959 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
20962 local file1=$DIR/$tfile.1
20963 local file2=$DIR/$tfile.2
20964 local tfile=$TMP/$tfile
20966 rm -f $file1 $file2 $tfile
20971 # 30 sec OBD_TIMEOUT in ll_getattr()
20972 # right before populating st_nlink
20973 $LCTL set_param fail_loc=0x80001409
20974 stat -c %h $file1 > $tfile &
20976 # create an alias, drop all locks and reclaim the dentry
20978 cancel_lru_locks mdc
20979 cancel_lru_locks osc
20980 sysctl -w vm.drop_caches=2
20984 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
20986 rm -f $tfile $file1 $file2
20988 run_test 403 "i_nlink should not drop to zero due to aliasing"
20990 test_404() { # LU-6601
20991 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
20992 skip "Need server version newer than 2.8.52"
20993 remote_mds_nodsh && skip "remote MDS with nodsh"
20995 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
20996 awk '/osp .*-osc-MDT/ { print $4}')
20999 for osp in $mosps; do
21000 echo "Deactivate: " $osp
21001 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
21002 local stat=$(do_facet $SINGLEMDS $LCTL dl |
21003 awk -vp=$osp '$4 == p { print $2 }')
21004 [ $stat = IN ] || {
21005 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
21006 error "deactivate error"
21008 echo "Activate: " $osp
21009 do_facet $SINGLEMDS $LCTL --device %$osp activate
21010 local stat=$(do_facet $SINGLEMDS $LCTL dl |
21011 awk -vp=$osp '$4 == p { print $2 }')
21012 [ $stat = UP ] || {
21013 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
21014 error "activate error"
21018 run_test 404 "validate manual {de}activated works properly for OSPs"
21021 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
21022 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
21023 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
21024 skip "Layout swap lock is not supported"
21026 check_swap_layouts_support
21028 test_mkdir $DIR/$tdir
21029 swap_lock_test -d $DIR/$tdir ||
21030 error "One layout swap locked test failed"
21032 run_test 405 "Various layout swap lock tests"
21035 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21036 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
21037 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
21038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21039 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
21040 skip "Need MDS version at least 2.8.50"
21042 local def_stripe_size=$($LFS getstripe -S $MOUNT)
21043 local test_pool=$TESTNAME
21045 pool_add $test_pool || error "pool_add failed"
21046 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
21047 error "pool_add_targets failed"
21049 save_layout_restore_at_exit $MOUNT
21051 # parent set default stripe count only, child will stripe from both
21052 # parent and fs default
21053 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
21054 error "setstripe $MOUNT failed"
21055 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
21056 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
21057 for i in $(seq 10); do
21058 local f=$DIR/$tdir/$tfile.$i
21059 touch $f || error "touch failed"
21060 local count=$($LFS getstripe -c $f)
21061 [ $count -eq $OSTCOUNT ] ||
21062 error "$f stripe count $count != $OSTCOUNT"
21063 local offset=$($LFS getstripe -i $f)
21064 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
21065 local size=$($LFS getstripe -S $f)
21066 [ $size -eq $((def_stripe_size * 2)) ] ||
21067 error "$f stripe size $size != $((def_stripe_size * 2))"
21068 local pool=$($LFS getstripe -p $f)
21069 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
21072 # change fs default striping, delete parent default striping, now child
21073 # will stripe from new fs default striping only
21074 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
21075 error "change $MOUNT default stripe failed"
21076 $LFS setstripe -c 0 $DIR/$tdir ||
21077 error "delete $tdir default stripe failed"
21078 for i in $(seq 11 20); do
21079 local f=$DIR/$tdir/$tfile.$i
21080 touch $f || error "touch $f failed"
21081 local count=$($LFS getstripe -c $f)
21082 [ $count -eq 1 ] || error "$f stripe count $count != 1"
21083 local offset=$($LFS getstripe -i $f)
21084 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
21085 local size=$($LFS getstripe -S $f)
21086 [ $size -eq $def_stripe_size ] ||
21087 error "$f stripe size $size != $def_stripe_size"
21088 local pool=$($LFS getstripe -p $f)
21089 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
21092 unlinkmany $DIR/$tdir/$tfile. 1 20
21094 local f=$DIR/$tdir/$tfile
21095 pool_remove_all_targets $test_pool $f
21096 pool_remove $test_pool $f
21098 run_test 406 "DNE support fs default striping"
21101 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21102 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
21103 skip "Need MDS version at least 2.8.55"
21104 remote_mds_nodsh && skip "remote MDS with nodsh"
21106 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
21107 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
21108 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
21109 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
21110 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
21112 #define OBD_FAIL_DT_TXN_STOP 0x2019
21113 for idx in $(seq $MDSCOUNT); do
21114 do_facet mds$idx "lctl set_param fail_loc=0x2019"
21116 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
21117 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
21118 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
21121 run_test 407 "transaction fail should cause operation fail"
21124 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
21126 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
21127 lctl set_param fail_loc=0x8000040a
21128 # let ll_prepare_partial_page() fail
21129 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
21133 # create at least 100 unused inodes so that
21134 # shrink_icache_memory(0) should not return 0
21135 touch $DIR/$tfile-{0..100}
21136 rm -f $DIR/$tfile-{0..100}
21139 echo 2 > /proc/sys/vm/drop_caches
21141 run_test 408 "drop_caches should not hang due to page leaks"
21145 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21147 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
21148 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
21149 touch $DIR/$tdir/guard || error "(2) Fail to create"
21151 local PREFIX=$(str_repeat 'A' 128)
21152 echo "Create 1K hard links start at $(date)"
21153 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
21154 error "(3) Fail to hard link"
21156 echo "Links count should be right although linkEA overflow"
21157 stat $DIR/$tdir/guard || error "(4) Fail to stat"
21158 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
21159 [ $linkcount -eq 1001 ] ||
21160 error "(5) Unexpected hard links count: $linkcount"
21162 echo "List all links start at $(date)"
21163 ls -l $DIR/$tdir/foo > /dev/null ||
21164 error "(6) Fail to list $DIR/$tdir/foo"
21166 echo "Unlink hard links start at $(date)"
21167 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
21168 error "(7) Fail to unlink"
21169 echo "Unlink hard links finished at $(date)"
21171 run_test 409 "Large amount of cross-MDTs hard links on the same file"
21175 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
21176 skip "Need client version at least 2.9.59"
21178 # Create a file, and stat it from the kernel
21179 local testfile=$DIR/$tfile
21182 local run_id=$RANDOM
21183 local my_ino=$(stat --format "%i" $testfile)
21185 # Try to insert the module. This will always fail as the
21186 # module is designed to not be inserted.
21187 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
21190 # Anything but success is a test failure
21192 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
21193 error "no inode match"
21195 run_test 410 "Test inode number returned from kernel thread"
21197 cleanup_test411_cgroup() {
21203 local cg_basedir=/sys/fs/cgroup/memory
21205 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
21206 skip "no setup for cgroup"
21208 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
21209 error "test file creation failed"
21210 cancel_lru_locks osc
21212 # Create a very small memory cgroup to force a slab allocation error
21213 local cgdir=$cg_basedir/osc_slab_alloc
21214 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
21215 trap "cleanup_test411_cgroup $cgdir" EXIT
21216 echo 2M > $cgdir/memory.kmem.limit_in_bytes
21217 echo 1M > $cgdir/memory.limit_in_bytes
21219 # Should not LBUG, just be killed by oom-killer
21220 # dd will return 0 even allocation failure in some environment.
21221 # So don't check return value
21222 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
21223 cleanup_test411_cgroup $cgdir
21227 run_test 411 "Slab allocation error with cgroup does not LBUG"
21230 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21231 if [ $MDS1_VERSION -lt $(version_code 2.10.55) ]; then
21232 skip "Need server version at least 2.10.55"
21235 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
21236 error "mkdir failed"
21237 $LFS getdirstripe $DIR/$tdir
21238 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
21239 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
21240 error "expect $((MDSCOUT - 1)) get $stripe_index"
21241 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
21242 [ $stripe_count -eq 2 ] ||
21243 error "expect 2 get $stripe_count"
21245 run_test 412 "mkdir on specific MDTs"
21249 local stripe_count=$2
21250 local mdts=$(comma_list $(mdts_nodes))
21253 local lmv_qos_prio_free
21254 local lmv_qos_threshold_rr
21255 local lmv_qos_maxage
21256 local lod_qos_prio_free
21257 local lod_qos_threshold_rr
21258 local lod_qos_maxage
21262 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
21263 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
21264 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
21266 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
21267 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
21268 stack_trap "$LCTL set_param \
21269 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null" EXIT
21270 stack_trap "$LCTL set_param \
21271 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
21272 stack_trap "$LCTL set_param \
21273 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" EXIT
21275 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
21276 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
21277 lod_qos_prio_free=${lod_qos_prio_free%%%}
21278 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
21279 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
21280 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
21281 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
21282 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
21283 stack_trap "do_nodes $mdts $LCTL set_param \
21284 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null" EXIT
21285 stack_trap "do_nodes $mdts $LCTL set_param \
21286 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null" \
21288 stack_trap "do_nodes $mdts $LCTL set_param \
21289 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" EXIT
21292 echo "Mkdir (stripe_count $stripe_count) roundrobin:"
21294 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
21295 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
21297 testdir=$DIR/$tdir-s$stripe_count/rr
21299 for i in $(seq $((100 * MDSCOUNT))); do
21300 eval $mkdir_cmd $testdir/subdir$i ||
21301 error "$mkdir_cmd subdir$i failed"
21304 for i in $(seq $MDSCOUNT); do
21305 count=$($LFS getdirstripe -i $testdir/* |
21306 grep ^$((i - 1))$ | wc -l)
21307 echo "$count directories created on MDT$((i - 1))"
21308 [ $count -eq 100 ] || error "subdirs are not evenly distributed"
21310 if [ $stripe_count -gt 1 ]; then
21311 count=$($LFS getdirstripe $testdir/* |
21312 grep -P "^\s+$((i - 1))\t" | wc -l)
21313 echo "$count stripes created on MDT$((i - 1))"
21314 # deviation should < 5% of average
21315 [ $count -lt $((95 * stripe_count)) ] ||
21316 [ $count -gt $((105 * stripe_count)) ] &&
21317 error "stripes are not evenly distributed"
21321 $LCTL set_param lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null
21322 do_nodes $mdts $LCTL set_param \
21323 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null
21326 echo "Check for uneven MDTs: "
21336 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
21337 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
21338 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
21340 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
21341 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
21344 for ((i = 1; i < ${#ffree[@]}; i++)); do
21345 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
21346 if [ $tmp -gt $max ]; then
21350 if [ $tmp -lt $min ]; then
21356 [ ${ffree[min_index]} -eq 0 ] &&
21357 skip "no free files in MDT$min_index"
21358 [ ${ffree[min_index]} -gt 100000000 ] &&
21359 skip "too much free files in MDT$min_index"
21361 # Check if we need to generate uneven MDTs
21363 local diff=$(((max - min) * 100 / min))
21364 local value="$(generate_string 1024)"
21366 while [ $diff -lt $threshold ]; do
21367 # generate uneven MDTs, create till $threshold% diff
21368 echo -n "weight diff=$diff% must be > $threshold% ..."
21369 count=$((${ffree[min_index]} / 10))
21370 # 50 sec per 10000 files in vm
21371 [ $count -gt 40000 ] && [ "$SLOW" = "no" ] &&
21372 skip "$count files to create"
21373 echo "Fill MDT$min_index with $count files"
21374 [ -d $DIR/$tdir-MDT$min_index ] ||
21375 $LFS mkdir -i $min_index $DIR/$tdir-MDT$min_index ||
21376 error "mkdir $tdir-MDT$min_index failed"
21377 for i in $(seq $count); do
21378 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE \
21379 $DIR/$tdir-MDT$min_index/f$j_$i > /dev/null ||
21380 error "create f$j_$i failed"
21381 setfattr -n user.413b -v $value \
21382 $DIR/$tdir-MDT$min_index/f$j_$i ||
21383 error "setfattr f$j_$i failed"
21386 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
21387 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
21388 max=$(((${ffree[max_index]} >> 8) * \
21389 (${bavail[max_index]} * bsize >> 16)))
21390 min=$(((${ffree[min_index]} >> 8) * \
21391 (${bavail[min_index]} * bsize >> 16)))
21392 diff=$(((max - min) * 100 / min))
21395 echo "MDT filesfree available: ${ffree[@]}"
21396 echo "MDT blocks available: ${bavail[@]}"
21397 echo "weight diff=$diff%"
21400 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
21402 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
21403 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
21404 # decrease statfs age, so that it can be updated in time
21405 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
21406 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
21410 testdir=$DIR/$tdir-s$stripe_count/qos
21412 for i in $(seq $((100 * MDSCOUNT))); do
21413 eval $mkdir_cmd $testdir/subdir$i ||
21414 error "$mkdir_cmd subdir$i failed"
21417 for i in $(seq $MDSCOUNT); do
21418 count=$($LFS getdirstripe -i $testdir/* | grep ^$((i - 1))$ |
21420 echo "$count directories created on MDT$((i - 1))"
21422 if [ $stripe_count -gt 1 ]; then
21423 count=$($LFS getdirstripe $testdir/* |
21424 grep -P "^\s+$((i - 1))\t" | wc -l)
21425 echo "$count stripes created on MDT$((i - 1))"
21429 max=$($LFS getdirstripe -i $testdir/* | grep ^$max_index$ | wc -l)
21430 min=$($LFS getdirstripe -i $testdir/* | grep ^$min_index$ | wc -l)
21432 # D-value should > 10% of averge
21433 [ $((max - min)) -lt 10 ] &&
21434 error "subdirs shouldn't be evenly distributed"
21437 if [ $stripe_count -gt 1 ]; then
21438 max=$($LFS getdirstripe $testdir/* |
21439 grep -P "^\s+$max_index\t" | wc -l)
21440 min=$($LFS getdirstripe $testdir/* |
21441 grep -P "^\s+$min_index\t" | wc -l)
21442 [ $((max - min)) -le $((10 * stripe_count)) ] &&
21443 error "stripes shouldn't be evenly distributed"|| true
21448 [ $MDSCOUNT -lt 2 ] &&
21449 skip "We need at least 2 MDTs for this test"
21451 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
21452 skip "Need server version at least 2.12.52"
21456 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
21457 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
21458 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
21459 mkdir $DIR/$tdir-s$stripe_count/qos || error "mkdir failed"
21460 test_qos_mkdir "$LFS mkdir -c $stripe_count" $stripe_count
21463 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
21466 [ $MDSCOUNT -lt 2 ] &&
21467 skip "We need at least 2 MDTs for this test"
21469 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
21470 skip "Need server version at least 2.12.52"
21474 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
21475 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
21476 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
21477 mkdir $DIR/$tdir-s$stripe_count/qos || error "mkdir failed"
21478 $LFS setdirstripe -D -c $stripe_count \
21479 $DIR/$tdir-s$stripe_count/rr ||
21480 error "setdirstripe failed"
21481 $LFS setdirstripe -D -c $stripe_count \
21482 $DIR/$tdir-s$stripe_count/qos ||
21483 error "setdirstripe failed"
21484 test_qos_mkdir "mkdir" $stripe_count
21487 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
21490 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
21491 $LCTL set_param fail_loc=0x80000521
21492 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
21495 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
21498 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21499 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21500 skip "Need server version at least 2.11.52"
21510 # this test may be slow on ZFS
21511 [ "$mds1_FSTYPE" == "zfs" ] && total=100
21513 # though this test is designed for striped directory, let's test normal
21514 # directory too since lock is always saved as CoS lock.
21515 test_mkdir $DIR/$tdir || error "mkdir $tdir"
21516 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
21525 start_time=$(date +%s)
21526 for i in $(seq $total); do
21527 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
21530 end_time=$(date +%s)
21531 duration=$((end_time - start_time))
21533 kill -9 $setattr_pid
21535 echo "rename $total files took $duration sec"
21536 [ $duration -lt 100 ] || error "rename took $duration sec"
21538 run_test 415 "lock revoke is not missing"
21541 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
21542 skip "Need server version at least 2.11.55"
21544 # define OBD_FAIL_OSD_TXN_START 0x19a
21545 do_facet mds1 lctl set_param fail_loc=0x19a
21547 lfs mkdir -c $MDSCOUNT $DIR/$tdir
21551 run_test 416 "transaction start failure won't cause system hung"
21555 do_nodes $(comma_list $(mdts_nodes)) \
21556 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
21557 do_nodes $(comma_list $(mdts_nodes)) \
21558 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
21559 do_nodes $(comma_list $(mdts_nodes)) \
21560 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
21564 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21565 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
21566 skip "Need MDS version at least 2.11.56"
21568 trap cleanup_417 RETURN EXIT
21570 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
21571 do_nodes $(comma_list $(mdts_nodes)) \
21572 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
21573 $LFS migrate -m 0 $DIR/$tdir.1 &&
21574 error "migrate dir $tdir.1 should fail"
21576 do_nodes $(comma_list $(mdts_nodes)) \
21577 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
21578 $LFS mkdir -i 1 $DIR/$tdir.2 &&
21579 error "create remote dir $tdir.2 should fail"
21581 do_nodes $(comma_list $(mdts_nodes)) \
21582 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
21583 $LFS mkdir -c 2 $DIR/$tdir.3 &&
21584 error "create striped dir $tdir.3 should fail"
21587 run_test 417 "disable remote dir, striped dir and dir migration"
21589 # Checks that the outputs of df [-i] and lfs df [-i] match
21591 # usage: check_lfs_df <blocks | inodes> <mountpoint>
21601 [ "$1" == "blocks" ] && inodes= || inodes="-i"
21603 for count in {1..100}; do
21607 # read the lines of interest
21608 df_out=($(df -P $inodes $dir | tail -n +2)) ||
21609 error "df $inodes $dir | tail -n +2 failed"
21610 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
21611 error "lfs df $inodes $dir | grep summary: failed"
21613 # skip first substrings of each output as they are different
21614 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
21615 # compare the two outputs
21617 for i in {1..5}; do
21618 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
21626 lfs df $inodes $dir
21627 error "df and lfs df $1 output mismatch: " \
21628 "df ${inodes}: ${df_out[*]}, " \
21629 "lfs df ${inodes}: ${lfs_df_out[*]}"
21634 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21636 local dir=$DIR/$tdir
21637 local numfiles=$((RANDOM % 4096 + 2))
21638 local numblocks=$((RANDOM % 256 + 1))
21640 wait_delete_completed
21643 # check block output
21644 check_lfs_df blocks $dir
21645 # check inode output
21646 check_lfs_df inodes $dir
21648 # create a single file and retest
21649 echo "Creating a single file and testing"
21650 createmany -o $dir/$tfile- 1 &>/dev/null ||
21651 error "creating 1 file in $dir failed"
21652 check_lfs_df blocks $dir
21653 check_lfs_df inodes $dir
21655 # create a random number of files
21656 echo "Creating $((numfiles - 1)) files and testing"
21657 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
21658 error "creating $((numfiles - 1)) files in $dir failed"
21660 # write a random number of blocks to the first test file
21661 echo "Writing $numblocks 4K blocks and testing"
21662 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
21663 count=$numblocks &>/dev/null ||
21664 error "dd to $dir/${tfile}-0 failed"
21667 check_lfs_df blocks $dir
21668 check_lfs_df inodes $dir
21670 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
21671 error "unlinking $numfiles files in $dir failed"
21673 run_test 418 "df and lfs df outputs match"
21677 local dir=$DIR/$tdir
21682 cancel_lru_locks mdc
21684 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
21685 $LCTL set_param fail_loc=0x1410
21687 $LCTL set_param fail_loc=0
21690 run_test 419 "Verify open file by name doesn't crash kernel"
21694 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
21695 skip "Need MDS version at least 2.12.53"
21697 local SAVE_UMASK=$(umask)
21698 local dir=$DIR/$tdir
21699 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
21703 mkdir -m03777 $dir/testdir
21704 ls -dn $dir/testdir
21705 # Need to remove trailing '.' when SELinux is enabled
21706 local dirperms=$(ls -dn $dir/testdir |
21707 awk '{ sub(/\.$/, "", $1); print $1}')
21708 [ $dirperms == "drwxrwsrwt" ] ||
21709 error "incorrect perms on $dir/testdir"
21711 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
21712 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
21713 ls -n $dir/testdir/testfile
21714 local fileperms=$(ls -n $dir/testdir/testfile |
21715 awk '{ sub(/\.$/, "", $1); print $1}')
21716 [ $fileperms == "-rwxr-xr-x" ] ||
21717 error "incorrect perms on $dir/testdir/testfile"
21721 run_test 420 "clear SGID bit on non-directories for non-members"
21728 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21729 skip "Need MDS version at least 2.12.54"
21731 test_mkdir $DIR/$tdir
21732 createmany -o $DIR/$tdir/f 3
21733 cnt=$(ls -1 $DIR/$tdir | wc -l)
21734 [ $cnt != 3 ] && error "unexpected #files: $cnt"
21736 fid1=$(lfs path2fid $DIR/$tdir/f1)
21737 fid2=$(lfs path2fid $DIR/$tdir/f2)
21738 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
21740 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
21741 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
21743 cnt=$(ls -1 $DIR/$tdir | wc -l)
21744 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
21746 rm -f $DIR/$tdir/f3 || error "can't remove f3"
21747 createmany -o $DIR/$tdir/f 3
21748 cnt=$(ls -1 $DIR/$tdir | wc -l)
21749 [ $cnt != 3 ] && error "unexpected #files: $cnt"
21751 fid1=$(lfs path2fid $DIR/$tdir/f1)
21752 fid2=$(lfs path2fid $DIR/$tdir/f2)
21753 echo "remove using fsname $FSNAME"
21754 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
21756 cnt=$(ls -1 $DIR/$tdir | wc -l)
21757 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
21759 run_test 421a "simple rm by fid"
21766 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21767 skip "Need MDS version at least 2.12.54"
21769 test_mkdir $DIR/$tdir
21770 createmany -o $DIR/$tdir/f 3
21771 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
21774 FID1=$(lfs path2fid $DIR/$tdir/f1)
21775 FID2=$(lfs path2fid $DIR/$tdir/f2)
21776 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
21778 kill -USR1 $MULTIPID
21781 cnt=$(ls $DIR/$tdir | wc -l)
21782 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
21784 run_test 421b "rm by fid on open file"
21790 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21791 skip "Need MDS version at least 2.12.54"
21793 test_mkdir $DIR/$tdir
21794 createmany -o $DIR/$tdir/f 3
21795 touch $DIR/$tdir/$tfile
21796 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
21797 cnt=$(ls -1 $DIR/$tdir | wc -l)
21798 [ $cnt != 184 ] && error "unexpected #files: $cnt"
21800 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
21801 $LFS rmfid $DIR $FID1 || error "rmfid failed"
21803 cnt=$(ls $DIR/$tdir | wc -l)
21804 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
21806 run_test 421c "rm by fid against hardlinked files"
21812 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21813 skip "Need MDS version at least 2.12.54"
21815 test_mkdir $DIR/$tdir
21816 createmany -o $DIR/$tdir/f 4097
21817 cnt=$(ls -1 $DIR/$tdir | wc -l)
21818 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
21820 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
21821 $LFS rmfid $DIR $FIDS || error "rmfid failed"
21823 cnt=$(ls $DIR/$tdir | wc -l)
21825 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21827 run_test 421d "rmfid en masse"
21833 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21834 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21835 skip "Need MDS version at least 2.12.54"
21837 mkdir -p $DIR/$tdir
21838 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
21839 createmany -o $DIR/$tdir/striped_dir/f 512
21840 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21841 [ $cnt != 512 ] && error "unexpected #files: $cnt"
21843 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
21844 sed "s/[/][^:]*://g")
21845 $LFS rmfid $DIR $FIDS || error "rmfid failed"
21847 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
21849 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21851 run_test 421e "rmfid in DNE"
21857 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21858 skip "Need MDS version at least 2.12.54"
21860 test_mkdir $DIR/$tdir
21862 cnt=$(ls -1 $DIR/$tdir | wc -l)
21863 [ $cnt != 1 ] && error "unexpected #files: $cnt"
21865 FID=$(lfs path2fid $DIR/$tdir/f)
21866 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
21867 # rmfid should fail
21868 cnt=$(ls -1 $DIR/$tdir | wc -l)
21869 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
21871 chmod a+rw $DIR/$tdir
21873 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
21874 # rmfid should fail
21875 cnt=$(ls -1 $DIR/$tdir | wc -l)
21876 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
21879 $RUNAS touch $DIR/$tdir/f
21880 FID=$(lfs path2fid $DIR/$tdir/f)
21881 echo "rmfid as root"
21882 $LFS rmfid $DIR $FID || error "rmfid as root failed"
21883 cnt=$(ls -1 $DIR/$tdir | wc -l)
21884 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
21887 $RUNAS touch $DIR/$tdir/f
21888 cnt=$(ls -1 $DIR/$tdir | wc -l)
21889 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
21890 FID=$(lfs path2fid $DIR/$tdir/f)
21891 # rmfid w/o user_fid2path mount option should fail
21892 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
21893 cnt=$(ls -1 $DIR/$tdir | wc -l)
21894 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
21896 umount_client $MOUNT || error "failed to umount client"
21897 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
21898 error "failed to mount client'"
21900 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
21901 # rmfid should succeed
21902 cnt=$(ls -1 $DIR/$tdir | wc -l)
21903 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
21905 # rmfid shouldn't allow to remove files due to dir's permission
21906 chmod a+rwx $DIR/$tdir
21909 FID=$(lfs path2fid $DIR/$tdir/f)
21910 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
21912 umount_client $MOUNT || error "failed to umount client"
21913 mount_client $MOUNT "$MOUNT_OPTS" ||
21914 error "failed to mount client'"
21917 run_test 421f "rmfid checks permissions"
21923 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21924 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21925 skip "Need MDS version at least 2.12.54"
21927 mkdir -p $DIR/$tdir
21928 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
21929 createmany -o $DIR/$tdir/striped_dir/f 512
21930 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21931 [ $cnt != 512 ] && error "unexpected #files: $cnt"
21933 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
21934 sed "s/[/][^:]*://g")
21936 rm -f $DIR/$tdir/striped_dir/f1*
21937 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21938 removed=$((512 - cnt))
21940 # few files have been just removed, so we expect
21941 # rmfid to fail on their fids
21942 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
21943 [ $removed != $errors ] && error "$errors != $removed"
21945 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
21947 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21949 run_test 421g "rmfid to return errors properly"
21952 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
21953 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
21954 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
21955 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
21956 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
21958 local amc=$(at_max_get client)
21959 local amo=$(at_max_get mds1)
21960 local timeout=`lctl get_param -n timeout`
21962 at_max_set 0 client
21965 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
21966 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
21967 fail_val=$(((2*timeout + 10)*1000))
21968 touch $DIR/$tdir/d3/file &
21970 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
21971 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
21972 fail_val=$((2*timeout + 5))
21973 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
21977 sleep $((2 * timeout))
21981 touch $DIR/$tdir/d2/file3
21982 touch $DIR/$tdir/d2/file4
21983 touch $DIR/$tdir/d2/file5
21986 at_max_set $amc client
21987 at_max_set $amo mds1
21989 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
21990 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
21991 error "Watchdog is always throttled"
21993 run_test 422 "kill a process with RPC in progress"
22006 # ensure statfs cache is expired
22009 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
22010 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
22014 run_test 423 "statfs should return a right data"
22017 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
22018 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
22019 skip "Need server version at least 2.9.55"
22021 start_full_debug_logging
22025 stop_full_debug_logging
22029 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
22030 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
22031 awk '/The barrier for/ { print $7 }')
22034 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
22039 barrier_expired() {
22042 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
22043 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
22044 awk '/will be expired/ { print $7 }')
22046 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
22055 echo "Start barrier_freeze at: $(date)"
22056 #define OBD_FAIL_BARRIER_DELAY 0x2202
22057 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
22058 # Do not reduce barrier time - See LU-11873
22059 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
22062 local b_status=$(barrier_stat)
22063 echo "Got barrier status at: $(date)"
22064 [ "$b_status" = "'freezing_p1'" ] ||
22065 error "(1) unexpected barrier status $b_status"
22067 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
22069 b_status=$(barrier_stat)
22070 [ "$b_status" = "'frozen'" ] ||
22071 error "(2) unexpected barrier status $b_status"
22073 local expired=$(barrier_expired)
22074 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
22075 sleep $((expired + 3))
22077 b_status=$(barrier_stat)
22078 [ "$b_status" = "'expired'" ] ||
22079 error "(3) unexpected barrier status $b_status"
22081 # Do not reduce barrier time - See LU-11873
22082 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
22083 error "(4) fail to freeze barrier"
22085 b_status=$(barrier_stat)
22086 [ "$b_status" = "'frozen'" ] ||
22087 error "(5) unexpected barrier status $b_status"
22089 echo "Start barrier_thaw at: $(date)"
22090 #define OBD_FAIL_BARRIER_DELAY 0x2202
22091 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
22092 do_facet mgs $LCTL barrier_thaw $FSNAME &
22095 b_status=$(barrier_stat)
22096 echo "Got barrier status at: $(date)"
22097 [ "$b_status" = "'thawing'" ] ||
22098 error "(6) unexpected barrier status $b_status"
22100 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
22102 b_status=$(barrier_stat)
22103 [ "$b_status" = "'thawed'" ] ||
22104 error "(7) unexpected barrier status $b_status"
22106 #define OBD_FAIL_BARRIER_FAILURE 0x2203
22107 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
22108 do_facet mgs $LCTL barrier_freeze $FSNAME
22110 b_status=$(barrier_stat)
22111 [ "$b_status" = "'failed'" ] ||
22112 error "(8) unexpected barrier status $b_status"
22114 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
22115 do_facet mgs $LCTL barrier_thaw $FSNAME
22119 run_test 801a "write barrier user interfaces and stat machine"
22124 mkdir $DIR/$tdir || error "(1) fail to mkdir"
22125 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
22126 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
22127 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
22128 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
22130 cancel_lru_locks mdc
22132 # 180 seconds should be long enough
22133 do_facet mgs $LCTL barrier_freeze $FSNAME 180
22135 local b_status=$(barrier_stat)
22136 [ "$b_status" = "'frozen'" ] ||
22137 error "(6) unexpected barrier status $b_status"
22139 mkdir $DIR/$tdir/d0/d10 &
22142 touch $DIR/$tdir/d1/f13 &
22145 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
22148 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
22151 rm -f $DIR/$tdir/d4/f12 &
22154 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
22156 # To guarantee taht the 'stat' is not blocked
22157 b_status=$(barrier_stat)
22158 [ "$b_status" = "'frozen'" ] ||
22159 error "(8) unexpected barrier status $b_status"
22161 # let above commands to run at background
22164 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
22165 ps -p $touch_pid || error "(10) touch should be blocked"
22166 ps -p $ln_pid || error "(11) link should be blocked"
22167 ps -p $mv_pid || error "(12) rename should be blocked"
22168 ps -p $rm_pid || error "(13) unlink should be blocked"
22170 b_status=$(barrier_stat)
22171 [ "$b_status" = "'frozen'" ] ||
22172 error "(14) unexpected barrier status $b_status"
22174 do_facet mgs $LCTL barrier_thaw $FSNAME
22175 b_status=$(barrier_stat)
22176 [ "$b_status" = "'thawed'" ] ||
22177 error "(15) unexpected barrier status $b_status"
22179 wait $mkdir_pid || error "(16) mkdir should succeed"
22180 wait $touch_pid || error "(17) touch should succeed"
22181 wait $ln_pid || error "(18) link should succeed"
22182 wait $mv_pid || error "(19) rename should succeed"
22183 wait $rm_pid || error "(20) unlink should succeed"
22187 run_test 801b "modification will be blocked by write barrier"
22190 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
22194 stop mds2 || error "(1) Fail to stop mds2"
22196 do_facet mgs $LCTL barrier_freeze $FSNAME 30
22198 local b_status=$(barrier_stat)
22199 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
22200 do_facet mgs $LCTL barrier_thaw $FSNAME
22201 error "(2) unexpected barrier status $b_status"
22204 do_facet mgs $LCTL barrier_rescan $FSNAME ||
22205 error "(3) Fail to rescan barrier bitmap"
22207 # Do not reduce barrier time - See LU-11873
22208 do_facet mgs $LCTL barrier_freeze $FSNAME 20
22210 b_status=$(barrier_stat)
22211 [ "$b_status" = "'frozen'" ] ||
22212 error "(4) unexpected barrier status $b_status"
22214 do_facet mgs $LCTL barrier_thaw $FSNAME
22215 b_status=$(barrier_stat)
22216 [ "$b_status" = "'thawed'" ] ||
22217 error "(5) unexpected barrier status $b_status"
22219 local devname=$(mdsdevname 2)
22221 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
22223 do_facet mgs $LCTL barrier_rescan $FSNAME ||
22224 error "(7) Fail to rescan barrier bitmap"
22228 run_test 801c "rescan barrier bitmap"
22230 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
22231 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
22232 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
22233 saved_MOUNT_OPTS=$MOUNT_OPTS
22239 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
22240 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
22241 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
22242 MOUNT_OPTS=$saved_MOUNT_OPTS
22247 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
22248 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
22249 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
22250 skip "Need server version at least 2.9.55"
22252 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
22254 mkdir $DIR/$tdir || error "(1) fail to mkdir"
22256 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
22257 error "(2) Fail to copy"
22259 trap cleanup_802a EXIT
22261 # sync by force before remount as readonly
22262 sync; sync_all_data; sleep 3; sync_all_data
22266 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
22267 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
22268 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
22270 echo "Mount the server as read only"
22271 setupall server_only || error "(3) Fail to start servers"
22273 echo "Mount client without ro should fail"
22274 mount_client $MOUNT &&
22275 error "(4) Mount client without 'ro' should fail"
22277 echo "Mount client with ro should succeed"
22278 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
22279 mount_client $MOUNT ||
22280 error "(5) Mount client with 'ro' should succeed"
22282 echo "Modify should be refused"
22283 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
22285 echo "Read should be allowed"
22286 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
22287 error "(7) Read should succeed under ro mode"
22291 run_test 802a "simulate readonly device"
22294 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22295 remote_mds_nodsh && skip "remote MDS with nodsh"
22297 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
22298 skip "readonly option not available"
22300 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
22302 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
22303 error "(2) Fail to copy"
22305 # write back all cached data before setting MDT to readonly
22309 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
22310 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
22312 echo "Modify should be refused"
22313 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
22315 echo "Read should be allowed"
22316 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
22317 error "(7) Read should succeed under ro mode"
22320 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
22322 run_test 802b "be able to set MDTs to readonly"
22325 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
22326 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
22327 skip "MDS needs to be newer than 2.10.54"
22329 mkdir -p $DIR/$tdir
22330 # Create some objects on all MDTs to trigger related logs objects
22331 for idx in $(seq $MDSCOUNT); do
22332 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
22333 $DIR/$tdir/dir${idx} ||
22334 error "Fail to create $DIR/$tdir/dir${idx}"
22338 wait_delete_completed # ensure old test cleanups are finished
22339 echo "before create:"
22341 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
22343 for i in {1..10}; do
22344 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
22345 error "Fail to create $DIR/$tdir/foo$i"
22349 echo "after create:"
22351 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
22353 # allow for an llog to be cleaned up during the test
22354 [ $after_used -ge $((before_used + 10 - 1)) ] ||
22355 error "before ($before_used) + 10 > after ($after_used)"
22357 for i in {1..10}; do
22358 rm -rf $DIR/$tdir/foo$i ||
22359 error "Fail to remove $DIR/$tdir/foo$i"
22362 sleep 3 # avoid MDT return cached statfs
22363 wait_delete_completed
22364 echo "after unlink:"
22366 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
22368 # allow for an llog to be created during the test
22369 [ $after_used -le $((before_used + 1)) ] ||
22370 error "after ($after_used) > before ($before_used) + 1"
22372 run_test 803 "verify agent object for remote object"
22375 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
22376 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
22377 skip "MDS needs to be newer than 2.10.54"
22378 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
22380 mkdir -p $DIR/$tdir
22381 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
22382 error "Fail to create $DIR/$tdir/dir0"
22384 local fid=$($LFS path2fid $DIR/$tdir/dir0)
22385 local dev=$(mdsdevname 2)
22387 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
22388 grep ${fid} || error "NOT found agent entry for dir0"
22390 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
22391 error "Fail to create $DIR/$tdir/dir1"
22393 touch $DIR/$tdir/dir1/foo0 ||
22394 error "Fail to create $DIR/$tdir/dir1/foo0"
22395 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
22398 for idx in $(seq $MDSCOUNT); do
22399 dev=$(mdsdevname $idx)
22400 do_facet mds${idx} \
22401 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
22402 grep ${fid} && rc=$idx
22405 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
22406 error "Fail to rename foo0 to foo1"
22407 if [ $rc -eq 0 ]; then
22408 for idx in $(seq $MDSCOUNT); do
22409 dev=$(mdsdevname $idx)
22410 do_facet mds${idx} \
22411 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
22412 grep ${fid} && rc=$idx
22416 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
22417 error "Fail to rename foo1 to foo2"
22418 if [ $rc -eq 0 ]; then
22419 for idx in $(seq $MDSCOUNT); do
22420 dev=$(mdsdevname $idx)
22421 do_facet mds${idx} \
22422 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
22423 grep ${fid} && rc=$idx
22427 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
22429 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
22430 error "Fail to link to $DIR/$tdir/dir1/foo2"
22431 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
22432 error "Fail to rename foo2 to foo0"
22433 unlink $DIR/$tdir/dir1/foo0 ||
22434 error "Fail to unlink $DIR/$tdir/dir1/foo0"
22435 rm -rf $DIR/$tdir/dir0 ||
22436 error "Fail to rm $DIR/$tdir/dir0"
22438 for idx in $(seq $MDSCOUNT); do
22439 dev=$(mdsdevname $idx)
22443 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
22445 start mds${idx} $dev $MDS_MOUNT_OPTS ||
22446 error "mount mds$idx failed"
22447 df $MOUNT > /dev/null 2>&1
22449 # e2fsck should not return error
22451 error "e2fsck detected error on MDT${idx}: rc=$rc"
22454 run_test 804 "verify agent entry for remote entry"
22457 do_facet $SINGLEMDS zfs set quota=$old $fsset
22458 unlinkmany $DIR/$tdir/f- 1000000
22463 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
22464 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
22465 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
22466 skip "netfree not implemented before 0.7"
22467 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
22468 skip "Need MDS version at least 2.10.57"
22475 local pref="osd-zfs.$FSNAME-MDT0000."
22477 # limit available space on MDS dataset to meet nospace issue
22478 # quickly. then ZFS 0.7.2 can use reserved space if asked
22479 # properly (using netfree flag in osd_declare_destroy()
22480 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
22481 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
22483 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
22484 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
22485 let "usedkb=usedkb-freekb"
22486 let "freekb=freekb/2"
22487 if let "freekb > 5000"; then
22490 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
22491 trap cleanup_805 EXIT
22493 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
22494 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
22495 rm -rf $DIR/$tdir || error "not able to remove"
22496 do_facet $SINGLEMDS zfs set quota=$old $fsset
22499 run_test 805 "ZFS can remove from full fs"
22505 local size=$($LFS getsom -s $file)
22506 local expect=$(stat -c %s $file)
22508 [[ $size == $expect ]] ||
22509 error "$file expected size: $expect, got: $size"
22511 local blocks=$($LFS getsom -b $file)
22512 expect=$(stat -c %b $file)
22513 [[ $blocks == $expect ]] ||
22514 error "$file expected blocks: $expect, got: $blocks"
22519 local size=$($LFS getsom -s $1)
22522 [[ $size == $expect ]] ||
22523 error "$file expected size: $expect, got: $size"
22527 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22528 skip "Need MDS version at least 2.11.52"
22532 touch $DIR/$tfile || error "touch $tfile failed"
22534 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22535 save_lustre_params client "llite.*.xattr_cache" > $save
22536 lctl set_param llite.*.xattr_cache=0
22537 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22539 # single-threaded write
22540 echo "Test SOM for single-threaded write"
22541 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
22542 error "write $tfile failed"
22543 check_lsom_size $DIR/$tfile $bs
22546 local size=$(($num * $bs))
22550 echo "Test SOM for single client multi-threaded($num) write"
22551 $TRUNCATE $DIR/$tfile 0
22552 for ((i = 0; i < $num; i++)); do
22553 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22555 offset=$((offset + $bs))
22557 for (( i=0; i < $num; i++ )); do
22560 check_lsom_size $DIR/$tfile $size
22562 $TRUNCATE $DIR/$tfile 0
22563 for ((i = 0; i < $num; i++)); do
22564 offset=$((offset - $bs))
22565 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22568 for (( i=0; i < $num; i++ )); do
22571 check_lsom_size $DIR/$tfile $size
22573 # multi-client writes
22574 num=$(get_node_count ${CLIENTS//,/ })
22575 size=$(($num * $bs))
22579 echo "Test SOM for multi-client ($num) writes"
22580 $TRUNCATE $DIR/$tfile 0
22581 for client in ${CLIENTS//,/ }; do
22582 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22585 offset=$((offset + $bs))
22587 for (( i=0; i < $num; i++ )); do
22590 check_lsom_size $DIR/$tfile $offset
22593 $TRUNCATE $DIR/$tfile 0
22594 for client in ${CLIENTS//,/ }; do
22595 offset=$((offset - $bs))
22596 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22600 for (( i=0; i < $num; i++ )); do
22603 check_lsom_size $DIR/$tfile $size
22606 echo "Test SOM for truncate"
22607 $TRUNCATE $DIR/$tfile 1048576
22608 check_lsom_size $DIR/$tfile 1048576
22609 $TRUNCATE $DIR/$tfile 1234
22610 check_lsom_size $DIR/$tfile 1234
22612 # verify SOM blocks count
22613 echo "Verify SOM block count"
22614 $TRUNCATE $DIR/$tfile 0
22615 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
22616 error "failed to write file $tfile"
22617 check_lsom_data $DIR/$tfile
22619 run_test 806 "Verify Lazy Size on MDS"
22622 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
22623 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22624 skip "Need MDS version at least 2.11.52"
22626 # Registration step
22627 changelog_register || error "changelog_register failed"
22628 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
22629 changelog_users $SINGLEMDS | grep -q $cl_user ||
22630 error "User $cl_user not found in changelog_users"
22632 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22633 save_lustre_params client "llite.*.xattr_cache" > $save
22634 lctl set_param llite.*.xattr_cache=0
22635 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22637 rm -rf $DIR/$tdir || error "rm $tdir failed"
22638 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
22639 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
22640 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
22641 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
22642 error "truncate $tdir/trunc failed"
22645 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
22646 error "write $tfile failed"
22648 # multi-client wirtes
22649 local num=$(get_node_count ${CLIENTS//,/ })
22653 echo "Test SOM for multi-client ($num) writes"
22654 touch $DIR/$tfile || error "touch $tfile failed"
22655 $TRUNCATE $DIR/$tfile 0
22656 for client in ${CLIENTS//,/ }; do
22657 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22660 offset=$((offset + $bs))
22662 for (( i=0; i < $num; i++ )); do
22667 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
22668 check_lsom_data $DIR/$tdir/trunc
22669 check_lsom_data $DIR/$tdir/single_dd
22670 check_lsom_data $DIR/$tfile
22673 # Deregistration step
22674 changelog_deregister || error "changelog_deregister failed"
22676 run_test 807 "verify LSOM syncing tool"
22678 check_som_nologged()
22680 local lines=$($LFS changelog $FSNAME-MDT0000 |
22681 grep 'x=trusted.som' | wc -l)
22682 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
22686 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
22687 skip "Need MDS version at least 2.11.55"
22689 # Registration step
22690 changelog_register || error "changelog_register failed"
22692 touch $DIR/$tfile || error "touch $tfile failed"
22695 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
22696 error "write $tfile failed"
22699 $TRUNCATE $DIR/$tfile 1234
22702 $TRUNCATE $DIR/$tfile 1048576
22705 # Deregistration step
22706 changelog_deregister || error "changelog_deregister failed"
22708 run_test 808 "Check trusted.som xattr not logged in Changelogs"
22713 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
22717 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22718 skip "Need MDS version at least 2.11.56"
22720 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
22721 error "failed to create DoM-only file $DIR/$tfile"
22722 touch $DIR/$tfile || error "touch $tfile failed"
22723 check_som_nodata $DIR/$tfile
22725 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
22726 error "write $tfile failed"
22727 check_som_nodata $DIR/$tfile
22729 $TRUNCATE $DIR/$tfile 1234
22730 check_som_nodata $DIR/$tfile
22732 $TRUNCATE $DIR/$tfile 4097
22733 check_som_nodata $DIR/$file
22735 run_test 809 "Verify no SOM xattr store for DoM-only files"
22738 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22739 $GSS && skip_env "could not run with gss"
22740 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
22741 skip "OST < 2.12.58 doesn't align checksum"
22744 stack_trap "set_checksums $ORIG_CSUM" EXIT
22745 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
22750 for csum in $CKSUM_TYPES; do
22751 #define OBD_FAIL_OSC_NO_GRANT 0x411
22752 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
22753 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
22755 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
22756 before=$(md5sum $DIR/$tfile)
22757 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
22758 after=$(md5sum $DIR/$tfile)
22759 [ "$before" == "$after" ] ||
22760 error "$csum: $before != $after bs=$1 seek=$2"
22764 run_test 810 "partial page writes on ZFS (LU-11663)"
22767 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22768 skip "Need MDS version at least 2.11.56"
22770 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
22771 do_facet mds1 $LCTL set_param fail_loc=0x165
22772 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
22775 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
22777 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
22778 error "MDD orphan cleanup thread not quit"
22780 run_test 811 "orphan name stub can be cleaned up in startup"
22783 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
22784 skip "OST < 2.12.51 doesn't support this fail_loc"
22785 [ "$SHARED_KEY" = true ] &&
22786 skip "OSC connections never go IDLE with Shared-Keys enabled"
22788 $LFS setstripe -c 1 -i 0 $DIR/$tfile
22789 # ensure ost1 is connected
22790 stat $DIR/$tfile >/dev/null || error "can't stat"
22791 wait_osc_import_state client ost1 FULL
22792 # no locks, no reqs to let the connection idle
22793 cancel_lru_locks osc
22795 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
22796 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
22797 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
22798 wait_osc_import_state client ost1 CONNECTING
22799 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
22801 stat $DIR/$tfile >/dev/null || error "can't stat file"
22803 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
22805 test_812b() { # LU-12378
22806 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
22807 skip "OST < 2.12.51 doesn't support this fail_loc"
22808 [ "$SHARED_KEY" = true ] &&
22809 skip "OSC connections never go IDLE with Shared-Keys enabled"
22811 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
22812 # ensure ost1 is connected
22813 stat $DIR/$tfile >/dev/null || error "can't stat"
22814 wait_osc_import_state client ost1 FULL
22815 # no locks, no reqs to let the connection idle
22816 cancel_lru_locks osc
22818 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
22819 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
22820 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
22821 wait_osc_import_state client ost1 CONNECTING
22822 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
22824 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
22825 wait_osc_import_state client ost1 IDLE
22827 run_test 812b "do not drop no resend request for idle connect"
22830 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
22831 [ -z "$file_heat_sav" ] && skip "no file heat support"
22842 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
22843 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
22845 $LCTL set_param -n llite.*.file_heat=1
22846 echo "Turn on file heat"
22847 echo "Period second: $period_second, Decay percentage: $decay_pct"
22849 echo "QQQQ" > $DIR/$tfile
22850 echo "QQQQ" > $DIR/$tfile
22851 echo "QQQQ" > $DIR/$tfile
22852 cat $DIR/$tfile > /dev/null
22853 cat $DIR/$tfile > /dev/null
22854 cat $DIR/$tfile > /dev/null
22855 cat $DIR/$tfile > /dev/null
22857 local out=$($LFS heat_get $DIR/$tfile)
22859 $LFS heat_get $DIR/$tfile
22860 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22861 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22862 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22863 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22865 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
22866 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
22867 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
22868 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
22870 sleep $((period_second + 3))
22871 echo "Sleep $((period_second + 3)) seconds..."
22872 # The recursion formula to calculate the heat of the file f is as
22874 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
22875 # Where Hi is the heat value in the period between time points i*I and
22876 # (i+1)*I; Ci is the access count in the period; the symbol P refers
22877 # to the weight of Ci.
22878 out=$($LFS heat_get $DIR/$tfile)
22879 $LFS heat_get $DIR/$tfile
22880 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22881 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22882 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22883 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22885 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
22886 error "read sample ($readsample) is wrong"
22887 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
22888 error "write sample ($writesample) is wrong"
22889 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
22890 error "read bytes ($readbyte) is wrong"
22891 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
22892 error "write bytes ($writebyte) is wrong"
22894 echo "QQQQ" > $DIR/$tfile
22895 echo "QQQQ" > $DIR/$tfile
22896 echo "QQQQ" > $DIR/$tfile
22897 cat $DIR/$tfile > /dev/null
22898 cat $DIR/$tfile > /dev/null
22899 cat $DIR/$tfile > /dev/null
22900 cat $DIR/$tfile > /dev/null
22902 sleep $((period_second + 3))
22903 echo "Sleep $((period_second + 3)) seconds..."
22905 out=$($LFS heat_get $DIR/$tfile)
22906 $LFS heat_get $DIR/$tfile
22907 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22908 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22909 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22910 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22912 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
22913 4 * $decay_pct) / 100") -eq 1 ] ||
22914 error "read sample ($readsample1) is wrong"
22915 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
22916 3 * $decay_pct) / 100") -eq 1 ] ||
22917 error "write sample ($writesample1) is wrong"
22918 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
22919 20 * $decay_pct) / 100") -eq 1 ] ||
22920 error "read bytes ($readbyte1) is wrong"
22921 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
22922 15 * $decay_pct) / 100") -eq 1 ] ||
22923 error "write bytes ($writebyte1) is wrong"
22925 echo "Turn off file heat for the file $DIR/$tfile"
22926 $LFS heat_set -o $DIR/$tfile
22928 echo "QQQQ" > $DIR/$tfile
22929 echo "QQQQ" > $DIR/$tfile
22930 echo "QQQQ" > $DIR/$tfile
22931 cat $DIR/$tfile > /dev/null
22932 cat $DIR/$tfile > /dev/null
22933 cat $DIR/$tfile > /dev/null
22934 cat $DIR/$tfile > /dev/null
22936 out=$($LFS heat_get $DIR/$tfile)
22937 $LFS heat_get $DIR/$tfile
22938 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22939 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22940 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22941 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22943 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
22944 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
22945 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
22946 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
22948 echo "Trun on file heat for the file $DIR/$tfile"
22949 $LFS heat_set -O $DIR/$tfile
22951 echo "QQQQ" > $DIR/$tfile
22952 echo "QQQQ" > $DIR/$tfile
22953 echo "QQQQ" > $DIR/$tfile
22954 cat $DIR/$tfile > /dev/null
22955 cat $DIR/$tfile > /dev/null
22956 cat $DIR/$tfile > /dev/null
22957 cat $DIR/$tfile > /dev/null
22959 out=$($LFS heat_get $DIR/$tfile)
22960 $LFS heat_get $DIR/$tfile
22961 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22962 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22963 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22964 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22966 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
22967 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
22968 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
22969 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
22971 $LFS heat_set -c $DIR/$tfile
22972 $LCTL set_param -n llite.*.file_heat=0
22973 echo "Turn off file heat support for the Lustre filesystem"
22975 echo "QQQQ" > $DIR/$tfile
22976 echo "QQQQ" > $DIR/$tfile
22977 echo "QQQQ" > $DIR/$tfile
22978 cat $DIR/$tfile > /dev/null
22979 cat $DIR/$tfile > /dev/null
22980 cat $DIR/$tfile > /dev/null
22981 cat $DIR/$tfile > /dev/null
22983 out=$($LFS heat_get $DIR/$tfile)
22984 $LFS heat_get $DIR/$tfile
22985 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22986 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22987 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22988 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22990 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
22991 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
22992 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
22993 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
22995 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
22998 run_test 813 "File heat verfication"
23002 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
23003 echo -n y >> $DIR/$tfile
23004 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
23005 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
23007 run_test 814 "sparse cp works as expected (LU-12361)"
23011 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
23012 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
23014 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
23017 [ "$SHARED_KEY" = true ] &&
23018 skip "OSC connections never go IDLE with Shared-Keys enabled"
23020 $LFS setstripe -c 1 -i 0 $DIR/$tfile
23021 # ensure ost1 is connected
23022 stat $DIR/$tfile >/dev/null || error "can't stat"
23023 wait_osc_import_state client ost1 FULL
23024 # no locks, no reqs to let the connection idle
23025 cancel_lru_locks osc
23026 lru_resize_disable osc
23029 before=$($LCTL get_param -n \
23030 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
23032 wait_osc_import_state client ost1 IDLE
23033 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
23034 now=$($LCTL get_param -n \
23035 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
23036 [ $before == $now ] || error "lru_size changed $before != $now"
23038 run_test 816 "do not reset lru_resize on idle reconnect"
23042 exportfs -u localhost:$DIR/nfsexp
23047 systemctl restart nfs-server.service || skip "failed to restart nfsd"
23049 mkdir -p $DIR/nfsexp
23050 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
23051 error "failed to export nfs"
23053 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
23054 stack_trap cleanup_817 EXIT
23056 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
23057 error "failed to mount nfs to $tmpdir"
23059 cp /bin/true $tmpdir
23060 $DIR/nfsexp/true || error "failed to execute 'true' command"
23062 run_test 817 "nfsd won't cache write lock for exec file"
23066 $LFS setstripe -c1 -i0 $DIR/$tfile
23067 $LFS setstripe -c1 -i1 $DIR/$tfile
23069 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
23070 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
23071 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
23072 error "start $SINGLEMDS failed"
23075 run_test 818 "unlink with failed llog"
23078 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23079 cancel_lru_locks osc
23080 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
23081 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
23082 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
23085 run_test 819a "too big niobuf in read"
23088 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
23089 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
23090 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23091 cancel_lru_locks osc
23095 run_test 819b "too big niobuf in write"
23098 function test_820_start_ost() {
23101 for num in $(seq $OSTCOUNT); do
23102 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
23107 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23110 umount_client $MOUNT || error "umount failed"
23111 for num in $(seq $OSTCOUNT); do
23115 # mount client with no active OSTs
23116 # so that the client can't initialize max LOV EA size
23117 # from OSC notifications
23118 mount_client $MOUNT || error "mount failed"
23119 # delay OST starting to keep this 0 max EA size for a while
23120 test_820_start_ost &
23122 # create a directory on MDS2
23123 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
23124 error "Failed to create directory"
23125 # open intent should update default EA size
23126 # see mdc_update_max_ea_from_body()
23127 # notice this is the very first RPC to MDS2
23128 cp /etc/services $DIR/$tdir/mds2 ||
23129 error "Failed to copy files to mds$n"
23131 run_test 820 "update max EA from open intent"
23134 # tests that do cleanup/setup should be run at the end
23138 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23141 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
23142 $LCTL set_param fail_loc=0x903
23144 cancel_lru_locks MGC
23146 FAIL_ON_ERROR=true cleanup
23147 FAIL_ON_ERROR=true setup
23149 run_test 900 "umount should not race with any mgc requeue thread"
23151 # LUS-6253/LU-11185
23157 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23159 # some get_param have a bug to handle dot in param name
23160 cancel_lru_locks MGC
23161 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
23162 olds=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
23163 umount_client $MOUNT || error "umount failed"
23164 mount_client $MOUNT || error "mount failed"
23165 cancel_lru_locks MGC
23166 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
23167 news=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
23169 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
23170 [ $olds -lt $news ] && error "mgs lock leak ($olds != $news)"
23174 run_test 901 "don't leak a mgc lock on client umount"
23177 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
23178 check_and_cleanup_lustre
23179 if [ "$I_MOUNTED" != "yes" ]; then
23180 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true