3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 MUNLINK=${MUNLINK:-munlink}
23 SOCKETSERVER=${SOCKETSERVER:-socketserver}
24 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
25 MEMHOG=${MEMHOG:-memhog}
26 DIRECTIO=${DIRECTIO:-directio}
27 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
31 export PARALLEL=${PARALLEL:-"no"}
34 LUSTRE=${LUSTRE:-$(dirname $0)/..}
35 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
36 . $LUSTRE/tests/test-framework.sh
41 ALWAYS_EXCEPT="$SANITY_EXCEPT "
42 # bug number for skipped test: LU-9693 LU-6493 LU-9693
43 ALWAYS_EXCEPT+=" 42a 42b 42c "
44 # bug number: LU-8411 LU-9054 LU-13314
45 ALWAYS_EXCEPT+=" 407 312 56ob"
48 # bug number: LU-9795 LU-9795 LU-9795 LU-9795
49 ALWAYS_EXCEPT+=" 17n 60a 133g 300f"
52 selinux_status=$(getenforce)
53 if [ "$selinux_status" != "Disabled" ]; then
58 # skip the grant tests for ARM until they are fixed
59 if [[ $(uname -m) = aarch64 ]]; then
60 # bug number: LU-11596
61 ALWAYS_EXCEPT+=" $GRANT_CHECK_LIST"
62 # bug number: LU-11671 LU-11667
63 ALWAYS_EXCEPT+=" 45 317"
66 # skip nfs tests on kernels >= 4.14.0 until they are fixed
67 if [ $LINUX_VERSION_CODE -ge $(version_code 4.14.0) ]; then
68 # bug number: LU-12661
71 # skip cgroup tests on RHEL8.1 kernels until they are fixed
72 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
73 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
74 # bug number: LU-13063
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 135 136 300o"
81 if [ "$mds1_FSTYPE" = "zfs" ]; then
82 # bug number for skipped test:
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
85 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
88 # Get the SLES distro version
90 # Returns a version string that should only be used in comparing
91 # strings returned by version_code()
94 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
96 # All SuSE Linux versions have one decimal. version_code expects two
97 local sles_version=$version.0
98 version_code $sles_version
101 # Check if we are running on Ubuntu or SLES so we can make decisions on
103 if [ -r /etc/SuSE-release ]; then
104 sles_version=$(sles_version_code)
105 [ $sles_version -lt $(version_code 11.4.0) ] &&
106 # bug number for skipped test: LU-4341
107 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
108 [ $sles_version -lt $(version_code 12.0.0) ] &&
109 # bug number for skipped test: LU-3703
110 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
111 elif [ -r /etc/os-release ]; then
112 if grep -qi ubuntu /etc/os-release; then
113 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
114 -e 's/^VERSION=//p' \
118 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
119 # bug number for skipped test:
121 ALWAYS_EXCEPT+=" 103a 410"
131 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
132 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
141 check_swap_layouts_support()
143 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
144 skip "Does not support layout lock."
147 check_and_setup_lustre
151 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
153 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
154 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
155 rm -rf $DIR/[Rdfs][0-9]*
157 # $RUNAS_ID may get set incorrectly somewhere else
158 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
159 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
161 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
163 if [ "${ONLY}" = "MOUNT" ] ; then
164 echo "Lustre is up, please go on"
168 echo "preparing for tests involving mounts"
169 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
171 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
172 echo # add a newline after mke2fs.
176 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
177 lctl set_param debug=-1 2> /dev/null || true
180 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
182 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
184 run_test 0a "touch; rm ====================="
187 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
188 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
190 run_test 0b "chmod 0755 $DIR ============================="
193 $LCTL get_param mdc.*.import | grep "state: FULL" ||
194 error "import not FULL"
195 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
198 run_test 0c "check import proc"
200 test_0d() { # LU-3397
201 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
202 skip "proc exports not supported before 2.10.57"
204 local mgs_exp="mgs.MGS.exports"
205 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
207 local exp_client_version
210 local temp_imp=$DIR/$tfile.import
211 local temp_exp=$DIR/$tfile.export
213 # save mgc import file to $temp_imp
214 $LCTL get_param mgc.*.import | tee $temp_imp
215 # Check if client uuid is found in MGS export
216 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
217 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
221 # save mgs export file to $temp_exp
222 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
224 # Compare the value of field "connect_flags"
225 imp_val=$(grep "connect_flags" $temp_imp)
226 exp_val=$(grep "connect_flags" $temp_exp)
227 [ "$exp_val" == "$imp_val" ] ||
228 error "export flags '$exp_val' != import flags '$imp_val'"
230 # Compare the value of client version
231 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
232 exp_val=$(version_code $exp_client_version)
233 imp_val=$CLIENT_VERSION
234 [ "$exp_val" == "$imp_val" ] ||
235 error "export client version '$exp_val' != '$imp_val'"
237 run_test 0d "check export proc ============================="
240 test_mkdir $DIR/$tdir
241 test_mkdir $DIR/$tdir/d2
242 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
243 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
246 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
248 run_test 1 "mkdir; remkdir; rmdir"
251 test_mkdir $DIR/$tdir
252 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
253 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
255 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
257 run_test 2 "mkdir; touch; rmdir; check file"
260 test_mkdir $DIR/$tdir
261 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
262 touch $DIR/$tdir/$tfile
263 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
265 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
267 run_test 3 "mkdir; touch; rmdir; check dir"
269 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
271 test_mkdir -i 1 $DIR/$tdir
273 touch $DIR/$tdir/$tfile ||
274 error "Create file under remote directory failed"
277 error "Expect error removing in-use dir $DIR/$tdir"
279 test -d $DIR/$tdir || error "Remote directory disappeared"
281 rm -rf $DIR/$tdir || error "remove remote dir error"
283 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
286 test_mkdir $DIR/$tdir
287 test_mkdir $DIR/$tdir/d2
288 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
289 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
290 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
292 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
295 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
296 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
297 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
298 error "$tfile does not have perm 0666 or UID $UID"
299 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
300 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
301 error "$tfile should be 0666 and owned by UID $UID"
303 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
306 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
309 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
310 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
311 error "$tfile should be owned by UID $RUNAS_ID"
312 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
313 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
314 error "$tfile should be owned by UID $RUNAS_ID"
316 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
319 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
322 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
323 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
324 error "$tfile should be owned by GID $UID"
325 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
326 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
327 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
329 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
332 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
334 test_mkdir $DIR/$tdir
335 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
336 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
337 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
338 test_mkdir $DIR/$tdir/d/subdir
339 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
340 error "$tdir/d/subdir should be GID $RUNAS_GID"
341 if [[ $MDSCOUNT -gt 1 ]]; then
342 # check remote dir sgid inherite
343 $LFS mkdir -i 0 $DIR/$tdir.local ||
344 error "mkdir $tdir.local failed"
345 chmod g+s $DIR/$tdir.local ||
346 error "chmod $tdir.local failed"
347 chgrp $RUNAS_GID $DIR/$tdir.local ||
348 error "chgrp $tdir.local failed"
349 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
350 error "mkdir $tdir.remote failed"
351 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
352 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
353 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
354 error "$tdir.remote should be mode 02755"
357 run_test 6g "verify new dir in sgid dir inherits group"
359 test_6h() { # bug 7331
360 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
362 touch $DIR/$tfile || error "touch failed"
363 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
364 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
365 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
366 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
367 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
369 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
372 test_mkdir $DIR/$tdir
373 $MCREATE $DIR/$tdir/$tfile
374 chmod 0666 $DIR/$tdir/$tfile
375 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
376 error "$tdir/$tfile should be mode 0666"
378 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
381 if [ ! -d $DIR/$tdir ]; then
382 test_mkdir $DIR/$tdir
384 $MCREATE $DIR/$tdir/$tfile
385 echo -n foo > $DIR/$tdir/$tfile
386 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
387 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
389 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
392 test_mkdir $DIR/$tdir
393 touch $DIR/$tdir/$tfile
394 chmod 0666 $DIR/$tdir/$tfile
395 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
396 error "$tfile mode not 0666"
398 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
401 test_mkdir $DIR/$tdir
402 test_mkdir $DIR/$tdir/d2
403 test_mkdir $DIR/$tdir/d2/d3
404 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
406 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
409 test_mkdir $DIR/$tdir
410 test_mkdir $DIR/$tdir/d2
411 touch $DIR/$tdir/d2/$tfile
412 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
413 error "$tdir/d2/$tfile not a file"
415 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
418 test_mkdir $DIR/$tdir
419 test_mkdir $DIR/$tdir/d2
420 chmod 0666 $DIR/$tdir/d2
421 chmod 0705 $DIR/$tdir/d2
422 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
423 error "$tdir/d2 mode not 0705"
425 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
428 test_mkdir $DIR/$tdir
429 touch $DIR/$tdir/$tfile
430 chmod 0666 $DIR/$tdir/$tfile
431 chmod 0654 $DIR/$tdir/$tfile
432 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
433 error "$tdir/d2 mode not 0654"
435 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
438 test_mkdir $DIR/$tdir
439 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
441 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
442 error "$tdir/$tfile size not 0 after truncate"
444 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
447 test_mkdir $DIR/$tdir
448 touch $DIR/$tdir/$tfile
450 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
452 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
455 test_mkdir $DIR/$tdir
456 touch $DIR/$tdir/$tfile
457 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
458 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
459 error "$tdir/${tfile_2} not a file after rename"
460 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
462 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
465 test_mkdir $DIR/$tdir
466 touch $DIR/$tdir/$tfile
467 rm -rf $DIR/$tdir/$tfile
468 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
470 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
473 test_mkdir $DIR/$tdir
474 touch $DIR/$tdir/$tfile
475 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
477 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
478 error "$tdir/l-exist not a symlink"
479 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
480 error "$tdir/l-exist not referencing a file"
481 rm -f $DIR/$tdir/l-exist
482 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
484 run_test 17a "symlinks: create, remove (real)"
487 test_mkdir $DIR/$tdir
488 ln -s no-such-file $DIR/$tdir/l-dangle
490 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
491 error "$tdir/l-dangle not referencing no-such-file"
492 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
493 error "$tdir/l-dangle not referencing non-existent file"
494 rm -f $DIR/$tdir/l-dangle
495 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
497 run_test 17b "symlinks: create, remove (dangling)"
499 test_17c() { # bug 3440 - don't save failed open RPC for replay
500 test_mkdir $DIR/$tdir
501 ln -s foo $DIR/$tdir/$tfile
502 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
504 run_test 17c "symlinks: open dangling (should return error)"
507 test_mkdir $DIR/$tdir
508 ln -s foo $DIR/$tdir/$tfile
509 touch $DIR/$tdir/$tfile || error "creating to new symlink"
511 run_test 17d "symlinks: create dangling"
514 test_mkdir $DIR/$tdir
515 local foo=$DIR/$tdir/$tfile
516 ln -s $foo $foo || error "create symlink failed"
517 ls -l $foo || error "ls -l failed"
518 ls $foo && error "ls not failed" || true
520 run_test 17e "symlinks: create recursive symlink (should return error)"
523 test_mkdir $DIR/$tdir
524 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
525 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
526 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
527 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
528 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
529 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
532 run_test 17f "symlinks: long and very long symlink name"
534 # str_repeat(S, N) generate a string that is string S repeated N times
539 while [ $((n -= 1)) -ge 0 ]; do
545 # Long symlinks and LU-2241
547 test_mkdir $DIR/$tdir
548 local TESTS="59 60 61 4094 4095"
550 # Fix for inode size boundary in 2.1.4
551 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
554 # Patch not applied to 2.2 or 2.3 branches
555 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
556 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
560 local SYMNAME=$(str_repeat 'x' $i)
561 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
562 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
565 run_test 17g "symlinks: really long symlink name and inode boundaries"
567 test_17h() { #bug 17378
568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
569 remote_mds_nodsh && skip "remote MDS with nodsh"
573 test_mkdir $DIR/$tdir
574 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
575 $LFS setstripe -c -1 $DIR/$tdir
576 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
577 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
578 touch $DIR/$tdir/$tfile || true
580 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
582 test_17i() { #bug 20018
583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
584 remote_mds_nodsh && skip "remote MDS with nodsh"
586 local foo=$DIR/$tdir/$tfile
589 test_mkdir -c1 $DIR/$tdir
590 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
591 ln -s $foo $foo || error "create symlink failed"
592 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
593 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
594 ls -l $foo && error "error not detected"
597 run_test 17i "don't panic on short symlink (should return error)"
599 test_17k() { #bug 22301
600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
601 [[ -z "$(which rsync 2>/dev/null)" ]] &&
602 skip "no rsync command"
603 rsync --help | grep -q xattr ||
604 skip_env "$(rsync --version | head -n1) does not support xattrs"
605 test_mkdir $DIR/$tdir
606 test_mkdir $DIR/$tdir.new
607 touch $DIR/$tdir/$tfile
608 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
609 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
610 error "rsync failed with xattrs enabled"
612 run_test 17k "symlinks: rsync with xattrs enabled"
614 test_17l() { # LU-279
615 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
616 skip "no getfattr command"
618 test_mkdir $DIR/$tdir
619 touch $DIR/$tdir/$tfile
620 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
621 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
622 # -h to not follow symlinks. -m '' to list all the xattrs.
623 # grep to remove first line: '# file: $path'.
624 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
626 lgetxattr_size_check $path $xattr ||
627 error "lgetxattr_size_check $path $xattr failed"
631 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
636 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
637 remote_mds_nodsh && skip "remote MDS with nodsh"
638 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
639 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
640 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
642 local short_sym="0123456789"
643 local wdir=$DIR/$tdir
648 # create a long symlink file
649 for ((i = 0; i < 4; ++i)); do
650 long_sym=${long_sym}${long_sym}
653 echo "create 512 short and long symlink files under $wdir"
654 for ((i = 0; i < 256; ++i)); do
655 ln -sf ${long_sym}"a5a5" $wdir/long-$i
656 ln -sf ${short_sym}"a5a5" $wdir/short-$i
662 wait_delete_completed
664 echo "recreate the 512 symlink files with a shorter string"
665 for ((i = 0; i < 512; ++i)); do
666 # rewrite the symlink file with a shorter string
667 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
668 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
671 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
672 local devname=$(mdsdevname $mds_index)
674 echo "stop and checking mds${mds_index}:"
675 # e2fsck should not return error
677 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
680 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
681 error "start mds${mds_index} failed"
682 df $MOUNT > /dev/null 2>&1
684 error "e2fsck detected error for short/long symlink: rc=$rc"
687 run_test 17m "run e2fsck against MDT which contains short/long symlink"
689 check_fs_consistency_17n() {
693 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
694 # so it only check MDT1/MDT2 instead of all of MDTs.
695 for mdt_index in 1 2; do
696 local devname=$(mdsdevname $mdt_index)
697 # e2fsck should not return error
699 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
702 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
703 error "mount mds$mdt_index failed"
704 df $MOUNT > /dev/null 2>&1
710 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
711 [ $PARALLEL == "yes" ] && skip "skip parallel run"
712 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
713 remote_mds_nodsh && skip "remote MDS with nodsh"
714 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
715 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
716 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
720 test_mkdir $DIR/$tdir
721 for ((i=0; i<10; i++)); do
722 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
723 error "create remote dir error $i"
724 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
725 error "create files under remote dir failed $i"
728 check_fs_consistency_17n ||
729 error "e2fsck report error after create files under remote dir"
731 for ((i = 0; i < 10; i++)); do
732 rm -rf $DIR/$tdir/remote_dir_${i} ||
733 error "destroy remote dir error $i"
736 check_fs_consistency_17n ||
737 error "e2fsck report error after unlink files under remote dir"
739 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
740 skip "lustre < 2.4.50 does not support migrate mv"
742 for ((i = 0; i < 10; i++)); do
743 mkdir -p $DIR/$tdir/remote_dir_${i}
744 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
745 error "create files under remote dir failed $i"
746 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
747 error "migrate remote dir error $i"
749 check_fs_consistency_17n || error "e2fsck report error after migration"
751 for ((i = 0; i < 10; i++)); do
752 rm -rf $DIR/$tdir/remote_dir_${i} ||
753 error "destroy remote dir error $i"
756 check_fs_consistency_17n || error "e2fsck report error after unlink"
758 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
761 remote_mds_nodsh && skip "remote MDS with nodsh"
762 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
763 skip "Need MDS version at least 2.3.64"
765 local wdir=$DIR/${tdir}o
771 mdt_index=$($LFS getstripe -m $wdir/$tfile)
772 mdt_index=$((mdt_index + 1))
775 #fail mds will wait the failover finish then set
776 #following fail_loc to avoid interfer the recovery process.
779 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
780 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
781 ls -l $wdir/$tfile && rc=1
782 do_facet mds${mdt_index} lctl set_param fail_loc=0
783 [[ $rc -eq 0 ]] || error "stat file should fail"
785 run_test 17o "stat file with incompat LMA feature"
788 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
789 ls $DIR || error "Failed to ls $DIR: $?"
791 run_test 18 "touch .../f ; ls ... =============================="
797 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
799 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
802 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
804 run_test 19b "ls -l .../f19 (should return error) =============="
807 [ $RUNAS_ID -eq $UID ] &&
808 skip_env "RUNAS_ID = UID = $UID -- skipping"
810 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
812 run_test 19c "$RUNAS touch .../f19 (should return error) =="
815 cat $DIR/f19 && error || true
817 run_test 19d "cat .../f19 (should return error) =============="
826 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
828 run_test 20 "touch .../f ; ls -l ..."
831 test_mkdir $DIR/$tdir
832 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
833 ln -s dangle $DIR/$tdir/link
834 echo foo >> $DIR/$tdir/link
835 cat $DIR/$tdir/dangle
836 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
837 $CHECKSTAT -f -t file $DIR/$tdir/link ||
838 error "$tdir/link not linked to a file"
840 run_test 21 "write to dangling link"
843 local wdir=$DIR/$tdir
845 chown $RUNAS_ID:$RUNAS_GID $wdir
846 (cd $wdir || error "cd $wdir failed";
847 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
849 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
850 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
851 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
852 error "checkstat -u failed"
854 run_test 22 "unpack tar archive as non-root user"
858 test_mkdir $DIR/$tdir
859 local file=$DIR/$tdir/$tfile
861 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
862 openfile -f O_CREAT:O_EXCL $file &&
863 error "$file recreate succeeded" || true
865 run_test 23a "O_CREAT|O_EXCL in subdir"
867 test_23b() { # bug 18988
868 test_mkdir $DIR/$tdir
869 local file=$DIR/$tdir/$tfile
872 echo foo > $file || error "write filed"
873 echo bar >> $file || error "append filed"
874 $CHECKSTAT -s 8 $file || error "wrong size"
877 run_test 23b "O_APPEND check"
879 # LU-9409, size with O_APPEND and tiny writes
881 local file=$DIR/$tfile
884 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
885 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
889 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
890 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
892 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
895 #racing tiny & normal writes
896 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
897 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
899 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
902 #racing tiny & normal writes 2, ugly numbers
903 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
904 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
906 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
909 run_test 23c "O_APPEND size checks for tiny writes"
911 # LU-11069 file offset is correct after appending writes
913 local file=$DIR/$tfile
916 echo CentaurHauls > $file
917 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
918 if ((offset != 26)); then
919 error "wrong offset, expected 26, got '$offset'"
922 run_test 23d "file offset is correct after appending writes"
926 echo '-- same directory rename'
927 test_mkdir $DIR/$tdir
928 touch $DIR/$tdir/$tfile.1
929 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
930 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
932 run_test 24a "rename file to non-existent target"
935 test_mkdir $DIR/$tdir
936 touch $DIR/$tdir/$tfile.{1,2}
937 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
938 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
939 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
941 run_test 24b "rename file to existing target"
944 test_mkdir $DIR/$tdir
945 test_mkdir $DIR/$tdir/d$testnum.1
946 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
947 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
948 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
950 run_test 24c "rename directory to non-existent target"
953 test_mkdir -c1 $DIR/$tdir
954 test_mkdir -c1 $DIR/$tdir/d$testnum.1
955 test_mkdir -c1 $DIR/$tdir/d$testnum.2
956 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
957 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
958 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
960 run_test 24d "rename directory to existing target"
963 echo '-- cross directory renames --'
967 mv $DIR/R5a/f $DIR/R5b/g
968 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
969 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
971 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
976 touch $DIR/R6a/f $DIR/R6b/g
977 mv $DIR/R6a/f $DIR/R6b/g
978 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
979 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
981 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
986 test_mkdir $DIR/R7a/d
987 mv $DIR/R7a/d $DIR/R7b/e
988 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
989 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
991 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
994 test_mkdir -c1 $DIR/R8a
995 test_mkdir -c1 $DIR/R8b
996 test_mkdir -c1 $DIR/R8a/d
997 test_mkdir -c1 $DIR/R8b/e
998 mrename $DIR/R8a/d $DIR/R8b/e
999 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1000 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1002 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1005 echo "-- rename error cases"
1007 test_mkdir $DIR/R9/a
1009 mrename $DIR/R9/f $DIR/R9/a
1010 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1011 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1012 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1014 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1018 mrename $DIR/R10/f $DIR/R10/g
1019 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1020 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1021 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1023 run_test 24j "source does not exist ============================"
1026 test_mkdir $DIR/R11a
1027 test_mkdir $DIR/R11a/d
1029 mv $DIR/R11a/f $DIR/R11a/d
1030 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1031 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1033 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1035 # bug 2429 - rename foo foo foo creates invalid file
1038 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1040 run_test 24l "Renaming a file to itself ========================"
1044 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1045 # on ext3 this does not remove either the source or target files
1046 # though the "expected" operation would be to remove the source
1047 $CHECKSTAT -t file ${f} || error "${f} missing"
1048 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1050 run_test 24m "Renaming a file to a hard link to itself ========="
1054 # this stats the old file after it was renamed, so it should fail
1056 $CHECKSTAT ${f} || error "${f} missing"
1058 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1059 $CHECKSTAT -a ${f} || error "${f} exists"
1061 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1064 test_mkdir $DIR/$tdir
1065 rename_many -s random -v -n 10 $DIR/$tdir
1067 run_test 24o "rename of files during htree split"
1070 test_mkdir $DIR/R12a
1071 test_mkdir $DIR/R12b
1072 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1073 mrename $DIR/R12a $DIR/R12b
1074 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1075 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1076 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1077 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1079 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1081 cleanup_multiop_pause() {
1083 kill -USR1 $MULTIPID
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1089 test_mkdir $DIR/R13a
1090 test_mkdir $DIR/R13b
1091 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1092 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1095 trap cleanup_multiop_pause EXIT
1096 mrename $DIR/R13a $DIR/R13b
1097 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1098 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1099 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1100 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1101 cleanup_multiop_pause
1102 wait $MULTIPID || error "multiop close failed"
1104 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1106 test_24r() { #bug 3789
1107 test_mkdir $DIR/R14a
1108 test_mkdir $DIR/R14a/b
1109 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1110 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1111 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1113 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1116 test_mkdir $DIR/R15a
1117 test_mkdir $DIR/R15a/b
1118 test_mkdir $DIR/R15a/b/c
1119 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1120 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1121 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1123 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1125 test_mkdir $DIR/R16a
1126 test_mkdir $DIR/R16a/b
1127 test_mkdir $DIR/R16a/b/c
1128 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1129 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1130 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1132 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1134 test_24u() { # bug12192
1135 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1136 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1138 run_test 24u "create stripe file"
1140 simple_cleanup_common() {
1143 [ -z "$DIR" ] || [ -z "$tdir" ] && return 0
1145 local start=$SECONDS
1148 wait_delete_completed
1149 echo "cleanup time $((SECONDS - start))"
1153 max_pages_per_rpc() {
1154 local mdtname="$(printf "MDT%04x" ${1:-0})"
1155 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1161 local nrfiles=${COUNT:-100000}
1162 local fname="$DIR/$tdir/$tfile"
1164 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1165 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1167 test_mkdir "$(dirname $fname)"
1168 # assume MDT0000 has the fewest inodes
1169 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1170 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1171 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1173 trap simple_cleanup_common EXIT
1175 createmany -m "$fname" $nrfiles
1177 cancel_lru_locks mdc
1178 lctl set_param mdc.*.stats clear
1180 # was previously test_24D: LU-6101
1181 # readdir() returns correct number of entries after cursor reload
1182 local num_ls=$(ls $DIR/$tdir | wc -l)
1183 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1184 local num_all=$(ls -a $DIR/$tdir | wc -l)
1185 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1186 [ $num_all -ne $((nrfiles + 2)) ]; then
1187 error "Expected $nrfiles files, got $num_ls " \
1188 "($num_uniq unique $num_all .&..)"
1190 # LU-5 large readdir
1191 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1192 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1193 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1194 # take into account of overhead in lu_dirpage header and end mark in
1195 # each page, plus one in rpc_num calculation.
1196 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1197 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1198 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1199 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1200 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1201 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1202 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1203 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1204 error "large readdir doesn't take effect: " \
1205 "$mds_readpage should be about $rpc_max"
1207 simple_cleanup_common
1209 run_test 24v "list large directory (test hash collision, b=17560)"
1211 test_24w() { # bug21506
1213 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1214 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1215 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1216 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1217 [[ "$SZ1" -eq "$SZ2" ]] ||
1218 error "Error reading at the end of the file $tfile"
1220 run_test 24w "Reading a file larger than 4Gb"
1223 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1225 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1226 skip "Need MDS version at least 2.7.56"
1229 local remote_dir=$DIR/$tdir/remote_dir
1231 test_mkdir $DIR/$tdir
1232 $LFS mkdir -i $MDTIDX $remote_dir ||
1233 error "create remote directory failed"
1235 test_mkdir $DIR/$tdir/src_dir
1236 touch $DIR/$tdir/src_file
1237 test_mkdir $remote_dir/tgt_dir
1238 touch $remote_dir/tgt_file
1240 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1241 error "rename dir cross MDT failed!"
1243 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1244 error "rename file cross MDT failed!"
1246 touch $DIR/$tdir/ln_file
1247 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1248 error "ln file cross MDT failed"
1250 rm -rf $DIR/$tdir || error "Can not delete directories"
1252 run_test 24x "cross MDT rename/link"
1255 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1258 local remote_dir=$DIR/$tdir/remote_dir
1261 test_mkdir $DIR/$tdir
1262 $LFS mkdir -i $mdtidx $remote_dir ||
1263 error "create remote directory failed"
1265 test_mkdir $remote_dir/src_dir
1266 touch $remote_dir/src_file
1267 test_mkdir $remote_dir/tgt_dir
1268 touch $remote_dir/tgt_file
1270 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1271 error "rename subdir in the same remote dir failed!"
1273 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1274 error "rename files in the same remote dir failed!"
1276 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1277 error "link files in the same remote dir failed!"
1279 rm -rf $DIR/$tdir || error "Can not delete directories"
1281 run_test 24y "rename/link on the same dir should succeed"
1284 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1285 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1286 skip "Need MDS version at least 2.12.51"
1290 for index in 0 1; do
1291 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1292 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1295 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1297 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1298 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1300 local mdts=$(comma_list $(mdts_nodes))
1302 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1303 stack_trap "do_nodes $mdts $LCTL \
1304 set_param mdt.*.enable_remote_rename=1" EXIT
1306 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1308 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1309 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1311 run_test 24z "cross-MDT rename is done as cp"
1313 test_24A() { # LU-3182
1317 test_mkdir $DIR/$tdir
1318 trap simple_cleanup_common EXIT
1319 createmany -m $DIR/$tdir/$tfile $NFILES
1320 local t=$(ls $DIR/$tdir | wc -l)
1321 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1322 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1323 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1324 [ $v -ne $((NFILES + 2)) ] ; then
1325 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1328 simple_cleanup_common || error "Can not delete directories"
1330 run_test 24A "readdir() returns correct number of entries."
1332 test_24B() { # LU-4805
1333 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1337 test_mkdir $DIR/$tdir
1338 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1339 error "create striped dir failed"
1341 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1342 [ $count -eq 2 ] || error "Expected 2, got $count"
1344 touch $DIR/$tdir/striped_dir/a
1346 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1347 [ $count -eq 3 ] || error "Expected 3, got $count"
1349 touch $DIR/$tdir/striped_dir/.f
1351 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1352 [ $count -eq 4 ] || error "Expected 4, got $count"
1354 rm -rf $DIR/$tdir || error "Can not delete directories"
1356 run_test 24B "readdir for striped dir return correct number of entries"
1359 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1365 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1366 error "create striped dir failed"
1368 cd $DIR/$tdir/d0/striped_dir
1370 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1371 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1372 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1374 [ "$d0_ino" = "$parent_ino" ] ||
1375 error ".. wrong, expect $d0_ino, get $parent_ino"
1377 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1378 error "mv striped dir failed"
1380 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1382 [ "$d1_ino" = "$parent_ino" ] ||
1383 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1385 run_test 24C "check .. in striped dir"
1388 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1389 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1392 mkdir $DIR/$tdir/src_dir
1393 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1394 error "create remote source failed"
1396 touch $DIR/$tdir/src_dir/src_child/a
1398 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1399 error "create remote target dir failed"
1401 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1402 error "create remote target child failed"
1404 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1405 error "rename dir cross MDT failed!"
1409 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1410 error "src_child still exists after rename"
1412 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1413 error "missing file(a) after rename"
1415 rm -rf $DIR/$tdir || error "Can not delete directories"
1417 run_test 24E "cross MDT rename/link"
1420 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1423 [ "$SLOW" = "no" ] && repeats=100
1427 echo "$repeats repeats"
1428 for ((i = 0; i < repeats; i++)); do
1429 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1430 touch $DIR/$tdir/test/a || error "touch fails"
1431 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1432 rm -rf $DIR/$tdir/test || error "rmdir fails"
1437 run_test 24F "hash order vs readdir (LU-11330)"
1440 echo '== symlink sanity ============================================='
1444 touch $DIR/s25/foo ||
1445 error "File creation in symlinked directory failed"
1447 run_test 25a "create file in symlinked directory ==============="
1450 [ ! -d $DIR/d25 ] && test_25a
1451 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1453 run_test 25b "lookup file in symlinked directory ==============="
1457 test_mkdir $DIR/d26/d26-2
1458 ln -s d26/d26-2 $DIR/s26
1459 touch $DIR/s26/foo || error "File creation failed"
1461 run_test 26a "multiple component symlink ======================="
1464 test_mkdir -p $DIR/$tdir/d26-2
1465 ln -s $tdir/d26-2/foo $DIR/s26-2
1466 touch $DIR/s26-2 || error "File creation failed"
1468 run_test 26b "multiple component symlink at end of lookup ======"
1471 test_mkdir $DIR/d26.2
1472 touch $DIR/d26.2/foo
1473 ln -s d26.2 $DIR/s26.2-1
1474 ln -s s26.2-1 $DIR/s26.2-2
1475 ln -s s26.2-2 $DIR/s26.2-3
1476 chmod 0666 $DIR/s26.2-3/foo
1478 run_test 26c "chain of symlinks"
1480 # recursive symlinks (bug 439)
1482 ln -s d26-3/foo $DIR/d26-3
1484 run_test 26d "create multiple component recursive symlink"
1487 [ ! -h $DIR/d26-3 ] && test_26d
1490 run_test 26e "unlink multiple component recursive symlink"
1492 # recursive symlinks (bug 7022)
1494 test_mkdir $DIR/$tdir
1495 test_mkdir $DIR/$tdir/$tfile
1496 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1497 test_mkdir -p lndir/bar1
1498 test_mkdir $DIR/$tdir/$tfile/$tfile
1499 cd $tfile || error "cd $tfile failed"
1500 ln -s .. dotdot || error "ln dotdot failed"
1501 ln -s dotdot/lndir lndir || error "ln lndir failed"
1502 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1503 output=`ls $tfile/$tfile/lndir/bar1`
1504 [ "$output" = bar1 ] && error "unexpected output"
1505 rm -r $tfile || error "rm $tfile failed"
1506 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1508 run_test 26f "rm -r of a directory which has recursive symlink"
1511 test_mkdir $DIR/$tdir
1512 $LFS getstripe $DIR/$tdir
1513 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1514 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1515 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1517 run_test 27a "one stripe file"
1520 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1522 test_mkdir $DIR/$tdir
1523 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1524 $LFS getstripe -c $DIR/$tdir/$tfile
1525 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1526 error "two-stripe file doesn't have two stripes"
1528 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1530 run_test 27b "create and write to two stripe file"
1532 # 27c family tests specific striping, setstripe -o
1534 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1535 test_mkdir -p $DIR/$tdir
1538 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1539 $LFS getstripe -i $DIR/$tdir/$tfile
1540 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1541 error "stripe not on specified OST"
1543 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1545 run_test 27ca "one stripe on specified OST"
1548 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1549 test_mkdir -p $DIR/$tdir
1551 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1552 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1555 # Strip getstripe output to a space separated list of OSTs
1556 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1557 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1558 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1559 error "stripes not on specified OSTs"
1561 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1563 run_test 27cb "two stripes on specified OSTs"
1566 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1567 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1568 skip "server does not support overstriping"
1570 test_mkdir -p $DIR/$tdir
1572 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1573 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1576 # Strip getstripe output to a space separated list of OSTs
1577 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1578 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1579 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1580 error "stripes not on specified OSTs"
1582 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1584 run_test 27cc "two stripes on the same OST"
1587 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1588 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1589 skip "server does not support overstriping"
1590 test_mkdir -p $DIR/$tdir
1591 local osts="0,1,1,0"
1592 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1593 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1596 # Strip getstripe output to a space separated list of OSTs
1597 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1598 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1599 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1600 error "stripes not on specified OSTs"
1602 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1604 run_test 27cd "four stripes on two OSTs"
1607 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1608 skip_env "too many osts, skipping"
1609 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1610 skip "server does not support overstriping"
1611 # We do one more stripe than we have OSTs
1612 [ $OSTCOUNT -ge 159 ] || large_xattr_enabled ||
1613 skip_env "ea_inode feature disabled"
1615 test_mkdir -p $DIR/$tdir
1617 for i in $(seq 0 $OSTCOUNT);
1620 if [ $i -ne $OSTCOUNT ]; then
1624 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1625 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1628 # Strip getstripe output to a space separated list of OSTs
1629 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1630 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1631 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1632 error "stripes not on specified OSTs"
1634 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1636 run_test 27ce "more stripes than OSTs with -o"
1639 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"
3753 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3754 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
3755 skip "Need MDS version at least 2.13.50"
3757 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir ||
3758 error "mkdir $tdir failed"
3759 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
3761 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
3764 for fname in $DIR/$tdir/$tfile.bak \
3765 $DIR/$tdir/$tfile.SAV \
3766 $DIR/$tdir/$tfile.orig \
3767 $DIR/$tdir/$tfile~; do
3768 touch $fname || error "touch $fname failed"
3769 index2=$($LFS getstripe -m $fname)
3770 [ $index -eq $index2 ] ||
3771 error "$fname MDT index mismatch $index != $index2"
3775 for i in {1..50}; do
3776 for fname in $(mktemp -u $DIR/$tdir/.$tfile.XXXXXX) \
3777 $(mktemp $DIR/$tdir/$tfile.XXXXXXXX); do
3778 touch $fname || error "touch $fname failed"
3779 index2=$($LFS getstripe -m $fname)
3780 if [[ $index != $index2 ]]; then
3781 failed=$((failed + 1))
3782 echo "$fname MDT index mismatch $index != $index2"
3786 echo "$failed MDT index mismatches"
3787 (( failed < 4 )) || error "MDT index mismatch $failed times"
3790 run_test 33h "temp file is located on the same MDT as target"
3792 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3795 $MCREATE $DIR/f34 || error "mcreate failed"
3796 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3797 error "getstripe failed"
3798 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3799 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3800 error "getstripe failed"
3801 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3802 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3804 run_test 34a "truncate file that has not been opened ==========="
3807 [ ! -f $DIR/f34 ] && test_34a
3808 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3809 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3810 $OPENFILE -f O_RDONLY $DIR/f34
3811 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3812 error "getstripe failed"
3813 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3814 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3816 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3819 [ ! -f $DIR/f34 ] && test_34a
3820 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3821 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3822 $OPENFILE -f O_RDWR $DIR/f34
3823 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3824 error "$LFS getstripe failed"
3825 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3826 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3828 run_test 34c "O_RDWR opening file-with-size works =============="
3831 [ ! -f $DIR/f34 ] && test_34a
3832 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3834 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3835 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3838 run_test 34d "write to sparse file ============================="
3842 $MCREATE $DIR/f34e || error "mcreate failed"
3843 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3844 $CHECKSTAT -s 1000 $DIR/f34e ||
3845 error "Size of $DIR/f34e not equal to 1000 bytes"
3846 $OPENFILE -f O_RDWR $DIR/f34e
3847 $CHECKSTAT -s 1000 $DIR/f34e ||
3848 error "Size of $DIR/f34e not equal to 1000 bytes"
3850 run_test 34e "create objects, some with size and some without =="
3852 test_34f() { # bug 6242, 6243
3853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3857 $MCREATE $DIR/f34f || error "mcreate failed"
3858 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3859 dd if=$DIR/f34f of=$TMP/f34f
3860 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3861 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3862 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3863 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3864 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3866 run_test 34f "read from a file with no objects until EOF ======="
3869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3871 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3873 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3874 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3875 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3876 cancel_lru_locks osc
3877 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3878 error "wrong size after lock cancel"
3880 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3881 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3882 error "expanding truncate failed"
3883 cancel_lru_locks osc
3884 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3885 error "wrong expanded size after lock cancel"
3887 run_test 34g "truncate long file ==============================="
3890 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3895 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3896 sync # Flush the cache so that multiop below does not block on cache
3897 # flush when getting the group lock
3898 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3901 # Since just timed wait is not good enough, let's do a sync write
3902 # that way we are sure enough time for a roundtrip + processing
3903 # passed + 2 seconds of extra margin.
3904 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3908 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3909 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3913 local nsz=`stat -c %s $DIR/$tfile`
3914 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3916 run_test 34h "ftruncate file under grouplock should not block"
3919 cp /bin/sh $DIR/f35a
3921 chown $RUNAS_ID $DIR/f35a
3922 $RUNAS $DIR/f35a && error || true
3925 run_test 35a "exec file with mode 444 (should return and not leak)"
3929 utime $DIR/f36 || error "utime failed for MDS"
3931 run_test 36a "MDS utime check (mknod, utime)"
3935 utime $DIR/f36 || error "utime failed for OST"
3937 run_test 36b "OST utime check (open, utime)"
3942 chown $RUNAS_ID $DIR/d36
3943 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3945 run_test 36c "non-root MDS utime check (mknod, utime)"
3948 [ ! -d $DIR/d36 ] && test_36c
3949 echo "" > $DIR/d36/f36
3950 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3952 run_test 36d "non-root OST utime check (open, utime)"
3955 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3957 test_mkdir $DIR/$tdir
3958 touch $DIR/$tdir/$tfile
3959 $RUNAS utime $DIR/$tdir/$tfile &&
3960 error "utime worked, expected failure" || true
3962 run_test 36e "utime on non-owned file (should return error)"
3966 local LANG_SAVE=$LANG
3967 local LC_LANG_SAVE=$LC_LANG
3968 export LANG=C LC_LANG=C # for date language
3970 DATESTR="Dec 20 2000"
3971 test_mkdir $DIR/$tdir
3972 lctl set_param fail_loc=$fl
3974 cp /etc/hosts $DIR/$tdir/$tfile
3975 sync & # write RPC generated with "current" inode timestamp, but delayed
3977 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3978 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3979 cancel_lru_locks $OSC
3980 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3982 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3983 echo "BEFORE: $LS_BEFORE" && \
3984 echo "AFTER : $LS_AFTER" && \
3985 echo "WANT : $DATESTR" && \
3986 error "$DIR/$tdir/$tfile timestamps changed" || true
3988 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3992 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3994 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3995 subr_36fh "0x80000214"
3997 run_test 36f "utime on file racing with OST BRW write =========="
4000 remote_ost_nodsh && skip "remote OST with nodsh"
4001 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4002 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4003 skip "Need MDS version at least 2.12.51"
4008 local tgt="obdfilter"
4010 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4012 test_mkdir $DIR/$tdir
4013 fmd_max_age=$(do_facet $facet \
4014 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4017 echo "FMD max age: ${fmd_max_age}s"
4018 touch $DIR/$tdir/$tfile
4019 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4020 gawk '{cnt=cnt+$1} END{print cnt}')
4021 echo "FMD before: $fmd"
4023 error "FMD wasn't create by touch"
4024 sleep $((fmd_max_age + 12))
4025 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4026 gawk '{cnt=cnt+$1} END{print cnt}')
4027 echo "FMD after: $fmd"
4029 error "FMD wasn't expired by ping"
4031 run_test 36g "FMD cache expiry ====================="
4034 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4036 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4037 subr_36fh "0x80000227"
4039 run_test 36h "utime on file racing with OST BRW write =========="
4042 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4044 test_mkdir $DIR/$tdir
4045 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4047 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4048 local new_mtime=$((mtime + 200))
4050 #change Modify time of striped dir
4051 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4052 error "change mtime failed"
4054 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4056 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4058 run_test 36i "change mtime on striped directory"
4060 # test_37 - duplicate with tests 32q 32r
4063 local file=$DIR/$tfile
4065 openfile -f O_DIRECTORY $file
4068 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4069 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4071 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4073 test_39a() { # was test_39
4075 touch $DIR/${tfile}2
4076 # ls -l $DIR/$tfile $DIR/${tfile}2
4077 # ls -lu $DIR/$tfile $DIR/${tfile}2
4078 # ls -lc $DIR/$tfile $DIR/${tfile}2
4080 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4081 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4083 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4085 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4087 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4088 error "O_TRUNC didn't change timestamps"
4091 run_test 39a "mtime changed on create"
4094 test_mkdir -c1 $DIR/$tdir
4095 cp -p /etc/passwd $DIR/$tdir/fopen
4096 cp -p /etc/passwd $DIR/$tdir/flink
4097 cp -p /etc/passwd $DIR/$tdir/funlink
4098 cp -p /etc/passwd $DIR/$tdir/frename
4099 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4102 echo "aaaaaa" >> $DIR/$tdir/fopen
4103 echo "aaaaaa" >> $DIR/$tdir/flink
4104 echo "aaaaaa" >> $DIR/$tdir/funlink
4105 echo "aaaaaa" >> $DIR/$tdir/frename
4107 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4108 local link_new=`stat -c %Y $DIR/$tdir/flink`
4109 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4110 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4112 cat $DIR/$tdir/fopen > /dev/null
4113 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4114 rm -f $DIR/$tdir/funlink2
4115 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4117 for (( i=0; i < 2; i++ )) ; do
4118 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4119 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4120 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4121 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4123 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4124 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4125 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4126 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4128 cancel_lru_locks $OSC
4129 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4132 run_test 39b "mtime change on open, link, unlink, rename ======"
4134 # this should be set to past
4135 TEST_39_MTIME=`date -d "1 year ago" +%s`
4141 local mtime0=`stat -c %Y $DIR1/$tfile`
4143 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4144 local mtime1=`stat -c %Y $DIR1/$tfile`
4145 [ "$mtime1" = $TEST_39_MTIME ] || \
4146 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4149 echo hello >> $DIR1/$tfile
4151 local mtime2=`stat -c %Y $DIR1/$tfile`
4152 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4153 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4155 mv $DIR1/$tfile $DIR1/$tfile-1
4157 for (( i=0; i < 2; i++ )) ; do
4158 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4159 [ "$mtime2" = "$mtime3" ] || \
4160 error "mtime ($mtime2) changed (to $mtime3) on rename"
4162 cancel_lru_locks $OSC
4163 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4166 run_test 39c "mtime change on rename ==========================="
4170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4173 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4175 for (( i=0; i < 2; i++ )) ; do
4176 local mtime=`stat -c %Y $DIR1/$tfile`
4177 [ $mtime = $TEST_39_MTIME ] || \
4178 error "mtime($mtime) is not set to $TEST_39_MTIME"
4180 cancel_lru_locks $OSC
4181 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4184 run_test 39d "create, utime, stat =============================="
4188 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4191 local mtime1=`stat -c %Y $DIR1/$tfile`
4193 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4195 for (( i=0; i < 2; i++ )) ; do
4196 local mtime2=`stat -c %Y $DIR1/$tfile`
4197 [ $mtime2 = $TEST_39_MTIME ] || \
4198 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4200 cancel_lru_locks $OSC
4201 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4204 run_test 39e "create, stat, utime, stat ========================"
4208 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4211 mtime1=`stat -c %Y $DIR1/$tfile`
4214 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4216 for (( i=0; i < 2; i++ )) ; do
4217 local mtime2=`stat -c %Y $DIR1/$tfile`
4218 [ $mtime2 = $TEST_39_MTIME ] || \
4219 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4221 cancel_lru_locks $OSC
4222 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4225 run_test 39f "create, stat, sleep, utime, stat ================="
4229 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4231 echo hello >> $DIR1/$tfile
4232 local mtime1=`stat -c %Y $DIR1/$tfile`
4235 chmod o+r $DIR1/$tfile
4237 for (( i=0; i < 2; i++ )) ; do
4238 local mtime2=`stat -c %Y $DIR1/$tfile`
4239 [ "$mtime1" = "$mtime2" ] || \
4240 error "lost mtime: $mtime2, should be $mtime1"
4242 cancel_lru_locks $OSC
4243 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4246 run_test 39g "write, chmod, stat ==============================="
4250 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4256 echo hello >> $DIR1/$tfile
4257 local mtime1=`stat -c %Y $DIR1/$tfile`
4259 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4261 if [ "$d1" != "$d2" ]; then
4262 echo "write and touch not within one second"
4264 for (( i=0; i < 2; i++ )) ; do
4265 local mtime2=`stat -c %Y $DIR1/$tfile`
4266 [ "$mtime2" = $TEST_39_MTIME ] || \
4267 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4269 cancel_lru_locks $OSC
4270 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4274 run_test 39h "write, utime within one second, stat ============="
4277 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4282 echo hello >> $DIR1/$tfile
4283 local mtime1=`stat -c %Y $DIR1/$tfile`
4285 mv $DIR1/$tfile $DIR1/$tfile-1
4287 for (( i=0; i < 2; i++ )) ; do
4288 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4290 [ "$mtime1" = "$mtime2" ] || \
4291 error "lost mtime: $mtime2, should be $mtime1"
4293 cancel_lru_locks $OSC
4294 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4297 run_test 39i "write, rename, stat =============================="
4300 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4302 start_full_debug_logging
4306 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4307 lctl set_param fail_loc=0x80000412
4308 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4309 error "multiop failed"
4311 local mtime1=`stat -c %Y $DIR1/$tfile`
4313 mv $DIR1/$tfile $DIR1/$tfile-1
4315 kill -USR1 $multipid
4316 wait $multipid || error "multiop close failed"
4318 for (( i=0; i < 2; i++ )) ; do
4319 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4320 [ "$mtime1" = "$mtime2" ] ||
4321 error "mtime is lost on close: $mtime2, " \
4325 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4327 lctl set_param fail_loc=0
4328 stop_full_debug_logging
4330 run_test 39j "write, rename, close, stat ======================="
4333 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4338 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4340 local mtime1=`stat -c %Y $DIR1/$tfile`
4342 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4344 kill -USR1 $multipid
4345 wait $multipid || error "multiop close failed"
4347 for (( i=0; i < 2; i++ )) ; do
4348 local mtime2=`stat -c %Y $DIR1/$tfile`
4350 [ "$mtime2" = $TEST_39_MTIME ] || \
4351 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4354 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4357 run_test 39k "write, utime, close, stat ========================"
4359 # this should be set to future
4360 TEST_39_ATIME=`date -d "1 year" +%s`
4363 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4364 remote_mds_nodsh && skip "remote MDS with nodsh"
4366 local atime_diff=$(do_facet $SINGLEMDS \
4367 lctl get_param -n mdd.*MDT0000*.atime_diff)
4371 # test setting directory atime to future
4372 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4373 local atime=$(stat -c %X $DIR/$tdir)
4374 [ "$atime" = $TEST_39_ATIME ] ||
4375 error "atime is not set to future: $atime, $TEST_39_ATIME"
4377 # test setting directory atime from future to now
4378 local now=$(date +%s)
4379 touch -a -d @$now $DIR/$tdir
4381 atime=$(stat -c %X $DIR/$tdir)
4382 [ "$atime" -eq "$now" ] ||
4383 error "atime is not updated from future: $atime, $now"
4385 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4388 # test setting directory atime when now > dir atime + atime_diff
4389 local d1=$(date +%s)
4391 local d2=$(date +%s)
4392 cancel_lru_locks mdc
4393 atime=$(stat -c %X $DIR/$tdir)
4394 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4395 error "atime is not updated : $atime, should be $d2"
4397 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4400 # test not setting directory atime when now < dir atime + atime_diff
4402 cancel_lru_locks mdc
4403 atime=$(stat -c %X $DIR/$tdir)
4404 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4405 error "atime is updated to $atime, should remain $d1<atime<$d2"
4407 do_facet $SINGLEMDS \
4408 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4410 run_test 39l "directory atime update ==========================="
4413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4417 local far_past_mtime=$(date -d "May 29 1953" +%s)
4418 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4420 touch -m -d @$far_past_mtime $DIR1/$tfile
4421 touch -a -d @$far_past_atime $DIR1/$tfile
4423 for (( i=0; i < 2; i++ )) ; do
4424 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4425 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4426 error "atime or mtime set incorrectly"
4428 cancel_lru_locks $OSC
4429 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4432 run_test 39m "test atime and mtime before 1970"
4434 test_39n() { # LU-3832
4435 remote_mds_nodsh && skip "remote MDS with nodsh"
4437 local atime_diff=$(do_facet $SINGLEMDS \
4438 lctl get_param -n mdd.*MDT0000*.atime_diff)
4443 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4446 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4447 atime0=$(stat -c %X $DIR/$tfile)
4450 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4451 atime1=$(stat -c %X $DIR/$tfile)
4454 cancel_lru_locks mdc
4455 cancel_lru_locks osc
4456 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4457 atime2=$(stat -c %X $DIR/$tfile)
4459 do_facet $SINGLEMDS \
4460 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4462 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4463 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4465 run_test 39n "check that O_NOATIME is honored"
4468 TESTDIR=$DIR/$tdir/$tfile
4469 [ -e $TESTDIR ] && rm -rf $TESTDIR
4476 links2=$(stat -c %h .)
4477 [ $(($links1 + 2)) != $links2 ] &&
4478 error "wrong links count $(($links1 + 2)) != $links2"
4480 links3=$(stat -c %h .)
4481 [ $(($links1 + 1)) != $links3 ] &&
4482 error "wrong links count $links1 != $links3"
4485 run_test 39o "directory cached attributes updated after create"
4488 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4491 TESTDIR=$DIR/$tdir/$tdir
4492 [ -e $TESTDIR ] && rm -rf $TESTDIR
4493 test_mkdir -p $TESTDIR
4497 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4498 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4500 links2=$(stat -c %h .)
4501 [ $(($links1 + 2)) != $links2 ] &&
4502 error "wrong links count $(($links1 + 2)) != $links2"
4504 links3=$(stat -c %h .)
4505 [ $(($links1 + 1)) != $links3 ] &&
4506 error "wrong links count $links1 != $links3"
4509 run_test 39p "remote directory cached attributes updated after create ========"
4512 test_39q() { # LU-8041
4513 local testdir=$DIR/$tdir
4515 multiop_bg_pause $testdir D_c || error "multiop failed"
4517 cancel_lru_locks mdc
4518 kill -USR1 $multipid
4519 local atime=$(stat -c %X $testdir)
4520 [ "$atime" -ne 0 ] || error "atime is zero"
4522 run_test 39q "close won't zero out atime"
4525 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4526 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4527 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4528 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4529 error "$tfile is not 4096 bytes in size"
4531 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4535 small_write $DIR/f41 18
4537 run_test 41 "test small file write + fstat ====================="
4539 count_ost_writes() {
4540 lctl get_param -n ${OSC}.*.stats |
4541 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4542 END { printf("%0.0f", writes) }'
4549 BG_DIRTY_RATIO_SAVE=10
4550 MAX_BG_DIRTY_RATIO=25
4554 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4555 # dirty_ratio, dirty_background_ratio
4556 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4557 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4558 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4559 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4561 # if file not here, we are a 2.4 kernel
4562 kill -CONT `pidof kupdated`
4567 # setup the trap first, so someone cannot exit the test at the
4568 # exact wrong time and mess up a machine
4569 trap start_writeback EXIT
4570 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4571 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4572 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4573 sysctl -w vm.dirty_writeback_centisecs=0
4574 sysctl -w vm.dirty_writeback_centisecs=0
4575 # save and increase /proc/sys/vm/dirty_ratio
4576 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4577 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4578 # save and increase /proc/sys/vm/dirty_background_ratio
4579 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4580 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4582 # if file not here, we are a 2.4 kernel
4583 kill -STOP `pidof kupdated`
4587 # ensure that all stripes have some grant before we test client-side cache
4589 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4590 dd if=/dev/zero of=$i bs=4k count=1
4595 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4596 # file truncation, and file removal.
4598 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4601 cancel_lru_locks $OSC
4603 sync; sleep 1; sync # just to be safe
4604 BEFOREWRITES=`count_ost_writes`
4605 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4606 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4607 AFTERWRITES=`count_ost_writes`
4608 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4609 error "$BEFOREWRITES < $AFTERWRITES"
4612 run_test 42a "ensure that we don't flush on close"
4615 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4618 cancel_lru_locks $OSC
4621 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4622 BEFOREWRITES=$(count_ost_writes)
4623 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4624 AFTERWRITES=$(count_ost_writes)
4625 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4626 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4628 BEFOREWRITES=$(count_ost_writes)
4629 sync || error "sync: $?"
4630 AFTERWRITES=$(count_ost_writes)
4631 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4632 error "$BEFOREWRITES < $AFTERWRITES on sync"
4634 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4638 run_test 42b "test destroy of file with cached dirty data ======"
4640 # if these tests just want to test the effect of truncation,
4641 # they have to be very careful. consider:
4642 # - the first open gets a {0,EOF}PR lock
4643 # - the first write conflicts and gets a {0, count-1}PW
4644 # - the rest of the writes are under {count,EOF}PW
4645 # - the open for truncate tries to match a {0,EOF}PR
4646 # for the filesize and cancels the PWs.
4647 # any number of fixes (don't get {0,EOF} on open, match
4648 # composite locks, do smarter file size management) fix
4649 # this, but for now we want these tests to verify that
4650 # the cancellation with truncate intent works, so we
4651 # start the file with a full-file pw lock to match against
4652 # until the truncate.
4657 cancel_lru_locks $OSC
4659 # prime the file with 0,EOF PW to match
4663 # now the real test..
4664 dd if=/dev/zero of=$file bs=1024 count=100
4665 BEFOREWRITES=`count_ost_writes`
4666 $TRUNCATE $file $offset
4667 cancel_lru_locks $OSC
4668 AFTERWRITES=`count_ost_writes`
4673 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4676 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4677 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4680 run_test 42c "test partial truncate of file with cached dirty data"
4683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4686 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4687 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4690 run_test 42d "test complete truncate of file with cached dirty data"
4692 test_42e() { # bug22074
4693 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4695 local TDIR=$DIR/${tdir}e
4696 local pages=16 # hardcoded 16 pages, don't change it.
4697 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4698 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4702 test_mkdir $DIR/${tdir}e
4703 $LFS setstripe -c 1 $TDIR
4704 createmany -o $TDIR/f $files
4706 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4708 # we assume that with $OSTCOUNT files, at least one of them will
4709 # be allocated on OST0.
4710 warmup_files=$((OSTCOUNT * max_dirty_mb))
4711 createmany -o $TDIR/w $warmup_files
4713 # write a large amount of data into one file and sync, to get good
4714 # avail_grant number from OST.
4715 for ((i=0; i<$warmup_files; i++)); do
4716 idx=$($LFS getstripe -i $TDIR/w$i)
4717 [ $idx -ne 0 ] && continue
4718 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4721 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4723 $LCTL get_param $proc_osc0/cur_dirty_bytes
4724 $LCTL get_param $proc_osc0/cur_grant_bytes
4726 # create as much dirty pages as we can while not to trigger the actual
4727 # RPCs directly. but depends on the env, VFS may trigger flush during this
4728 # period, hopefully we are good.
4729 for ((i=0; i<$warmup_files; i++)); do
4730 idx=$($LFS getstripe -i $TDIR/w$i)
4731 [ $idx -ne 0 ] && continue
4732 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4734 $LCTL get_param $proc_osc0/cur_dirty_bytes
4735 $LCTL get_param $proc_osc0/cur_grant_bytes
4737 # perform the real test
4738 $LCTL set_param $proc_osc0/rpc_stats 0
4739 for ((;i<$files; i++)); do
4740 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
4741 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4744 $LCTL get_param $proc_osc0/rpc_stats
4747 local have_ppr=false
4748 $LCTL get_param $proc_osc0/rpc_stats |
4749 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4750 # skip lines until we are at the RPC histogram data
4751 [ "$PPR" == "pages" ] && have_ppr=true && continue
4752 $have_ppr || continue
4754 # we only want the percent stat for < 16 pages
4755 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4757 percent=$((percent + WPCT))
4758 if [[ $percent -gt 15 ]]; then
4759 error "less than 16-pages write RPCs" \
4766 run_test 42e "verify sub-RPC writes are not done synchronously"
4768 test_43A() { # was test_43
4769 test_mkdir $DIR/$tdir
4770 cp -p /bin/ls $DIR/$tdir/$tfile
4771 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4773 # give multiop a chance to open
4776 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4779 run_test 43A "execution of file opened for write should return -ETXTBSY"
4782 test_mkdir $DIR/$tdir
4783 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4784 $DIR/$tdir/sleep 60 &
4786 # Make sure exec of $tdir/sleep wins race with truncate
4788 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4791 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4796 test_mkdir $DIR/$tdir
4797 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4798 $DIR/$tdir/sleep 60 &
4800 # Make sure exec of $tdir/sleep wins race with truncate
4802 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4805 run_test 43b "truncate of file being executed should return -ETXTBSY"
4808 local testdir="$DIR/$tdir"
4811 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4812 ( cd $testdir && md5sum -c )
4814 run_test 43c "md5sum of copy into lustre"
4816 test_44A() { # was test_44
4817 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4819 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4820 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4822 run_test 44A "zero length read from a sparse stripe"
4825 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4827 [ -z "$nstripe" ] && skip "can't get stripe info"
4828 [[ $nstripe -gt $OSTCOUNT ]] &&
4829 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4831 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4833 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4834 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4838 OFFSETS="0 $((stride/2)) $((stride-1))"
4839 for offset in $OFFSETS; do
4840 for i in $(seq 0 $((nstripe-1))); do
4841 local GLOBALOFFSETS=""
4843 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4844 local myfn=$DIR/d44a-$size
4845 echo "--------writing $myfn at $size"
4846 ll_sparseness_write $myfn $size ||
4847 error "ll_sparseness_write"
4848 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4849 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4850 error "ll_sparseness_verify $GLOBALOFFSETS"
4852 for j in $(seq 0 $((nstripe-1))); do
4854 size=$((((j + $nstripe )*$stride + $offset)))
4855 ll_sparseness_write $myfn $size ||
4856 error "ll_sparseness_write"
4857 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4859 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4860 error "ll_sparseness_verify $GLOBALOFFSETS"
4865 run_test 44a "test sparse pwrite ==============================="
4869 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4875 before=`dirty_osc_total`
4876 echo executing "\"$*\""
4878 after=`dirty_osc_total`
4879 echo before $before, after $after
4882 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4885 # Obtain grants from OST if it supports it
4886 echo blah > ${f}_grant
4889 do_dirty_record "echo blah > $f"
4890 [[ $before -eq $after ]] && error "write wasn't cached"
4891 do_dirty_record "> $f"
4892 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4893 do_dirty_record "echo blah > $f"
4894 [[ $before -eq $after ]] && error "write wasn't cached"
4895 do_dirty_record "sync"
4896 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4897 do_dirty_record "echo blah > $f"
4898 [[ $before -eq $after ]] && error "write wasn't cached"
4899 do_dirty_record "cancel_lru_locks osc"
4900 [[ $before -gt $after ]] ||
4901 error "lock cancellation didn't lower dirty count"
4904 run_test 45 "osc io page accounting ============================"
4906 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4907 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4908 # objects offset and an assert hit when an rpc was built with 1023's mapped
4909 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4916 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4918 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4919 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4923 run_test 46 "dirtying a previously written page ================"
4925 # test_47 is removed "Device nodes check" is moved to test_28
4927 test_48a() { # bug 2399
4928 [ "$mds1_FSTYPE" = "zfs" ] &&
4929 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4930 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4932 test_mkdir $DIR/$tdir
4934 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4935 test_mkdir $DIR/$tdir
4936 touch foo || error "'touch foo' failed after recreating cwd"
4938 touch .foo || error "'touch .foo' failed after recreating cwd"
4940 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4941 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4942 cd . || error "'cd .' failed after recreating cwd"
4943 mkdir . && error "'mkdir .' worked after recreating cwd"
4944 rmdir . && error "'rmdir .' worked after recreating cwd"
4945 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4946 cd .. || error "'cd ..' failed after recreating cwd"
4948 run_test 48a "Access renamed working dir (should return errors)="
4950 test_48b() { # bug 2399
4952 test_mkdir $DIR/$tdir
4954 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4955 touch foo && error "'touch foo' worked after removing cwd"
4956 mkdir foo && error "'mkdir foo' worked after removing cwd"
4957 touch .foo && error "'touch .foo' worked after removing cwd"
4958 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4959 ls . > /dev/null && error "'ls .' worked after removing cwd"
4960 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4961 mkdir . && error "'mkdir .' worked after removing cwd"
4962 rmdir . && error "'rmdir .' worked after removing cwd"
4963 ln -s . foo && error "'ln -s .' worked after removing cwd"
4964 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4966 run_test 48b "Access removed working dir (should return errors)="
4968 test_48c() { # bug 2350
4969 #lctl set_param debug=-1
4972 test_mkdir -p $DIR/$tdir/dir
4974 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4975 $TRACE touch foo && error "touch foo worked after removing cwd"
4976 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4977 touch .foo && error "touch .foo worked after removing cwd"
4978 mkdir .foo && error "mkdir .foo worked after removing cwd"
4979 $TRACE ls . && error "'ls .' worked after removing cwd"
4980 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4981 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4982 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4983 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4984 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4986 run_test 48c "Access removed working subdir (should return errors)"
4988 test_48d() { # bug 2350
4989 #lctl set_param debug=-1
4992 test_mkdir -p $DIR/$tdir/dir
4994 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4995 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4996 $TRACE touch foo && error "'touch foo' worked after removing parent"
4997 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4998 touch .foo && error "'touch .foo' worked after removing parent"
4999 mkdir .foo && error "mkdir .foo worked after removing parent"
5000 $TRACE ls . && error "'ls .' worked after removing parent"
5001 $TRACE ls .. && error "'ls ..' worked after removing parent"
5002 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5003 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5004 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5007 run_test 48d "Access removed parent subdir (should return errors)"
5009 test_48e() { # bug 4134
5010 #lctl set_param debug=-1
5013 test_mkdir -p $DIR/$tdir/dir
5015 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5016 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5017 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5018 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5019 # On a buggy kernel addition of "touch foo" after cd .. will
5020 # produce kernel oops in lookup_hash_it
5021 touch ../foo && error "'cd ..' worked after recreate parent"
5023 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5025 run_test 48e "Access to recreated parent subdir (should return errors)"
5027 test_49() { # LU-1030
5028 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5029 remote_ost_nodsh && skip "remote OST with nodsh"
5031 # get ost1 size - $FSNAME-OST0000
5032 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5034 # write 800M at maximum
5035 [[ $ost1_size -lt 2 ]] && ost1_size=2
5036 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5038 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5039 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5042 # change max_pages_per_rpc while writing the file
5043 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5044 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5045 # loop until dd process exits
5046 while ps ax -opid | grep -wq $dd_pid; do
5047 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5048 sleep $((RANDOM % 5 + 1))
5050 # restore original max_pages_per_rpc
5051 $LCTL set_param $osc1_mppc=$orig_mppc
5052 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5054 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5058 test_mkdir $DIR/$tdir
5060 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5062 run_test 50 "special situations: /proc symlinks ==============="
5064 test_51a() { # was test_51
5065 # bug 1516 - create an empty entry right after ".." then split dir
5066 test_mkdir -c1 $DIR/$tdir
5067 touch $DIR/$tdir/foo
5068 $MCREATE $DIR/$tdir/bar
5070 createmany -m $DIR/$tdir/longfile 201
5072 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5073 $MCREATE $DIR/$tdir/longfile$FNUM
5078 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5080 run_test 51a "special situations: split htree with empty entry =="
5082 cleanup_print_lfs_df () {
5089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5091 local dir=$DIR/$tdir
5092 local nrdirs=$((65536 + 100))
5094 # cleanup the directory
5101 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5102 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5103 [[ $numfree -lt $nrdirs ]] &&
5104 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5106 # need to check free space for the directories as well
5107 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5108 numfree=$(( blkfree / $(fs_inode_ksize) ))
5109 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5111 trap cleanup_print_lfs_df EXIT
5114 createmany -d $dir/d $nrdirs || {
5115 unlinkmany $dir/d $nrdirs
5116 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5120 nrdirs=$(ls -U $dir | wc -l)
5122 # unlink all but 100 subdirectories, then check it still works
5124 local delete=$((nrdirs - left))
5129 # for ldiskfs the nlink count should be 1, but this is OSD specific
5130 # and so this is listed for informational purposes only
5131 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5132 unlinkmany -d $dir/d $delete ||
5133 error "unlink of first $delete subdirs failed"
5135 echo "nlink between: $(stat -c %h $dir)"
5136 local found=$(ls -U $dir | wc -l)
5137 [ $found -ne $left ] &&
5138 error "can't find subdirs: found only $found, expected $left"
5140 unlinkmany -d $dir/d $delete $left ||
5141 error "unlink of second $left subdirs failed"
5142 # regardless of whether the backing filesystem tracks nlink accurately
5143 # or not, the nlink count shouldn't be more than "." and ".." here
5144 local after=$(stat -c %h $dir)
5145 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5146 echo "nlink after: $after"
5148 cleanup_print_lfs_df
5150 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5153 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5154 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5156 test_mkdir $DIR/$tdir
5157 createmany -o $DIR/$tdir/t- 1000
5158 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5159 for N in $(seq 0 $((OSTCOUNT - 1))); do
5160 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
5161 END { printf("%0.0f", objs) }' $TMP/$tfile)
5162 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5163 '($1 == '$N') { objs += 1 } \
5164 END { printf("%0.0f", objs) }')
5165 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
5167 unlinkmany $DIR/$tdir/t- 1000
5170 for N in $(seq 1 $((OSTCOUNT - 1))); do
5171 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
5172 error "OST $N has less objects vs OST $NLAST" \
5173 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5174 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
5175 error "OST $N has less objects vs OST $NLAST" \
5176 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5178 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
5179 error "OST $N has less #0 objects vs OST $NLAST" \
5180 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5181 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
5182 error "OST $N has less #0 objects vs OST $NLAST" \
5183 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5188 run_test 51d "check object distribution"
5191 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5192 skip_env "ldiskfs only test"
5195 test_mkdir -c1 $DIR/$tdir
5196 test_mkdir -c1 $DIR/$tdir/d0
5198 touch $DIR/$tdir/d0/foo
5199 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5200 error "file exceed 65000 nlink limit!"
5201 unlinkmany $DIR/$tdir/d0/f- 65001
5204 run_test 51e "check file nlink limit"
5207 test_mkdir $DIR/$tdir
5210 local ulimit_old=$(ulimit -n)
5211 local spare=20 # number of spare fd's for scripts/libraries, etc.
5212 local mdt=$($LFS getstripe -m $DIR/$tdir)
5213 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5215 echo "MDT$mdt numfree=$numfree, max=$max"
5216 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5217 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5218 while ! ulimit -n $((numfree + spare)); do
5219 numfree=$((numfree * 3 / 4))
5221 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5223 echo "left ulimit at $ulimit_old"
5226 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5227 unlinkmany $DIR/$tdir/f $numfree
5228 error "create+open $numfree files in $DIR/$tdir failed"
5230 ulimit -n $ulimit_old
5232 # if createmany exits at 120s there will be fewer than $numfree files
5233 unlinkmany $DIR/$tdir/f $numfree || true
5235 run_test 51f "check many open files limit"
5238 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5239 test_mkdir $DIR/$tdir
5240 touch $DIR/$tdir/foo
5241 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5242 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5243 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5244 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5245 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5247 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5248 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5249 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5251 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5252 cp -r $DIR/$tdir $TMP/
5253 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5255 run_test 52a "append-only flag test (should return errors)"
5258 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5259 test_mkdir $DIR/$tdir
5260 touch $DIR/$tdir/foo
5261 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5262 cat test > $DIR/$tdir/foo && error "cat test worked"
5263 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5264 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5265 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5267 echo foo >> $DIR/$tdir/foo && error "echo worked"
5268 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5269 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5270 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5271 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5273 chattr -i $DIR/$tdir/foo || error "chattr failed"
5275 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5277 run_test 52b "immutable flag test (should return errors) ======="
5280 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5281 remote_mds_nodsh && skip "remote MDS with nodsh"
5282 remote_ost_nodsh && skip "remote OST with nodsh"
5295 local support_last_seq=true
5297 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5298 support_last_seq=false
5301 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5303 for value in $(do_facet $SINGLEMDS \
5304 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5305 param=$(echo ${value[0]} | cut -d "=" -f1)
5306 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5308 if $support_last_seq; then
5309 param_seq=$(echo $param |
5310 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5311 mds_last_seq=$(do_facet $SINGLEMDS \
5312 $LCTL get_param -n $param_seq)
5314 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5316 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5317 node=$(facet_active_host ost$((ostnum+1)))
5318 param="obdfilter.$ostname.last_id"
5319 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5320 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5321 ost_last_id=$ost_last
5323 if $support_last_seq; then
5324 ost_last_id=$(echo $ost_last |
5325 awk -F':' '{print $2}' |
5327 ost_last_seq=$(echo $ost_last |
5328 awk -F':' '{print $1}')
5329 [[ $ost_last_seq = $mds_last_seq ]] || continue
5332 if [[ $ost_last_id != $mds_last ]]; then
5333 error "$ost_last_id != $mds_last"
5340 $found || error "can not match last_seq/last_id for $mdtosc"
5343 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5346 perl -MSocket -e ';' || skip "no Socket perl module installed"
5348 $SOCKETSERVER $DIR/socket ||
5349 error "$SOCKETSERVER $DIR/socket failed: $?"
5350 $SOCKETCLIENT $DIR/socket ||
5351 error "$SOCKETCLIENT $DIR/socket failed: $?"
5352 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5354 run_test 54a "unix domain socket test =========================="
5360 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5362 run_test 54b "char device works in lustre ======================"
5365 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5366 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5367 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5369 for i in $(seq 3 7); do
5370 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5379 loopdev="$DIR/loop54c"
5382 $UMOUNT $DIR/$tdir || rc=$?
5383 losetup -d $loopdev || true
5384 losetup -d $LOOPDEV || true
5385 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5390 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5392 loopdev="$DIR/loop54c"
5395 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5396 trap cleanup_54c EXIT
5397 mknod $loopdev b 7 $LOOPNUM
5398 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5399 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5400 losetup $loopdev $DIR/$tfile ||
5401 error "can't set up $loopdev for $DIR/$tfile"
5402 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5403 test_mkdir $DIR/$tdir
5404 mount -t ext2 $loopdev $DIR/$tdir ||
5405 error "error mounting $loopdev on $DIR/$tdir"
5406 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
5409 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
5413 run_test 54c "block device works in lustre ====================="
5419 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
5421 run_test 54d "fifo device works in lustre ======================"
5426 cp -aL /dev/console $f
5427 echo $string > $f || error "echo $string to $f failed"
5429 run_test 54e "console/tty device works in lustre ======================"
5433 local dir=$DIR/$tdir
5436 test_mkdir -p $dir/dir
5437 for i in $(seq $numfiles); do
5439 touch $dir/dir/file$i
5442 local numcomp=$($LFS getstripe --component-count $dir)
5444 [[ $numcomp == 0 ]] && numcomp=1
5446 # test lfs getstripe with --recursive
5447 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5449 [[ $filenum -eq $((numfiles * 2)) ]] ||
5450 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5451 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5452 [[ $filenum -eq $numfiles ]] ||
5453 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5454 echo "$LFS getstripe showed obdidx or l_ost_idx"
5456 # test lfs getstripe with file instead of dir
5457 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5458 [[ $filenum -eq 1 ]] ||
5459 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5460 echo "$LFS getstripe file1 passed"
5462 #test lfs getstripe with --verbose
5463 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5464 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5465 error "$LFS getstripe --verbose $dir: "\
5466 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5467 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5468 error "$LFS getstripe $dir: showed lmm_magic"
5470 #test lfs getstripe with -v prints lmm_fid
5471 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5472 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5473 error "$LFS getstripe -v $dir: "\
5474 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5475 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5476 error "$LFS getstripe $dir: showed lmm_fid by default"
5477 echo "$LFS getstripe --verbose passed"
5479 #check for FID information
5480 local fid1=$($LFS getstripe --fid $dir/file1)
5481 local fid2=$($LFS getstripe --verbose $dir/file1 |
5482 awk '/lmm_fid: / { print $2; exit; }')
5483 local fid3=$($LFS path2fid $dir/file1)
5485 [ "$fid1" != "$fid2" ] &&
5486 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5487 [ "$fid1" != "$fid3" ] &&
5488 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5489 echo "$LFS getstripe --fid passed"
5491 #test lfs getstripe with --obd
5492 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5493 error "$LFS getstripe --obd wrong_uuid: should return error"
5495 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5498 local obduuid=$(ostuuid_from_index $ostidx)
5499 local found=$($LFS getstripe -r --obd $obduuid $dir |
5500 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5502 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5503 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5505 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5508 [[ $found -eq $filenum ]] ||
5509 error "$LFS getstripe --obd: found $found expect $filenum"
5510 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5511 sed '/^[ ]*'${ostidx}'[ ]/d' |
5512 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5513 error "$LFS getstripe --obd: should not show file on other obd"
5514 echo "$LFS getstripe --obd passed"
5516 run_test 56a "check $LFS getstripe"
5519 local dir=$DIR/$tdir
5523 for i in $(seq $numdirs); do
5524 test_mkdir $dir/dir$i
5527 # test lfs getdirstripe default mode is non-recursion, which is
5528 # different from lfs getstripe
5529 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5531 [[ $dircnt -eq 1 ]] ||
5532 error "$LFS getdirstripe: found $dircnt, not 1"
5533 dircnt=$($LFS getdirstripe --recursive $dir |
5534 grep -c lmv_stripe_count)
5535 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5536 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5538 run_test 56b "check $LFS getdirstripe"
5541 remote_ost_nodsh && skip "remote OST with nodsh"
5544 local ost_name=$(ostname_from_index $ost_idx)
5545 local old_status=$(ost_dev_status $ost_idx)
5547 [[ -z "$old_status" ]] ||
5548 skip_env "OST $ost_name is in $old_status status"
5550 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5551 [[ $OST1_VERSION -ge $(version_code 2.12.55) ]] && do_facet ost1 \
5552 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
5555 local new_status=$(ost_dev_status $ost_idx)
5557 [[ "$new_status" =~ "D" ]] ||
5558 error "$ost_name status is '$new_status', missing 'D'"
5559 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
5560 [[ "$new_status" =~ "N" ]] ||
5561 error "$ost_name status is '$new_status', missing 'N'"
5564 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5565 [[ $OST1_VERSION -ge $(version_code 2.12.55) ]] && do_facet ost1 \
5566 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
5569 new_status=$(ost_dev_status $ost_idx)
5570 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
5571 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
5573 run_test 56c "check 'lfs df' showing device status"
5578 local local_tdir="$1"
5579 local local_numfiles="$2"
5580 local local_numdirs="$3"
5581 local dir_params="$4"
5582 local dir_stripe_params="$5"
5584 if [ ! -d "$local_tdir" ] ; then
5585 test_mkdir -p $dir_stripe_params $local_tdir
5586 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5587 for i in $(seq $local_numfiles) ; do
5588 touch $local_tdir/file$i
5590 for i in $(seq $local_numdirs) ; do
5591 test_mkdir $dir_stripe_params $local_tdir/dir$i
5592 for j in $(seq $local_numfiles) ; do
5593 touch $local_tdir/dir$i/file$j
5599 setup_56_special() {
5601 local local_numfiles=$2
5602 local local_numdirs=$3
5604 setup_56 $local_tdir $local_numfiles $local_numdirs
5606 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5607 for i in $(seq $local_numfiles) ; do
5608 mknod $local_tdir/loop${i}b b 7 $i
5609 mknod $local_tdir/null${i}c c 1 3
5610 ln -s $local_tdir/file1 $local_tdir/link${i}
5612 for i in $(seq $local_numdirs) ; do
5613 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5614 mknod $local_tdir/dir$i/null${i}c c 1 3
5615 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5621 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5622 local expected=$(($NUMDIRS + 2))
5624 setup_56 $dir $NUMFILES $NUMDIRS
5626 # test lfs find with -name
5627 for i in $(seq $NUMFILES) ; do
5628 local nums=$($LFS find -name "*$i" $dir | wc -l)
5630 [ $nums -eq $expected ] ||
5631 error "lfs find -name '*$i' $dir wrong: "\
5632 "found $nums, expected $expected"
5635 run_test 56g "check lfs find -name"
5638 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5639 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5641 setup_56 $dir $NUMFILES $NUMDIRS
5643 # test lfs find with ! -name
5644 for i in $(seq $NUMFILES) ; do
5645 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5647 [ $nums -eq $expected ] ||
5648 error "lfs find ! -name '*$i' $dir wrong: "\
5649 "found $nums, expected $expected"
5652 run_test 56h "check lfs find ! -name"
5655 local dir=$DIR/$tdir
5659 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5662 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5664 run_test 56i "check 'lfs find -ost UUID' skips directories"
5667 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5669 setup_56_special $dir $NUMFILES $NUMDIRS
5671 local expected=$((NUMDIRS + 1))
5672 local cmd="$LFS find -type d $dir"
5673 local nums=$($cmd | wc -l)
5675 [ $nums -eq $expected ] ||
5676 error "'$cmd' wrong: found $nums, expected $expected"
5678 run_test 56j "check lfs find -type d"
5681 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5683 setup_56_special $dir $NUMFILES $NUMDIRS
5685 local expected=$(((NUMDIRS + 1) * NUMFILES))
5686 local cmd="$LFS find -type f $dir"
5687 local nums=$($cmd | wc -l)
5689 [ $nums -eq $expected ] ||
5690 error "'$cmd' wrong: found $nums, expected $expected"
5692 run_test 56k "check lfs find -type f"
5695 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5697 setup_56_special $dir $NUMFILES $NUMDIRS
5699 local expected=$((NUMDIRS + NUMFILES))
5700 local cmd="$LFS find -type b $dir"
5701 local nums=$($cmd | wc -l)
5703 [ $nums -eq $expected ] ||
5704 error "'$cmd' wrong: found $nums, expected $expected"
5706 run_test 56l "check lfs find -type b"
5709 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5711 setup_56_special $dir $NUMFILES $NUMDIRS
5713 local expected=$((NUMDIRS + NUMFILES))
5714 local cmd="$LFS find -type c $dir"
5715 local nums=$($cmd | wc -l)
5716 [ $nums -eq $expected ] ||
5717 error "'$cmd' wrong: found $nums, expected $expected"
5719 run_test 56m "check lfs find -type c"
5722 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5723 setup_56_special $dir $NUMFILES $NUMDIRS
5725 local expected=$((NUMDIRS + NUMFILES))
5726 local cmd="$LFS find -type l $dir"
5727 local nums=$($cmd | wc -l)
5729 [ $nums -eq $expected ] ||
5730 error "'$cmd' wrong: found $nums, expected $expected"
5732 run_test 56n "check lfs find -type l"
5735 local dir=$DIR/$tdir
5737 setup_56 $dir $NUMFILES $NUMDIRS
5738 utime $dir/file1 > /dev/null || error "utime (1)"
5739 utime $dir/file2 > /dev/null || error "utime (2)"
5740 utime $dir/dir1 > /dev/null || error "utime (3)"
5741 utime $dir/dir2 > /dev/null || error "utime (4)"
5742 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5743 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5746 local nums=$($LFS find -mtime +0 $dir | wc -l)
5748 [ $nums -eq $expected ] ||
5749 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5752 cmd="$LFS find -mtime 0 $dir"
5753 nums=$($cmd | wc -l)
5754 [ $nums -eq $expected ] ||
5755 error "'$cmd' wrong: found $nums, expected $expected"
5757 run_test 56o "check lfs find -mtime for old files"
5760 local dir=$DIR/$tdir
5764 # just to make sure there is something that won't be found
5766 touch $dir/$tfile.now
5768 for age in year week day hour min; do
5769 count=$((count + 1))
5771 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
5772 touch --date="$count $age ago" -a $dir/$tfile-a.$age
5773 touch --date="$count $age ago" -m $dir/$tfile-m.$age
5775 local cmd="$LFS find $dir -mtime $count${age:0:1}"
5776 local nums=$($cmd | wc -l)
5777 [ $nums -eq $expected ] ||
5778 error "'$cmd' wrong: found $nums, expected $expected"
5780 cmd="$LFS find $dir -atime $count${age:0:1}"
5781 nums=$($cmd | wc -l)
5782 [ $nums -eq $expected ] ||
5783 error "'$cmd' wrong: found $nums, expected $expected"
5787 cmd="$LFS find $dir -ctime +1s -type f"
5788 nums=$($cmd | wc -l)
5789 (( $nums == $count * 2 + 1)) ||
5790 error "'$cmd' wrong: found $nums, expected $((expected*2+1))"
5792 run_test 56ob "check lfs find -atime -mtime -ctime with units"
5794 test_newerXY_base() {
5797 local dir=$DIR/$tdir
5801 if [ $y == "t" ]; then
5802 ref="\"$(date +"%Y-%m-%d %H:%M:%S")\""
5804 ref=$DIR/$tfile.newer
5805 touch $ref || error "touch $ref failed"
5808 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
5810 if [ $y == "t" ]; then
5811 negref="\"$(date +"%Y-%m-%d %H:%M:%S")\""
5813 negref=$DIR/$tfile.newerneg
5814 touch $negref || error "touch $negref failed"
5817 local cmd="$LFS find $dir -newer$x$y $ref"
5818 local nums=$(eval $cmd | wc -l)
5819 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
5821 [ $nums -eq $expected ] ||
5822 error "'$cmd' wrong: found $nums, expected $expected"
5824 cmd="$LFS find $dir ! -newer$x$y $negref"
5825 nums=$(eval $cmd | wc -l)
5826 [ $nums -eq $expected ] ||
5827 error "'$cmd' wrong: found $nums, expected $expected"
5829 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
5830 nums=$(eval $cmd | wc -l)
5831 [ $nums -eq $expected ] ||
5832 error "'$cmd' wrong: found $nums, expected $expected"
5838 test_newerXY_base "a" "a"
5839 test_newerXY_base "a" "m"
5840 test_newerXY_base "a" "c"
5841 test_newerXY_base "m" "a"
5842 test_newerXY_base "m" "m"
5843 test_newerXY_base "m" "c"
5844 test_newerXY_base "c" "a"
5845 test_newerXY_base "c" "m"
5846 test_newerXY_base "c" "c"
5847 test_newerXY_base "a" "t"
5848 test_newerXY_base "m" "t"
5849 test_newerXY_base "c" "t"
5851 run_test 56oc "check lfs find -newerXY work"
5854 [ $RUNAS_ID -eq $UID ] &&
5855 skip_env "RUNAS_ID = UID = $UID -- skipping"
5857 local dir=$DIR/$tdir
5859 setup_56 $dir $NUMFILES $NUMDIRS
5860 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5862 local expected=$NUMFILES
5863 local cmd="$LFS find -uid $RUNAS_ID $dir"
5864 local nums=$($cmd | wc -l)
5866 [ $nums -eq $expected ] ||
5867 error "'$cmd' wrong: found $nums, expected $expected"
5869 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5870 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5871 nums=$($cmd | wc -l)
5872 [ $nums -eq $expected ] ||
5873 error "'$cmd' wrong: found $nums, expected $expected"
5875 run_test 56p "check lfs find -uid and ! -uid"
5878 [ $RUNAS_ID -eq $UID ] &&
5879 skip_env "RUNAS_ID = UID = $UID -- skipping"
5881 local dir=$DIR/$tdir
5883 setup_56 $dir $NUMFILES $NUMDIRS
5884 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5886 local expected=$NUMFILES
5887 local cmd="$LFS find -gid $RUNAS_GID $dir"
5888 local nums=$($cmd | wc -l)
5890 [ $nums -eq $expected ] ||
5891 error "'$cmd' wrong: found $nums, expected $expected"
5893 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5894 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5895 nums=$($cmd | wc -l)
5896 [ $nums -eq $expected ] ||
5897 error "'$cmd' wrong: found $nums, expected $expected"
5899 run_test 56q "check lfs find -gid and ! -gid"
5902 local dir=$DIR/$tdir
5904 setup_56 $dir $NUMFILES $NUMDIRS
5907 local cmd="$LFS find -size 0 -type f -lazy $dir"
5908 local nums=$($cmd | wc -l)
5910 [ $nums -eq $expected ] ||
5911 error "'$cmd' wrong: found $nums, expected $expected"
5912 cmd="$LFS find -size 0 -type f $dir"
5913 nums=$($cmd | wc -l)
5914 [ $nums -eq $expected ] ||
5915 error "'$cmd' wrong: found $nums, expected $expected"
5918 cmd="$LFS find ! -size 0 -type f -lazy $dir"
5919 nums=$($cmd | wc -l)
5920 [ $nums -eq $expected ] ||
5921 error "'$cmd' wrong: found $nums, expected $expected"
5922 cmd="$LFS find ! -size 0 -type f $dir"
5923 nums=$($cmd | wc -l)
5924 [ $nums -eq $expected ] ||
5925 error "'$cmd' wrong: found $nums, expected $expected"
5927 echo "test" > $dir/$tfile
5928 echo "test2" > $dir/$tfile.2 && sync
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"
5940 cmd="$LFS find -size +5 -type f -lazy $dir"
5941 nums=$($cmd | wc -l)
5942 [ $nums -eq $expected ] ||
5943 error "'$cmd' wrong: found $nums, expected $expected"
5944 cmd="$LFS find -size +5 -type f $dir"
5945 nums=$($cmd | wc -l)
5946 [ $nums -eq $expected ] ||
5947 error "'$cmd' wrong: found $nums, expected $expected"
5950 cmd="$LFS find -size +0 -type f -lazy $dir"
5951 nums=$($cmd | wc -l)
5952 [ $nums -eq $expected ] ||
5953 error "'$cmd' wrong: found $nums, expected $expected"
5954 cmd="$LFS find -size +0 -type f $dir"
5955 nums=$($cmd | wc -l)
5956 [ $nums -eq $expected ] ||
5957 error "'$cmd' wrong: found $nums, expected $expected"
5960 cmd="$LFS find ! -size -5 -type f -lazy $dir"
5961 nums=$($cmd | wc -l)
5962 [ $nums -eq $expected ] ||
5963 error "'$cmd' wrong: found $nums, expected $expected"
5964 cmd="$LFS find ! -size -5 -type f $dir"
5965 nums=$($cmd | wc -l)
5966 [ $nums -eq $expected ] ||
5967 error "'$cmd' wrong: found $nums, expected $expected"
5970 cmd="$LFS find -size -5 -type f -lazy $dir"
5971 nums=$($cmd | wc -l)
5972 [ $nums -eq $expected ] ||
5973 error "'$cmd' wrong: found $nums, expected $expected"
5974 cmd="$LFS find -size -5 -type f $dir"
5975 nums=$($cmd | wc -l)
5976 [ $nums -eq $expected ] ||
5977 error "'$cmd' wrong: found $nums, expected $expected"
5979 run_test 56r "check lfs find -size works"
5982 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
5983 skip "MDS < 2.12.58 doesn't return LSOM data"
5984 local dir=$DIR/$tdir
5986 [[ $OSC == "mdc" ]] && skip "DoM files" && return
5988 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5990 cancel_lru_locks $OSC
5992 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5994 local cmd="$LFS find -size 0 -type f -lazy $dir"
5995 local nums=$($cmd | wc -l)
5997 [ $nums -eq $expected ] ||
5998 error "'$cmd' wrong: found $nums, expected $expected"
6000 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6001 [ $rpcs_before -eq $rpcs_after ] ||
6002 error "'$cmd' should not send glimpse RPCs to OST"
6003 cmd="$LFS find -size 0 -type f $dir"
6004 nums=$($cmd | wc -l)
6005 [ $nums -eq $expected ] ||
6006 error "'$cmd' wrong: found $nums, expected $expected"
6007 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6008 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6009 $LCTL get_param osc.*.stats
6010 [ $rpcs_after -eq $((rpcs_before + 12)) ] ||
6011 error "'$cmd' should send 12 glimpse RPCs to OST"
6013 cancel_lru_locks $OSC
6014 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6016 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6017 nums=$($cmd | wc -l)
6018 [ $nums -eq $expected ] ||
6019 error "'$cmd' wrong: found $nums, expected $expected"
6020 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6021 $LCTL get_param mdc.*.stats
6022 [ $rpcs_before -eq $rpcs_after ] ||
6023 error "'$cmd' should not send glimpse RPCs to OST"
6024 cmd="$LFS find ! -size 0 -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 + 12)) ] ||
6031 error "'$cmd' should send 12 glimpse RPCs to OST"
6033 echo "test" > $dir/$tfile
6034 echo "test2" > $dir/$tfile.2 && sync
6035 cancel_lru_locks $OSC
6036 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6038 cmd="$LFS find -size 5 -type f -lazy $dir"
6039 nums=$($cmd | wc -l)
6040 [ $nums -eq $expected ] ||
6041 error "'$cmd' wrong: found $nums, expected $expected"
6042 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6043 [ $rpcs_before -eq $rpcs_after ] ||
6044 error "'$cmd' should not send glimpse RPCs to OST"
6045 cmd="$LFS find -size 5 -type f $dir"
6046 nums=$($cmd | wc -l)
6047 [ $nums -eq $expected ] ||
6048 error "'$cmd' wrong: found $nums, expected $expected"
6049 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6050 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6051 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6052 error "'$cmd' should send 14 glimpse RPCs to OST"
6054 cancel_lru_locks $OSC
6055 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6057 cmd="$LFS find -size +5 -type f -lazy $dir"
6058 nums=$($cmd | wc -l)
6059 [ $nums -eq $expected ] ||
6060 error "'$cmd' wrong: found $nums, expected $expected"
6061 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6062 [ $rpcs_before -eq $rpcs_after ] ||
6063 error "'$cmd' should not send glimpse RPCs to OST"
6064 cmd="$LFS find -size +5 -type f $dir"
6065 nums=$($cmd | wc -l)
6066 [ $nums -eq $expected ] ||
6067 error "'$cmd' wrong: found $nums, expected $expected"
6068 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6069 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6070 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6071 error "'$cmd' should send 14 glimpse RPCs to OST"
6073 cancel_lru_locks $OSC
6074 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6076 cmd="$LFS find -size +0 -type f -lazy $dir"
6077 nums=$($cmd | wc -l)
6078 [ $nums -eq $expected ] ||
6079 error "'$cmd' wrong: found $nums, expected $expected"
6080 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6081 [ $rpcs_before -eq $rpcs_after ] ||
6082 error "'$cmd' should not send glimpse RPCs to OST"
6083 cmd="$LFS find -size +0 -type f $dir"
6084 nums=$($cmd | wc -l)
6085 [ $nums -eq $expected ] ||
6086 error "'$cmd' wrong: found $nums, expected $expected"
6087 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6088 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6089 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6090 error "'$cmd' should send 14 glimpse RPCs to OST"
6092 cancel_lru_locks $OSC
6093 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6095 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6096 nums=$($cmd | wc -l)
6097 [ $nums -eq $expected ] ||
6098 error "'$cmd' wrong: found $nums, expected $expected"
6099 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6100 [ $rpcs_before -eq $rpcs_after ] ||
6101 error "'$cmd' should not send glimpse RPCs to OST"
6102 cmd="$LFS find ! -size -5 -type f $dir"
6103 nums=$($cmd | wc -l)
6104 [ $nums -eq $expected ] ||
6105 error "'$cmd' wrong: found $nums, expected $expected"
6106 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6107 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6108 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6109 error "'$cmd' should send 14 glimpse RPCs to OST"
6111 cancel_lru_locks $OSC
6112 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6114 cmd="$LFS find -size -5 -type f -lazy $dir"
6115 nums=$($cmd | wc -l)
6116 [ $nums -eq $expected ] ||
6117 error "'$cmd' wrong: found $nums, expected $expected"
6118 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6119 [ $rpcs_before -eq $rpcs_after ] ||
6120 error "'$cmd' should not send glimpse RPCs to OST"
6121 cmd="$LFS find -size -5 -type f $dir"
6122 nums=$($cmd | wc -l)
6123 [ $nums -eq $expected ] ||
6124 error "'$cmd' wrong: found $nums, expected $expected"
6125 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6126 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6127 [ $rpcs_after -eq $((rpcs_before + 14)) ] ||
6128 error "'$cmd' should send 14 glimpse RPCs to OST"
6130 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6132 test_56s() { # LU-611 #LU-9369
6133 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
6135 local dir=$DIR/$tdir
6136 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
6138 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6139 for i in $(seq $NUMDIRS); do
6140 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
6143 local expected=$NUMDIRS
6144 local cmd="$LFS find -c $OSTCOUNT $dir"
6145 local nums=$($cmd | wc -l)
6147 [ $nums -eq $expected ] || {
6148 $LFS getstripe -R $dir
6149 error "'$cmd' wrong: found $nums, expected $expected"
6152 expected=$((NUMDIRS + onestripe))
6153 cmd="$LFS find -stripe-count +0 -type f $dir"
6154 nums=$($cmd | wc -l)
6155 [ $nums -eq $expected ] || {
6156 $LFS getstripe -R $dir
6157 error "'$cmd' wrong: found $nums, expected $expected"
6161 cmd="$LFS find -stripe-count 1 -type f $dir"
6162 nums=$($cmd | wc -l)
6163 [ $nums -eq $expected ] || {
6164 $LFS getstripe -R $dir
6165 error "'$cmd' wrong: found $nums, expected $expected"
6168 cmd="$LFS find -stripe-count -2 -type f $dir"
6169 nums=$($cmd | wc -l)
6170 [ $nums -eq $expected ] || {
6171 $LFS getstripe -R $dir
6172 error "'$cmd' wrong: found $nums, expected $expected"
6176 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
6177 nums=$($cmd | wc -l)
6178 [ $nums -eq $expected ] || {
6179 $LFS getstripe -R $dir
6180 error "'$cmd' wrong: found $nums, expected $expected"
6183 run_test 56s "check lfs find -stripe-count works"
6185 test_56t() { # LU-611 #LU-9369
6186 local dir=$DIR/$tdir
6188 setup_56 $dir 0 $NUMDIRS
6189 for i in $(seq $NUMDIRS); do
6190 $LFS setstripe -S 8M $dir/dir$i/$tfile
6193 local expected=$NUMDIRS
6194 local cmd="$LFS find -S 8M $dir"
6195 local nums=$($cmd | wc -l)
6197 [ $nums -eq $expected ] || {
6198 $LFS getstripe -R $dir
6199 error "'$cmd' wrong: found $nums, expected $expected"
6203 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
6205 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
6207 expected=$(((NUMDIRS + 1) * NUMFILES))
6208 cmd="$LFS find -stripe-size 512k -type f $dir"
6209 nums=$($cmd | wc -l)
6210 [ $nums -eq $expected ] ||
6211 error "'$cmd' wrong: found $nums, expected $expected"
6213 cmd="$LFS find -stripe-size +320k -type f $dir"
6214 nums=$($cmd | wc -l)
6215 [ $nums -eq $expected ] ||
6216 error "'$cmd' wrong: found $nums, expected $expected"
6218 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
6219 cmd="$LFS find -stripe-size +200k -type f $dir"
6220 nums=$($cmd | wc -l)
6221 [ $nums -eq $expected ] ||
6222 error "'$cmd' wrong: found $nums, expected $expected"
6224 cmd="$LFS find -stripe-size -640k -type f $dir"
6225 nums=$($cmd | wc -l)
6226 [ $nums -eq $expected ] ||
6227 error "'$cmd' wrong: found $nums, expected $expected"
6230 cmd="$LFS find -stripe-size 256k -type f $dir"
6231 nums=$($cmd | wc -l)
6232 [ $nums -eq $expected ] ||
6233 error "'$cmd' wrong: found $nums, expected $expected"
6235 cmd="$LFS find -stripe-size -320k -type f $dir"
6236 nums=$($cmd | wc -l)
6237 [ $nums -eq $expected ] ||
6238 error "'$cmd' wrong: found $nums, expected $expected"
6241 cmd="$LFS find -stripe-size 1024k -type f $dir"
6242 nums=$($cmd | wc -l)
6243 [ $nums -eq $expected ] ||
6244 error "'$cmd' wrong: found $nums, expected $expected"
6246 run_test 56t "check lfs find -stripe-size works"
6248 test_56u() { # LU-611
6249 local dir=$DIR/$tdir
6251 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
6253 if [[ $OSTCOUNT -gt 1 ]]; then
6254 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
6260 local expected=$(((NUMDIRS + 1) * NUMFILES))
6261 local cmd="$LFS find -stripe-index 0 -type f $dir"
6262 local nums=$($cmd | wc -l)
6264 [ $nums -eq $expected ] ||
6265 error "'$cmd' wrong: found $nums, expected $expected"
6268 cmd="$LFS find -stripe-index 1 -type f $dir"
6269 nums=$($cmd | wc -l)
6270 [ $nums -eq $expected ] ||
6271 error "'$cmd' wrong: found $nums, expected $expected"
6273 cmd="$LFS find ! -stripe-index 0 -type f $dir"
6274 nums=$($cmd | wc -l)
6275 [ $nums -eq $expected ] ||
6276 error "'$cmd' wrong: found $nums, expected $expected"
6279 # This should produce an error and not return any files
6280 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
6281 nums=$($cmd 2>/dev/null | wc -l)
6282 [ $nums -eq $expected ] ||
6283 error "'$cmd' wrong: found $nums, expected $expected"
6285 if [[ $OSTCOUNT -gt 1 ]]; then
6286 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
6287 cmd="$LFS find -stripe-index 0,1 -type f $dir"
6288 nums=$($cmd | wc -l)
6289 [ $nums -eq $expected ] ||
6290 error "'$cmd' wrong: found $nums, expected $expected"
6293 run_test 56u "check lfs find -stripe-index works"
6297 local dir=$DIR/$tdir
6299 setup_56 $dir $NUMFILES $NUMDIRS
6301 UUID=$(mdtuuid_from_index $mdt_idx $dir)
6302 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
6304 for file in $($LFS find -m $UUID $dir); do
6305 file_midx=$($LFS getstripe -m $file)
6306 [ $file_midx -eq $mdt_idx ] ||
6307 error "lfs find -m $UUID != getstripe -m $file_midx"
6310 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
6313 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6314 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6316 local dir=$DIR/$tdir
6318 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
6320 local stripe_size=$($LFS getstripe -S -d $dir) ||
6321 error "$LFS getstripe -S -d $dir failed"
6322 stripe_size=${stripe_size%% *}
6324 local file_size=$((stripe_size * OSTCOUNT))
6325 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
6326 local required_space=$((file_num * file_size))
6327 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
6329 [[ $free_space -le $((required_space / 1024)) ]] &&
6330 skip_env "need $required_space, have $free_space kbytes"
6333 local dd_count=$((file_size / dd_bs))
6335 # write data into the files
6340 for i in $(seq $NUMFILES); do
6342 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6343 error "write data into $file failed"
6345 for i in $(seq $NUMDIRS); do
6346 for j in $(seq $NUMFILES); do
6347 file=$dir/dir$i/file$j
6348 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6349 error "write data into $file failed"
6353 # $LFS_MIGRATE will fail if hard link migration is unsupported
6354 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
6355 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
6356 error "creating links to $dir/dir1/file1 failed"
6361 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
6364 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
6367 eval $cmd || error "$cmd failed"
6369 check_stripe_count $dir/file1 $expected
6371 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
6373 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
6374 # OST 1 if it is on OST 0. This file is small enough to
6375 # be on only one stripe.
6376 file=$dir/migr_1_ost
6377 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
6378 error "write data into $file failed"
6379 local obdidx=$($LFS getstripe -i $file)
6380 local oldmd5=$(md5sum $file)
6383 [[ $obdidx -eq 0 ]] && newobdidx=1
6384 cmd="$LFS migrate -i $newobdidx $file"
6386 eval $cmd || error "$cmd failed"
6388 local realobdix=$($LFS getstripe -i $file)
6389 local newmd5=$(md5sum $file)
6391 [[ $newobdidx -ne $realobdix ]] &&
6392 error "new OST is different (was=$obdidx, "\
6393 "wanted=$newobdidx, got=$realobdix)"
6394 [[ "$oldmd5" != "$newmd5" ]] &&
6395 error "md5sum differ: $oldmd5, $newmd5"
6399 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
6401 eval $cmd || error "$cmd failed"
6403 for j in $(seq $NUMFILES); do
6404 check_stripe_count $dir/dir1/file$j $expected
6407 # lfs_migrate works with lfs find
6408 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
6409 $LFS_MIGRATE -y -c $expected"
6411 eval $cmd || error "$cmd failed"
6413 for i in $(seq 2 $NUMFILES); do
6414 check_stripe_count $dir/file$i $expected
6416 for i in $(seq 2 $NUMDIRS); do
6417 for j in $(seq $NUMFILES); do
6418 check_stripe_count $dir/dir$i/file$j $expected
6422 run_test 56w "check lfs_migrate -c stripe_count works"
6425 local file1=$DIR/$tdir/file1
6426 local create_pool=false
6427 local initial_pool=$($LFS getstripe -p $DIR)
6431 echo -n "Creating test dir..."
6432 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6435 echo -n "Creating test file..."
6436 touch $file1 || error "cannot create file"
6439 echo -n "Detecting existing pools..."
6440 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
6442 if [ ${#pool_list[@]} -gt 0 ]; then
6443 echo "${pool_list[@]}"
6444 for thispool in "${pool_list[@]}"; do
6445 if [[ -z "$initial_pool" ||
6446 "$initial_pool" != "$thispool" ]]; then
6448 echo "Using existing pool '$pool'"
6453 echo "none detected."
6455 if [ -z "$pool" ]; then
6456 pool=${POOL:-testpool}
6457 [ "$initial_pool" = "$pool" ] && pool="testpool2"
6458 echo -n "Creating pool '$pool'..."
6460 pool_add $pool &> /dev/null ||
6461 error "pool_add failed"
6464 echo -n "Adding target to pool..."
6465 pool_add_targets $pool 0 0 1 &> /dev/null ||
6466 error "pool_add_targets failed"
6470 echo -n "Setting pool using -p option..."
6471 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
6472 error "migrate failed rc = $?"
6475 echo -n "Verifying test file is in pool after migrating..."
6476 [ "$($LFS getstripe -p $file1)" = $pool ] ||
6477 error "file was not migrated to pool $pool"
6480 echo -n "Removing test file from pool '$pool'..."
6481 # "lfs migrate $file" won't remove the file from the pool
6482 # until some striping information is changed.
6483 $LFS migrate -c 1 $file1 &> /dev/null ||
6484 error "cannot remove from pool"
6485 [ "$($LFS getstripe -p $file1)" ] &&
6486 error "pool still set"
6489 echo -n "Setting pool using --pool option..."
6490 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
6491 error "migrate failed rc = $?"
6496 if $create_pool; then
6497 destroy_test_pools 2> /dev/null ||
6498 error "destroy test pools failed"
6501 run_test 56wb "check lfs_migrate pool support"
6504 local file1="$DIR/$tdir/file1"
6511 echo -n "Creating test dir..."
6512 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6513 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
6514 error "cannot set stripe by '-S 1M -c 1'"
6517 echo -n "Setting initial stripe for test file..."
6518 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
6519 error "cannot set stripe"
6520 cur_ssize=$($LFS getstripe -S "$file1")
6521 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
6524 # File currently set to -S 512K -c 1
6526 # Ensure -c and -S options are rejected when -R is set
6527 echo -n "Verifying incompatible options are detected..."
6528 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
6529 error "incompatible -c and -R options not detected"
6530 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
6531 error "incompatible -S and -R options not detected"
6534 # Ensure unrecognized options are passed through to 'lfs migrate'
6535 echo -n "Verifying -S option is passed through to lfs migrate..."
6536 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
6537 error "migration failed"
6538 cur_ssize=$($LFS getstripe -S "$file1")
6539 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
6542 # File currently set to -S 1M -c 1
6544 # Ensure long options are supported
6545 echo -n "Verifying long options supported..."
6546 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
6547 error "long option without argument not supported"
6548 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
6549 error "long option with argument not supported"
6550 cur_ssize=$($LFS getstripe -S "$file1")
6551 [ $cur_ssize -eq 524288 ] ||
6552 error "migrate --stripe-size $cur_ssize != 524288"
6555 # File currently set to -S 512K -c 1
6557 if [ "$OSTCOUNT" -gt 1 ]; then
6558 echo -n "Verifying explicit stripe count can be set..."
6559 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
6560 error "migrate failed"
6561 cur_scount=$($LFS getstripe -c "$file1")
6562 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
6566 # File currently set to -S 512K -c 1 or -S 512K -c 2
6568 # Ensure parent striping is used if -R is set, and no stripe
6569 # count or size is specified
6570 echo -n "Setting stripe for parent directory..."
6571 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6572 error "cannot set stripe '-S 2M -c 1'"
6575 echo -n "Verifying restripe option uses parent stripe settings..."
6576 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
6577 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
6578 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
6579 error "migrate failed"
6580 cur_ssize=$($LFS getstripe -S "$file1")
6581 [ $cur_ssize -eq $parent_ssize ] ||
6582 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
6583 cur_scount=$($LFS getstripe -c "$file1")
6584 [ $cur_scount -eq $parent_scount ] ||
6585 error "migrate -R stripe_count $cur_scount != $parent_scount"
6588 # File currently set to -S 1M -c 1
6590 # Ensure striping is preserved if -R is not set, and no stripe
6591 # count or size is specified
6592 echo -n "Verifying striping size preserved when not specified..."
6593 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
6594 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6595 error "cannot set stripe on parent directory"
6596 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6597 error "migrate failed"
6598 cur_ssize=$($LFS getstripe -S "$file1")
6599 [ $cur_ssize -eq $orig_ssize ] ||
6600 error "migrate by default $cur_ssize != $orig_ssize"
6603 # Ensure file name properly detected when final option has no argument
6604 echo -n "Verifying file name properly detected..."
6605 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6606 error "file name interpreted as option argument"
6612 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
6615 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6617 local file1=$DIR/$tdir/file1
6619 echo -n "Creating test dir..."
6620 test_mkdir $DIR/$tdir || error "cannot create dir"
6623 echo -n "Creating test file..."
6627 # Ensure 'lfs migrate' will fail by using a non-existent option,
6628 # and make sure rsync is not called to recover
6629 echo -n "Make sure --no-rsync option works..."
6630 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
6631 grep -q 'refusing to fall back to rsync' ||
6632 error "rsync was called with --no-rsync set"
6635 # Ensure rsync is called without trying 'lfs migrate' first
6636 echo -n "Make sure --rsync option works..."
6637 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
6638 grep -q 'falling back to rsync' &&
6639 error "lfs migrate was called with --rsync set"
6642 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
6643 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
6644 grep -q 'at the same time' ||
6645 error "--rsync and --no-rsync accepted concurrently"
6651 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
6654 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6655 check_swap_layouts_support
6657 local dir=$DIR/$tdir
6658 local ref1=/etc/passwd
6659 local file1=$dir/file1
6661 test_mkdir $dir || error "creating dir $dir"
6662 $LFS setstripe -c 2 $file1
6664 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
6665 stripe=$($LFS getstripe -c $file1)
6666 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6667 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6672 run_test 56x "lfs migration support"
6675 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6676 check_swap_layouts_support
6678 local dir=$DIR/$tdir/$testnum
6682 local ref1=/etc/passwd
6683 local file1=$dir/file1
6685 $LFS setstripe -c 2 $file1
6687 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6689 local stripe=$($LFS getstripe -c $file1)
6691 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6692 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6697 run_test 56xa "lfs migration --block support"
6699 check_migrate_links() {
6701 local file1="$dir/file1"
6705 local total_count=$(($begin + $count - 1))
6706 local symlink_count=10
6709 if [ ! -f "$file1" ]; then
6710 echo -n "creating initial file..."
6711 $LFS setstripe -c 1 -S "512k" "$file1" ||
6712 error "cannot setstripe initial file"
6715 echo -n "creating symlinks..."
6716 for s in $(seq 1 $symlink_count); do
6717 ln -s "$file1" "$dir/slink$s" ||
6718 error "cannot create symlinks"
6722 echo -n "creating nonlinked files..."
6723 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6724 error "cannot create nonlinked files"
6729 if [ ! -f "$dir/file$total_count" ]; then
6730 echo -n "creating hard links $begin:$total_count..."
6731 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6732 /dev/null || error "cannot create hard links"
6736 echo -n "checking number of hard links listed in xattrs..."
6737 local fid=$($LFS getstripe -F "$file1")
6738 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6741 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6742 skip "hard link list has unexpected size, skipping test"
6744 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6745 error "link names should exceed xattrs size"
6748 echo -n "migrating files..."
6749 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
6751 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6754 # make sure all links have been properly migrated
6755 echo -n "verifying files..."
6756 fid=$($LFS getstripe -F "$file1") ||
6757 error "cannot get fid for file $file1"
6758 for i in $(seq 2 $total_count); do
6759 local fid2=$($LFS getstripe -F $dir/file$i)
6761 [ "$fid2" == "$fid" ] ||
6762 error "migrated hard link has mismatched FID"
6765 # make sure hard links were properly detected, and migration was
6766 # performed only once for the entire link set; nonlinked files should
6768 local actual=$(grep -c 'done' <<< "$migrate_out")
6769 local expected=$(($uniq_count + 1))
6771 [ "$actual" -eq "$expected" ] ||
6772 error "hard links individually migrated ($actual != $expected)"
6774 # make sure the correct number of hard links are present
6775 local hardlinks=$(stat -c '%h' "$file1")
6777 [ $hardlinks -eq $total_count ] ||
6778 error "num hard links $hardlinks != $total_count"
6785 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6786 skip "Need MDS version at least 2.10.55"
6788 local dir="$DIR/$tdir"
6790 test_mkdir "$dir" || error "cannot create dir $dir"
6792 echo "testing lfs migrate mode when all links fit within xattrs"
6793 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6795 echo "testing rsync mode when all links fit within xattrs"
6796 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6798 echo "testing lfs migrate mode when all links do not fit within xattrs"
6799 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6801 echo "testing rsync mode when all links do not fit within xattrs"
6802 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6804 chown -R $RUNAS_ID $dir
6805 echo "testing non-root lfs migrate mode when not all links are in xattr"
6806 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
6811 run_test 56xb "lfs migration hard link support"
6814 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6816 local dir="$DIR/$tdir"
6818 test_mkdir "$dir" || error "cannot create dir $dir"
6820 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6821 echo -n "Setting initial stripe for 20MB test file..."
6822 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
6823 error "cannot setstripe 20MB file"
6825 echo -n "Sizing 20MB test file..."
6826 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6828 echo -n "Verifying small file autostripe count is 1..."
6829 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
6830 error "cannot migrate 20MB file"
6831 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
6832 error "cannot get stripe for $dir/20mb"
6833 [ $stripe_count -eq 1 ] ||
6834 error "unexpected stripe count $stripe_count for 20MB file"
6838 # Test 2: File is small enough to fit within the available space on
6839 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
6840 # have at least an additional 1KB for each desired stripe for test 3
6841 echo -n "Setting stripe for 1GB test file..."
6842 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
6844 echo -n "Sizing 1GB test file..."
6845 # File size is 1GB + 3KB
6846 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
6849 # need at least 512MB per OST for 1GB file to fit in 2 stripes
6850 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
6851 if (( avail > 524288 * OSTCOUNT )); then
6852 echo -n "Migrating 1GB file..."
6853 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
6854 error "cannot migrate 1GB file"
6856 echo -n "Verifying autostripe count is sqrt(n) + 1..."
6857 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
6858 error "cannot getstripe for 1GB file"
6859 [ $stripe_count -eq 2 ] ||
6860 error "unexpected stripe count $stripe_count != 2"
6864 # Test 3: File is too large to fit within the available space on
6865 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
6866 if [ $OSTCOUNT -ge 3 ]; then
6867 # The required available space is calculated as
6868 # file size (1GB + 3KB) / OST count (3).
6869 local kb_per_ost=349526
6871 echo -n "Migrating 1GB file with limit..."
6872 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
6873 error "cannot migrate 1GB file with limit"
6876 stripe_count=$($LFS getstripe -c "$dir/1gb")
6877 echo -n "Verifying 1GB autostripe count with limited space..."
6878 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
6879 error "unexpected stripe count $stripe_count (min 3)"
6886 run_test 56xc "lfs migration autostripe"
6889 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6891 local dir=$DIR/$tdir
6892 local f_mgrt=$dir/$tfile.mgrt
6893 local f_yaml=$dir/$tfile.yaml
6894 local f_copy=$dir/$tfile.copy
6895 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6896 local layout_copy="-c 2 -S 2M -i 1"
6897 local yamlfile=$dir/yamlfile
6898 local layout_before;
6901 test_mkdir "$dir" || error "cannot create dir $dir"
6902 $LFS setstripe $layout_yaml $f_yaml ||
6903 error "cannot setstripe $f_yaml with layout $layout_yaml"
6904 $LFS getstripe --yaml $f_yaml > $yamlfile
6905 $LFS setstripe $layout_copy $f_copy ||
6906 error "cannot setstripe $f_copy with layout $layout_copy"
6908 dd if=/dev/zero of=$f_mgrt bs=1M count=4
6910 # 1. test option --yaml
6911 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
6912 error "cannot migrate $f_mgrt with --yaml $yamlfile"
6913 layout_before=$(get_layout_param $f_yaml)
6914 layout_after=$(get_layout_param $f_mgrt)
6915 [ "$layout_after" == "$layout_before" ] ||
6916 error "lfs_migrate --yaml: $layout_after != $layout_before"
6918 # 2. test option --copy
6919 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
6920 error "cannot migrate $f_mgrt with --copy $f_copy"
6921 layout_before=$(get_layout_param $f_copy)
6922 layout_after=$(get_layout_param $f_mgrt)
6923 [ "$layout_after" == "$layout_before" ] ||
6924 error "lfs_migrate --copy: $layout_after != $layout_before"
6926 run_test 56xd "check lfs_migrate --yaml and --copy support"
6929 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6931 local dir=$DIR/$tdir
6932 local f_comp=$dir/$tfile
6933 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6934 local layout_before=""
6935 local layout_after=""
6937 test_mkdir "$dir" || error "cannot create dir $dir"
6938 $LFS setstripe $layout $f_comp ||
6939 error "cannot setstripe $f_comp with layout $layout"
6940 layout_before=$(get_layout_param $f_comp)
6941 dd if=/dev/zero of=$f_comp bs=1M count=4
6943 # 1. migrate a comp layout file by lfs_migrate
6944 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
6945 layout_after=$(get_layout_param $f_comp)
6946 [ "$layout_before" == "$layout_after" ] ||
6947 error "lfs_migrate: $layout_before != $layout_after"
6949 # 2. migrate a comp layout file by lfs migrate
6950 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
6951 layout_after=$(get_layout_param $f_comp)
6952 [ "$layout_before" == "$layout_after" ] ||
6953 error "lfs migrate: $layout_before != $layout_after"
6955 run_test 56xe "migrate a composite layout file"
6958 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
6959 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
6962 local dir=$DIR/$tdir
6966 test_mkdir -p $dir || error "creating dir $dir"
6967 touch $f1 || error "creating std file $f1"
6968 $MULTIOP $f2 H2c || error "creating released file $f2"
6970 # a directory can be raid0, so ask only for files
6971 res=$($LFS find $dir -L raid0 -type f | wc -l)
6972 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
6974 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
6975 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
6977 # only files can be released, so no need to force file search
6978 res=$($LFS find $dir -L released)
6979 [[ $res == $f2 ]] || error "search released: found $res != $f2"
6981 res=$($LFS find $dir -type f \! -L released)
6982 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
6984 run_test 56y "lfs find -L raid0|released"
6986 test_56z() { # LU-4824
6987 # This checks to make sure 'lfs find' continues after errors
6988 # There are two classes of errors that should be caught:
6989 # - If multiple paths are provided, all should be searched even if one
6991 # - If errors are encountered during the search, it should not terminate
6993 local dir=$DIR/$tdir
6997 for i in d{0..9}; do
6999 touch $dir/$i/$tfile
7001 $LFS find $DIR/non_existent_dir $dir &&
7002 error "$LFS find did not return an error"
7003 # Make a directory unsearchable. This should NOT be the last entry in
7004 # directory order. Arbitrarily pick the 6th entry
7005 chmod 700 $($LFS find $dir -type d | sed '6!d')
7007 $RUNAS $LFS find $DIR/non_existent $dir
7008 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
7010 # The user should be able to see 10 directories and 9 files
7011 (( count == 19 )) ||
7012 error "$LFS find found $count != 19 entries after error"
7014 run_test 56z "lfs find should continue after an error"
7016 test_56aa() { # LU-5937
7017 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
7019 local dir=$DIR/$tdir
7022 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
7024 createmany -o $dir/striped_dir/${tfile}- 1024
7025 local dirs=$($LFS find --size +8k $dir/)
7027 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
7029 run_test 56aa "lfs find --size under striped dir"
7031 test_56ab() { # LU-10705
7032 test_mkdir $DIR/$tdir
7033 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
7034 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
7035 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
7036 # Flush writes to ensure valid blocks. Need to be more thorough for
7037 # ZFS, since blocks are not allocated/returned to client immediately.
7039 wait_zfs_commit ost1 2
7040 cancel_lru_locks osc
7043 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
7045 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
7047 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
7048 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
7050 rm -f $DIR/$tdir/$tfile.[123]
7052 run_test 56ab "lfs find --blocks"
7055 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
7056 skip "Need MDS version at least 2.10.50"
7058 # Create composite files with one component
7059 local dir=$DIR/$tdir
7061 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
7062 # Create composite files with three components
7063 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
7064 # Create non-composite files
7065 createmany -o $dir/${tfile}- 10
7067 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
7069 [[ $nfiles == 10 ]] ||
7070 error "lfs find -E 1M found $nfiles != 10 files"
7072 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
7073 [[ $nfiles == 25 ]] ||
7074 error "lfs find ! -E 1M found $nfiles != 25 files"
7076 # All files have a component that starts at 0
7077 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
7078 [[ $nfiles == 35 ]] ||
7079 error "lfs find --component-start 0 - $nfiles != 35 files"
7081 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
7082 [[ $nfiles == 15 ]] ||
7083 error "lfs find --component-start 2M - $nfiles != 15 files"
7085 # All files created here have a componenet that does not starts at 2M
7086 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
7087 [[ $nfiles == 35 ]] ||
7088 error "lfs find ! --component-start 2M - $nfiles != 35 files"
7090 # Find files with a specified number of components
7091 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
7092 [[ $nfiles == 15 ]] ||
7093 error "lfs find --component-count 3 - $nfiles != 15 files"
7095 # Remember non-composite files have a component count of zero
7096 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
7097 [[ $nfiles == 10 ]] ||
7098 error "lfs find --component-count 0 - $nfiles != 10 files"
7100 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
7101 [[ $nfiles == 20 ]] ||
7102 error "lfs find ! --component-count 3 - $nfiles != 20 files"
7104 # All files have a flag called "init"
7105 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
7106 [[ $nfiles == 35 ]] ||
7107 error "lfs find --component-flags init - $nfiles != 35 files"
7109 # Multi-component files will have a component not initialized
7110 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
7111 [[ $nfiles == 15 ]] ||
7112 error "lfs find !--component-flags init - $nfiles != 15 files"
7117 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
7120 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
7121 skip "Need MDS version at least 2.10.57"
7131 # create mirrored directories and mirrored files
7132 mkdir $td || error "mkdir $td failed"
7133 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
7134 createmany -o $tf- 10 || error "create $tf- failed"
7136 for i in $(seq 2); do
7138 mkdir $dir || error "mkdir $dir failed"
7139 $LFS mirror create -N$((3 + i)) $dir ||
7140 error "create mirrored dir $dir failed"
7141 createmany -o $dir/$tfile- 10 ||
7142 error "create $dir/$tfile- failed"
7145 # change the states of some mirrored files
7147 for i in $(seq 2); do
7149 for j in $(seq 4 9); do
7150 echo foo > $dir/$tfile-$j
7154 # find mirrored files with specific mirror count
7155 cmd="$LFS find --mirror-count 3 --type f $td"
7156 nfiles=$($cmd | wc -l)
7157 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
7159 cmd="$LFS find ! --mirror-count 3 --type f $td"
7160 nfiles=$($cmd | wc -l)
7161 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
7163 cmd="$LFS find --mirror-count +2 --type f $td"
7164 nfiles=$($cmd | wc -l)
7165 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7167 cmd="$LFS find --mirror-count -6 --type f $td"
7168 nfiles=$($cmd | wc -l)
7169 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7171 # find mirrored files with specific file state
7172 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
7173 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
7175 cmd="$LFS find --mirror-state=ro --type f $td"
7176 nfiles=$($cmd | wc -l)
7177 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
7179 cmd="$LFS find ! --mirror-state=ro --type f $td"
7180 nfiles=$($cmd | wc -l)
7181 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7183 cmd="$LFS find --mirror-state=wp --type f $td"
7184 nfiles=$($cmd | wc -l)
7185 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7187 cmd="$LFS find ! --mirror-state=sp --type f $td"
7188 nfiles=$($cmd | wc -l)
7189 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7191 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
7194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7195 # note test will not do anything if MDS is not local
7196 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7197 skip_env "ldiskfs only test"
7199 remote_mds_nodsh && skip "remote MDS with nodsh"
7201 local MNTDEV="osd*.*MDT*.mntdev"
7202 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
7203 [ -z "$DEV" ] && error "can't access $MNTDEV"
7204 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
7205 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
7206 error "can't access $DEV"
7207 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
7208 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
7212 run_test 57a "verify MDS filesystem created with large inodes =="
7215 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7216 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7217 skip_env "ldiskfs only test"
7219 remote_mds_nodsh && skip "remote MDS with nodsh"
7221 local dir=$DIR/$tdir
7224 local fileN=$dir/f$filecount
7226 rm -rf $dir || error "removing $dir"
7228 local mdtidx=$($LFS getstripe -m $dir)
7229 local mdtname=MDT$(printf %04x $mdtidx)
7230 local facet=mds$((mdtidx + 1))
7232 echo "mcreating $filecount files"
7233 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
7235 # verify that files do not have EAs yet
7236 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
7237 error "$file1 has an EA"
7238 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
7239 error "$fileN has an EA"
7243 df $dir #make sure we get new statfs data
7244 local mdsfree=$(do_facet $facet \
7245 lctl get_param -n osd*.*$mdtname.kbytesfree)
7246 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7249 echo "opening files to create objects/EAs"
7250 for file in $(seq -f $dir/f%g 1 $filecount); do
7251 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
7252 error "opening $file"
7255 # verify that files have EAs now
7256 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
7257 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
7259 sleep 1 #make sure we get new statfs data
7261 local mdsfree2=$(do_facet $facet \
7262 lctl get_param -n osd*.*$mdtname.kbytesfree)
7263 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7265 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
7266 if [ "$mdsfree" != "$mdsfree2" ]; then
7267 error "MDC before $mdcfree != after $mdcfree2"
7269 echo "MDC before $mdcfree != after $mdcfree2"
7270 echo "unable to confirm if MDS has large inodes"
7275 run_test 57b "default LOV EAs are stored inside large inodes ==="
7278 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7279 [ -z "$(which wiretest 2>/dev/null)" ] &&
7280 skip_env "could not find wiretest"
7284 run_test 58 "verify cross-platform wire constants =============="
7287 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7289 echo "touch 130 files"
7290 createmany -o $DIR/f59- 130
7292 unlinkmany $DIR/f59- 130
7294 # wait for commitment of removal
7295 wait_delete_completed
7297 run_test 59 "verify cancellation of llog records async ========="
7299 TEST60_HEAD="test_60 run $RANDOM"
7301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7302 remote_mgs_nodsh && skip "remote MGS with nodsh"
7303 do_facet mgs "! which run-llog.sh &> /dev/null" &&
7304 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
7305 skip_env "missing subtest run-llog.sh"
7307 log "$TEST60_HEAD - from kernel mode"
7308 do_facet mgs "$LCTL dk > /dev/null"
7309 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
7310 do_facet mgs $LCTL dk > $TMP/$tfile
7312 # LU-6388: test llog_reader
7313 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
7314 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
7315 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
7316 skip_env "missing llog_reader"
7317 local fstype=$(facet_fstype mgs)
7318 [ $fstype != ldiskfs -a $fstype != zfs ] &&
7319 skip_env "Only for ldiskfs or zfs type mgs"
7321 local mntpt=$(facet_mntpt mgs)
7322 local mgsdev=$(mgsdevname 1)
7334 #get fid and record list
7335 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
7337 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
7339 #remount mgs as ldiskfs or zfs type
7340 stop mgs || error "stop mgs failed"
7341 mount_fstype mgs || error "remount mgs failed"
7342 for ((i = 0; i < ${#fid_list[@]}; i++)); do
7345 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
7346 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
7351 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
7353 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
7355 echo "obj_file is $obj_file"
7356 do_facet mgs $llog_reader $obj_file
7358 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
7359 awk '{ print $3 }' | sed -e "s/^type=//g")
7360 if [ $rec_type != $rec ]; then
7361 echo "FAILED test_60a wrong record type $rec_type," \
7367 #check obj path if record type is LLOG_LOGID_MAGIC
7368 if [ "$rec" == "1064553b" ]; then
7369 path=$(do_facet mgs $llog_reader $obj_file |
7370 grep "path=" | awk '{ print $NF }' |
7371 sed -e "s/^path=//g")
7372 if [ $obj_file != $mntpt/$path ]; then
7373 echo "FAILED test_60a wrong obj path" \
7374 "$montpt/$path, should be $obj_file"
7381 #restart mgs before "error", otherwise it will block the next test
7382 stop mgs || error "stop mgs failed"
7383 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
7384 $pass || error "test failed, see FAILED test_60a messages for specifics"
7386 run_test 60a "llog_test run from kernel module and test llog_reader"
7388 test_60b() { # bug 6411
7389 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7392 LLOG_COUNT=$(do_facet mgs dmesg |
7393 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
7394 /llog_[a-z]*.c:[0-9]/ {
7406 [[ $LLOG_COUNT -gt 120 ]] &&
7407 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
7409 run_test 60b "limit repeated messages from CERROR/CWARN"
7412 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7414 echo "create 5000 files"
7415 createmany -o $DIR/f60c- 5000
7416 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
7417 lctl set_param fail_loc=0x80000137
7418 unlinkmany $DIR/f60c- 5000
7419 lctl set_param fail_loc=0
7421 run_test 60c "unlink file when mds full"
7424 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7426 SAVEPRINTK=$(lctl get_param -n printk)
7427 # verify "lctl mark" is even working"
7428 MESSAGE="test message ID $RANDOM $$"
7429 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7430 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
7432 lctl set_param printk=0 || error "set lnet.printk failed"
7433 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
7434 MESSAGE="new test message ID $RANDOM $$"
7435 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
7436 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7437 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
7439 lctl set_param -n printk="$SAVEPRINTK"
7441 run_test 60d "test printk console message masking"
7444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7445 remote_mds_nodsh && skip "remote MDS with nodsh"
7448 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
7449 do_facet mds1 lctl set_param fail_loc=0x15b
7452 run_test 60e "no space while new llog is being created"
7458 test_mkdir -c $MDSCOUNT $DIR/$tdir
7463 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
7464 -c $MDSCOUNT $DIR/$tdir/subdir$index \
7466 mkdir $DIR/$tdir/subdir$index 2>/dev/null
7467 rmdir $DIR/$tdir/subdir$index 2>/dev/null
7468 index=$((index + 1))
7474 for i in {0..100}; do
7475 # define OBD_FAIL_OSD_TXN_START 0x19a
7476 local index=$((i % MDSCOUNT + 1))
7478 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
7485 for i in $(seq $MDSCOUNT); do
7486 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
7489 mkdir $DIR/$tdir/new || error "mkdir failed"
7490 rmdir $DIR/$tdir/new || error "rmdir failed"
7492 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
7494 for i in $(seq $MDSCOUNT); do
7495 wait_update_facet mds$i "$LCTL get_param -n \
7496 mdd.$(facet_svc mds$i).lfsck_namespace |
7497 awk '/^status/ { print \\\$2 }'" "completed"
7500 ls -R $DIR/$tdir || error "ls failed"
7501 rm -rf $DIR/$tdir || error "rmdir failed"
7503 run_test 60g "transaction abort won't cause MDT hung"
7506 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
7507 skip "Need MDS version at least 2.12.52"
7508 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
7512 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
7513 #define OBD_FAIL_MDS_STRIPE_FID 0x189
7514 for fail_loc in 0x80000188 0x80000189; do
7515 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
7516 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
7517 error "mkdir $dir-$fail_loc failed"
7518 for i in {0..10}; do
7519 # create may fail on missing stripe
7520 echo $i > $DIR/$tdir-$fail_loc/$i
7522 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7523 error "getdirstripe $tdir-$fail_loc failed"
7524 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
7525 error "migrate $tdir-$fail_loc failed"
7526 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7527 error "getdirstripe $tdir-$fail_loc failed"
7528 pushd $DIR/$tdir-$fail_loc
7530 echo $f | cmp $f - || error "$f data mismatch"
7533 rm -rf $DIR/$tdir-$fail_loc
7536 run_test 60h "striped directory with missing stripes can be accessed"
7539 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7542 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
7543 cancel_lru_locks osc
7544 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
7547 run_test 61a "mmap() writes don't make sync hang ================"
7550 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
7552 run_test 61b "mmap() of unstriped file is successful"
7554 # bug 2330 - insufficient obd_match error checking causes LBUG
7556 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7560 cancel_lru_locks osc
7561 lctl set_param fail_loc=0x405
7562 cat $f && error "cat succeeded, expect -EIO"
7563 lctl set_param fail_loc=0
7565 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
7566 # match every page all of the time.
7567 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
7569 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
7570 # Though this test is irrelevant anymore, it helped to reveal some
7571 # other grant bugs (LU-4482), let's keep it.
7572 test_63a() { # was test_63
7573 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7575 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
7577 for i in `seq 10` ; do
7578 dd if=/dev/zero of=$DIR/f63 bs=8k &
7584 rm -f $DIR/f63 || true
7586 run_test 63a "Verify oig_wait interruption does not crash ======="
7588 # bug 2248 - async write errors didn't return to application on sync
7589 # bug 3677 - async write errors left page locked
7591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7594 lctl set_param debug=-1
7596 # ensure we have a grant to do async writes
7597 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
7600 sync # sync lest earlier test intercept the fail_loc
7602 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7603 lctl set_param fail_loc=0x80000406
7604 $MULTIOP $DIR/$tfile Owy && \
7605 error "sync didn't return ENOMEM"
7606 sync; sleep 2; sync # do a real sync this time to flush page
7607 lctl get_param -n llite.*.dump_page_cache | grep locked && \
7608 error "locked page left in cache after async error" || true
7611 run_test 63b "async write errors should be returned to fsync ==="
7614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7617 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
7619 run_test 64a "verify filter grant calculations (in kernel) ====="
7622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7624 sh oos.sh $MOUNT || error "oos.sh failed: $?"
7626 run_test 64b "check out-of-space detection on client"
7629 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
7631 run_test 64c "verify grant shrink"
7633 # this does exactly what osc_request.c:osc_announce_cached() does in
7634 # order to calculate max amount of grants to ask from server
7638 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
7639 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
7641 ((rpc_in_flight ++));
7642 nrpages=$((nrpages * rpc_in_flight))
7644 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
7646 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
7648 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
7649 local undirty=$((nrpages * PAGE_SIZE))
7651 local max_extent_pages
7652 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
7653 grep grant_max_extent_size | awk '{print $2}')
7654 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
7655 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
7656 local grant_extent_tax
7657 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7658 grep grant_extent_tax | awk '{print $2}')
7660 undirty=$((undirty + nrextents * grant_extent_tax))
7665 # this is size of unit for grant allocation. It should be equal to
7666 # what tgt_grant.c:tgt_grant_chunk() calculates
7670 local grant_extent_tax
7672 max_brw_size=$($LCTL get_param osc.${tgt}.import |
7673 grep max_brw_size | awk '{print $2}')
7675 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7676 grep grant_extent_tax | awk '{print $2}')
7678 echo $(((max_brw_size + grant_extent_tax) * 2))
7682 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
7683 skip "OST < 2.10.55 doesn't limit grants enough"
7685 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
7686 local file=$DIR/$tfile
7688 [[ $($LCTL get_param osc.${tgt}.import |
7689 grep "connect_flags:.*grant_param") ]] ||
7690 skip "no grant_param connect flag"
7692 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
7694 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
7696 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
7697 stack_trap "rm -f $file" EXIT
7699 $LFS setstripe $file -i 0 -c 1
7700 dd if=/dev/zero of=$file bs=1M count=1000 &
7705 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
7706 if [[ $cur_grant -gt $max_cur_granted ]]
7709 error "cur_grant $cur_grant > $max_cur_granted"
7712 [[ $? -ne 0 ]] && break;
7717 wait_delete_completed
7718 $LCTL set_param debug="$olddebug" 2> /dev/null || true
7720 run_test 64d "check grant limit exceed"
7722 # bug 1414 - set/get directories' stripe info
7724 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7726 test_mkdir $DIR/$tdir
7728 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7730 run_test 65a "directory with no stripe info"
7733 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7735 test_mkdir $DIR/$tdir
7736 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7738 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7741 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
7743 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
7746 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7747 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
7749 test_mkdir $DIR/$tdir
7750 local stripesize=$($LFS getstripe -S $DIR/$tdir)
7752 $LFS setstripe -S $((stripesize * 4)) -i 1 \
7753 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
7755 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
7757 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
7760 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7762 test_mkdir $DIR/$tdir
7763 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
7764 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7766 if [[ $STRIPECOUNT -le 0 ]]; then
7768 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
7769 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
7770 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
7772 sc=$(($STRIPECOUNT - 1))
7774 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
7775 touch $DIR/$tdir/f4 $DIR/$tdir/f5
7776 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
7777 error "lverify failed"
7779 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
7782 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7784 test_mkdir $DIR/$tdir
7786 $LFS setstripe $DIR/$tdir || error "setstripe"
7787 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7788 error "no stripe info failed"
7790 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
7792 run_test 65e "directory setstripe defaults"
7795 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7797 test_mkdir $DIR/${tdir}f
7798 $RUNAS $LFS setstripe $DIR/${tdir}f &&
7799 error "setstripe succeeded" || true
7801 run_test 65f "dir setstripe permission (should return error) ==="
7804 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7806 test_mkdir $DIR/$tdir
7807 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7809 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7810 error "setstripe -S failed"
7811 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
7812 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7813 error "delete default stripe failed"
7815 run_test 65g "directory setstripe -d"
7818 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7820 test_mkdir $DIR/$tdir
7821 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7823 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7824 error "setstripe -S failed"
7825 test_mkdir $DIR/$tdir/dd1
7826 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
7827 error "stripe info inherit failed"
7829 run_test 65h "directory stripe info inherit ===================="
7832 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7834 save_layout_restore_at_exit $MOUNT
7836 # bug6367: set non-default striping on root directory
7837 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
7839 # bug12836: getstripe on -1 default directory striping
7840 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
7842 # bug12836: getstripe -v on -1 default directory striping
7843 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
7845 # bug12836: new find on -1 default directory striping
7846 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
7848 run_test 65i "various tests to set root directory striping"
7850 test_65j() { # bug6367
7851 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7855 # if we aren't already remounting for each test, do so for this test
7856 if [ "$I_MOUNTED" = "yes" ]; then
7857 cleanup || error "failed to unmount"
7861 save_layout_restore_at_exit $MOUNT
7863 $LFS setstripe -d $MOUNT || error "setstripe failed"
7865 run_test 65j "set default striping on root directory (bug 6367)="
7869 wait_delete_completed
7870 do_facet $SINGLEMDS "lctl set_param -n \
7871 osp.$ost*MDT0000.max_create_count=$max_count"
7872 do_facet $SINGLEMDS "lctl set_param -n \
7873 osp.$ost*MDT0000.create_count=$count"
7874 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7875 echo $INACTIVE_OSC "is Activate"
7877 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7880 test_65k() { # bug11679
7881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7882 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7883 remote_mds_nodsh && skip "remote MDS with nodsh"
7885 local disable_precreate=true
7886 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
7887 disable_precreate=false
7889 echo "Check OST status: "
7890 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
7891 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
7893 for OSC in $MDS_OSCS; do
7894 echo $OSC "is active"
7895 do_facet $SINGLEMDS lctl --device %$OSC activate
7898 for INACTIVE_OSC in $MDS_OSCS; do
7899 local ost=$(osc_to_ost $INACTIVE_OSC)
7900 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
7901 lov.*md*.target_obd |
7902 awk -F: /$ost/'{ print $1 }' | head -n 1)
7905 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
7906 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
7908 echo "Deactivate: " $INACTIVE_OSC
7909 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
7911 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
7912 osp.$ost*MDT0000.create_count")
7913 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
7914 osp.$ost*MDT0000.max_create_count")
7915 $disable_precreate &&
7916 do_facet $SINGLEMDS "lctl set_param -n \
7917 osp.$ost*MDT0000.max_create_count=0"
7919 for idx in $(seq 0 $((OSTCOUNT - 1))); do
7920 [ -f $DIR/$tdir/$idx ] && continue
7921 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
7922 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
7924 error "setstripe $idx should succeed"; }
7925 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
7927 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
7930 do_facet $SINGLEMDS "lctl set_param -n \
7931 osp.$ost*MDT0000.max_create_count=$max_count"
7932 do_facet $SINGLEMDS "lctl set_param -n \
7933 osp.$ost*MDT0000.create_count=$count"
7934 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7935 echo $INACTIVE_OSC "is Activate"
7937 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7940 run_test 65k "validate manual striping works properly with deactivated OSCs"
7942 test_65l() { # bug 12836
7943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7945 test_mkdir -p $DIR/$tdir/test_dir
7946 $LFS setstripe -c -1 $DIR/$tdir/test_dir
7947 $LFS find -mtime -1 $DIR/$tdir >/dev/null
7949 run_test 65l "lfs find on -1 stripe dir ========================"
7952 local layout=$(save_layout $MOUNT)
7953 $RUNAS $LFS setstripe -c 2 $MOUNT && {
7954 restore_layout $MOUNT $layout
7955 error "setstripe should fail by non-root users"
7959 run_test 65m "normal user can't set filesystem default stripe"
7962 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
7963 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
7964 skip "Need MDS version at least 2.12.50"
7965 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7967 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7968 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
7969 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
7971 local root_layout=$(save_layout $MOUNT)
7972 stack_trap "restore_layout $MOUNT $root_layout" EXIT
7974 # new subdirectory under root directory should not inherit
7975 # the default layout from root
7976 local dir1=$MOUNT/$tdir-1
7977 mkdir $dir1 || error "mkdir $dir1 failed"
7978 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
7979 error "$dir1 shouldn't have LOV EA"
7981 # delete the default layout on root directory
7982 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
7984 local dir2=$MOUNT/$tdir-2
7985 mkdir $dir2 || error "mkdir $dir2 failed"
7986 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
7987 error "$dir2 shouldn't have LOV EA"
7989 # set a new striping pattern on root directory
7990 local def_stripe_size=$($LFS getstripe -S $MOUNT)
7991 local new_def_stripe_size=$((def_stripe_size * 2))
7992 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
7993 error "set stripe size on $MOUNT failed"
7995 # new file created in $dir2 should inherit the new stripe size from
7996 # the filesystem default
7997 local file2=$dir2/$tfile-2
7998 touch $file2 || error "touch $file2 failed"
8000 local file2_stripe_size=$($LFS getstripe -S $file2)
8001 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
8002 error "$file2 didn't inherit stripe size $new_def_stripe_size"
8004 local dir3=$MOUNT/$tdir-3
8005 mkdir $dir3 || error "mkdir $dir3 failed"
8006 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
8007 # the root layout, which is the actual default layout that will be used
8008 # when new files are created in $dir3.
8009 local dir3_layout=$(get_layout_param $dir3)
8010 local root_dir_layout=$(get_layout_param $MOUNT)
8011 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
8012 error "$dir3 should show the default layout from $MOUNT"
8014 # set OST pool on root directory
8015 local pool=$TESTNAME
8016 pool_add $pool || error "add $pool failed"
8017 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8018 error "add targets to $pool failed"
8020 $LFS setstripe -p $pool $MOUNT ||
8021 error "set OST pool on $MOUNT failed"
8023 # new file created in $dir3 should inherit the pool from
8024 # the filesystem default
8025 local file3=$dir3/$tfile-3
8026 touch $file3 || error "touch $file3 failed"
8028 local file3_pool=$($LFS getstripe -p $file3)
8029 [[ "$file3_pool" = "$pool" ]] ||
8030 error "$file3 didn't inherit OST pool $pool"
8032 local dir4=$MOUNT/$tdir-4
8033 mkdir $dir4 || error "mkdir $dir4 failed"
8034 local dir4_layout=$(get_layout_param $dir4)
8035 root_dir_layout=$(get_layout_param $MOUNT)
8036 echo "$LFS getstripe -d $dir4"
8037 $LFS getstripe -d $dir4
8038 echo "$LFS getstripe -d $MOUNT"
8039 $LFS getstripe -d $MOUNT
8040 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
8041 error "$dir4 should show the default layout from $MOUNT"
8043 # new file created in $dir4 should inherit the pool from
8044 # the filesystem default
8045 local file4=$dir4/$tfile-4
8046 touch $file4 || error "touch $file4 failed"
8048 local file4_pool=$($LFS getstripe -p $file4)
8049 [[ "$file4_pool" = "$pool" ]] ||
8050 error "$file4 didn't inherit OST pool $pool"
8052 # new subdirectory under non-root directory should inherit
8053 # the default layout from its parent directory
8054 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
8055 error "set directory layout on $dir4 failed"
8057 local dir5=$dir4/$tdir-5
8058 mkdir $dir5 || error "mkdir $dir5 failed"
8060 dir4_layout=$(get_layout_param $dir4)
8061 local dir5_layout=$(get_layout_param $dir5)
8062 [[ "$dir4_layout" = "$dir5_layout" ]] ||
8063 error "$dir5 should inherit the default layout from $dir4"
8065 # though subdir under ROOT doesn't inherit default layout, but
8066 # its sub dir/file should be created with default layout.
8067 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
8068 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
8069 skip "Need MDS version at least 2.12.59"
8071 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
8072 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
8073 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
8075 if [ $default_lmv_hash == "none" ]; then
8076 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
8078 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
8079 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
8082 $LFS setdirstripe -D -c 2 $MOUNT ||
8083 error "setdirstripe -D -c 2 failed"
8084 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
8085 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
8086 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
8088 run_test 65n "don't inherit default layout from root for new subdirectories"
8090 # bug 2543 - update blocks count on client
8092 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8095 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
8096 sync; sync_all_data; sync; sync_all_data
8097 cancel_lru_locks osc
8098 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
8099 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
8101 run_test 66 "update inode blocks count on client ==============="
8104 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
8108 swapon -s | awk '($1 == "'$1'") { print $4 }'
8111 # bug5265, obdfilter oa2dentry return -ENOENT
8112 # #define OBD_FAIL_SRV_ENOENT 0x217
8114 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8115 remote_ost_nodsh && skip "remote OST with nodsh"
8118 $LFS setstripe -c 1 -i 0 $f
8120 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
8122 do_facet ost1 lctl set_param fail_loc=0x217
8123 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
8124 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
8126 do_facet ost1 lctl set_param fail_loc=0
8127 $DIRECTIO write $f 0 2 || error "write error"
8129 cancel_lru_locks osc
8130 $DIRECTIO read $f 0 1 || error "read error"
8132 do_facet ost1 lctl set_param fail_loc=0x217
8133 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
8135 do_facet ost1 lctl set_param fail_loc=0
8138 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
8141 test_mkdir $DIR/$tdir
8142 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
8143 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
8145 run_test 71 "Running dbench on lustre (don't segment fault) ===="
8147 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
8148 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8149 [ "$RUNAS_ID" = "$UID" ] &&
8150 skip_env "RUNAS_ID = UID = $UID -- skipping"
8151 # Check that testing environment is properly set up. Skip if not
8152 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
8153 skip_env "User $RUNAS_ID does not exist - skipping"
8156 chmod 777 $DIR/$tfile
8157 chmod ug+s $DIR/$tfile
8158 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
8159 error "$RUNAS dd $DIR/$tfile failed"
8160 # See if we are still setuid/sgid
8161 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
8162 error "S/gid is not dropped on write"
8163 # Now test that MDS is updated too
8164 cancel_lru_locks mdc
8165 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
8166 error "S/gid is not dropped on MDS"
8169 run_test 72a "Test that remove suid works properly (bug5695) ===="
8171 test_72b() { # bug 24226 -- keep mode setting when size is not changing
8174 [ "$RUNAS_ID" = "$UID" ] &&
8175 skip_env "RUNAS_ID = UID = $UID -- skipping"
8176 [ "$RUNAS_ID" -eq 0 ] &&
8177 skip_env "RUNAS_ID = 0 -- skipping"
8178 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8179 # Check that testing environment is properly set up. Skip if not
8180 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
8181 skip_env "User $RUNAS_ID does not exist - skipping"
8183 touch $DIR/${tfile}-f{g,u}
8184 test_mkdir $DIR/${tfile}-dg
8185 test_mkdir $DIR/${tfile}-du
8186 chmod 770 $DIR/${tfile}-{f,d}{g,u}
8187 chmod g+s $DIR/${tfile}-{f,d}g
8188 chmod u+s $DIR/${tfile}-{f,d}u
8189 for perm in 777 2777 4777; do
8190 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
8191 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
8192 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
8193 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
8197 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
8199 # bug 3462 - multiple simultaneous MDC requests
8201 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8203 test_mkdir $DIR/d73-1
8204 test_mkdir $DIR/d73-2
8205 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
8208 lctl set_param fail_loc=0x80000129
8209 $MULTIOP $DIR/d73-1/f73-2 Oc &
8211 lctl set_param fail_loc=0
8213 $MULTIOP $DIR/d73-2/f73-3 Oc &
8217 wait $pid1 || return 1
8221 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
8222 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
8223 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
8227 run_test 73 "multiple MDC requests (should not deadlock)"
8229 test_74a() { # bug 6149, 6184
8230 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8233 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8235 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8236 # will spin in a tight reconnection loop
8237 $LCTL set_param fail_loc=0x8000030e
8238 # get any lock that won't be difficult - lookup works.
8240 $LCTL set_param fail_loc=0
8244 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
8246 test_74b() { # bug 13310
8247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8249 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8251 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8252 # will spin in a tight reconnection loop
8253 $LCTL set_param fail_loc=0x8000030e
8254 # get a "difficult" lock
8256 $LCTL set_param fail_loc=0
8260 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
8263 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8265 #define OBD_FAIL_LDLM_NEW_LOCK
8266 $LCTL set_param fail_loc=0x319
8267 touch $DIR/$tfile && error "touch successful"
8268 $LCTL set_param fail_loc=0
8271 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
8274 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
8277 test_76() { # Now for bug 20433, added originally in bug 1443
8278 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8280 cancel_lru_locks osc
8281 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
8282 local before=$(num_inodes)
8283 local count=$((512 * cpus))
8284 [ "$SLOW" = "no" ] && count=$((64 * cpus))
8286 echo "before inodes: $before"
8287 for i in $(seq $count); do
8291 cancel_lru_locks osc
8292 local after=$(num_inodes)
8293 echo "after inodes: $after"
8294 while (( after > before + 8 * ${cpus:-1} )); do
8298 (( wait % 5 == 0 )) && echo "wait $wait seconds inodes: $after"
8299 if (( wait > 30 )); then
8300 error "inode slab grew from $before to $after"
8304 run_test 76 "confirm clients recycle inodes properly ===="
8310 # Note: in sptlrpc modes which enable its own bulk checksum, the
8311 # original crc32_le bulk checksum will be automatically disabled,
8312 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
8313 # will be checked by sptlrpc code against sptlrpc bulk checksum.
8314 # In this case set_checksums() will not be no-op, because sptlrpc
8315 # bulk checksum will be enabled all through the test.
8317 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
8318 lctl set_param -n osc.*.checksums $1
8322 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8323 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
8324 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8325 tr -d [] | head -n1)}
8328 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
8330 log "set checksum type to $1, rc = $rc"
8334 get_osc_checksum_type()
8336 # arugment 1: OST name, like OST0000
8338 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
8339 sed 's/.*\[\(.*\)\].*/\1/g')
8341 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
8345 F77_TMP=$TMP/f77-temp
8348 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
8349 error "error writing to $F77_TMP"
8352 test_77a() { # bug 10889
8353 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8354 $GSS && skip_env "could not run with gss"
8356 [ ! -f $F77_TMP ] && setup_f77
8358 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
8362 run_test 77a "normal checksum read/write operation"
8364 test_77b() { # bug 10889
8365 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8366 $GSS && skip_env "could not run with gss"
8368 [ ! -f $F77_TMP ] && setup_f77
8369 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8370 $LCTL set_param fail_loc=0x80000409
8373 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8374 error "dd error: $?"
8375 $LCTL set_param fail_loc=0
8377 for algo in $CKSUM_TYPES; do
8378 cancel_lru_locks osc
8379 set_checksum_type $algo
8380 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8381 $LCTL set_param fail_loc=0x80000408
8382 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
8383 $LCTL set_param fail_loc=0
8386 set_checksum_type $ORIG_CSUM_TYPE
8389 run_test 77b "checksum error on client write, read"
8394 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
8396 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
8397 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
8398 $check_ost && [ -n "$ost_file_prefix" ] &&
8399 do_facet ost1 rm -f ${ost_file_prefix}\*
8403 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8404 $GSS && skip_env "could not run with gss"
8405 remote_ost_nodsh && skip "remote OST with nodsh"
8408 local osc_file_prefix
8410 local check_ost=false
8411 local ost_file_prefix
8417 # ensure corruption will occur on first OSS/OST
8418 $LFS setstripe -i 0 $DIR/$tfile
8420 [ ! -f $F77_TMP ] && setup_f77
8421 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8422 error "dd write error: $?"
8423 fid=$($LFS path2fid $DIR/$tfile)
8425 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
8428 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
8429 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
8431 echo "OSS do not support bulk pages dump upon error"
8434 osc_file_prefix=$($LCTL get_param -n debug_path)
8435 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
8437 trap cleanup_77c EXIT
8440 # enable bulk pages dump upon error on Client
8441 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
8442 # enable bulk pages dump upon error on OSS
8444 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
8446 # flush Client cache to allow next read to reach OSS
8447 cancel_lru_locks osc
8449 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8450 $LCTL set_param fail_loc=0x80000408
8451 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
8452 $LCTL set_param fail_loc=0
8456 # check cksum dump on Client
8457 osc_file=$(ls ${osc_file_prefix}*)
8458 [ -n "$osc_file" ] || error "no checksum dump file on Client"
8459 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
8460 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
8461 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
8462 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
8464 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
8465 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8466 error "dump content does not match on Client"
8468 $check_ost || skip "No need to check cksum dump on OSS"
8470 # check cksum dump on OSS
8471 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
8472 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
8473 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
8474 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
8475 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8476 error "dump content does not match on OSS"
8480 run_test 77c "checksum error on client read with debug"
8482 test_77d() { # bug 10889
8483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8484 $GSS && skip_env "could not run with gss"
8486 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8487 $LCTL set_param fail_loc=0x80000409
8489 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8490 error "direct write: rc=$?"
8491 $LCTL set_param fail_loc=0
8494 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8495 $LCTL set_param fail_loc=0x80000408
8497 cancel_lru_locks osc
8498 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8499 error "direct read: rc=$?"
8500 $LCTL set_param fail_loc=0
8503 run_test 77d "checksum error on OST direct write, read"
8505 test_77f() { # bug 10889
8506 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8507 $GSS && skip_env "could not run with gss"
8510 for algo in $CKSUM_TYPES; do
8511 cancel_lru_locks osc
8512 set_checksum_type $algo
8513 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8514 $LCTL set_param fail_loc=0x409
8515 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
8516 error "direct write succeeded"
8517 $LCTL set_param fail_loc=0
8519 set_checksum_type $ORIG_CSUM_TYPE
8522 run_test 77f "repeat checksum error on write (expect error)"
8524 test_77g() { # bug 10889
8525 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8526 $GSS && skip_env "could not run with gss"
8527 remote_ost_nodsh && skip "remote OST with nodsh"
8529 [ ! -f $F77_TMP ] && setup_f77
8531 local file=$DIR/$tfile
8532 stack_trap "rm -f $file" EXIT
8534 $LFS setstripe -c 1 -i 0 $file
8535 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
8536 do_facet ost1 lctl set_param fail_loc=0x8000021a
8538 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
8539 error "write error: rc=$?"
8540 do_facet ost1 lctl set_param fail_loc=0
8543 cancel_lru_locks osc
8544 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
8545 do_facet ost1 lctl set_param fail_loc=0x8000021b
8547 cmp $F77_TMP $file || error "file compare failed"
8548 do_facet ost1 lctl set_param fail_loc=0
8551 run_test 77g "checksum error on OST write, read"
8553 test_77k() { # LU-10906
8554 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8555 $GSS && skip_env "could not run with gss"
8557 local cksum_param="osc.$FSNAME*.checksums"
8558 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
8562 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
8563 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
8564 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
8568 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
8569 error "failed to set checksum=$i on MGS"
8570 wait_update $HOSTNAME "$get_checksum" $i
8572 echo "remount client, checksum should be $i"
8573 remount_client $MOUNT || error "failed to remount client"
8574 checksum=$(eval $get_checksum)
8575 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8577 # remove persistent param to avoid races with checksum mountopt below
8578 do_facet mgs $LCTL set_param -P -d $cksum_param ||
8579 error "failed to delete checksum on MGS"
8581 for opt in "checksum" "nochecksum"; do
8582 #remount with mount option
8583 echo "remount client with option $opt, checksum should be $i"
8584 umount_client $MOUNT || error "failed to umount client"
8585 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
8586 error "failed to mount client with option '$opt'"
8587 checksum=$(eval $get_checksum)
8588 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8592 remount_client $MOUNT || error "failed to remount client"
8594 run_test 77k "enable/disable checksum correctly"
8597 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8598 $GSS && skip_env "could not run with gss"
8601 stack_trap "set_checksums $ORIG_CSUM" EXIT
8602 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
8604 set_checksum_type invalid && error "unexpected success of invalid checksum type"
8606 $LFS setstripe -c 1 -i 0 $DIR/$tfile
8607 for algo in $CKSUM_TYPES; do
8608 set_checksum_type $algo || error "fail to set checksum type $algo"
8609 osc_algo=$(get_osc_checksum_type OST0000)
8610 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
8612 # no locks, no reqs to let the connection idle
8613 cancel_lru_locks osc
8614 lru_resize_disable osc
8615 wait_osc_import_state client ost1 IDLE
8617 # ensure ost1 is connected
8618 stat $DIR/$tfile >/dev/null || error "can't stat"
8619 wait_osc_import_state client ost1 FULL
8621 osc_algo=$(get_osc_checksum_type OST0000)
8622 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
8626 run_test 77l "preferred checksum type is remembered after reconnected"
8628 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
8637 test_78() { # bug 10901
8638 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8639 remote_ost || skip_env "local OST"
8642 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
8643 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
8644 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
8645 echo "MemTotal: $MEMTOTAL"
8647 # reserve 256MB of memory for the kernel and other running processes,
8648 # and then take 1/2 of the remaining memory for the read/write buffers.
8649 if [ $MEMTOTAL -gt 512 ] ;then
8650 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
8652 # for those poor memory-starved high-end clusters...
8653 MEMTOTAL=$((MEMTOTAL / 2))
8655 echo "Mem to use for directio: $MEMTOTAL"
8657 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
8658 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
8659 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
8660 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
8662 echo "Smallest OST: $SMALLESTOST"
8663 [[ $SMALLESTOST -lt 10240 ]] &&
8664 skip "too small OSTSIZE, useless to run large O_DIRECT test"
8666 trap cleanup_test_78 EXIT
8668 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
8669 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
8671 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
8672 echo "File size: $F78SIZE"
8673 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
8674 for i in $(seq 1 $NSEQ); do
8675 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
8676 echo directIO rdwr round $i of $NSEQ
8677 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
8682 run_test 78 "handle large O_DIRECT writes correctly ============"
8684 test_79() { # bug 12743
8685 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8687 wait_delete_completed
8689 BKTOTAL=$(calc_osc_kbytes kbytestotal)
8690 BKFREE=$(calc_osc_kbytes kbytesfree)
8691 BKAVAIL=$(calc_osc_kbytes kbytesavail)
8693 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
8694 DFTOTAL=`echo $STRING | cut -d, -f1`
8695 DFUSED=`echo $STRING | cut -d, -f2`
8696 DFAVAIL=`echo $STRING | cut -d, -f3`
8697 DFFREE=$(($DFTOTAL - $DFUSED))
8699 ALLOWANCE=$((64 * $OSTCOUNT))
8701 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
8702 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
8703 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
8705 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
8706 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
8707 error "df free($DFFREE) mismatch OST free($BKFREE)"
8709 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
8710 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
8711 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
8714 run_test 79 "df report consistency check ======================="
8716 test_80() { # bug 10718
8717 remote_ost_nodsh && skip "remote OST with nodsh"
8718 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8720 # relax strong synchronous semantics for slow backends like ZFS
8721 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
8722 local soc="obdfilter.*.sync_lock_cancel"
8723 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8725 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
8726 if [ -z "$save" ]; then
8727 soc="obdfilter.*.sync_on_lock_cancel"
8728 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8731 if [ "$save" != "never" ]; then
8732 local hosts=$(comma_list $(osts_nodes))
8734 do_nodes $hosts $LCTL set_param $soc=never
8735 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
8739 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
8741 local before=$(date +%s)
8742 cancel_lru_locks osc
8743 local after=$(date +%s)
8744 local diff=$((after - before))
8745 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
8749 run_test 80 "Page eviction is equally fast at high offsets too"
8751 test_81a() { # LU-456
8752 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8753 remote_ost_nodsh && skip "remote OST with nodsh"
8755 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8756 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
8757 do_facet ost1 lctl set_param fail_loc=0x80000228
8759 # write should trigger a retry and success
8760 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8761 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8763 if [ $RC -ne 0 ] ; then
8764 error "write should success, but failed for $RC"
8767 run_test 81a "OST should retry write when get -ENOSPC ==============="
8769 test_81b() { # LU-456
8770 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8771 remote_ost_nodsh && skip "remote OST with nodsh"
8773 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8774 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
8775 do_facet ost1 lctl set_param fail_loc=0x228
8777 # write should retry several times and return -ENOSPC finally
8778 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8779 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8782 if [ $RC -ne $ENOSPC ] ; then
8783 error "dd should fail for -ENOSPC, but succeed."
8786 run_test 81b "OST should return -ENOSPC when retry still fails ======="
8788 test_82() { # LU-1031
8789 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
8793 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
8795 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
8797 kill -USR1 $MULTIPID2
8799 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
8800 error "First grouplock does not block second one"
8802 echo "Second grouplock blocks first one"
8804 kill -USR1 $MULTIPID1
8808 run_test 82 "Basic grouplock test"
8811 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
8813 test_mkdir $DIR/$tdir.cvsroot
8814 chown $RUNAS_ID $DIR/$tdir.cvsroot
8817 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
8820 # some versions of cvs import exit(1) when asked to import links or
8821 # files they can't read. ignore those files.
8822 local toignore=$(find . -type l -printf '-I %f\n' -o \
8823 ! -perm /4 -printf '-I %f\n')
8824 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
8825 $tdir.reposname vtag rtag
8828 test_mkdir $DIR/$tdir.reposname
8829 chown $RUNAS_ID $DIR/$tdir.reposname
8830 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
8832 cd $DIR/$tdir.reposname
8834 $RUNAS cvs add -m 'addmsg' foo99
8836 $RUNAS cvs commit -m 'nomsg' foo99
8837 rm -fr $DIR/$tdir.cvsroot
8839 run_test 99 "cvs strange file/directory operations"
8842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8843 [[ "$NETTYPE" =~ tcp ]] ||
8844 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
8845 remote_ost_nodsh && skip "remote OST with nodsh"
8846 remote_mds_nodsh && skip "remote MDS with nodsh"
8848 skip "useless for local single node setup"
8850 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
8851 [ "$PROT" != "tcp" ] && continue
8852 RPORT=$(echo $REMOTE | cut -d: -f2)
8853 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
8856 LPORT=`echo $LOCAL | cut -d: -f2`
8857 if [ $LPORT -ge 1024 ]; then
8858 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
8860 error_exit "local: $LPORT > 1024, remote: $RPORT"
8863 [ "$rc" = 0 ] || error_exit "privileged port not found" )
8865 run_test 100 "check local port using privileged port ==========="
8867 function get_named_value()
8876 echo $line | sed "s/^$tag[ ]*//"
8883 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
8884 awk '/^max_cached_mb/ { print $2 }')
8887 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
8892 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8897 local cache_limit=32
8899 $LCTL set_param -n osc.*-osc*.rpc_stats 0
8900 trap cleanup_101a EXIT
8901 $LCTL set_param -n llite.*.read_ahead_stats 0
8902 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
8905 # randomly read 10000 of 64K chunks from file 3x 32MB in size
8907 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
8908 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
8911 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
8912 get_named_value 'read but discarded' | cut -d" " -f1); do
8913 discard=$(($discard + $s))
8917 $LCTL get_param osc.*-osc*.rpc_stats
8918 $LCTL get_param llite.*.read_ahead_stats
8920 # Discard is generally zero, but sometimes a few random reads line up
8921 # and trigger larger readahead, which is wasted & leads to discards.
8922 if [[ $(($discard)) -gt $nreads ]]; then
8923 error "too many ($discard) discarded pages"
8925 rm -f $DIR/$tfile || true
8927 run_test 101a "check read-ahead for random reads"
8930 test_mkdir $DIR/$tdir
8932 local FILE_LENGTH=$2
8935 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
8937 local list=$(comma_list $(osts_nodes))
8938 set_osd_param $list '' read_cache_enable 0
8939 set_osd_param $list '' writethrough_cache_enable 0
8941 trap cleanup_test101bc EXIT
8942 # prepare the read-ahead file
8943 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
8945 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
8946 count=$FILE_SIZE_MB 2> /dev/null
8950 cleanup_test101bc() {
8955 local list=$(comma_list $(osts_nodes))
8956 set_osd_param $list '' read_cache_enable 1
8957 set_osd_param $list '' writethrough_cache_enable 1
8961 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
8966 local STRIPE_SIZE=$2
8967 local FILE_LENGTH=$3
8968 local RA_INC=1048576
8969 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
8970 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
8971 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
8972 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
8973 get_named_value 'read but discarded' |
8974 cut -d" " -f1 | calc_total)
8975 if [[ $DISCARD -gt $discard_limit ]]; then
8976 $LCTL get_param llite.*.read_ahead_stats
8977 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
8979 echo "Read-ahead success for size ${READ_SIZE}"
8984 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8985 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8987 local STRIPE_SIZE=1048576
8988 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
8990 if [ $SLOW == "yes" ]; then
8991 local FILE_LENGTH=$((STRIDE_SIZE * 64))
8993 local FILE_LENGTH=$((STRIDE_SIZE * 8))
8996 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
8998 # prepare the read-ahead file
8999 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
9000 cancel_lru_locks osc
9001 for BIDX in 2 4 8 16 32 64 128 256
9003 local BSIZE=$((BIDX*4096))
9004 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
9005 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
9006 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
9007 $LCTL set_param -n llite.*.read_ahead_stats 0
9008 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
9009 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
9010 cancel_lru_locks osc
9011 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
9016 run_test 101b "check stride-io mode read-ahead ================="
9019 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9021 local STRIPE_SIZE=1048576
9022 local FILE_LENGTH=$((STRIPE_SIZE*100))
9027 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
9029 cancel_lru_locks osc
9030 $LCTL set_param osc.*.rpc_stats 0
9031 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
9032 $LCTL get_param osc.*.rpc_stats
9033 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
9034 local stats=$($LCTL get_param -n $osc_rpc_stats)
9035 local lines=$(echo "$stats" | awk 'END {print NR;}')
9038 if [ $lines -le 20 ]; then
9039 echo "continue debug"
9042 for size in 1 2 4 8; do
9043 local rpc=$(echo "$stats" |
9044 awk '($1 == "'$size':") {print $2; exit; }')
9045 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
9046 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
9048 echo "$osc_rpc_stats check passed!"
9053 run_test 101c "check stripe_size aligned read-ahead ================="
9056 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9058 local file=$DIR/$tfile
9059 local sz_MB=${FILESIZE_101d:-500}
9060 local ra_MB=${READAHEAD_MB:-40}
9062 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
9063 [ $free_MB -lt $sz_MB ] &&
9064 skip "Need free space ${sz_MB}M, have ${free_MB}M"
9066 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
9067 $LFS setstripe -c -1 $file || error "setstripe failed"
9069 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
9070 echo Cancel LRU locks on lustre client to flush the client cache
9071 cancel_lru_locks osc
9073 echo Disable read-ahead
9074 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
9075 $LCTL set_param -n llite.*.max_read_ahead_mb=0
9076 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_RA" EXIT
9077 $LCTL get_param -n llite.*.max_read_ahead_mb
9079 echo Reading the test file $file with read-ahead disabled
9080 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
9082 echo Cancel LRU locks on lustre client to flush the client cache
9083 cancel_lru_locks osc
9084 echo Enable read-ahead with ${ra_MB}MB
9085 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
9087 echo Reading the test file $file with read-ahead enabled
9088 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
9090 echo "read-ahead disabled time read $raOFF"
9091 echo "read-ahead enabled time read $raON"
9094 wait_delete_completed
9096 [ $raOFF -le 1 ] || [ $raON -lt $raOFF ] ||
9097 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
9099 run_test 101d "file read with and without read-ahead enabled"
9102 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9104 local file=$DIR/$tfile
9105 local size_KB=500 #KB
9109 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
9110 local need_KB=$((count * size_KB))
9111 [[ $free_KB -le $need_KB ]] &&
9112 skip_env "Need free space $need_KB, have $free_KB"
9114 echo "Creating $count ${size_KB}K test files"
9115 for ((i = 0; i < $count; i++)); do
9116 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
9119 echo "Cancel LRU locks on lustre client to flush the client cache"
9120 cancel_lru_locks $OSC
9122 echo "Reset readahead stats"
9123 $LCTL set_param -n llite.*.read_ahead_stats 0
9125 for ((i = 0; i < $count; i++)); do
9126 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
9129 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9130 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9132 for ((i = 0; i < $count; i++)); do
9133 rm -rf $file.$i 2>/dev/null
9136 #10000 means 20% reads are missing in readahead
9137 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
9139 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
9142 which iozone || skip_env "no iozone installed"
9144 local old_debug=$($LCTL get_param debug)
9145 old_debug=${old_debug#*=}
9146 $LCTL set_param debug="reada mmap"
9148 # create a test file
9149 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
9151 echo Cancel LRU locks on lustre client to flush the client cache
9152 cancel_lru_locks osc
9154 echo Reset readahead stats
9155 $LCTL set_param -n llite.*.read_ahead_stats 0
9157 echo mmap read the file with small block size
9158 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
9161 echo checking missing pages
9162 $LCTL get_param llite.*.read_ahead_stats
9163 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9164 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9166 $LCTL set_param debug="$old_debug"
9167 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
9170 run_test 101f "check mmap read performance"
9172 test_101g_brw_size_test() {
9174 local pages=$((mb * 1048576 / PAGE_SIZE))
9175 local file=$DIR/$tfile
9177 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
9178 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
9179 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
9180 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
9184 stack_trap "rm -f $file" EXIT
9185 $LCTL set_param -n osc.*.rpc_stats=0
9187 # 10 RPCs should be enough for the test
9189 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
9190 { error "dd write ${mb} MB blocks failed"; return 3; }
9191 cancel_lru_locks osc
9192 dd of=/dev/null if=$file bs=${mb}M count=$count ||
9193 { error "dd write ${mb} MB blocks failed"; return 4; }
9195 # calculate number of full-sized read and write RPCs
9196 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
9197 sed -n '/pages per rpc/,/^$/p' |
9198 awk '/'$pages':/ { reads += $2; writes += $6 }; \
9199 END { print reads,writes }'))
9200 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
9202 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
9209 remote_ost_nodsh && skip "remote OST with nodsh"
9212 local osts=$(get_facets OST)
9213 local list=$(comma_list $(osts_nodes))
9214 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9215 local brw_size="obdfilter.*.brw_size"
9217 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9219 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
9221 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
9222 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
9223 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
9224 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
9225 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
9226 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
9228 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
9231 if [[ $orig_mb -lt 16 ]]; then
9232 save_lustre_params $osts "$brw_size" > $p
9233 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
9234 error "set 16MB RPC size failed"
9236 echo "remount client to enable new RPC size"
9237 remount_client $MOUNT || error "remount_client failed"
9240 test_101g_brw_size_test 16 || error "16MB RPC test failed"
9241 # should be able to set brw_size=12, but no rpc_stats for that
9242 test_101g_brw_size_test 8 || error "8MB RPC test failed"
9245 test_101g_brw_size_test 4 || error "4MB RPC test failed"
9247 if [[ $orig_mb -lt 16 ]]; then
9248 restore_lustre_params < $p
9249 remount_client $MOUNT || error "remount_client restore failed"
9252 rm -f $p $DIR/$tfile
9254 run_test 101g "Big bulk(4/16 MiB) readahead"
9257 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9259 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
9260 error "dd 70M file failed"
9261 echo Cancel LRU locks on lustre client to flush the client cache
9262 cancel_lru_locks osc
9264 echo "Reset readahead stats"
9265 $LCTL set_param -n llite.*.read_ahead_stats 0
9267 echo "Read 10M of data but cross 64M bundary"
9268 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
9269 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9270 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9271 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
9272 rm -f $p $DIR/$tfile
9274 run_test 101h "Readahead should cover current read window"
9277 test_mkdir $DIR/$tdir
9278 chown $RUNAS_ID $DIR/$tdir
9281 STRIPE_COUNT=$OSTCOUNT
9282 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
9284 trap cleanup_test102 EXIT
9286 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
9288 for num in 1 2 3 4; do
9289 for count in $(seq 1 $STRIPE_COUNT); do
9290 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
9291 local size=`expr $STRIPE_SIZE \* $num`
9292 local file=file"$num-$idx-$count"
9293 $1 $LFS setstripe -S $size -i $idx -c $count $file
9299 $1 tar cf $TMP/f102.tar $tdir --xattrs
9305 rm -rf $DIR/d0.sanity/d102
9309 [ "$UID" != 0 ] && skip "must run as root"
9310 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
9311 skip_env "must have user_xattr"
9313 [ -z "$(which setfattr 2>/dev/null)" ] &&
9314 skip_env "could not find setfattr"
9316 local testfile=$DIR/$tfile
9319 echo "set/get xattr..."
9320 setfattr -n trusted.name1 -v value1 $testfile ||
9321 error "setfattr -n trusted.name1=value1 $testfile failed"
9322 getfattr -n trusted.name1 $testfile 2> /dev/null |
9323 grep "trusted.name1=.value1" ||
9324 error "$testfile missing trusted.name1=value1"
9326 setfattr -n user.author1 -v author1 $testfile ||
9327 error "setfattr -n user.author1=author1 $testfile failed"
9328 getfattr -n user.author1 $testfile 2> /dev/null |
9329 grep "user.author1=.author1" ||
9330 error "$testfile missing trusted.author1=author1"
9333 setfattr -n trusted.name2 -v value2 $testfile ||
9334 error "$testfile unable to set trusted.name2"
9335 setfattr -n trusted.name3 -v value3 $testfile ||
9336 error "$testfile unable to set trusted.name3"
9337 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
9338 grep "trusted.name" | wc -l) -eq 3 ] ||
9339 error "$testfile missing 3 trusted.name xattrs"
9341 setfattr -n user.author2 -v author2 $testfile ||
9342 error "$testfile unable to set user.author2"
9343 setfattr -n user.author3 -v author3 $testfile ||
9344 error "$testfile unable to set user.author3"
9345 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
9346 grep "user.author" | wc -l) -eq 3 ] ||
9347 error "$testfile missing 3 user.author xattrs"
9349 echo "remove xattr..."
9350 setfattr -x trusted.name1 $testfile ||
9351 error "$testfile error deleting trusted.name1"
9352 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
9353 error "$testfile did not delete trusted.name1 xattr"
9355 setfattr -x user.author1 $testfile ||
9356 error "$testfile error deleting user.author1"
9357 echo "set lustre special xattr ..."
9358 $LFS setstripe -c1 $testfile
9359 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
9360 awk -F "=" '/trusted.lov/ { print $2 }' )
9361 setfattr -n "trusted.lov" -v $lovea $testfile ||
9362 error "$testfile doesn't ignore setting trusted.lov again"
9363 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
9364 error "$testfile allow setting invalid trusted.lov"
9367 run_test 102a "user xattr test =================================="
9370 [ -z "$(which setfattr 2>/dev/null)" ] &&
9371 skip_env "could not find setfattr"
9372 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9374 # b10930: get/set/list trusted.lov xattr
9375 echo "get/set/list trusted.lov xattr ..."
9376 local testfile=$DIR/$tfile
9377 $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
9378 error "setstripe failed"
9379 local STRIPECOUNT=$($LFS getstripe -c $testfile) ||
9380 error "getstripe failed"
9381 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
9382 error "can't get trusted.lov from $testfile"
9384 local testfile2=${testfile}2
9385 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
9386 grep "trusted.lov" | sed -e 's/[^=]\+=//')
9389 setfattr -n trusted.lov -v $value $testfile2
9390 local stripe_size=$($LFS getstripe -S $testfile2)
9391 local stripe_count=$($LFS getstripe -c $testfile2)
9392 [[ $stripe_size -eq 65536 ]] ||
9393 error "stripe size $stripe_size != 65536"
9394 [[ $stripe_count -eq $STRIPECOUNT ]] ||
9395 error "stripe count $stripe_count != $STRIPECOUNT"
9398 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
9401 [ -z "$(which setfattr 2>/dev/null)" ] &&
9402 skip_env "could not find setfattr"
9403 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9405 # b10930: get/set/list lustre.lov xattr
9406 echo "get/set/list lustre.lov xattr ..."
9407 test_mkdir $DIR/$tdir
9408 chown $RUNAS_ID $DIR/$tdir
9409 local testfile=$DIR/$tdir/$tfile
9410 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
9411 error "setstripe failed"
9412 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
9413 error "getstripe failed"
9414 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
9415 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
9417 local testfile2=${testfile}2
9418 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
9419 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
9421 $RUNAS $MCREATE $testfile2
9422 $RUNAS setfattr -n lustre.lov -v $value $testfile2
9423 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
9424 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
9425 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
9426 [ $stripe_count -eq $STRIPECOUNT ] ||
9427 error "stripe count $stripe_count != $STRIPECOUNT"
9429 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
9431 compare_stripe_info1() {
9432 local stripe_index_all_zero=true
9434 for num in 1 2 3 4; do
9435 for count in $(seq 1 $STRIPE_COUNT); do
9436 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
9437 local size=$((STRIPE_SIZE * num))
9438 local file=file"$num-$offset-$count"
9439 stripe_size=$($LFS getstripe -S $PWD/$file)
9440 [[ $stripe_size -ne $size ]] &&
9441 error "$file: size $stripe_size != $size"
9442 stripe_count=$($LFS getstripe -c $PWD/$file)
9443 # allow fewer stripes to be created, ORI-601
9444 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
9445 error "$file: count $stripe_count != $count"
9446 stripe_index=$($LFS getstripe -i $PWD/$file)
9447 [[ $stripe_index -ne 0 ]] &&
9448 stripe_index_all_zero=false
9452 $stripe_index_all_zero &&
9453 error "all files are being extracted starting from OST index 0"
9457 have_xattrs_include() {
9458 tar --help | grep -q xattrs-include &&
9459 echo --xattrs-include="lustre.*"
9463 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9464 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9466 XINC=$(have_xattrs_include)
9468 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9470 compare_stripe_info1
9472 run_test 102d "tar restore stripe info from tarfile,not keep osts"
9475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9476 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9478 XINC=$(have_xattrs_include)
9480 test_mkdir $DIR/$tdir.restore
9482 tar cf - --xattrs $tdir | tar xf - \
9483 -C $DIR/$tdir.restore --xattrs $XINC
9484 cd $DIR/$tdir.restore/$tdir
9485 compare_stripe_info1
9487 run_test 102f "tar copy files, not keep osts"
9490 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
9491 skip "must have user_xattr"
9492 [ -z "$(which setfattr 2>/dev/null)" ] &&
9493 skip_env "could not find setfattr"
9494 [ -z "$(which getfattr 2>/dev/null)" ] &&
9495 skip_env "could not find getfattr"
9497 local xsize=${1:-1024} # in bytes
9498 local file=$DIR/$tfile
9499 local value="$(generate_string $xsize)"
9500 local xbig=trusted.big
9504 log "save $xbig on $file"
9507 setfattr -n $xbig -v $value $file ||
9508 error "saving $xbig on $file failed"
9510 setfattr -n $xbig -v $value $file &&
9511 error "saving $xbig on $file succeeded"
9515 local orig=$(get_xattr_value $xbig $file)
9516 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
9518 local xsml=trusted.sml
9519 log "save $xsml on $file"
9520 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
9522 local new=$(get_xattr_value $xbig $file)
9523 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
9525 log "grow $xsml on $file"
9526 setfattr -n $xsml -v "$value" $file ||
9527 error "growing $xsml on $file failed"
9529 new=$(get_xattr_value $xbig $file)
9530 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
9531 log "$xbig still valid after growing $xsml"
9536 test_102h() { # bug 15777
9539 run_test 102h "grow xattr from inside inode to external block"
9542 large_xattr_enabled || skip_env "ea_inode feature disabled"
9544 echo "setting xattr of max xattr size: $(max_xattr_size)"
9545 grow_xattr $(max_xattr_size)
9547 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
9548 echo "This should fail:"
9549 grow_xattr $(($(max_xattr_size) + 10)) 1
9551 run_test 102ha "grow xattr from inside inode to external inode"
9553 test_102i() { # bug 17038
9554 [ -z "$(which getfattr 2>/dev/null)" ] &&
9555 skip "could not find getfattr"
9558 ln -s $DIR/$tfile $DIR/${tfile}link
9559 getfattr -n trusted.lov $DIR/$tfile ||
9560 error "lgetxattr on $DIR/$tfile failed"
9561 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
9562 grep -i "no such attr" ||
9563 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
9564 rm -f $DIR/$tfile $DIR/${tfile}link
9566 run_test 102i "lgetxattr test on symbolic link ============"
9569 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9570 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9572 XINC=$(have_xattrs_include)
9573 setup_test102 "$RUNAS"
9574 chown $RUNAS_ID $DIR/$tdir
9575 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9577 compare_stripe_info1 "$RUNAS"
9579 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
9582 [ -z "$(which setfattr 2>/dev/null)" ] &&
9583 skip "could not find setfattr"
9586 # b22187 just check that does not crash for regular file.
9587 setfattr -n trusted.lov $DIR/$tfile
9588 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
9589 local test_kdir=$DIR/$tdir
9590 test_mkdir $test_kdir
9591 local default_size=$($LFS getstripe -S $test_kdir)
9592 local default_count=$($LFS getstripe -c $test_kdir)
9593 local default_offset=$($LFS getstripe -i $test_kdir)
9594 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
9595 error 'dir setstripe failed'
9596 setfattr -n trusted.lov $test_kdir
9597 local stripe_size=$($LFS getstripe -S $test_kdir)
9598 local stripe_count=$($LFS getstripe -c $test_kdir)
9599 local stripe_offset=$($LFS getstripe -i $test_kdir)
9600 [ $stripe_size -eq $default_size ] ||
9601 error "stripe size $stripe_size != $default_size"
9602 [ $stripe_count -eq $default_count ] ||
9603 error "stripe count $stripe_count != $default_count"
9604 [ $stripe_offset -eq $default_offset ] ||
9605 error "stripe offset $stripe_offset != $default_offset"
9606 rm -rf $DIR/$tfile $test_kdir
9608 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
9611 [ -z "$(which getfattr 2>/dev/null)" ] &&
9612 skip "could not find getfattr"
9614 # LU-532 trusted. xattr is invisible to non-root
9615 local testfile=$DIR/$tfile
9619 echo "listxattr as user..."
9620 chown $RUNAS_ID $testfile
9621 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
9622 grep -q "trusted" &&
9623 error "$testfile trusted xattrs are user visible"
9627 run_test 102l "listxattr size test =================================="
9629 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
9630 local path=$DIR/$tfile
9633 listxattr_size_check $path || error "listattr_size_check $path failed"
9635 run_test 102m "Ensure listxattr fails on small bufffer ========"
9639 getxattr() { # getxattr path name
9640 # Return the base64 encoding of the value of xattr name on path.
9644 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
9646 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9648 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9650 getfattr --absolute-names --encoding=base64 --name=$name $path |
9651 awk -F= -v name=$name '$1 == name {
9652 print substr($0, index($0, "=") + 1);
9656 test_102n() { # LU-4101 mdt: protect internal xattrs
9657 [ -z "$(which setfattr 2>/dev/null)" ] &&
9658 skip "could not find setfattr"
9659 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
9661 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
9664 local file0=$DIR/$tfile.0
9665 local file1=$DIR/$tfile.1
9666 local xattr0=$TMP/$tfile.0
9667 local xattr1=$TMP/$tfile.1
9668 local namelist="lov lma lmv link fid version som hsm"
9672 rm -rf $file0 $file1 $xattr0 $xattr1
9675 # Get 'before' xattrs of $file1.
9676 getfattr --absolute-names --dump --match=- $file1 > $xattr0
9678 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
9679 namelist+=" lfsck_namespace"
9680 for name in $namelist; do
9681 # Try to copy xattr from $file0 to $file1.
9682 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9684 setfattr --name=trusted.$name --value="$value" $file1 ||
9685 error "setxattr 'trusted.$name' failed"
9687 # Try to set a garbage xattr.
9688 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9690 if [[ x$name == "xlov" ]]; then
9691 setfattr --name=trusted.lov --value="$value" $file1 &&
9692 error "setxattr invalid 'trusted.lov' success"
9694 setfattr --name=trusted.$name --value="$value" $file1 ||
9695 error "setxattr invalid 'trusted.$name' failed"
9698 # Try to remove the xattr from $file1. We don't care if this
9699 # appears to succeed or fail, we just don't want there to be
9700 # any changes or crashes.
9701 setfattr --remove=$trusted.$name $file1 2> /dev/null
9704 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
9707 # Try to copy xattr from $file0 to $file1.
9708 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9710 setfattr --name=trusted.$name --value="$value" $file1 ||
9711 error "setxattr 'trusted.$name' failed"
9713 # Try to set a garbage xattr.
9714 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9716 setfattr --name=trusted.$name --value="$value" $file1 ||
9717 error "setxattr 'trusted.$name' failed"
9719 # Try to remove the xattr from $file1. We don't care if this
9720 # appears to succeed or fail, we just don't want there to be
9721 # any changes or crashes.
9722 setfattr --remove=$trusted.$name $file1 2> /dev/null
9725 # Get 'after' xattrs of file1.
9726 getfattr --absolute-names --dump --match=- $file1 > $xattr1
9728 if ! diff $xattr0 $xattr1; then
9729 error "before and after xattrs of '$file1' differ"
9732 rm -rf $file0 $file1 $xattr0 $xattr1
9736 run_test 102n "silently ignore setxattr on internal trusted xattrs"
9738 test_102p() { # LU-4703 setxattr did not check ownership
9739 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
9740 skip "MDS needs to be at least 2.5.56"
9742 local testfile=$DIR/$tfile
9746 echo "setfacl as user..."
9747 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
9748 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
9750 echo "setfattr as user..."
9751 setfacl -m "u:$RUNAS_ID:---" $testfile
9752 $RUNAS setfattr -x system.posix_acl_access $testfile
9753 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
9755 run_test 102p "check setxattr(2) correctly fails without permission"
9758 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
9759 skip "MDS needs to be at least 2.6.92"
9761 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
9763 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
9766 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
9767 skip "MDS needs to be at least 2.6.93"
9769 touch $DIR/$tfile || error "touch"
9770 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
9771 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
9772 rm $DIR/$tfile || error "rm"
9775 mkdir -p $DIR/$tdir || error "mkdir"
9776 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9777 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9778 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9779 error "$testfile error deleting user.author1"
9780 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9781 grep "user.$(basename $tdir)" &&
9782 error "$tdir did not delete user.$(basename $tdir)"
9783 rmdir $DIR/$tdir || error "rmdir"
9786 test_mkdir $DIR/$tdir
9787 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
9788 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
9789 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
9790 error "$testfile error deleting user.author1"
9791 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
9792 grep "user.$(basename $tdir)" &&
9793 error "$tdir did not delete user.$(basename $tdir)"
9794 rmdir $DIR/$tdir || error "rm striped dir"
9796 run_test 102r "set EAs with empty values"
9799 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9800 skip "MDS needs to be at least 2.11.52"
9802 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9804 save_lustre_params client "llite.*.xattr_cache" > $save
9806 for cache in 0 1; do
9807 lctl set_param llite.*.xattr_cache=$cache
9810 touch $DIR/$tfile || error "touch"
9811 for prefix in lustre security system trusted user; do
9812 # Note getxattr() may fail with 'Operation not
9813 # supported' or 'No such attribute' depending
9814 # on prefix and cache.
9815 getfattr -n $prefix.n102s $DIR/$tfile &&
9816 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
9820 restore_lustre_params < $save
9822 run_test 102s "getting nonexistent xattrs should fail"
9825 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9826 skip "MDS needs to be at least 2.11.52"
9828 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9830 save_lustre_params client "llite.*.xattr_cache" > $save
9832 for cache in 0 1; do
9833 lctl set_param llite.*.xattr_cache=$cache
9835 for buf_size in 0 256; do
9837 touch $DIR/$tfile || error "touch"
9838 setfattr -n user.multiop $DIR/$tfile
9839 $MULTIOP $DIR/$tfile oa$buf_size ||
9840 error "cannot get zero length xattr value (buf_size = $buf_size)"
9844 restore_lustre_params < $save
9846 run_test 102t "zero length xattr values handled correctly"
9850 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
9855 [ "$UID" != 0 ] && skip "must run as root"
9856 $GSS && skip_env "could not run under gss"
9857 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
9858 skip_env "must have acl enabled"
9859 [ -z "$(which setfacl 2>/dev/null)" ] &&
9860 skip_env "could not find setfacl"
9861 remote_mds_nodsh && skip "remote MDS with nodsh"
9863 gpasswd -a daemon bin # LU-5641
9864 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
9866 declare -a identity_old
9868 for num in $(seq $MDSCOUNT); do
9869 switch_identity $num true || identity_old[$num]=$?
9877 echo "performing cp ..."
9878 run_acl_subtest cp || error "run_acl_subtest cp failed"
9879 echo "performing getfacl-noacl..."
9880 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
9881 echo "performing misc..."
9882 run_acl_subtest misc || error "misc test failed"
9883 echo "performing permissions..."
9884 run_acl_subtest permissions || error "permissions failed"
9885 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
9886 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
9887 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
9888 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
9890 echo "performing permissions xattr..."
9891 run_acl_subtest permissions_xattr ||
9892 error "permissions_xattr failed"
9894 echo "performing setfacl..."
9895 run_acl_subtest setfacl || error "setfacl test failed"
9897 # inheritance test got from HP
9898 echo "performing inheritance..."
9899 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
9900 chmod +x make-tree || error "chmod +x failed"
9901 run_acl_subtest inheritance || error "inheritance test failed"
9904 echo "LU-974 ignore umask when acl is enabled..."
9905 run_acl_subtest 974 || error "LU-974 umask test failed"
9906 if [ $MDSCOUNT -ge 2 ]; then
9907 run_acl_subtest 974_remote ||
9908 error "LU-974 umask test failed under remote dir"
9911 echo "LU-2561 newly created file is same size as directory..."
9912 if [ "$mds1_FSTYPE" != "zfs" ]; then
9913 run_acl_subtest 2561 || error "LU-2561 test failed"
9915 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
9918 run_acl_subtest 4924 || error "LU-4924 test failed"
9923 for num in $(seq $MDSCOUNT); do
9924 if [ "${identity_old[$num]}" = 1 ]; then
9925 switch_identity $num false || identity_old[$num]=$?
9929 run_test 103a "acl test"
9935 for U in {0..511}; do
9937 local O=$(printf "%04o" $U)
9939 umask $(printf "%04o" $((511 ^ $O)))
9940 $LFS setstripe -c 1 $DIR/$tfile.s$O
9941 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
9943 (( $S == ($O & 0666) )) ||
9944 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
9946 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
9947 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
9948 (( $S == ($O & 0666) )) ||
9949 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
9951 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
9952 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
9953 (( $S == ($O & 0666) )) ||
9954 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
9955 rm -f $DIR/$tfile.[smp]$0
9959 # limit the concurrently running threads to 64. LU-11878
9960 local idx=$((U % 64))
9961 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
9966 run_test 103b "umask lfs setstripe"
9970 cp -rp $DIR/$tdir $DIR/$tdir.bak
9972 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
9973 error "$DIR/$tdir shouldn't contain default ACL"
9974 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
9975 error "$DIR/$tdir.bak shouldn't contain default ACL"
9978 run_test 103c "'cp -rp' won't set empty acl"
9981 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9984 lfs df || error "lfs df failed"
9985 lfs df -ih || error "lfs df -ih failed"
9986 lfs df -h $DIR || error "lfs df -h $DIR failed"
9987 lfs df -i $DIR || error "lfs df -i $DIR failed"
9988 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
9989 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
9991 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
9992 lctl --device %$OSC deactivate
9993 lfs df || error "lfs df with deactivated OSC failed"
9994 lctl --device %$OSC activate
9995 # wait the osc back to normal
9996 wait_osc_import_ready client ost
9998 lfs df || error "lfs df with reactivated OSC failed"
10001 run_test 104a "lfs df [-ih] [path] test ========================="
10004 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10005 [ $RUNAS_ID -eq $UID ] &&
10006 skip_env "RUNAS_ID = UID = $UID -- skipping"
10008 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
10009 grep "Permission denied" | wc -l)))
10010 if [ $denied_cnt -ne 0 ]; then
10011 error "lfs check servers test failed"
10014 run_test 104b "$RUNAS lfs check servers test ===================="
10017 # doesn't work on 2.4 kernels
10019 if $(flock_is_enabled); then
10020 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
10022 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
10026 run_test 105a "flock when mounted without -o flock test ========"
10030 if $(flock_is_enabled); then
10031 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
10033 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
10037 run_test 105b "fcntl when mounted without -o flock test ========"
10041 if $(flock_is_enabled); then
10042 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
10044 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
10048 run_test 105c "lockf when mounted without -o flock test"
10050 test_105d() { # bug 15924
10051 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10053 test_mkdir $DIR/$tdir
10054 flock_is_enabled || skip_env "mount w/o flock enabled"
10055 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
10056 $LCTL set_param fail_loc=0x80000315
10057 flocks_test 2 $DIR/$tdir
10059 run_test 105d "flock race (should not freeze) ========"
10061 test_105e() { # bug 22660 && 22040
10062 flock_is_enabled || skip_env "mount w/o flock enabled"
10065 flocks_test 3 $DIR/$tfile
10067 run_test 105e "Two conflicting flocks from same process"
10069 test_106() { #bug 10921
10070 test_mkdir $DIR/$tdir
10071 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
10072 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
10074 run_test 106 "attempt exec of dir followed by chown of that dir"
10077 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10085 local save_pattern=$(sysctl -n kernel.core_pattern)
10086 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
10087 sysctl -w kernel.core_pattern=$file
10088 sysctl -w kernel.core_uses_pid=0
10090 ulimit -c unlimited
10096 kill -s 11 $SLEEPPID
10098 if [ -e $file ]; then
10099 size=`stat -c%s $file`
10100 [ $size -eq 0 ] && error "Fail to create core file $file"
10102 error "Fail to create core file $file"
10105 sysctl -w kernel.core_pattern=$save_pattern
10106 sysctl -w kernel.core_uses_pid=$save_uses_pid
10109 run_test 107 "Coredump on SIG"
10112 test_mkdir $DIR/$tdir
10113 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
10114 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
10115 error "mkdir with 256 char should fail, but did not"
10116 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
10117 error "create with 255 char failed"
10118 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
10119 error "create with 256 char should fail, but did not"
10124 run_test 110 "filename length checking"
10127 # Purpose: To verify dynamic thread (OSS) creation.
10130 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10131 remote_ost_nodsh && skip "remote OST with nodsh"
10133 # Lustre does not stop service threads once they are started.
10134 # Reset number of running threads to default.
10139 local save_params="$TMP/sanity-$TESTNAME.parameters"
10141 # Get ll_ost_io count before I/O
10142 OSTIO_pre=$(do_facet ost1 \
10143 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
10144 # Exit if lustre is not running (ll_ost_io not running).
10145 [ -z "$OSTIO_pre" ] && error "no OSS threads"
10147 echo "Starting with $OSTIO_pre threads"
10148 local thread_max=$((OSTIO_pre * 2))
10149 local rpc_in_flight=$((thread_max * 2))
10150 # Number of I/O Process proposed to be started.
10152 local facets=$(get_facets OST)
10154 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
10155 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
10157 # Set in_flight to $rpc_in_flight
10158 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
10159 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
10160 nfiles=${rpc_in_flight}
10161 # Set ost thread_max to $thread_max
10162 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
10164 # 5 Minutes should be sufficient for max number of OSS
10165 # threads(thread_max) to be created.
10169 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
10170 test_mkdir $DIR/$tdir
10171 for i in $(seq $nfiles); do
10172 local file=$DIR/$tdir/${tfile}-$i
10173 $LFS setstripe -c -1 -i 0 $file
10174 ($WTL $file $timeout)&
10177 # I/O Started - Wait for thread_started to reach thread_max or report
10178 # error if thread_started is more than thread_max.
10179 echo "Waiting for thread_started to reach thread_max"
10180 local thread_started=0
10181 local end_time=$((SECONDS + timeout))
10183 while [ $SECONDS -le $end_time ] ; do
10185 # Get ost i/o thread_started count.
10186 thread_started=$(do_facet ost1 \
10188 ost.OSS.ost_io.threads_started | cut -d= -f2")
10189 # Break out if thread_started is equal/greater than thread_max
10190 if [[ $thread_started -ge $thread_max ]]; then
10191 echo ll_ost_io thread_started $thread_started, \
10192 equal/greater than thread_max $thread_max
10198 # Cleanup - We have the numbers, Kill i/o jobs if running.
10199 jobcount=($(jobs -p))
10200 for i in $(seq 0 $((${#jobcount[@]}-1)))
10202 kill -9 ${jobcount[$i]}
10203 if [ $? -ne 0 ] ; then
10205 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
10209 # Cleanup files left by WTL binary.
10210 for i in $(seq $nfiles); do
10211 local file=$DIR/$tdir/${tfile}-$i
10213 if [ $? -ne 0 ] ; then
10214 echo "Warning: Failed to delete file $file"
10218 restore_lustre_params <$save_params
10219 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
10221 # Error out if no new thread has started or Thread started is greater
10223 if [[ $thread_started -le $OSTIO_pre ||
10224 $thread_started -gt $thread_max ]]; then
10225 error "ll_ost_io: thread_started $thread_started" \
10226 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
10227 "No new thread started or thread started greater " \
10231 run_test 115 "verify dynamic thread creation===================="
10234 wait_delete_completed
10235 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
10236 echo "OST kbytes available: ${AVAIL[@]}"
10241 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
10242 #echo OST $i: ${AVAIL[i]}kb
10243 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
10247 if [[ ${AVAIL[i]} -lt $MINV ]]; then
10252 echo "Min free space: OST $MINI: $MINV"
10253 echo "Max free space: OST $MAXI: $MAXV"
10256 test_116a() { # was previously test_116()
10257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10258 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10259 remote_mds_nodsh && skip "remote MDS with nodsh"
10261 echo -n "Free space priority "
10262 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
10267 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
10268 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
10269 trap simple_cleanup_common EXIT
10271 # Check if we need to generate uneven OSTs
10272 test_mkdir -p $DIR/$tdir/OST${MINI}
10273 local FILL=$((MINV / 4))
10274 local DIFF=$((MAXV - MINV))
10275 local DIFF2=$((DIFF * 100 / MINV))
10277 local threshold=$(do_facet $SINGLEMDS \
10278 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
10279 threshold=${threshold%%%}
10280 echo -n "Check for uneven OSTs: "
10281 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
10283 if [[ $DIFF2 -gt $threshold ]]; then
10285 echo "Don't need to fill OST$MINI"
10287 # generate uneven OSTs. Write 2% over the QOS threshold value
10289 DIFF=$((threshold - DIFF2 + 2))
10290 DIFF2=$((MINV * DIFF / 100))
10291 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
10292 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
10293 error "setstripe failed"
10294 DIFF=$((DIFF2 / 2048))
10296 while [ $i -lt $DIFF ]; do
10298 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
10299 bs=2M count=1 2>/dev/null
10308 DIFF=$((MAXV - MINV))
10309 DIFF2=$((DIFF * 100 / MINV))
10310 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
10311 if [ $DIFF2 -gt $threshold ]; then
10314 echo "failed - QOS mode won't be used"
10315 simple_cleanup_common
10316 skip "QOS imbalance criteria not met"
10324 # now fill using QOS
10325 $LFS setstripe -c 1 $DIR/$tdir
10326 FILL=$((FILL / 200))
10327 if [ $FILL -gt 600 ]; then
10330 echo "writing $FILL files to QOS-assigned OSTs"
10332 while [ $i -lt $FILL ]; do
10334 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
10335 count=1 2>/dev/null
10338 echo "wrote $i 200k files"
10342 echo "Note: free space may not be updated, so measurements might be off"
10344 DIFF2=$((MAXV - MINV))
10345 echo "free space delta: orig $DIFF final $DIFF2"
10346 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
10347 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
10348 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
10349 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
10350 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
10351 if [[ $DIFF -gt 0 ]]; then
10352 FILL=$((DIFF2 * 100 / DIFF - 100))
10353 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
10356 # Figure out which files were written where
10357 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10358 awk '/'$MINI1': / {print $2; exit}')
10360 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10361 echo "$MINC files created on smaller OST $MINI1"
10362 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10363 awk '/'$MAXI1': / {print $2; exit}')
10365 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10366 echo "$MAXC files created on larger OST $MAXI1"
10367 if [[ $MINC -gt 0 ]]; then
10368 FILL=$((MAXC * 100 / MINC - 100))
10369 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
10371 [[ $MAXC -gt $MINC ]] ||
10372 error_ignore LU-9 "stripe QOS didn't balance free space"
10373 simple_cleanup_common
10375 run_test 116a "stripe QOS: free space balance ==================="
10377 test_116b() { # LU-2093
10378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10379 remote_mds_nodsh && skip "remote MDS with nodsh"
10381 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
10382 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
10383 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
10384 [ -z "$old_rr" ] && skip "no QOS"
10385 do_facet $SINGLEMDS lctl set_param \
10386 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
10387 mkdir -p $DIR/$tdir
10388 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
10389 createmany -o $DIR/$tdir/f- 20 || error "can't create"
10390 do_facet $SINGLEMDS lctl set_param fail_loc=0
10392 do_facet $SINGLEMDS lctl set_param \
10393 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
10395 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
10397 test_117() # bug 10891
10399 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10401 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
10402 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
10403 lctl set_param fail_loc=0x21e
10404 > $DIR/$tfile || error "truncate failed"
10405 lctl set_param fail_loc=0
10406 echo "Truncate succeeded."
10409 run_test 117 "verify osd extend =========="
10411 NO_SLOW_RESENDCOUNT=4
10412 export OLD_RESENDCOUNT=""
10413 set_resend_count () {
10414 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
10415 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
10416 lctl set_param -n $PROC_RESENDCOUNT $1
10417 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
10420 # for reduce test_118* time (b=14842)
10421 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10423 # Reset async IO behavior after error case
10425 FILE=$DIR/reset_async
10427 # Ensure all OSCs are cleared
10428 $LFS setstripe -c -1 $FILE
10429 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
10434 test_118a() #bug 11710
10436 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10440 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10441 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10442 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10444 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10445 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10450 run_test 118a "verify O_SYNC works =========="
10454 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10455 remote_ost_nodsh && skip "remote OST with nodsh"
10459 #define OBD_FAIL_SRV_ENOENT 0x217
10460 set_nodes_failloc "$(osts_nodes)" 0x217
10461 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10463 set_nodes_failloc "$(osts_nodes)" 0
10464 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10465 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10468 if [[ $RC -eq 0 ]]; then
10469 error "Must return error due to dropped pages, rc=$RC"
10473 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10474 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10478 echo "Dirty pages not leaked on ENOENT"
10480 # Due to the above error the OSC will issue all RPCs syncronously
10481 # until a subsequent RPC completes successfully without error.
10482 $MULTIOP $DIR/$tfile Ow4096yc
10487 run_test 118b "Reclaim dirty pages on fatal error =========="
10491 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10493 # for 118c, restore the original resend count, LU-1940
10494 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
10495 set_resend_count $OLD_RESENDCOUNT
10496 remote_ost_nodsh && skip "remote OST with nodsh"
10500 #define OBD_FAIL_OST_EROFS 0x216
10501 set_nodes_failloc "$(osts_nodes)" 0x216
10503 # multiop should block due to fsync until pages are written
10504 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10508 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10509 error "Multiop failed to block on fsync, pid=$MULTIPID"
10512 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10514 if [[ $WRITEBACK -eq 0 ]]; then
10515 error "No page in writeback, writeback=$WRITEBACK"
10518 set_nodes_failloc "$(osts_nodes)" 0
10521 if [[ $RC -ne 0 ]]; then
10522 error "Multiop fsync failed, rc=$RC"
10525 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10526 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10528 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10529 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10533 echo "Dirty pages flushed via fsync on EROFS"
10536 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
10538 # continue to use small resend count to reduce test_118* time (b=14842)
10539 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10543 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10544 remote_ost_nodsh && skip "remote OST with nodsh"
10548 #define OBD_FAIL_OST_BRW_PAUSE_BULK
10549 set_nodes_failloc "$(osts_nodes)" 0x214
10550 # multiop should block due to fsync until pages are written
10551 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10555 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10556 error "Multiop failed to block on fsync, pid=$MULTIPID"
10559 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10561 if [[ $WRITEBACK -eq 0 ]]; then
10562 error "No page in writeback, writeback=$WRITEBACK"
10565 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
10566 set_nodes_failloc "$(osts_nodes)" 0
10568 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10569 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10571 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10572 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10576 echo "Dirty pages gaurenteed flushed via fsync"
10579 run_test 118d "Fsync validation inject a delay of the bulk =========="
10582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10586 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
10587 lctl set_param fail_loc=0x8000040a
10589 # Should simulate EINVAL error which is fatal
10590 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10592 if [[ $RC -eq 0 ]]; then
10593 error "Must return error due to dropped pages, rc=$RC"
10596 lctl set_param fail_loc=0x0
10598 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10599 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10600 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10602 if [[ $LOCKED -ne 0 ]]; then
10603 error "Locked pages remain in cache, locked=$LOCKED"
10606 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10607 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10611 echo "No pages locked after fsync"
10616 run_test 118f "Simulate unrecoverable OSC side error =========="
10619 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10623 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
10624 lctl set_param fail_loc=0x406
10626 # simulate local -ENOMEM
10627 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10630 lctl set_param fail_loc=0
10631 if [[ $RC -eq 0 ]]; then
10632 error "Must return error due to dropped pages, rc=$RC"
10635 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10636 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10637 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10639 if [[ $LOCKED -ne 0 ]]; then
10640 error "Locked pages remain in cache, locked=$LOCKED"
10643 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10644 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10648 echo "No pages locked after fsync"
10653 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
10656 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10657 remote_ost_nodsh && skip "remote OST with nodsh"
10661 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10662 set_nodes_failloc "$(osts_nodes)" 0x20e
10663 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10664 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10667 set_nodes_failloc "$(osts_nodes)" 0
10668 if [[ $RC -eq 0 ]]; then
10669 error "Must return error due to dropped pages, rc=$RC"
10672 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10673 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10674 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10676 if [[ $LOCKED -ne 0 ]]; then
10677 error "Locked pages remain in cache, locked=$LOCKED"
10680 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10681 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10685 echo "No pages locked after fsync"
10689 run_test 118h "Verify timeout in handling recoverables errors =========="
10691 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10694 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10695 remote_ost_nodsh && skip "remote OST with nodsh"
10699 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10700 set_nodes_failloc "$(osts_nodes)" 0x20e
10702 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10703 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10706 set_nodes_failloc "$(osts_nodes)" 0
10710 if [[ $RC -ne 0 ]]; then
10711 error "got error, but should be not, rc=$RC"
10714 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10715 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10716 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10717 if [[ $LOCKED -ne 0 ]]; then
10718 error "Locked pages remain in cache, locked=$LOCKED"
10721 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10722 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10726 echo "No pages locked after fsync"
10730 run_test 118i "Fix error before timeout in recoverable error =========="
10732 [ "$SLOW" = "no" ] && set_resend_count 4
10735 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10736 remote_ost_nodsh && skip "remote OST with nodsh"
10740 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
10741 set_nodes_failloc "$(osts_nodes)" 0x220
10743 # return -EIO from OST
10744 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10746 set_nodes_failloc "$(osts_nodes)" 0x0
10747 if [[ $RC -eq 0 ]]; then
10748 error "Must return error due to dropped pages, rc=$RC"
10751 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10752 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10753 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10754 if [[ $LOCKED -ne 0 ]]; then
10755 error "Locked pages remain in cache, locked=$LOCKED"
10758 # in recoverable error on OST we want resend and stay until it finished
10759 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10760 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10764 echo "No pages locked after fsync"
10768 run_test 118j "Simulate unrecoverable OST side error =========="
10772 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10773 remote_ost_nodsh && skip "remote OSTs with nodsh"
10775 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10776 set_nodes_failloc "$(osts_nodes)" 0x20e
10777 test_mkdir $DIR/$tdir
10779 for ((i=0;i<10;i++)); do
10780 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
10781 error "dd to $DIR/$tdir/$tfile-$i failed" )&
10788 set_nodes_failloc "$(osts_nodes)" 0
10791 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
10793 test_118l() # LU-646
10795 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10797 test_mkdir $DIR/$tdir
10798 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
10801 run_test 118l "fsync dir"
10803 test_118m() # LU-3066
10805 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10807 test_mkdir $DIR/$tdir
10808 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
10811 run_test 118m "fdatasync dir ========="
10813 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10820 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10821 remote_ost_nodsh && skip "remote OSTs with nodsh"
10823 # Sleep to avoid a cached response.
10824 #define OBD_STATFS_CACHE_SECONDS 1
10827 # Inject a 10 second delay in the OST_STATFS handler.
10828 #define OBD_FAIL_OST_STATFS_DELAY 0x242
10829 set_nodes_failloc "$(osts_nodes)" 0x242
10832 stat --file-system $MOUNT > /dev/null
10835 set_nodes_failloc "$(osts_nodes)" 0
10837 if ((end - begin > 20)); then
10838 error "statfs took $((end - begin)) seconds, expected 10"
10841 run_test 118n "statfs() sends OST_STATFS requests in parallel"
10843 test_119a() # bug 11737
10845 BSIZE=$((512 * 1024))
10846 directio write $DIR/$tfile 0 1 $BSIZE
10847 # We ask to read two blocks, which is more than a file size.
10848 # directio will indicate an error when requested and actual
10849 # sizes aren't equeal (a normal situation in this case) and
10850 # print actual read amount.
10851 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
10852 if [ "$NOB" != "$BSIZE" ]; then
10853 error "read $NOB bytes instead of $BSIZE"
10857 run_test 119a "Short directIO read must return actual read amount"
10859 test_119b() # bug 11737
10861 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10863 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
10864 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
10866 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
10867 error "direct read failed"
10870 run_test 119b "Sparse directIO read must return actual read amount"
10872 test_119c() # bug 13099
10875 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
10876 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
10879 run_test 119c "Testing for direct read hitting hole"
10881 test_119d() # bug 15950
10883 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10885 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
10886 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
10888 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
10889 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
10890 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
10891 lctl set_param fail_loc=0x40d
10892 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
10895 cat $DIR/$tfile > /dev/null &
10896 lctl set_param fail_loc=0
10899 log "the DIO writes have completed, now wait for the reads (should not block very long)"
10901 [ -n "`ps h -p $pid_reads -o comm`" ] && \
10902 error "the read rpcs have not completed in 2s"
10904 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
10906 run_test 119d "The DIO path should try to send a new rpc once one is completed"
10909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10910 remote_mds_nodsh && skip "remote MDS with nodsh"
10911 test_mkdir -i0 -c1 $DIR/$tdir
10912 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10913 skip_env "no early lock cancel on server"
10915 lru_resize_disable mdc
10916 lru_resize_disable osc
10917 cancel_lru_locks mdc
10918 # asynchronous object destroy at MDT could cause bl ast to client
10919 cancel_lru_locks osc
10921 stat $DIR/$tdir > /dev/null
10922 can1=$(do_facet mds1 \
10923 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10924 awk '/ldlm_cancel/ {print $2}')
10925 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10926 awk '/ldlm_bl_callback/ {print $2}')
10927 test_mkdir -i0 -c1 $DIR/$tdir/d1
10928 can2=$(do_facet mds1 \
10929 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10930 awk '/ldlm_cancel/ {print $2}')
10931 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10932 awk '/ldlm_bl_callback/ {print $2}')
10933 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10934 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10935 lru_resize_enable mdc
10936 lru_resize_enable osc
10938 run_test 120a "Early Lock Cancel: mkdir test"
10941 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10942 remote_mds_nodsh && skip "remote MDS with nodsh"
10943 test_mkdir $DIR/$tdir
10944 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10945 skip_env "no early lock cancel on server"
10947 lru_resize_disable mdc
10948 lru_resize_disable osc
10949 cancel_lru_locks mdc
10950 stat $DIR/$tdir > /dev/null
10951 can1=$(do_facet $SINGLEMDS \
10952 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10953 awk '/ldlm_cancel/ {print $2}')
10954 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10955 awk '/ldlm_bl_callback/ {print $2}')
10956 touch $DIR/$tdir/f1
10957 can2=$(do_facet $SINGLEMDS \
10958 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10959 awk '/ldlm_cancel/ {print $2}')
10960 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10961 awk '/ldlm_bl_callback/ {print $2}')
10962 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10963 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10964 lru_resize_enable mdc
10965 lru_resize_enable osc
10967 run_test 120b "Early Lock Cancel: create test"
10970 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10971 remote_mds_nodsh && skip "remote MDS with nodsh"
10972 test_mkdir -i0 -c1 $DIR/$tdir
10973 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10974 skip "no early lock cancel on server"
10976 lru_resize_disable mdc
10977 lru_resize_disable osc
10978 test_mkdir -i0 -c1 $DIR/$tdir/d1
10979 test_mkdir -i0 -c1 $DIR/$tdir/d2
10980 touch $DIR/$tdir/d1/f1
10981 cancel_lru_locks mdc
10982 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
10983 can1=$(do_facet mds1 \
10984 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10985 awk '/ldlm_cancel/ {print $2}')
10986 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10987 awk '/ldlm_bl_callback/ {print $2}')
10988 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10989 can2=$(do_facet mds1 \
10990 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10991 awk '/ldlm_cancel/ {print $2}')
10992 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10993 awk '/ldlm_bl_callback/ {print $2}')
10994 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10995 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10996 lru_resize_enable mdc
10997 lru_resize_enable osc
10999 run_test 120c "Early Lock Cancel: link test"
11002 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11003 remote_mds_nodsh && skip "remote MDS with nodsh"
11004 test_mkdir -i0 -c1 $DIR/$tdir
11005 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11006 skip_env "no early lock cancel on server"
11008 lru_resize_disable mdc
11009 lru_resize_disable osc
11011 cancel_lru_locks mdc
11012 stat $DIR/$tdir > /dev/null
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 chmod a+x $DIR/$tdir
11019 can2=$(do_facet mds1 \
11020 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11021 awk '/ldlm_cancel/ {print $2}')
11022 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11023 awk '/ldlm_bl_callback/ {print $2}')
11024 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11025 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11026 lru_resize_enable mdc
11027 lru_resize_enable osc
11029 run_test 120d "Early Lock Cancel: setattr test"
11032 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11033 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11034 skip_env "no early lock cancel on server"
11035 remote_mds_nodsh && skip "remote MDS with nodsh"
11037 local dlmtrace_set=false
11039 test_mkdir -i0 -c1 $DIR/$tdir
11040 lru_resize_disable mdc
11041 lru_resize_disable osc
11042 ! $LCTL get_param debug | grep -q dlmtrace &&
11043 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
11044 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
11045 cancel_lru_locks mdc
11046 cancel_lru_locks osc
11047 dd if=$DIR/$tdir/f1 of=/dev/null
11048 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
11049 # XXX client can not do early lock cancel of OST lock
11050 # during unlink (LU-4206), so cancel osc lock now.
11052 cancel_lru_locks osc
11053 can1=$(do_facet mds1 \
11054 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11055 awk '/ldlm_cancel/ {print $2}')
11056 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11057 awk '/ldlm_bl_callback/ {print $2}')
11058 unlink $DIR/$tdir/f1
11060 can2=$(do_facet mds1 \
11061 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11062 awk '/ldlm_cancel/ {print $2}')
11063 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11064 awk '/ldlm_bl_callback/ {print $2}')
11065 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
11066 $LCTL dk $TMP/cancel.debug.txt
11067 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
11068 $LCTL dk $TMP/blocking.debug.txt
11069 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
11070 lru_resize_enable mdc
11071 lru_resize_enable osc
11073 run_test 120e "Early Lock Cancel: unlink test"
11076 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11077 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11078 skip_env "no early lock cancel on server"
11079 remote_mds_nodsh && skip "remote MDS with nodsh"
11081 test_mkdir -i0 -c1 $DIR/$tdir
11082 lru_resize_disable mdc
11083 lru_resize_disable osc
11084 test_mkdir -i0 -c1 $DIR/$tdir/d1
11085 test_mkdir -i0 -c1 $DIR/$tdir/d2
11086 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
11087 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
11088 cancel_lru_locks mdc
11089 cancel_lru_locks osc
11090 dd if=$DIR/$tdir/d1/f1 of=/dev/null
11091 dd if=$DIR/$tdir/d2/f2 of=/dev/null
11092 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
11093 # XXX client can not do early lock cancel of OST lock
11094 # during rename (LU-4206), so cancel osc lock now.
11096 cancel_lru_locks osc
11097 can1=$(do_facet mds1 \
11098 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11099 awk '/ldlm_cancel/ {print $2}')
11100 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11101 awk '/ldlm_bl_callback/ {print $2}')
11102 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
11104 can2=$(do_facet mds1 \
11105 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11106 awk '/ldlm_cancel/ {print $2}')
11107 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11108 awk '/ldlm_bl_callback/ {print $2}')
11109 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11110 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11111 lru_resize_enable mdc
11112 lru_resize_enable osc
11114 run_test 120f "Early Lock Cancel: rename test"
11117 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11118 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11119 skip_env "no early lock cancel on server"
11120 remote_mds_nodsh && skip "remote MDS with nodsh"
11122 lru_resize_disable mdc
11123 lru_resize_disable osc
11125 echo create $count files
11126 test_mkdir $DIR/$tdir
11127 cancel_lru_locks mdc
11128 cancel_lru_locks osc
11131 can0=$(do_facet $SINGLEMDS \
11132 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11133 awk '/ldlm_cancel/ {print $2}')
11134 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11135 awk '/ldlm_bl_callback/ {print $2}')
11136 createmany -o $DIR/$tdir/f $count
11138 can1=$(do_facet $SINGLEMDS \
11139 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11140 awk '/ldlm_cancel/ {print $2}')
11141 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11142 awk '/ldlm_bl_callback/ {print $2}')
11144 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
11145 echo rm $count files
11148 can2=$(do_facet $SINGLEMDS \
11149 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11150 awk '/ldlm_cancel/ {print $2}')
11151 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11152 awk '/ldlm_bl_callback/ {print $2}')
11154 echo total: $count removes in $((t2-t1))
11155 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
11157 # wait for commitment of removal
11158 lru_resize_enable mdc
11159 lru_resize_enable osc
11161 run_test 120g "Early Lock Cancel: performance test"
11163 test_121() { #bug #10589
11164 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11167 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
11168 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
11169 lctl set_param fail_loc=0x310
11170 cancel_lru_locks osc > /dev/null
11171 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
11172 lctl set_param fail_loc=0
11173 [[ $reads -eq $writes ]] ||
11174 error "read $reads blocks, must be $writes blocks"
11176 run_test 121 "read cancel race ========="
11178 test_123a() { # was test 123, statahead(bug 11401)
11179 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11182 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
11183 log "testing UP system. Performance may be lower than expected."
11188 test_mkdir $DIR/$tdir
11189 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
11190 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
11192 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
11193 createmany -o $DIR/$tdir/$tfile $j $((i - j))
11195 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
11196 lctl set_param -n llite.*.statahead_max 0
11197 lctl get_param llite.*.statahead_max
11198 cancel_lru_locks mdc
11199 cancel_lru_locks osc
11201 time ls -l $DIR/$tdir | wc -l
11203 delta=$((etime - stime))
11204 log "ls $i files without statahead: $delta sec"
11205 lctl set_param llite.*.statahead_max=$max
11207 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
11208 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
11209 cancel_lru_locks mdc
11210 cancel_lru_locks osc
11212 time ls -l $DIR/$tdir | wc -l
11214 delta_sa=$((etime - stime))
11215 log "ls $i files with statahead: $delta_sa sec"
11216 lctl get_param -n llite.*.statahead_stats
11217 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
11219 [[ $swrong -lt $ewrong ]] &&
11220 log "statahead was stopped, maybe too many locks held!"
11221 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
11223 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
11224 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
11225 lctl set_param -n llite.*.statahead_max 0
11226 lctl get_param llite.*.statahead_max
11227 cancel_lru_locks mdc
11228 cancel_lru_locks osc
11230 time ls -l $DIR/$tdir | wc -l
11232 delta=$((etime - stime))
11233 log "ls $i files again without statahead: $delta sec"
11234 lctl set_param llite.*.statahead_max=$max
11235 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
11236 if [ $SLOWOK -eq 0 ]; then
11237 error "ls $i files is slower with statahead!"
11239 log "ls $i files is slower with statahead!"
11245 [ $delta -gt 20 ] && break
11246 [ $delta -gt 8 ] && MULT=$((50 / delta))
11247 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
11255 delta=$((etime - stime))
11256 log "rm -r $DIR/$tdir/: $delta seconds"
11258 lctl get_param -n llite.*.statahead_stats
11260 run_test 123a "verify statahead work"
11262 test_123b () { # statahead(bug 15027)
11263 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11265 test_mkdir $DIR/$tdir
11266 createmany -o $DIR/$tdir/$tfile-%d 1000
11268 cancel_lru_locks mdc
11269 cancel_lru_locks osc
11271 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
11272 lctl set_param fail_loc=0x80000803
11273 ls -lR $DIR/$tdir > /dev/null
11275 lctl set_param fail_loc=0x0
11276 lctl get_param -n llite.*.statahead_stats
11281 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
11284 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
11286 test_mkdir -i 0 -c 1 $DIR/$tdir.0
11287 test_mkdir -i 1 -c 1 $DIR/$tdir.1
11288 touch $DIR/$tdir.1/{1..3}
11289 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
11291 remount_client $MOUNT
11293 $MULTIOP $DIR/$tdir.0 Q
11295 # let statahead to complete
11296 ls -l $DIR/$tdir.0 > /dev/null
11298 testid=$(echo $TESTNAME | tr '_' ' ')
11299 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
11300 error "statahead warning" || true
11302 run_test 123c "Can not initialize inode warning on DNE statahead"
11305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11306 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11307 skip_env "no lru resize on server"
11311 test_mkdir $DIR/$tdir
11313 log "create $NR files at $DIR/$tdir"
11314 createmany -o $DIR/$tdir/f $NR ||
11315 error "failed to create $NR files in $DIR/$tdir"
11317 cancel_lru_locks mdc
11318 ls -l $DIR/$tdir > /dev/null
11322 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
11323 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
11324 LRU_SIZE=$($LCTL get_param -n $PARAM)
11325 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
11326 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
11328 log "NS=$(basename $NSDIR)"
11333 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
11334 skip "Not enough cached locks created!"
11336 log "LRU=$LRU_SIZE"
11340 # We know that lru resize allows one client to hold $LIMIT locks
11341 # for 10h. After that locks begin to be killed by client.
11343 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
11345 if [ $LIMIT -lt $LRU_SIZE ]; then
11346 skip "Limit is too small $LIMIT"
11349 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
11350 # killing locks. Some time was spent for creating locks. This means
11351 # that up to the moment of sleep finish we must have killed some of
11352 # them (10-100 locks). This depends on how fast ther were created.
11353 # Many of them were touched in almost the same moment and thus will
11354 # be killed in groups.
11355 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
11357 # Use $LRU_SIZE_B here to take into account real number of locks
11358 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
11359 local LRU_SIZE_B=$LRU_SIZE
11361 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
11362 log "OLD_LVF=$OLD_LVF"
11363 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
11365 # Let's make sure that we really have some margin. Client checks
11366 # cached locks every 10 sec.
11367 SLEEP=$((SLEEP+20))
11368 log "Sleep ${SLEEP} sec"
11370 while ((SEC<$SLEEP)); do
11374 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
11375 echo -n "$LRU_SIZE"
11378 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
11379 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
11381 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
11382 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
11383 unlinkmany $DIR/$tdir/f $NR
11387 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
11388 log "unlink $NR files at $DIR/$tdir"
11389 unlinkmany $DIR/$tdir/f $NR
11391 run_test 124a "lru resize ======================================="
11393 get_max_pool_limit()
11395 local limit=$($LCTL get_param \
11396 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
11398 for l in $limit; do
11399 if [[ $l -gt $max ]]; then
11407 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11408 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11409 skip_env "no lru resize on server"
11411 LIMIT=$(get_max_pool_limit)
11413 NR=$(($(default_lru_size)*20))
11414 if [[ $NR -gt $LIMIT ]]; then
11415 log "Limit lock number by $LIMIT locks"
11419 IFree=$(mdsrate_inodes_available)
11420 if [ $IFree -lt $NR ]; then
11421 log "Limit lock number by $IFree inodes"
11425 lru_resize_disable mdc
11426 test_mkdir -p $DIR/$tdir/disable_lru_resize
11428 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
11429 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
11430 cancel_lru_locks mdc
11433 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11436 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11439 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11443 nolruresize_delta=$((etime-stime))
11444 log "ls -la time: $nolruresize_delta seconds"
11445 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11446 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
11448 lru_resize_enable mdc
11449 test_mkdir -p $DIR/$tdir/enable_lru_resize
11451 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
11452 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
11453 cancel_lru_locks mdc
11456 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11459 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11462 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11466 lruresize_delta=$((etime-stime))
11467 log "ls -la time: $lruresize_delta seconds"
11468 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11470 if [ $lruresize_delta -gt $nolruresize_delta ]; then
11471 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
11472 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
11473 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
11475 log "lru resize performs the same with no lru resize"
11477 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
11479 run_test 124b "lru resize (performance test) ======================="
11482 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11483 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11484 skip_env "no lru resize on server"
11486 # cache ununsed locks on client
11488 cancel_lru_locks mdc
11489 test_mkdir $DIR/$tdir
11490 createmany -o $DIR/$tdir/f $nr ||
11491 error "failed to create $nr files in $DIR/$tdir"
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)
11498 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11500 # set lru_max_age to 1 sec
11501 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11502 echo "sleep $((recalc_p * 2)) seconds..."
11503 sleep $((recalc_p * 2))
11505 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11506 # restore lru_max_age
11507 $LCTL set_param -n $nsdir.lru_max_age $max_age
11508 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11509 unlinkmany $DIR/$tdir/f $nr
11511 run_test 124c "LRUR cancel very aged locks"
11514 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11515 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11516 skip_env "no lru resize on server"
11518 # cache ununsed locks on client
11521 lru_resize_disable mdc
11522 stack_trap "lru_resize_enable mdc" EXIT
11524 cancel_lru_locks mdc
11526 # asynchronous object destroy at MDT could cause bl ast to client
11527 test_mkdir $DIR/$tdir
11528 createmany -o $DIR/$tdir/f $nr ||
11529 error "failed to create $nr files in $DIR/$tdir"
11530 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
11532 ls -l $DIR/$tdir > /dev/null
11534 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11535 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11536 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11537 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11539 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11541 # set lru_max_age to 1 sec
11542 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11543 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
11545 echo "sleep $((recalc_p * 2)) seconds..."
11546 sleep $((recalc_p * 2))
11548 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11550 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11552 run_test 124d "cancel very aged locks if lru-resize diasbaled"
11554 test_125() { # 13358
11555 $LCTL get_param -n llite.*.client_type | grep -q local ||
11556 skip "must run as local client"
11557 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
11558 skip_env "must have acl enabled"
11559 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11561 test_mkdir $DIR/$tdir
11562 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
11563 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
11564 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
11566 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
11568 test_126() { # bug 12829/13455
11569 $GSS && skip_env "must run as gss disabled"
11570 $LCTL get_param -n llite.*.client_type | grep -q local ||
11571 skip "must run as local client"
11572 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
11574 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
11575 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
11577 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
11579 run_test 126 "check that the fsgid provided by the client is taken into account"
11581 test_127a() { # bug 15521
11582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11583 local name count samp unit min max sum sumsq
11585 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
11586 echo "stats before reset"
11587 $LCTL get_param osc.*.stats
11588 $LCTL set_param osc.*.stats=0
11589 local fsize=$((2048 * 1024))
11591 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
11592 cancel_lru_locks osc
11593 dd if=$DIR/$tfile of=/dev/null bs=$fsize
11595 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
11596 stack_trap "rm -f $TMP/$tfile.tmp"
11597 while read name count samp unit min max sum sumsq; do
11598 echo "got name=$name count=$count unit=$unit min=$min max=$max"
11599 [ ! $min ] && error "Missing min value for $name proc entry"
11600 eval $name=$count || error "Wrong proc format"
11603 read_bytes|write_bytes)
11604 [[ "$unit" =~ "bytes" ]] ||
11605 error "unit is not 'bytes': $unit"
11606 (( $min >= 4096 )) || error "min is too small: $min"
11607 (( $min <= $fsize )) || error "min is too big: $min"
11608 (( $max >= 4096 )) || error "max is too small: $max"
11609 (( $max <= $fsize )) || error "max is too big: $max"
11610 (( $sum == $fsize )) || error "sum is wrong: $sum"
11611 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
11612 error "sumsquare is too small: $sumsq"
11613 (( $sumsq <= $fsize * $fsize )) ||
11614 error "sumsquare is too big: $sumsq"
11616 ost_read|ost_write)
11617 [[ "$unit" =~ "usec" ]] ||
11618 error "unit is not 'usec': $unit"
11622 done < $DIR/$tfile.tmp
11624 #check that we actually got some stats
11625 [ "$read_bytes" ] || error "Missing read_bytes stats"
11626 [ "$write_bytes" ] || error "Missing write_bytes stats"
11627 [ "$read_bytes" != 0 ] || error "no read done"
11628 [ "$write_bytes" != 0 ] || error "no write done"
11630 run_test 127a "verify the client stats are sane"
11632 test_127b() { # bug LU-333
11633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11634 local name count samp unit min max sum sumsq
11636 echo "stats before reset"
11637 $LCTL get_param llite.*.stats
11638 $LCTL set_param llite.*.stats=0
11640 # perform 2 reads and writes so MAX is different from SUM.
11641 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11642 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11643 cancel_lru_locks osc
11644 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11645 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11647 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
11648 stack_trap "rm -f $TMP/$tfile.tmp"
11649 while read name count samp unit min max sum sumsq; do
11650 echo "got name=$name count=$count unit=$unit min=$min max=$max"
11651 eval $name=$count || error "Wrong proc format"
11654 read_bytes|write_bytes)
11655 [[ "$unit" =~ "bytes" ]] ||
11656 error "unit is not 'bytes': $unit"
11657 (( $count == 2 )) || error "count is not 2: $count"
11658 (( $min == $PAGE_SIZE )) ||
11659 error "min is not $PAGE_SIZE: $min"
11660 (( $max == $PAGE_SIZE )) ||
11661 error "max is not $PAGE_SIZE: $max"
11662 (( $sum == $PAGE_SIZE * 2 )) ||
11663 error "sum is not $((PAGE_SIZE * 2)): $sum"
11666 [[ "$unit" =~ "usec" ]] ||
11667 error "unit is not 'usec': $unit"
11671 done < $TMP/$tfile.tmp
11673 #check that we actually got some stats
11674 [ "$read_bytes" ] || error "Missing read_bytes stats"
11675 [ "$write_bytes" ] || error "Missing write_bytes stats"
11676 [ "$read_bytes" != 0 ] || error "no read done"
11677 [ "$write_bytes" != 0 ] || error "no write done"
11679 run_test 127b "verify the llite client stats are sane"
11681 test_127c() { # LU-12394
11682 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11689 $LCTL set_param llite.*.extents_stats=1
11690 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
11692 # Use two stripes so there is enough space in default config
11693 $LFS setstripe -c 2 $DIR/$tfile
11695 # Extent stats start at 0-4K and go in power of two buckets
11696 # LL_HIST_START = 12 --> 2^12 = 4K
11697 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
11698 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
11700 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
11702 # Write and read, 2x each, second time at a non-zero offset
11703 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
11704 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
11705 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
11706 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
11710 $LCTL get_param llite.*.extents_stats
11713 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
11715 local bucket=$($LCTL get_param -n llite.*.extents_stats |
11717 reads=$(echo $bucket | awk '{print $5}')
11718 writes=$(echo $bucket | awk '{print $9}')
11719 [ "$reads" -eq $count ] ||
11720 error "$reads reads in < $bsize bucket, expect $count"
11721 [ "$writes" -eq $count ] ||
11722 error "$writes writes in < $bsize bucket, expect $count"
11725 # Test mmap write and read
11726 $LCTL set_param llite.*.extents_stats=c
11728 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
11729 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
11730 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
11732 $LCTL get_param llite.*.extents_stats
11734 count=$(((size*1024) / PAGE_SIZE))
11736 bsize=$((2 * PAGE_SIZE / 1024))K
11738 bucket=$($LCTL get_param -n llite.*.extents_stats |
11740 reads=$(echo $bucket | awk '{print $5}')
11741 writes=$(echo $bucket | awk '{print $9}')
11742 # mmap writes fault in the page first, creating an additonal read
11743 [ "$reads" -eq $((2 * count)) ] ||
11744 error "$reads reads in < $bsize bucket, expect $count"
11745 [ "$writes" -eq $count ] ||
11746 error "$writes writes in < $bsize bucket, expect $count"
11748 run_test 127c "test llite extent stats with regular & mmap i/o"
11750 test_128() { # bug 15212
11752 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
11757 result=$(grep error $TMP/$tfile.log)
11758 rm -f $DIR/$tfile $TMP/$tfile.log
11759 [ -z "$result" ] ||
11760 error "consecutive find's under interactive lfs failed"
11762 run_test 128 "interactive lfs for 2 consecutive find's"
11764 set_dir_limits () {
11769 local ldproc=/proc/fs/ldiskfs
11770 local facets=$(get_facets MDS)
11772 for facet in ${facets//,/ }; do
11773 canondev=$(ldiskfs_canon \
11774 *.$(convert_facet2label $facet).mntdev $facet)
11775 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
11776 ldproc=/sys/fs/ldiskfs
11777 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
11778 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
11782 check_mds_dmesg() {
11783 local facets=$(get_facets MDS)
11784 for facet in ${facets//,/ }; do
11785 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
11791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11792 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
11793 skip "Need MDS version with at least 2.5.56"
11794 if [ "$mds1_FSTYPE" != ldiskfs ]; then
11795 skip_env "ldiskfs only test"
11797 remote_mds_nodsh && skip "remote MDS with nodsh"
11801 local has_warning=false
11804 mkdir -p $DIR/$tdir
11806 # block size of mds1
11807 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
11808 set_dir_limits $maxsize $maxsize
11809 local dirsize=$(stat -c%s "$DIR/$tdir")
11811 while [[ $dirsize -le $maxsize ]]; do
11812 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
11814 if ! $has_warning; then
11815 check_mds_dmesg '"is approaching"' && has_warning=true
11817 # check two errors:
11818 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
11819 # EFBIG for previous versions included in ldiskfs series
11820 if [ $rc -eq $EFBIG ] || [ $rc -eq $ENOSPC ]; then
11822 echo "return code $rc received as expected"
11824 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
11825 error_exit "create failed w/o dir size limit"
11827 check_mds_dmesg '"has reached"' ||
11828 error_exit "reached message should be output"
11830 [ $has_warning = "false" ] &&
11831 error_exit "warning message should be output"
11833 dirsize=$(stat -c%s "$DIR/$tdir")
11835 [[ $dirsize -ge $maxsize ]] && return 0
11836 error_exit "current dir size $dirsize, " \
11837 "previous limit $maxsize"
11838 elif [ $rc -ne 0 ]; then
11840 error_exit "return $rc received instead of expected " \
11841 "$EFBIG or $ENOSPC, files in dir $dirsize"
11843 nfiles=$((nfiles + 1))
11844 dirsize=$(stat -c%s "$DIR/$tdir")
11848 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
11850 run_test 129 "test directory size limit ========================"
11859 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11860 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11862 trap cleanup_130 EXIT RETURN
11864 local fm_file=$DIR/$tfile
11865 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
11866 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
11867 error "dd failed for $fm_file"
11869 # LU-1795: test filefrag/FIEMAP once, even if unsupported
11870 filefrag -ves $fm_file
11872 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11873 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11874 [ $RC != 0 ] && error "filefrag $fm_file failed"
11876 filefrag_op=$(filefrag -ve -k $fm_file |
11877 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11878 lun=$($LFS getstripe -i $fm_file)
11880 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
11883 for line in $filefrag_op
11885 frag_lun=`echo $line | cut -d: -f5`
11886 ext_len=`echo $line | cut -d: -f4`
11887 if (( $frag_lun != $lun )); then
11889 error "FIEMAP on 1-stripe file($fm_file) failed"
11892 (( tot_len += ext_len ))
11895 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
11897 error "FIEMAP on 1-stripe file($fm_file) failed;"
11903 echo "FIEMAP on single striped file succeeded"
11905 run_test 130a "FIEMAP (1-stripe file)"
11908 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11910 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11911 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11913 trap cleanup_130 EXIT RETURN
11915 local fm_file=$DIR/$tfile
11916 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
11917 error "setstripe on $fm_file"
11918 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11919 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11921 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
11922 error "dd failed on $fm_file"
11924 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11925 filefrag_op=$(filefrag -ve -k $fm_file |
11926 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11928 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11929 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11934 for line in $filefrag_op
11936 frag_lun=$(echo $line | cut -d: -f5 |
11937 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11938 ext_len=$(echo $line | cut -d: -f4)
11939 if (( $frag_lun != $last_lun )); then
11940 if (( tot_len != 1024 )); then
11942 error "FIEMAP on $fm_file failed; returned " \
11943 "len $tot_len for OST $last_lun instead of 1024"
11946 (( num_luns += 1 ))
11950 (( tot_len += ext_len ))
11953 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
11955 error "FIEMAP on $fm_file failed; returned wrong number of " \
11956 "luns or wrong len for OST $last_lun"
11962 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
11964 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
11967 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11969 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11970 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11972 trap cleanup_130 EXIT RETURN
11974 local fm_file=$DIR/$tfile
11975 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
11976 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
11977 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11979 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
11980 error "dd failed on $fm_file"
11982 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11983 filefrag_op=$(filefrag -ve -k $fm_file |
11984 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11986 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11987 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11992 for line in $filefrag_op
11994 frag_lun=$(echo $line | cut -d: -f5 |
11995 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11996 ext_len=$(echo $line | cut -d: -f4)
11997 if (( $frag_lun != $last_lun )); then
11998 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
11999 if (( logical != 512 )); then
12001 error "FIEMAP on $fm_file failed; returned " \
12002 "logical start for lun $logical instead of 512"
12005 if (( tot_len != 512 )); then
12007 error "FIEMAP on $fm_file failed; returned " \
12008 "len $tot_len for OST $last_lun instead of 1024"
12011 (( num_luns += 1 ))
12015 (( tot_len += ext_len ))
12018 if (( num_luns != 2 || tot_len != 512 )); then
12020 error "FIEMAP on $fm_file failed; returned wrong number of " \
12021 "luns or wrong len for OST $last_lun"
12027 echo "FIEMAP on 2-stripe file with hole succeeded"
12029 run_test 130c "FIEMAP (2-stripe file with hole)"
12032 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
12034 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12035 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12037 trap cleanup_130 EXIT RETURN
12039 local fm_file=$DIR/$tfile
12040 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
12041 error "setstripe on $fm_file"
12042 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12043 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12045 local actual_stripe_count=$($LFS getstripe -c $fm_file)
12046 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
12047 error "dd failed on $fm_file"
12049 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12050 filefrag_op=$(filefrag -ve -k $fm_file |
12051 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12053 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12054 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12059 for line in $filefrag_op
12061 frag_lun=$(echo $line | cut -d: -f5 |
12062 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12063 ext_len=$(echo $line | cut -d: -f4)
12064 if (( $frag_lun != $last_lun )); then
12065 if (( tot_len != 1024 )); then
12067 error "FIEMAP on $fm_file failed; returned " \
12068 "len $tot_len for OST $last_lun instead of 1024"
12071 (( num_luns += 1 ))
12075 (( tot_len += ext_len ))
12078 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
12080 error "FIEMAP on $fm_file failed; returned wrong number of " \
12081 "luns or wrong len for OST $last_lun"
12087 echo "FIEMAP on N-stripe file succeeded"
12089 run_test 130d "FIEMAP (N-stripe file)"
12092 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12094 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12095 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12097 trap cleanup_130 EXIT RETURN
12099 local fm_file=$DIR/$tfile
12100 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
12101 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12102 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12105 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
12106 for ((i = 0; i < $NUM_BLKS; i++))
12108 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
12111 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12112 filefrag_op=$(filefrag -ve -k $fm_file |
12113 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12115 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12116 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12121 for line in $filefrag_op
12123 frag_lun=$(echo $line | cut -d: -f5 |
12124 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12125 ext_len=$(echo $line | cut -d: -f4)
12126 if (( $frag_lun != $last_lun )); then
12127 if (( tot_len != $EXPECTED_LEN )); then
12129 error "FIEMAP on $fm_file failed; returned " \
12130 "len $tot_len for OST $last_lun instead " \
12134 (( num_luns += 1 ))
12138 (( tot_len += ext_len ))
12141 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
12143 error "FIEMAP on $fm_file failed; returned wrong number " \
12144 "of luns or wrong len for OST $last_lun"
12150 echo "FIEMAP with continuation calls succeeded"
12152 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
12155 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12156 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12158 local fm_file=$DIR/$tfile
12159 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
12160 error "multiop create with lov_delay_create on $fm_file"
12162 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12163 filefrag_extents=$(filefrag -vek $fm_file |
12164 awk '/extents? found/ { print $2 }')
12165 if [[ "$filefrag_extents" != "0" ]]; then
12166 error "FIEMAP on $fm_file failed; " \
12167 "returned $filefrag_extents expected 0"
12172 run_test 130f "FIEMAP (unstriped file)"
12174 # Test for writev/readv
12176 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
12177 error "writev test failed"
12178 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
12179 error "readv failed"
12182 run_test 131a "test iov's crossing stripe boundary for writev/readv"
12185 local fsize=$((524288 + 1048576 + 1572864))
12186 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
12187 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
12188 error "append writev test failed"
12190 ((fsize += 1572864 + 1048576))
12191 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
12192 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
12193 error "append writev test failed"
12196 run_test 131b "test append writev"
12199 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
12202 run_test 131c "test read/write on file w/o objects"
12205 rwv -f $DIR/$tfile -w -n 1 1572864
12206 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
12207 if [ "$NOB" != 1572864 ]; then
12208 error "Short read filed: read $NOB bytes instead of 1572864"
12212 run_test 131d "test short read"
12215 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
12216 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
12217 error "read hitting hole failed"
12220 run_test 131e "test read hitting hole"
12229 mds*) res=$(do_facet $facet \
12230 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
12232 ost*) res=$(do_facet $facet \
12233 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
12235 *) error "Wrong facet '$facet'" ;;
12237 [ "$res" ] || error "The counter for $op on $facet was not incremented"
12238 # if the argument $3 is zero, it means any stat increment is ok.
12239 if [[ $want -gt 0 ]]; then
12240 local count=$(echo $res | awk '{ print $2 }')
12241 [[ $count -ne $want ]] &&
12242 error "The $op counter on $facet is $count, not $want"
12247 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12248 remote_ost_nodsh && skip "remote OST with nodsh"
12249 remote_mds_nodsh && skip "remote MDS with nodsh"
12250 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12251 skip_env "MDS doesn't support rename stats"
12253 local testdir=$DIR/${tdir}/stats_testdir
12255 mkdir -p $DIR/${tdir}
12258 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12259 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12261 # verify mdt stats first.
12262 mkdir ${testdir} || error "mkdir failed"
12263 check_stats $SINGLEMDS "mkdir" 1
12264 touch ${testdir}/${tfile} || error "touch failed"
12265 check_stats $SINGLEMDS "open" 1
12266 check_stats $SINGLEMDS "close" 1
12267 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
12268 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
12269 check_stats $SINGLEMDS "mknod" 2
12271 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
12272 check_stats $SINGLEMDS "unlink" 1
12273 rm -f ${testdir}/${tfile} || error "file remove failed"
12274 check_stats $SINGLEMDS "unlink" 2
12276 # remove working dir and check mdt stats again.
12277 rmdir ${testdir} || error "rmdir failed"
12278 check_stats $SINGLEMDS "rmdir" 1
12280 local testdir1=$DIR/${tdir}/stats_testdir1
12281 mkdir -p ${testdir}
12282 mkdir -p ${testdir1}
12283 touch ${testdir1}/test1
12284 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
12285 check_stats $SINGLEMDS "crossdir_rename" 1
12287 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
12288 check_stats $SINGLEMDS "samedir_rename" 1
12290 rm -rf $DIR/${tdir}
12292 run_test 133a "Verifying MDT stats ========================================"
12297 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12298 remote_ost_nodsh && skip "remote OST with nodsh"
12299 remote_mds_nodsh && skip "remote MDS with nodsh"
12301 local testdir=$DIR/${tdir}/stats_testdir
12303 mkdir -p ${testdir} || error "mkdir failed"
12304 touch ${testdir}/${tfile} || error "touch failed"
12305 cancel_lru_locks mdc
12308 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12309 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12311 # extra mdt stats verification.
12312 chmod 444 ${testdir}/${tfile} || error "chmod failed"
12313 check_stats $SINGLEMDS "setattr" 1
12314 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12315 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
12317 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
12318 check_stats $SINGLEMDS "getattr" 1
12320 rm -rf $DIR/${tdir}
12322 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
12323 # so the check below is not reliable
12324 [ $MDSCOUNT -eq 1 ] || return 0
12326 # Sleep to avoid a cached response.
12327 #define OBD_STATFS_CACHE_SECONDS 1
12329 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12330 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12331 $LFS df || error "lfs failed"
12332 check_stats $SINGLEMDS "statfs" 1
12334 # check aggregated statfs (LU-10018)
12335 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
12337 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
12340 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12341 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12343 check_stats $SINGLEMDS "statfs" 1
12345 # We want to check that the client didn't send OST_STATFS to
12346 # ost1 but the MDT also uses OST_STATFS for precreate. So some
12347 # extra care is needed here.
12348 if remote_mds; then
12349 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
12350 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
12352 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
12353 [ "$res" ] && error "OST got STATFS"
12358 run_test 133b "Verifying extra MDT stats =================================="
12361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12362 remote_ost_nodsh && skip "remote OST with nodsh"
12363 remote_mds_nodsh && skip "remote MDS with nodsh"
12365 local testdir=$DIR/$tdir/stats_testdir
12367 test_mkdir -p $testdir
12369 # verify obdfilter stats.
12370 $LFS setstripe -c 1 -i 0 $testdir/$tfile
12372 cancel_lru_locks osc
12373 wait_delete_completed
12376 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12377 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12379 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
12382 cancel_lru_locks osc
12383 check_stats ost1 "write" 1
12385 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
12386 check_stats ost1 "read" 1
12388 > $testdir/$tfile || error "truncate failed"
12389 check_stats ost1 "punch" 1
12391 rm -f $testdir/$tfile || error "file remove failed"
12392 wait_delete_completed
12393 check_stats ost1 "destroy" 1
12397 run_test 133c "Verifying OST stats ========================================"
12404 while [ $value -ge 2 ]; do
12409 if [ $orig -gt $order ]; then
12417 local size=('K' 'M' 'G' 'T');
12419 local size_string=$value
12421 while [ $value -ge 1024 ]; do
12422 if [ $i -gt 3 ]; then
12423 #T is the biggest unit we get here, if that is bigger,
12425 size_string=${value}T
12428 value=$((value >> 10))
12429 if [ $value -lt 1024 ]; then
12430 size_string=${value}${size[$i]}
12439 get_rename_size() {
12441 local context=${2:-.}
12442 local sample=$(do_facet $SINGLEMDS $LCTL \
12443 get_param mdt.$FSNAME-MDT0000.rename_stats |
12444 grep -A1 $context |
12445 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
12450 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12451 remote_ost_nodsh && skip "remote OST with nodsh"
12452 remote_mds_nodsh && skip "remote MDS with nodsh"
12453 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12454 skip_env "MDS doesn't support rename stats"
12456 local testdir1=$DIR/${tdir}/stats_testdir1
12457 local testdir2=$DIR/${tdir}/stats_testdir2
12458 mkdir -p $DIR/${tdir}
12460 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12462 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
12463 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
12465 createmany -o $testdir1/test 512 || error "createmany failed"
12467 # check samedir rename size
12468 mv ${testdir1}/test0 ${testdir1}/test_0
12470 local testdir1_size=$(ls -l $DIR/${tdir} |
12471 awk '/stats_testdir1/ {print $5}')
12472 local testdir2_size=$(ls -l $DIR/${tdir} |
12473 awk '/stats_testdir2/ {print $5}')
12475 testdir1_size=$(order_2 $testdir1_size)
12476 testdir2_size=$(order_2 $testdir2_size)
12478 testdir1_size=$(size_in_KMGT $testdir1_size)
12479 testdir2_size=$(size_in_KMGT $testdir2_size)
12481 echo "source rename dir size: ${testdir1_size}"
12482 echo "target rename dir size: ${testdir2_size}"
12484 local cmd="do_facet $SINGLEMDS $LCTL "
12485 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
12487 eval $cmd || error "$cmd failed"
12488 local samedir=$($cmd | grep 'same_dir')
12489 local same_sample=$(get_rename_size $testdir1_size)
12490 [ -z "$samedir" ] && error "samedir_rename_size count error"
12491 [[ $same_sample -eq 1 ]] ||
12492 error "samedir_rename_size error $same_sample"
12493 echo "Check same dir rename stats success"
12495 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12497 # check crossdir rename size
12498 mv ${testdir1}/test_0 ${testdir2}/test_0
12500 testdir1_size=$(ls -l $DIR/${tdir} |
12501 awk '/stats_testdir1/ {print $5}')
12502 testdir2_size=$(ls -l $DIR/${tdir} |
12503 awk '/stats_testdir2/ {print $5}')
12505 testdir1_size=$(order_2 $testdir1_size)
12506 testdir2_size=$(order_2 $testdir2_size)
12508 testdir1_size=$(size_in_KMGT $testdir1_size)
12509 testdir2_size=$(size_in_KMGT $testdir2_size)
12511 echo "source rename dir size: ${testdir1_size}"
12512 echo "target rename dir size: ${testdir2_size}"
12514 eval $cmd || error "$cmd failed"
12515 local crossdir=$($cmd | grep 'crossdir')
12516 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
12517 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
12518 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
12519 [[ $src_sample -eq 1 ]] ||
12520 error "crossdir_rename_size error $src_sample"
12521 [[ $tgt_sample -eq 1 ]] ||
12522 error "crossdir_rename_size error $tgt_sample"
12523 echo "Check cross dir rename stats success"
12524 rm -rf $DIR/${tdir}
12526 run_test 133d "Verifying rename_stats ========================================"
12529 remote_mds_nodsh && skip "remote MDS with nodsh"
12530 remote_ost_nodsh && skip "remote OST with nodsh"
12531 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12533 local testdir=$DIR/${tdir}/stats_testdir
12534 local ctr f0 f1 bs=32768 count=42 sum
12536 mkdir -p ${testdir} || error "mkdir failed"
12538 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
12540 for ctr in {write,read}_bytes; do
12542 cancel_lru_locks osc
12544 do_facet ost1 $LCTL set_param -n \
12545 "obdfilter.*.exports.clear=clear"
12547 if [ $ctr = write_bytes ]; then
12549 f1=${testdir}/${tfile}
12551 f0=${testdir}/${tfile}
12555 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
12558 cancel_lru_locks osc
12560 sum=$(do_facet ost1 $LCTL get_param \
12561 "obdfilter.*.exports.*.stats" |
12562 awk -v ctr=$ctr 'BEGIN { sum = 0 }
12563 $1 == ctr { sum += $7 }
12564 END { printf("%0.0f", sum) }')
12566 if ((sum != bs * count)); then
12567 error "Bad $ctr sum, expected $((bs * count)), got $sum"
12571 rm -rf $DIR/${tdir}
12573 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
12575 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
12577 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
12578 # not honor the -ignore_readdir_race option correctly. So we call
12579 # error_ignore() rather than error() in these cases. See LU-11152.
12581 if (find --version; do_facet mds1 find --version) |
12582 grep -q '\b4\.5\.1[1-4]\b'; then
12583 error_ignore LU-11152 "$@"
12590 # First without trusting modes.
12591 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
12592 echo "proc_dirs='$proc_dirs'"
12593 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
12594 find $proc_dirs -exec cat '{}' \; &> /dev/null
12596 # Second verifying readability.
12597 $LCTL get_param -R '*' &> /dev/null
12599 # Verifing writability with badarea_io.
12601 -ignore_readdir_race \
12603 -not -name force_lbug \
12604 -not -name changelog_mask \
12605 -exec badarea_io '{}' \; ||
12606 error_133 "find $proc_dirs failed"
12608 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
12611 remote_mds_nodsh && skip "remote MDS with nodsh"
12612 remote_ost_nodsh && skip "remote OST with nodsh"
12615 for facet in mds1 ost1; do
12616 local facet_ver=$(lustre_version_code $facet)
12617 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
12618 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
12620 log "$facet: too old lustre for get_param -R"
12622 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
12623 do_facet $facet "$LCTL list_param -R '*' | grep '=' |
12624 tr -d= | egrep -v 'force_lbug|changelog_mask' |
12625 xargs badarea_io" ||
12626 error_133 "$facet badarea_io failed"
12628 skip_noexit "$facet: too old lustre for get_param -R"
12632 # remount the FS in case writes/reads /proc break the FS
12633 cleanup || error "failed to unmount"
12634 setup || error "failed to setup"
12637 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
12640 remote_mds_nodsh && skip "remote MDS with nodsh"
12641 remote_ost_nodsh && skip "remote OST with nodsh"
12642 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
12643 skip "Need MDS version at least 2.9.54"
12647 for facet in client mds1 ost1; do
12648 local facet_proc_dirs=$(do_facet $facet \
12649 \\\ls -d $proc_regexp 2> /dev/null)
12650 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
12651 echo "${facet}_proc_dirs='$facet_proc_dirs'"
12652 # Get the list of files that are missing the terminating newline
12653 local missing=($(do_facet $facet \
12654 find ${facet_proc_dirs} -type f \| \
12655 while read F\; do \
12656 awk -v FS='\v' -v RS='\v\v' \
12657 "'END { if(NR>0 && \
12658 \\\$NF !~ /.*\\\n\$/) \
12659 print FILENAME}'" \
12662 [ ${#missing[*]} -eq 0 ] ||
12663 error "files do not end with newline: ${missing[*]}"
12666 run_test 133h "Proc files should end with newlines"
12669 remote_mds_nodsh && skip "remote MDS with nodsh"
12670 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12671 skip "Need MDS version at least 2.7.54"
12673 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12674 cancel_lru_locks mdc
12676 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12677 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12678 [ $unused -eq 0 ] || error "$unused locks are not cleared"
12681 createmany -o $DIR/$tdir/f $nr ||
12682 error "failed to create $nr files in $DIR/$tdir"
12683 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12685 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
12686 do_facet mds1 $LCTL set_param fail_loc=0x327
12687 do_facet mds1 $LCTL set_param fail_val=500
12690 echo "sleep 10 seconds ..."
12692 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
12694 do_facet mds1 $LCTL set_param fail_loc=0
12695 do_facet mds1 $LCTL set_param fail_val=0
12696 [ $lck_cnt -lt $unused ] ||
12697 error "No locks reclaimed, before:$unused, after:$lck_cnt"
12700 unlinkmany $DIR/$tdir/f $nr
12702 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
12705 remote_mds_nodsh && skip "remote MDS with nodsh"
12706 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12707 skip "Need MDS version at least 2.7.54"
12709 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12710 cancel_lru_locks mdc
12712 local low_wm=$(do_facet mds1 $LCTL get_param -n \
12713 ldlm.lock_reclaim_threshold_mb)
12714 # disable reclaim temporarily
12715 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
12717 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
12718 do_facet mds1 $LCTL set_param fail_loc=0x328
12719 do_facet mds1 $LCTL set_param fail_val=500
12721 $LCTL set_param debug=+trace
12724 createmany -o $DIR/$tdir/f $nr &
12725 local create_pid=$!
12727 echo "Sleep $TIMEOUT seconds ..."
12729 if ! ps -p $create_pid > /dev/null 2>&1; then
12730 do_facet mds1 $LCTL set_param fail_loc=0
12731 do_facet mds1 $LCTL set_param fail_val=0
12732 do_facet mds1 $LCTL set_param \
12733 ldlm.lock_reclaim_threshold_mb=${low_wm}m
12734 error "createmany finished incorrectly!"
12736 do_facet mds1 $LCTL set_param fail_loc=0
12737 do_facet mds1 $LCTL set_param fail_val=0
12738 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
12739 wait $create_pid || return 1
12741 unlinkmany $DIR/$tdir/f $nr
12743 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
12746 remote_mds_nodsh && skip "remote MDS with nodsh"
12747 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
12748 skip "Need MDS version at least 2.13.50"
12751 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12753 #define OBD_FAIL_PLAIN_RECORDS 0x1319
12754 #set only one record at plain llog
12755 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
12757 #fill already existed plain llog each 64767
12758 #wrapping whole catalog
12759 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
12761 createmany -o $DIR/$tdir/$tfile_ 64700
12762 for (( i = 0; i < 64700; i = i + 2 ))
12764 rm $DIR/$tdir/$tfile_$i &
12765 rm $DIR/$tdir/$tfile_$((i + 1)) &
12770 #waiting osp synchronization
12771 wait_delete_completed
12773 run_test 135 "Race catalog processing"
12776 remote_mds_nodsh && skip "remote MDS with nodsh"
12777 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
12778 skip "Need MDS version at least 2.13.50"
12781 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12782 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
12783 #set only one record at plain llog
12784 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
12785 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
12787 #fill already existed 2 plain llogs each 64767
12788 #wrapping whole catalog
12789 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
12790 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
12791 wait_delete_completed
12793 createmany -o $DIR/$tdir/$tfile_ 10
12796 do_facet $SINGLEMDS $LCTL set_param fail_val=3
12797 for (( i = 0; i < 10; i = i + 3 ))
12799 rm $DIR/$tdir/$tfile_$i &
12800 rm $DIR/$tdir/$tfile_$((i + 1)) &
12804 rm $DIR/$tdir/$tfile_$((i + 2)) &
12807 #waiting osp synchronization
12808 wait_delete_completed
12810 run_test 136 "Race catalog processing 2"
12812 test_140() { #bug-17379
12813 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12815 test_mkdir $DIR/$tdir
12816 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
12817 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
12819 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
12820 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
12822 while i=$((i + 1)); do
12824 cd $i || error "Changing to $i"
12825 ln -s ../stat stat || error "Creating stat symlink"
12826 # Read the symlink until ELOOP present,
12827 # not LBUGing the system is considered success,
12828 # we didn't overrun the stack.
12829 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
12830 if [ $ret -ne 0 ]; then
12831 if [ $ret -eq 40 ]; then
12834 error "Open stat symlink"
12840 echo "The symlink depth = $i"
12841 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
12842 error "Invalid symlink depth"
12844 # Test recursive symlink
12845 ln -s symlink_self symlink_self
12846 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
12847 echo "open symlink_self returns $ret"
12848 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
12850 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
12853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12855 local TF="$TMP/$tfile"
12857 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12859 cancel_lru_locks $OSC
12860 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
12861 remount_client $MOUNT
12863 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
12866 $TRUNCATE $DIR/$tfile 6000
12867 cancel_lru_locks $OSC
12868 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
12871 echo "12345" >>$DIR/$tfile
12872 cancel_lru_locks $OSC
12873 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
12876 echo "12345" >>$DIR/$tfile
12877 cancel_lru_locks $OSC
12878 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
12883 run_test 150 "truncate/append tests"
12885 #LU-2902 roc_hit was not able to read all values from lproc
12886 function roc_hit_init() {
12887 local list=$(comma_list $(osts_nodes))
12888 local dir=$DIR/$tdir-check
12889 local file=$dir/$tfile
12895 #use setstripe to do a write to every ost
12896 for i in $(seq 0 $((OSTCOUNT-1))); do
12897 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
12898 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
12899 idx=$(printf %04x $i)
12900 BEFORE=$(get_osd_param $list *OST*$idx stats |
12901 awk '$1 == "cache_access" {sum += $7}
12902 END { printf("%0.0f", sum) }')
12904 cancel_lru_locks osc
12905 cat $file >/dev/null
12907 AFTER=$(get_osd_param $list *OST*$idx stats |
12908 awk '$1 == "cache_access" {sum += $7}
12909 END { printf("%0.0f", sum) }')
12911 echo BEFORE:$BEFORE AFTER:$AFTER
12912 if ! let "AFTER - BEFORE == 4"; then
12914 error "roc_hit is not safe to use"
12922 function roc_hit() {
12923 local list=$(comma_list $(osts_nodes))
12924 echo $(get_osd_param $list '' stats |
12925 awk '$1 == "cache_hit" {sum += $7}
12926 END { printf("%0.0f", sum) }')
12929 function set_cache() {
12932 if [ "$2" == "off" ]; then
12935 local list=$(comma_list $(osts_nodes))
12936 set_osd_param $list '' $1_cache_enable $on
12938 cancel_lru_locks osc
12942 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12943 remote_ost_nodsh && skip "remote OST with nodsh"
12946 local list=$(comma_list $(osts_nodes))
12948 # check whether obdfilter is cache capable at all
12949 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
12950 skip "not cache-capable obdfilter"
12953 # check cache is enabled on all obdfilters
12954 if get_osd_param $list '' read_cache_enable | grep 0; then
12955 skip "oss cache is disabled"
12958 set_osd_param $list '' writethrough_cache_enable 1
12960 # check write cache is enabled on all obdfilters
12961 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
12962 skip "oss write cache is NOT enabled"
12967 #define OBD_FAIL_OBD_NO_LRU 0x609
12968 do_nodes $list $LCTL set_param fail_loc=0x609
12970 # pages should be in the case right after write
12971 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
12974 local BEFORE=$(roc_hit)
12975 cancel_lru_locks osc
12976 cat $DIR/$tfile >/dev/null
12977 local AFTER=$(roc_hit)
12979 do_nodes $list $LCTL set_param fail_loc=0
12981 if ! let "AFTER - BEFORE == CPAGES"; then
12982 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12985 cancel_lru_locks osc
12986 # invalidates OST cache
12987 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
12988 set_osd_param $list '' read_cache_enable 0
12989 cat $DIR/$tfile >/dev/null
12991 # now data shouldn't be found in the cache
12993 cancel_lru_locks osc
12994 cat $DIR/$tfile >/dev/null
12996 if let "AFTER - BEFORE != 0"; then
12997 error "IN CACHE: before: $BEFORE, after: $AFTER"
13000 set_osd_param $list '' read_cache_enable 1
13003 run_test 151 "test cache on oss and controls ==============================="
13006 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13008 local TF="$TMP/$tfile"
13010 # simulate ENOMEM during write
13011 #define OBD_FAIL_OST_NOMEM 0x226
13012 lctl set_param fail_loc=0x80000226
13013 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
13015 sync || error "sync failed"
13016 lctl set_param fail_loc=0
13018 # discard client's cache
13019 cancel_lru_locks osc
13021 # simulate ENOMEM during read
13022 lctl set_param fail_loc=0x80000226
13023 cmp $TF $DIR/$tfile || error "cmp failed"
13024 lctl set_param fail_loc=0
13028 run_test 152 "test read/write with enomem ============================"
13031 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
13033 run_test 153 "test if fdatasync does not crash ======================="
13035 dot_lustre_fid_permission_check() {
13037 local ffid=$MOUNT/.lustre/fid/$fid
13040 echo "stat fid $fid"
13041 stat $ffid > /dev/null || error "stat $ffid failed."
13042 echo "touch fid $fid"
13043 touch $ffid || error "touch $ffid failed."
13044 echo "write to fid $fid"
13045 cat /etc/hosts > $ffid || error "write $ffid failed."
13046 echo "read fid $fid"
13047 diff /etc/hosts $ffid || error "read $ffid failed."
13048 echo "append write to fid $fid"
13049 cat /etc/hosts >> $ffid || error "append write $ffid failed."
13050 echo "rename fid $fid"
13051 mv $ffid $test_dir/$tfile.1 &&
13052 error "rename $ffid to $tfile.1 should fail."
13053 touch $test_dir/$tfile.1
13054 mv $test_dir/$tfile.1 $ffid &&
13055 error "rename $tfile.1 to $ffid should fail."
13056 rm -f $test_dir/$tfile.1
13057 echo "truncate fid $fid"
13058 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
13059 echo "link fid $fid"
13060 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
13061 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
13062 echo "setfacl fid $fid"
13063 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
13064 echo "getfacl fid $fid"
13065 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
13067 echo "unlink fid $fid"
13068 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
13069 echo "mknod fid $fid"
13070 mknod $ffid c 1 3 && error "mknod $ffid should fail."
13072 fid=[0xf00000400:0x1:0x0]
13073 ffid=$MOUNT/.lustre/fid/$fid
13075 echo "stat non-exist fid $fid"
13076 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
13077 echo "write to non-exist fid $fid"
13078 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
13079 echo "link new fid $fid"
13080 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
13082 mkdir -p $test_dir/$tdir
13083 touch $test_dir/$tdir/$tfile
13084 fid=$($LFS path2fid $test_dir/$tdir)
13087 error "error: could not get fid for $test_dir/$dir/$tfile."
13089 ffid=$MOUNT/.lustre/fid/$fid
13092 ls $ffid > /dev/null || error "ls $ffid failed."
13093 echo "touch $fid/$tfile.1"
13094 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
13096 echo "touch $MOUNT/.lustre/fid/$tfile"
13097 touch $MOUNT/.lustre/fid/$tfile && \
13098 error "touch $MOUNT/.lustre/fid/$tfile should fail."
13100 echo "setxattr to $MOUNT/.lustre/fid"
13101 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
13103 echo "listxattr for $MOUNT/.lustre/fid"
13104 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
13106 echo "delxattr from $MOUNT/.lustre/fid"
13107 setfattr -x trusted.name1 $MOUNT/.lustre/fid
13109 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
13110 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
13111 error "touch invalid fid should fail."
13113 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
13114 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
13115 error "touch non-normal fid should fail."
13117 echo "rename $tdir to $MOUNT/.lustre/fid"
13118 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
13119 error "rename to $MOUNT/.lustre/fid should fail."
13121 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
13123 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
13124 local new_obf_mode=777
13126 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
13127 chmod $new_obf_mode $DIR/.lustre/fid ||
13128 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
13130 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
13131 [ $obf_mode -eq $new_obf_mode ] ||
13132 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
13134 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
13135 chmod $old_obf_mode $DIR/.lustre/fid ||
13136 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
13139 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
13140 fid=$($LFS path2fid $test_dir/$tfile-2)
13142 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
13144 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
13145 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
13146 error "create lov data thru .lustre failed"
13148 echo "cp /etc/passwd $test_dir/$tfile-2"
13149 cp /etc/passwd $test_dir/$tfile-2 ||
13150 error "copy to $test_dir/$tfile-2 failed."
13151 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
13152 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
13153 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
13155 rm -rf $test_dir/tfile.lnk
13156 rm -rf $test_dir/$tfile-2
13160 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13161 skip "Need MDS version at least 2.4.1"
13163 local tf=$DIR/$tfile
13166 local fid=$($LFS path2fid $tf)
13167 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
13169 # check that we get the same pathname back
13170 local found=$($LFS fid2path $MOUNT "$fid")
13171 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
13172 [ "$found" == "$tf" ] ||
13173 error "fid2path($fid=path2fid($tf)) = $found != $tf"
13175 run_test 154A "lfs path2fid and fid2path basic checks"
13178 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13179 skip "Need MDS version at least 2.4.1"
13181 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
13182 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
13183 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
13184 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
13186 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
13187 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
13189 # check that we get the same pathname
13190 echo "PFID: $PFID, name: $name"
13191 local FOUND=$($LFS fid2path $MOUNT "$PFID")
13192 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
13193 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
13194 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
13196 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
13198 run_test 154B "verify the ll_decode_linkea tool"
13201 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13202 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13203 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
13204 skip "Need MDS version at least 2.2.51"
13205 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13207 cp /etc/hosts $DIR/$tfile
13209 fid=$($LFS path2fid $DIR/$tfile)
13211 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
13213 dot_lustre_fid_permission_check "$fid" $DIR ||
13214 error "dot lustre permission check $fid failed"
13216 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
13218 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
13220 touch $MOUNT/.lustre/file &&
13221 error "creation is not allowed under .lustre"
13223 mkdir $MOUNT/.lustre/dir &&
13224 error "mkdir is not allowed under .lustre"
13228 run_test 154a "Open-by-FID"
13231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13232 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13233 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13234 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
13235 skip "Need MDS version at least 2.2.51"
13237 local remote_dir=$DIR/$tdir/remote_dir
13241 mkdir -p $DIR/$tdir
13242 $LFS mkdir -i $MDTIDX $remote_dir ||
13243 error "create remote directory failed"
13245 cp /etc/hosts $remote_dir/$tfile
13247 fid=$($LFS path2fid $remote_dir/$tfile)
13249 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
13251 dot_lustre_fid_permission_check "$fid" $remote_dir ||
13252 error "dot lustre permission check $fid failed"
13255 run_test 154b "Open-by-FID for remote directory"
13258 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13259 skip "Need MDS version at least 2.4.1"
13261 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
13262 local FID1=$($LFS path2fid $DIR/$tfile.1)
13263 local FID2=$($LFS path2fid $DIR/$tfile.2)
13264 local FID3=$($LFS path2fid $DIR/$tfile.3)
13267 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
13268 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
13269 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
13271 [ "$FID" = "${!want}" ] ||
13272 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
13276 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
13278 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
13279 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
13283 run_test 154c "lfs path2fid and fid2path multiple arguments"
13286 remote_mds_nodsh && skip "remote MDS with nodsh"
13287 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
13288 skip "Need MDS version at least 2.5.53"
13290 if remote_mds; then
13291 nid=$($LCTL list_nids | sed "s/\./\\\./g")
13295 local proc_ofile="mdt.*.exports.'$nid'.open_files"
13302 local fid=$($LFS path2fid $DIR/$tfile)
13305 cmd="exec $fd<$DIR/$tfile"
13307 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
13308 echo "$fid_list" | grep "$fid"
13311 cmd="exec $fd>/dev/null"
13313 if [ $rc -ne 0 ]; then
13314 error "FID $fid not found in open files list $fid_list"
13317 run_test 154d "Verify open file fid"
13321 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
13322 skip "Need MDS version at least 2.6.50"
13324 if ls -a $MOUNT | grep -q '^\.lustre$'; then
13325 error ".lustre returned by readdir"
13328 run_test 154e ".lustre is not returned by readdir"
13331 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13333 # create parent directory on a single MDT to avoid cross-MDT hardlinks
13334 test_mkdir -p -c1 $DIR/$tdir/d
13335 # test dirs inherit from its stripe
13336 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
13337 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
13338 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
13339 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
13342 # get fid of parents
13343 local FID0=$($LFS path2fid $DIR/$tdir/d)
13344 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
13345 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
13346 local FID3=$($LFS path2fid $DIR)
13348 # check that path2fid --parents returns expected <parent_fid>/name
13349 # 1) test for a directory (single parent)
13350 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
13351 [ "$parent" == "$FID0/foo1" ] ||
13352 error "expected parent: $FID0/foo1, got: $parent"
13354 # 2) test for a file with nlink > 1 (multiple parents)
13355 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
13356 echo "$parent" | grep -F "$FID1/$tfile" ||
13357 error "$FID1/$tfile not returned in parent list"
13358 echo "$parent" | grep -F "$FID2/link" ||
13359 error "$FID2/link not returned in parent list"
13361 # 3) get parent by fid
13362 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
13363 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13364 echo "$parent" | grep -F "$FID1/$tfile" ||
13365 error "$FID1/$tfile not returned in parent list (by fid)"
13366 echo "$parent" | grep -F "$FID2/link" ||
13367 error "$FID2/link not returned in parent list (by fid)"
13369 # 4) test for entry in root directory
13370 parent=$($LFS path2fid --parents $DIR/f)
13371 echo "$parent" | grep -F "$FID3/f" ||
13372 error "$FID3/f not returned in parent list"
13374 # 5) test it on root directory
13375 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
13376 error "$MOUNT should not have parents"
13378 # enable xattr caching and check that linkea is correctly updated
13379 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
13380 save_lustre_params client "llite.*.xattr_cache" > $save
13381 lctl set_param llite.*.xattr_cache 1
13383 # 6.1) linkea update on rename
13384 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
13386 # get parents by fid
13387 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13388 # foo1 should no longer be returned in parent list
13389 echo "$parent" | grep -F "$FID1" &&
13390 error "$FID1 should no longer be in parent list"
13391 # the new path should appear
13392 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
13393 error "$FID2/$tfile.moved is not in parent list"
13395 # 6.2) linkea update on unlink
13396 rm -f $DIR/$tdir/d/foo2/link
13397 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13398 # foo2/link should no longer be returned in parent list
13399 echo "$parent" | grep -F "$FID2/link" &&
13400 error "$FID2/link should no longer be in parent list"
13404 restore_lustre_params < $save
13407 run_test 154f "get parent fids by reading link ea"
13411 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13412 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
13413 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
13414 skip "Need MDS version at least 2.6.92"
13416 mkdir -p $DIR/$tdir
13417 llapi_fid_test -d $DIR/$tdir
13419 run_test 154g "various llapi FID tests"
13421 test_155_small_load() {
13422 local temp=$TMP/$tfile
13423 local file=$DIR/$tfile
13425 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
13426 error "dd of=$temp bs=6096 count=1 failed"
13428 cancel_lru_locks $OSC
13429 cmp $temp $file || error "$temp $file differ"
13431 $TRUNCATE $temp 6000
13432 $TRUNCATE $file 6000
13433 cmp $temp $file || error "$temp $file differ (truncate1)"
13435 echo "12345" >>$temp
13436 echo "12345" >>$file
13437 cmp $temp $file || error "$temp $file differ (append1)"
13439 echo "12345" >>$temp
13440 echo "12345" >>$file
13441 cmp $temp $file || error "$temp $file differ (append2)"
13447 test_155_big_load() {
13448 remote_ost_nodsh && skip "remote OST with nodsh"
13450 local temp=$TMP/$tfile
13451 local file=$DIR/$tfile
13454 local cache_size=$(do_facet ost$((MAXI+1)) \
13455 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
13456 local large_file_size=$((cache_size * 2))
13458 echo "OSS cache size: $cache_size KB"
13459 echo "Large file size: $large_file_size KB"
13461 [ $MAXV -le $large_file_size ] &&
13462 skip_env "max available OST size needs > $large_file_size KB"
13464 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
13466 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
13467 error "dd of=$temp bs=$large_file_size count=1k failed"
13470 cancel_lru_locks osc
13471 cmp $temp $file || error "$temp $file differ"
13477 save_writethrough() {
13478 local facets=$(get_facets OST)
13480 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
13484 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13486 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13488 save_writethrough $p
13491 set_cache writethrough on
13492 test_155_small_load
13493 restore_lustre_params < $p
13496 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
13499 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13501 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13503 save_writethrough $p
13506 set_cache writethrough off
13507 test_155_small_load
13508 restore_lustre_params < $p
13511 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
13514 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13516 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13518 save_writethrough $p
13521 set_cache writethrough on
13522 test_155_small_load
13523 restore_lustre_params < $p
13526 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
13529 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13531 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13533 save_writethrough $p
13536 set_cache writethrough off
13537 test_155_small_load
13538 restore_lustre_params < $p
13541 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
13544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13546 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13548 save_writethrough $p
13551 set_cache writethrough on
13553 restore_lustre_params < $p
13556 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
13559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13561 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13563 save_writethrough $p
13566 set_cache writethrough off
13568 restore_lustre_params < $p
13571 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
13574 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13576 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13578 save_writethrough $p
13581 set_cache writethrough on
13583 restore_lustre_params < $p
13586 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
13589 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13591 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13593 save_writethrough $p
13596 set_cache writethrough off
13598 restore_lustre_params < $p
13601 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
13604 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13605 remote_ost_nodsh && skip "remote OST with nodsh"
13606 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
13607 skip "stats not implemented on old servers"
13608 [ "$ost1_FSTYPE" = "zfs" ] &&
13609 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
13614 local file="$DIR/$tfile"
13615 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13617 save_writethrough $p
13620 log "Turn on read and write cache"
13622 set_cache writethrough on
13624 log "Write data and read it back."
13625 log "Read should be satisfied from the cache."
13626 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13628 cancel_lru_locks osc
13629 cat $file >/dev/null
13631 if ! let "AFTER - BEFORE == CPAGES"; then
13632 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
13634 log "cache hits: before: $BEFORE, after: $AFTER"
13637 log "Read again; it should be satisfied from the cache."
13639 cancel_lru_locks osc
13640 cat $file >/dev/null
13642 if ! let "AFTER - BEFORE == CPAGES"; then
13643 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
13645 log "cache hits:: before: $BEFORE, after: $AFTER"
13648 log "Turn off the read cache and turn on the write cache"
13650 set_cache writethrough on
13652 log "Read again; it should be satisfied from the cache."
13654 cancel_lru_locks osc
13655 cat $file >/dev/null
13657 if ! let "AFTER - BEFORE == CPAGES"; then
13658 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
13660 log "cache hits:: before: $BEFORE, after: $AFTER"
13663 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
13664 # > 2.12.56 uses pagecache if cached
13665 log "Read again; it should not be satisfied from the cache."
13667 cancel_lru_locks osc
13668 cat $file >/dev/null
13670 if ! let "AFTER - BEFORE == 0"; then
13671 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
13673 log "cache hits:: before: $BEFORE, after: $AFTER"
13677 log "Write data and read it back."
13678 log "Read should be satisfied from the cache."
13679 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13681 cancel_lru_locks osc
13682 cat $file >/dev/null
13684 if ! let "AFTER - BEFORE == CPAGES"; then
13685 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
13687 log "cache hits:: before: $BEFORE, after: $AFTER"
13690 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
13691 # > 2.12.56 uses pagecache if cached
13692 log "Read again; it should not be satisfied from the cache."
13694 cancel_lru_locks osc
13695 cat $file >/dev/null
13697 if ! let "AFTER - BEFORE == 0"; then
13698 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
13700 log "cache hits:: before: $BEFORE, after: $AFTER"
13704 log "Turn off read and write cache"
13706 set_cache writethrough off
13708 log "Write data and read it back"
13709 log "It should not be satisfied from the cache."
13711 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13712 cancel_lru_locks osc
13714 cat $file >/dev/null
13716 if ! let "AFTER - BEFORE == 0"; then
13717 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
13719 log "cache hits:: before: $BEFORE, after: $AFTER"
13722 log "Turn on the read cache and turn off the write cache"
13724 set_cache writethrough off
13726 log "Write data and read it back"
13727 log "It should not be satisfied from the cache."
13729 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13731 cancel_lru_locks osc
13732 cat $file >/dev/null
13734 if ! let "AFTER - BEFORE == 0"; then
13735 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
13737 log "cache hits:: before: $BEFORE, after: $AFTER"
13740 log "Read again; it should be satisfied from the cache."
13742 cancel_lru_locks osc
13743 cat $file >/dev/null
13745 if ! let "AFTER - BEFORE == CPAGES"; then
13746 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
13748 log "cache hits:: before: $BEFORE, after: $AFTER"
13751 restore_lustre_params < $p
13754 run_test 156 "Verification of tunables"
13757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13758 remote_mds_nodsh && skip "remote MDS with nodsh"
13759 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13760 skip "Need MDS version at least 2.2.0"
13762 changelog_register || error "changelog_register failed"
13763 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13764 changelog_users $SINGLEMDS | grep -q $cl_user ||
13765 error "User $cl_user not found in changelog_users"
13768 test_mkdir -p $DIR/$tdir/pics/2008/zachy
13769 changelog_clear 0 || error "changelog_clear failed"
13770 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
13771 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
13772 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
13773 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
13774 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
13775 rm $DIR/$tdir/pics/desktop.jpg
13777 changelog_dump | tail -10
13779 echo "verifying changelog mask"
13780 changelog_chmask "-MKDIR"
13781 changelog_chmask "-CLOSE"
13783 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
13784 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
13786 changelog_chmask "+MKDIR"
13787 changelog_chmask "+CLOSE"
13789 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
13790 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
13792 changelog_dump | tail -10
13793 MKDIRS=$(changelog_dump | grep -c "MKDIR")
13794 CLOSES=$(changelog_dump | grep -c "CLOSE")
13795 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
13796 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
13799 echo "verifying target fid"
13800 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
13801 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
13802 [ "$fidc" == "$fidf" ] ||
13803 error "changelog '$tfile' fid $fidc != file fid $fidf"
13804 echo "verifying parent fid"
13805 # The FID returned from the Changelog may be the directory shard on
13806 # a different MDT, and not the FID returned by path2fid on the parent.
13807 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
13808 # since this is what will matter when recreating this file in the tree.
13809 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
13810 local pathp=$($LFS fid2path $MOUNT "$fidp")
13811 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
13812 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
13814 echo "getting records for $cl_user"
13815 changelog_users $SINGLEMDS
13816 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
13818 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
13819 error "changelog_clear failed"
13820 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
13821 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
13822 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
13823 error "user index expect $user_rec1 + $nclr != $user_rec2"
13825 local min0_rec=$(changelog_users $SINGLEMDS |
13826 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
13827 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
13828 awk '{ print $1; exit; }')
13830 changelog_dump | tail -n 5
13831 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
13832 [ $first_rec == $((min0_rec + 1)) ] ||
13833 error "first index should be $min0_rec + 1 not $first_rec"
13835 # LU-3446 changelog index reset on MDT restart
13836 local cur_rec1=$(changelog_users $SINGLEMDS |
13837 awk '/^current.index:/ { print $NF }')
13838 changelog_clear 0 ||
13839 error "clear all changelog records for $cl_user failed"
13840 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
13841 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
13842 error "Fail to start $SINGLEMDS"
13843 local cur_rec2=$(changelog_users $SINGLEMDS |
13844 awk '/^current.index:/ { print $NF }')
13845 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
13846 [ $cur_rec1 == $cur_rec2 ] ||
13847 error "current index should be $cur_rec1 not $cur_rec2"
13849 echo "verifying users from this test are deregistered"
13850 changelog_deregister || error "changelog_deregister failed"
13851 changelog_users $SINGLEMDS | grep -q $cl_user &&
13852 error "User '$cl_user' still in changelog_users"
13854 # lctl get_param -n mdd.*.changelog_users
13855 # current index: 144
13856 # ID index (idle seconds)
13858 if ! changelog_users $SINGLEMDS | grep "^cl"; then
13859 # this is the normal case where all users were deregistered
13860 # make sure no new records are added when no users are present
13861 local last_rec1=$(changelog_users $SINGLEMDS |
13862 awk '/^current.index:/ { print $NF }')
13863 touch $DIR/$tdir/chloe
13864 local last_rec2=$(changelog_users $SINGLEMDS |
13865 awk '/^current.index:/ { print $NF }')
13866 echo "verify changelogs are off: $last_rec1 == $last_rec2"
13867 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
13869 # any changelog users must be leftovers from a previous test
13870 changelog_users $SINGLEMDS
13871 echo "other changelog users; can't verify off"
13874 run_test 160a "changelog sanity"
13876 test_160b() { # LU-3587
13877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13878 remote_mds_nodsh && skip "remote MDS with nodsh"
13879 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13880 skip "Need MDS version at least 2.2.0"
13882 changelog_register || error "changelog_register failed"
13883 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13884 changelog_users $SINGLEMDS | grep -q $cl_user ||
13885 error "User '$cl_user' not found in changelog_users"
13887 local longname1=$(str_repeat a 255)
13888 local longname2=$(str_repeat b 255)
13891 echo "creating very long named file"
13892 touch $longname1 || error "create of '$longname1' failed"
13893 echo "renaming very long named file"
13894 mv $longname1 $longname2
13896 changelog_dump | grep RENME | tail -n 5
13899 run_test 160b "Verify that very long rename doesn't crash in changelog"
13902 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13903 remote_mds_nodsh && skip "remote MDS with nodsh"
13905 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
13906 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
13907 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
13908 skip "Need MDS version at least 2.5.58 or 2.5.2+"
13912 # Registration step
13913 changelog_register || error "changelog_register failed"
13916 mkdir -p $DIR/$tdir
13917 $MCREATE $DIR/$tdir/foo_160c
13918 changelog_chmask "-TRUNC"
13919 $TRUNCATE $DIR/$tdir/foo_160c 200
13920 changelog_chmask "+TRUNC"
13921 $TRUNCATE $DIR/$tdir/foo_160c 199
13922 changelog_dump | tail -n 5
13923 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
13924 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
13926 run_test 160c "verify that changelog log catch the truncate event"
13929 remote_mds_nodsh && skip "remote MDS with nodsh"
13930 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13931 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13932 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
13933 skip "Need MDS version at least 2.7.60"
13935 # Registration step
13936 changelog_register || error "changelog_register failed"
13938 mkdir -p $DIR/$tdir/migrate_dir
13939 changelog_clear 0 || error "changelog_clear failed"
13941 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
13942 changelog_dump | tail -n 5
13943 local migrates=$(changelog_dump | grep -c "MIGRT")
13944 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
13946 run_test 160d "verify that changelog log catch the migrate event"
13949 remote_mds_nodsh && skip "remote MDS with nodsh"
13952 changelog_register || error "changelog_register failed"
13954 # Delete a future user (expect fail)
13955 local MDT0=$(facet_svc $SINGLEMDS)
13956 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
13959 if [ $rc -eq 0 ]; then
13960 error "Deleted non-existant user cl77"
13961 elif [ $rc -ne 2 ]; then
13962 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
13965 # Clear to a bad index (1 billion should be safe)
13966 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
13969 if [ $rc -eq 0 ]; then
13970 error "Successfully cleared to invalid CL index"
13971 elif [ $rc -ne 22 ]; then
13972 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
13975 run_test 160e "changelog negative testing (should return errors)"
13978 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13979 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13980 skip "Need MDS version at least 2.10.56"
13982 local mdts=$(comma_list $(mdts_nodes))
13985 changelog_register || error "first changelog_register failed"
13986 changelog_register || error "second changelog_register failed"
13988 declare -A cl_user1
13989 declare -A cl_user2
13994 # generate some changelog records to accumulate on each MDT
13995 # use fnv1a because created files should be evenly distributed
13996 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
13997 error "test_mkdir $tdir failed"
13998 log "$(date +%s): creating first files"
13999 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14000 error "create $DIR/$tdir/$tfile failed"
14002 # check changelogs have been generated
14003 local start=$SECONDS
14004 local idle_time=$((MDSCOUNT * 5 + 5))
14005 local nbcl=$(changelog_dump | wc -l)
14006 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14008 for param in "changelog_max_idle_time=$idle_time" \
14010 "changelog_min_gc_interval=2" \
14011 "changelog_min_free_cat_entries=3"; do
14012 local MDT0=$(facet_svc $SINGLEMDS)
14013 local var="${param%=*}"
14014 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14016 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14017 do_nodes $mdts $LCTL set_param mdd.*.$param
14020 # force cl_user2 to be idle (1st part), but also cancel the
14021 # cl_user1 records so that it is not evicted later in the test.
14022 local sleep1=$((idle_time / 2))
14023 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
14026 # simulate changelog catalog almost full
14027 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
14028 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
14030 for i in $(seq $MDSCOUNT); do
14031 cl_users=(${CL_USERS[mds$i]})
14032 cl_user1[mds$i]="${cl_users[0]}"
14033 cl_user2[mds$i]="${cl_users[1]}"
14035 [ -n "${cl_user1[mds$i]}" ] ||
14036 error "mds$i: no user registered"
14037 [ -n "${cl_user2[mds$i]}" ] ||
14038 error "mds$i: only ${cl_user2[mds$i]} is registered"
14040 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14041 [ -n "$user_rec1" ] ||
14042 error "mds$i: User ${cl_user1[mds$i]} not registered"
14043 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14044 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14045 [ -n "$user_rec2" ] ||
14046 error "mds$i: User ${cl_user1[mds$i]} not registered"
14047 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14048 "$user_rec1 + 2 == $user_rec2"
14049 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14050 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14051 "$user_rec1 + 2, but is $user_rec2"
14052 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14053 [ -n "$user_rec2" ] ||
14054 error "mds$i: User ${cl_user2[mds$i]} not registered"
14055 [ $user_rec1 == $user_rec2 ] ||
14056 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14057 "$user_rec1, but is $user_rec2"
14060 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
14061 local sleep2=$((idle_time - (SECONDS - start) + 1))
14062 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
14065 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
14066 # cl_user1 should be OK because it recently processed records.
14067 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
14068 createmany -m $DIR/$tdir/${tfile}b $((MDSCOUNT * 2)) ||
14069 error "create $DIR/$tdir/${tfile}b failed"
14071 # ensure gc thread is done
14072 for i in $(mdts_nodes); do
14074 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
14075 error "$i: GC-thread not done"
14079 for i in $(seq $MDSCOUNT); do
14080 # check cl_user1 still registered
14081 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14082 error "mds$i: User ${cl_user1[mds$i]} not registered"
14083 # check cl_user2 unregistered
14084 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14085 error "mds$i: User ${cl_user2[mds$i]} still registered"
14087 # check changelogs are present and starting at $user_rec1 + 1
14088 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14089 [ -n "$user_rec1" ] ||
14090 error "mds$i: User ${cl_user1[mds$i]} not registered"
14091 first_rec=$($LFS changelog $(facet_svc mds$i) |
14092 awk '{ print $1; exit; }')
14094 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14095 [ $((user_rec1 + 1)) == $first_rec ] ||
14096 error "mds$i: first index should be $user_rec1 + 1, " \
14097 "but is $first_rec"
14100 run_test 160f "changelog garbage collect (timestamped users)"
14103 remote_mds_nodsh && skip "remote MDS with nodsh"
14104 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14105 skip "Need MDS version at least 2.10.56"
14107 local mdts=$(comma_list $(mdts_nodes))
14109 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
14110 do_nodes $mdts $LCTL set_param fail_loc=0x1314
14113 changelog_register || error "first changelog_register failed"
14114 changelog_register || error "second changelog_register failed"
14116 declare -A cl_user1
14117 declare -A cl_user2
14122 # generate some changelog records to accumulate on each MDT
14123 # use fnv1a because created files should be evenly distributed
14124 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14125 error "mkdir $tdir failed"
14126 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14127 error "create $DIR/$tdir/$tfile failed"
14129 # check changelogs have been generated
14130 local nbcl=$(changelog_dump | wc -l)
14131 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14133 # reduce the max_idle_indexes value to make sure we exceed it
14134 max_ndx=$((nbcl / 2 - 1))
14136 for param in "changelog_max_idle_indexes=$max_ndx" \
14138 "changelog_min_gc_interval=2" \
14139 "changelog_min_free_cat_entries=3"; do
14140 local MDT0=$(facet_svc $SINGLEMDS)
14141 local var="${param%=*}"
14142 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14144 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14145 do_nodes $mdts $LCTL set_param mdd.*.$param ||
14146 error "unable to set mdd.*.$param"
14149 # simulate changelog catalog almost full
14150 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
14151 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
14153 for i in $(seq $MDSCOUNT); do
14154 cl_users=(${CL_USERS[mds$i]})
14155 cl_user1[mds$i]="${cl_users[0]}"
14156 cl_user2[mds$i]="${cl_users[1]}"
14158 [ -n "${cl_user1[mds$i]}" ] ||
14159 error "mds$i: no user registered"
14160 [ -n "${cl_user2[mds$i]}" ] ||
14161 error "mds$i: only ${cl_user1[mds$i]} is registered"
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 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14167 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14168 [ -n "$user_rec2" ] ||
14169 error "mds$i: User ${cl_user1[mds$i]} not registered"
14170 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14171 "$user_rec1 + 2 == $user_rec2"
14172 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14173 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14174 "$user_rec1 + 2, but is $user_rec2"
14175 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14176 [ -n "$user_rec2" ] ||
14177 error "mds$i: User ${cl_user2[mds$i]} not registered"
14178 [ $user_rec1 == $user_rec2 ] ||
14179 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14180 "$user_rec1, but is $user_rec2"
14183 # ensure we are past the previous changelog_min_gc_interval set above
14186 # generate one more changelog to trigger fail_loc
14187 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14188 error "create $DIR/$tdir/${tfile}bis failed"
14190 # ensure gc thread is done
14191 for i in $(mdts_nodes); do
14193 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
14194 error "$i: GC-thread not done"
14198 for i in $(seq $MDSCOUNT); do
14199 # check cl_user1 still registered
14200 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14201 error "mds$i: User ${cl_user1[mds$i]} not registered"
14202 # check cl_user2 unregistered
14203 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14204 error "mds$i: User ${cl_user2[mds$i]} still registered"
14206 # check changelogs are present and starting at $user_rec1 + 1
14207 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14208 [ -n "$user_rec1" ] ||
14209 error "mds$i: User ${cl_user1[mds$i]} not registered"
14210 first_rec=$($LFS changelog $(facet_svc mds$i) |
14211 awk '{ print $1; exit; }')
14213 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14214 [ $((user_rec1 + 1)) == $first_rec ] ||
14215 error "mds$i: first index should be $user_rec1 + 1, " \
14216 "but is $first_rec"
14219 run_test 160g "changelog garbage collect (old users)"
14222 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14223 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14224 skip "Need MDS version at least 2.10.56"
14226 local mdts=$(comma_list $(mdts_nodes))
14229 changelog_register || error "first changelog_register failed"
14230 changelog_register || error "second changelog_register failed"
14232 declare -A cl_user1
14233 declare -A cl_user2
14238 # generate some changelog records to accumulate on each MDT
14239 # use fnv1a because created files should be evenly distributed
14240 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14241 error "test_mkdir $tdir failed"
14242 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14243 error "create $DIR/$tdir/$tfile failed"
14245 # check changelogs have been generated
14246 local nbcl=$(changelog_dump | wc -l)
14247 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14249 for param in "changelog_max_idle_time=10" \
14251 "changelog_min_gc_interval=2"; do
14252 local MDT0=$(facet_svc $SINGLEMDS)
14253 local var="${param%=*}"
14254 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14256 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14257 do_nodes $mdts $LCTL set_param mdd.*.$param
14260 # force cl_user2 to be idle (1st part)
14263 for i in $(seq $MDSCOUNT); do
14264 cl_users=(${CL_USERS[mds$i]})
14265 cl_user1[mds$i]="${cl_users[0]}"
14266 cl_user2[mds$i]="${cl_users[1]}"
14268 [ -n "${cl_user1[mds$i]}" ] ||
14269 error "mds$i: no user registered"
14270 [ -n "${cl_user2[mds$i]}" ] ||
14271 error "mds$i: only ${cl_user2[mds$i]} is registered"
14273 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14274 [ -n "$user_rec1" ] ||
14275 error "mds$i: User ${cl_user1[mds$i]} not registered"
14276 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14277 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14278 [ -n "$user_rec2" ] ||
14279 error "mds$i: User ${cl_user1[mds$i]} not registered"
14280 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14281 "$user_rec1 + 2 == $user_rec2"
14282 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14283 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14284 "$user_rec1 + 2, but is $user_rec2"
14285 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14286 [ -n "$user_rec2" ] ||
14287 error "mds$i: User ${cl_user2[mds$i]} not registered"
14288 [ $user_rec1 == $user_rec2 ] ||
14289 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14290 "$user_rec1, but is $user_rec2"
14293 # force cl_user2 to be idle (2nd part) and to reach
14294 # changelog_max_idle_time
14297 # force each GC-thread start and block then
14298 # one per MDT/MDD, set fail_val accordingly
14299 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
14300 do_nodes $mdts $LCTL set_param fail_loc=0x1316
14302 # generate more changelogs to trigger fail_loc
14303 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14304 error "create $DIR/$tdir/${tfile}bis failed"
14306 # stop MDT to stop GC-thread, should be done in back-ground as it will
14307 # block waiting for the thread to be released and exit
14308 declare -A stop_pids
14309 for i in $(seq $MDSCOUNT); do
14311 stop_pids[mds$i]=$!
14314 for i in $(mdts_nodes); do
14317 local facets=$(facets_up_on_host $i)
14319 for facet in ${facets//,/ }; do
14320 if [[ $facet == mds* ]]; then
14324 # ensure each MDS's gc threads are still present and all in "R"
14325 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
14326 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
14327 error "$i: expected $nb GC-thread"
14329 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
14331 error "$i: GC-thread not found in R-state"
14332 # check umounts of each MDT on MDS have reached kthread_stop()
14333 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
14334 error "$i: expected $nb umount"
14336 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
14337 error "$i: umount not found in D-state"
14340 # release all GC-threads
14341 do_nodes $mdts $LCTL set_param fail_loc=0
14343 # wait for MDT stop to complete
14344 for i in $(seq $MDSCOUNT); do
14345 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
14349 # may try to check if any orphan changelog records are present
14350 # via ldiskfs/zfs and llog_reader...
14352 # re-start/mount MDTs
14353 for i in $(seq $MDSCOUNT); do
14354 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
14355 error "Fail to start mds$i"
14359 for i in $(seq $MDSCOUNT); do
14360 # check cl_user1 still registered
14361 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14362 error "mds$i: User ${cl_user1[mds$i]} not registered"
14363 # check cl_user2 unregistered
14364 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14365 error "mds$i: User ${cl_user2[mds$i]} still registered"
14367 # check changelogs are present and starting at $user_rec1 + 1
14368 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14369 [ -n "$user_rec1" ] ||
14370 error "mds$i: User ${cl_user1[mds$i]} not registered"
14371 first_rec=$($LFS changelog $(facet_svc mds$i) |
14372 awk '{ print $1; exit; }')
14374 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14375 [ $((user_rec1 + 1)) == $first_rec ] ||
14376 error "mds$i: first index should be $user_rec1 + 1, " \
14377 "but is $first_rec"
14380 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
14385 local mdts=$(comma_list $(mdts_nodes))
14387 changelog_register || error "first changelog_register failed"
14389 # generate some changelog records to accumulate on each MDT
14390 # use fnv1a because created files should be evenly distributed
14391 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14392 error "mkdir $tdir failed"
14393 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14394 error "create $DIR/$tdir/$tfile failed"
14396 # check changelogs have been generated
14397 local nbcl=$(changelog_dump | wc -l)
14398 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14400 # simulate race between register and unregister
14401 # XXX as fail_loc is set per-MDS, with DNE configs the race
14402 # simulation will only occur for one MDT per MDS and for the
14403 # others the normal race scenario will take place
14404 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
14405 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
14406 do_nodes $mdts $LCTL set_param fail_val=1
14408 # unregister 1st user
14409 changelog_deregister &
14411 # wait some time for deregister work to reach race rdv
14413 # register 2nd user
14414 changelog_register || error "2nd user register failed"
14416 wait $pid1 || error "1st user deregister failed"
14420 declare -A LAST_REC
14421 for i in $(seq $MDSCOUNT); do
14422 if changelog_users mds$i | grep "^cl"; then
14423 # make sure new records are added with one user present
14424 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
14425 awk '/^current.index:/ { print $NF }')
14427 error "mds$i has no user registered"
14431 # generate more changelog records to accumulate on each MDT
14432 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14433 error "create $DIR/$tdir/${tfile}bis failed"
14435 for i in $(seq $MDSCOUNT); do
14436 last_rec=$(changelog_users $SINGLEMDS |
14437 awk '/^current.index:/ { print $NF }')
14438 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
14439 [ $last_rec != ${LAST_REC[mds$i]} ] ||
14440 error "changelogs are off on mds$i"
14443 run_test 160i "changelog user register/unregister race"
14446 remote_mds_nodsh && skip "remote MDS with nodsh"
14447 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
14448 skip "Need MDS version at least 2.12.56"
14450 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
14451 stack_trap "umount $MOUNT2" EXIT
14453 changelog_register || error "first changelog_register failed"
14454 stack_trap "changelog_deregister" EXIT
14456 # generate some changelog
14457 # use fnv1a because created files should be evenly distributed
14458 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14459 error "mkdir $tdir failed"
14460 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14461 error "create $DIR/$tdir/${tfile}bis failed"
14463 # open the changelog device
14464 exec 3>/dev/changelog-$FSNAME-MDT0000
14465 stack_trap "exec 3>&-" EXIT
14466 exec 4</dev/changelog-$FSNAME-MDT0000
14467 stack_trap "exec 4<&-" EXIT
14469 # umount the first lustre mount
14471 stack_trap "mount_client $MOUNT" EXIT
14474 cat <&4 >/dev/null || error "read changelog failed"
14477 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14478 changelog_users $SINGLEMDS | grep -q $cl_user ||
14479 error "User $cl_user not found in changelog_users"
14481 printf 'clear:'$cl_user':0' >&3
14483 run_test 160j "client can be umounted while its chanangelog is being used"
14486 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14487 remote_mds_nodsh && skip "remote MDS with nodsh"
14489 mkdir -p $DIR/$tdir/1/1
14491 changelog_register || error "changelog_register failed"
14492 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14494 changelog_users $SINGLEMDS | grep -q $cl_user ||
14495 error "User '$cl_user' not found in changelog_users"
14496 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
14497 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
14498 rmdir $DIR/$tdir/1/1 & sleep 1
14500 touch $DIR/$tdir/2/2
14501 rm -rf $DIR/$tdir/2
14506 changelog_dump | grep rmdir || error "rmdir not recorded"
14509 changelog_deregister
14511 run_test 160k "Verify that changelog records are not lost"
14514 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14516 test_mkdir -c1 $DIR/$tdir
14517 cp /etc/hosts $DIR/$tdir/$tfile
14518 test_mkdir -c1 $DIR/$tdir/foo1
14519 test_mkdir -c1 $DIR/$tdir/foo2
14520 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
14521 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
14522 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
14523 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
14524 local FID=$($LFS path2fid $DIR/$tdir/$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 $DIR/$tdir/foo2/zachary
14532 rm $DIR/$tdir/foo2/thor
14534 rm $DIR/$tdir/$tfile
14536 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
14537 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
14538 { $LFS fid2path $DIR $FID; error "bad link rename"; }
14539 rm $DIR/$tdir/foo2/maggie
14542 local longname=$tfile.avg_len_is_thirty_two_
14543 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
14544 error_noexit 'failed to unlink many hardlinks'" EXIT
14545 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
14546 error "failed to hardlink many files"
14547 links=$($LFS fid2path $DIR $FID | wc -l)
14548 echo -n "${links}/1000 links in link EA"
14549 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
14551 run_test 161a "link ea sanity"
14554 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14555 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
14558 local remote_dir=$DIR/$tdir/remote_dir
14560 mkdir -p $DIR/$tdir
14561 $LFS mkdir -i $MDTIDX $remote_dir ||
14562 error "create remote directory failed"
14564 cp /etc/hosts $remote_dir/$tfile
14565 mkdir -p $remote_dir/foo1
14566 mkdir -p $remote_dir/foo2
14567 ln $remote_dir/$tfile $remote_dir/foo1/sofia
14568 ln $remote_dir/$tfile $remote_dir/foo2/zachary
14569 ln $remote_dir/$tfile $remote_dir/foo1/luna
14570 ln $remote_dir/$tfile $remote_dir/foo2/thor
14572 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
14574 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14575 $LFS fid2path $DIR $FID
14576 error "bad link ea"
14579 rm $remote_dir/foo2/zachary
14581 rm $remote_dir/foo2/thor
14583 rm $remote_dir/$tfile
14585 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
14586 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
14587 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
14588 $LFS fid2path $DIR $FID
14589 error "bad link rename"
14591 rm $remote_dir/foo2/maggie
14594 local longname=filename_avg_len_is_thirty_two_
14595 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
14596 error "failed to hardlink many files"
14597 links=$($LFS fid2path $DIR $FID | wc -l)
14598 echo -n "${links}/1000 links in link EA"
14599 [[ ${links} -gt 60 ]] ||
14600 error "expected at least 60 links in link EA"
14601 unlinkmany $remote_dir/foo2/$longname 1000 ||
14602 error "failed to unlink many hardlinks"
14604 run_test 161b "link ea sanity under remote directory"
14607 remote_mds_nodsh && skip "remote MDS with nodsh"
14608 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14609 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
14610 skip "Need MDS version at least 2.1.5"
14612 # define CLF_RENAME_LAST 0x0001
14613 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
14614 changelog_register || error "changelog_register failed"
14617 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
14618 touch $DIR/$tdir/foo_161c
14619 touch $DIR/$tdir/bar_161c
14620 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14621 changelog_dump | grep RENME | tail -n 5
14622 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14623 changelog_clear 0 || error "changelog_clear failed"
14624 if [ x$flags != "x0x1" ]; then
14625 error "flag $flags is not 0x1"
14628 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
14629 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
14630 touch $DIR/$tdir/foo_161c
14631 touch $DIR/$tdir/bar_161c
14632 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14633 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14634 changelog_dump | grep RENME | tail -n 5
14635 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14636 changelog_clear 0 || error "changelog_clear failed"
14637 if [ x$flags != "x0x0" ]; then
14638 error "flag $flags is not 0x0"
14640 echo "rename overwrite a target having nlink > 1," \
14641 "changelog record has flags of $flags"
14643 # rename doesn't overwrite a target (changelog flag 0x0)
14644 touch $DIR/$tdir/foo_161c
14645 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
14646 changelog_dump | grep RENME | tail -n 5
14647 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
14648 changelog_clear 0 || error "changelog_clear failed"
14649 if [ x$flags != "x0x0" ]; then
14650 error "flag $flags is not 0x0"
14652 echo "rename doesn't overwrite a target," \
14653 "changelog record has flags of $flags"
14655 # define CLF_UNLINK_LAST 0x0001
14656 # unlink a file having nlink = 1 (changelog flag 0x1)
14657 rm -f $DIR/$tdir/foo2_161c
14658 changelog_dump | grep UNLNK | tail -n 5
14659 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14660 changelog_clear 0 || error "changelog_clear failed"
14661 if [ x$flags != "x0x1" ]; then
14662 error "flag $flags is not 0x1"
14664 echo "unlink a file having nlink = 1," \
14665 "changelog record has flags of $flags"
14667 # unlink a file having nlink > 1 (changelog flag 0x0)
14668 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14669 rm -f $DIR/$tdir/foobar_161c
14670 changelog_dump | grep UNLNK | tail -n 5
14671 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14672 changelog_clear 0 || error "changelog_clear failed"
14673 if [ x$flags != "x0x0" ]; then
14674 error "flag $flags is not 0x0"
14676 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
14678 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
14681 remote_mds_nodsh && skip "remote MDS with nodsh"
14682 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
14687 changelog_register || error "changelog_register failed"
14689 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
14690 # interfer with $MOUNT/.lustre/fid/ access
14692 [[ $? -eq 0 ]] || error "mkdir failed"
14694 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
14695 $LCTL set_param fail_loc=0x8000140c
14697 $LCTL set_param fail_val=5
14700 echo foofoo > $DIR/$tdir/$tfile &
14703 # wait for create to be delayed
14707 [[ $? -eq 0 ]] || error "create should be blocked"
14709 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
14710 stack_trap "rm -f $tempfile"
14711 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
14712 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
14713 # some delay may occur during ChangeLog publishing and file read just
14714 # above, that could allow file write to happen finally
14715 [[ -s $tempfile ]] && echo "file should be empty"
14717 $LCTL set_param fail_loc=0
14720 [[ $? -eq 0 ]] || error "create failed"
14722 run_test 161d "create with concurrent .lustre/fid access"
14725 local expected="$1"
14730 path=$($LFS fid2path "$@")
14733 if [ $rc -ne 0 ]; then
14734 error "path looked up of '$expected' failed: rc=$rc"
14735 elif [ "$path" != "$expected" ]; then
14736 error "path looked up '$path' instead of '$expected'"
14738 echo "FID '$fid' resolves to path '$path' as expected"
14742 test_162a() { # was test_162
14743 test_mkdir -p -c1 $DIR/$tdir/d2
14744 touch $DIR/$tdir/d2/$tfile
14745 touch $DIR/$tdir/d2/x1
14746 touch $DIR/$tdir/d2/x2
14747 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
14748 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
14750 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
14751 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
14754 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
14755 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
14756 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
14758 # softlink to wrong file
14759 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
14760 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
14761 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
14764 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
14765 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
14766 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
14767 # fid2path dir/fsname should both work
14768 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
14769 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
14771 # hardlink count: check that there are 2 links
14772 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
14773 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
14775 # hardlink indexing: remove the first link
14776 rm $DIR/$tdir/d2/p/q/r/hlink
14777 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
14779 run_test 162a "path lookup sanity"
14782 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14783 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14786 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
14787 error "create striped dir failed"
14789 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
14790 tail -n 1 | awk '{print $2}')
14791 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
14793 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
14794 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
14797 for ((i=0;i<5;i++)); do
14798 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
14799 error "get fid for f$i failed"
14800 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
14802 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
14803 error "get fid for d$i failed"
14804 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
14809 run_test 162b "striped directory path lookup sanity"
14811 # LU-4239: Verify fid2path works with paths 100 or more directories deep
14813 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
14814 skip "Need MDS version at least 2.7.51"
14816 local lpath=$tdir.local
14817 local rpath=$tdir.remote
14819 test_mkdir $DIR/$lpath
14820 test_mkdir $DIR/$rpath
14822 for ((i = 0; i <= 101; i++)); do
14825 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
14826 error "get fid for local directory $DIR/$lpath failed"
14827 check_path "$DIR/$lpath" $MOUNT $FID --link 0
14830 test_mkdir $DIR/$rpath
14831 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
14832 error "get fid for remote directory $DIR/$rpath failed"
14833 check_path "$DIR/$rpath" $MOUNT $FID --link 0
14838 run_test 162c "fid2path works with paths 100 or more directories deep"
14841 # do directio so as not to populate the page cache
14842 log "creating a 10 Mb file"
14843 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14844 log "starting reads"
14845 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14846 log "truncating the file"
14847 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14849 kill %+ || true # reads might have finished
14850 echo "wait until dd is finished"
14852 log "removing the temporary file"
14853 rm -rf $DIR/$tfile || error "tmp file removal failed"
14855 run_test 169 "parallel read and truncate should not deadlock"
14858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14860 $LCTL clear # bug 18514
14861 $LCTL debug_daemon start $TMP/${tfile}_log_good
14863 $LCTL debug_daemon stop
14864 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
14865 error "sed failed to read log_good"
14867 $LCTL debug_daemon start $TMP/${tfile}_log_good
14869 $LCTL debug_daemon stop
14871 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
14872 error "lctl df log_bad failed"
14874 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14875 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14877 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
14878 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
14880 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
14881 error "bad_line good_line1 good_line2 are empty"
14883 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14884 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
14885 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14887 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
14888 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14889 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14891 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
14892 error "bad_line_new good_line_new are empty"
14894 local expected_good=$((good_line1 + good_line2*2))
14896 rm -f $TMP/${tfile}*
14897 # LU-231, short malformed line may not be counted into bad lines
14898 if [ $bad_line -ne $bad_line_new ] &&
14899 [ $bad_line -ne $((bad_line_new - 1)) ]; then
14900 error "expected $bad_line bad lines, but got $bad_line_new"
14904 if [ $expected_good -ne $good_line_new ]; then
14905 error "expected $expected_good good lines, but got $good_line_new"
14910 run_test 170 "test lctl df to handle corrupted log ====================="
14912 test_171() { # bug20592
14913 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14915 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
14916 $LCTL set_param fail_loc=0x50e
14917 $LCTL set_param fail_val=3000
14918 multiop_bg_pause $DIR/$tfile O_s || true
14920 kill -USR1 $MULTIPID
14924 if dmesg | grep "recursive fault"; then
14925 error "caught a recursive fault"
14927 $LCTL set_param fail_loc=0
14930 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
14932 # it would be good to share it with obdfilter-survey/iokit-libecho code
14933 setup_obdecho_osc () {
14936 local obdfilter_name=$2
14937 echo "Creating new osc for $obdfilter_name on $ost_nid"
14938 # make sure we can find loopback nid
14939 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
14941 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
14942 ${obdfilter_name}_osc_UUID || rc=2; }
14943 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
14944 ${obdfilter_name}_UUID $ost_nid || rc=3; }
14948 cleanup_obdecho_osc () {
14949 local obdfilter_name=$1
14950 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
14951 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
14958 local pages=${3:-64}
14963 local obd_size=$(get_obd_size $node $OBD)
14964 local page_size=$(get_page_size $node)
14965 if [[ -n "$obd_size" ]]; then
14966 local new_count=$((obd_size / (pages * page_size / 1024)))
14967 [[ $new_count -ge $count ]] || count=$new_count
14970 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
14971 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
14973 if [ $rc -eq 0 ]; then
14974 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
14975 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
14977 echo "New object id is $id"
14978 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
14980 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
14981 "test_brw $count w v $pages $id" || rc=4; }
14982 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
14984 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
14985 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
14986 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
14987 { do_facet $node "$LCTL --device ec detach" || rc=6; }
14988 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
14993 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14995 if ! module_loaded obdecho; then
14996 load_module obdecho/obdecho &&
14997 stack_trap "rmmod obdecho" EXIT ||
14998 error "unable to load obdecho on client"
15001 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
15002 local host=$($LCTL get_param -n osc.$osc.import |
15003 awk '/current_connection:/ { print $2 }' )
15004 local target=$($LCTL get_param -n osc.$osc.import |
15005 awk '/target:/ { print $2 }' )
15006 target=${target%_UUID}
15008 if [ -n "$target" ]; then
15009 setup_obdecho_osc $host $target &&
15010 stack_trap "cleanup_obdecho_osc $target" EXIT ||
15011 { error "obdecho setup failed with $?"; return; }
15013 obdecho_test ${target}_osc client ||
15014 error "obdecho_test failed on ${target}_osc"
15016 $LCTL get_param osc.$osc.import
15017 error "there is no osc.$osc.import target"
15020 run_test 180a "test obdecho on osc"
15023 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15024 remote_ost_nodsh && skip "remote OST with nodsh"
15026 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
15027 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
15028 error "failed to load module obdecho"
15030 local target=$(do_facet ost1 $LCTL dl |
15031 awk '/obdfilter/ { print $4; exit; }')
15033 if [ -n "$target" ]; then
15034 obdecho_test $target ost1 || error "obdecho_test failed with $?"
15036 do_facet ost1 $LCTL dl
15037 error "there is no obdfilter target on ost1"
15040 run_test 180b "test obdecho directly on obdfilter"
15042 test_180c() { # LU-2598
15043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15044 remote_ost_nodsh && skip "remote OST with nodsh"
15045 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
15046 skip "Need MDS version at least 2.4.0"
15048 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
15049 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
15050 error "failed to load module obdecho"
15052 local target=$(do_facet ost1 $LCTL dl |
15053 awk '/obdfilter/ { print $4; exit; }')
15055 if [ -n "$target" ]; then
15056 local pages=16384 # 64MB bulk I/O RPC size
15058 obdecho_test "$target" ost1 "$pages" ||
15059 error "obdecho_test with pages=$pages failed with $?"
15061 do_facet ost1 $LCTL dl
15062 error "there is no obdfilter target on ost1"
15065 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
15067 test_181() { # bug 22177
15068 test_mkdir $DIR/$tdir
15069 # create enough files to index the directory
15070 createmany -o $DIR/$tdir/foobar 4000
15071 # print attributes for debug purpose
15074 multiop_bg_pause $DIR/$tdir D_Sc || return 1
15076 # remove the files & current working dir
15077 unlinkmany $DIR/$tdir/foobar 4000
15079 kill -USR1 $MULTIPID
15081 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
15084 run_test 181 "Test open-unlinked dir ========================"
15090 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15092 $LCTL set_param mdc.*.rpc_stats=clear
15094 for (( i = 0; i < $tcount; i++ )) ; do
15095 mkdir $DIR/$tdir/$i
15098 for (( i = 0; i < $tcount; i++ )) ; do
15099 createmany -o $DIR/$tdir/$i/f- $fcount &
15103 for (( i = 0; i < $tcount; i++ )) ; do
15104 unlinkmany $DIR/$tdir/$i/f- $fcount &
15108 $LCTL get_param mdc.*.rpc_stats
15112 run_test 182 "Test parallel modify metadata operations ================"
15114 test_183() { # LU-2275
15115 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15116 remote_mds_nodsh && skip "remote MDS with nodsh"
15117 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
15118 skip "Need MDS version at least 2.3.56"
15120 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15121 echo aaa > $DIR/$tdir/$tfile
15123 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
15124 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
15126 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
15127 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
15129 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
15131 # Flush negative dentry cache
15132 touch $DIR/$tdir/$tfile
15134 # We are not checking for any leaked references here, they'll
15135 # become evident next time we do cleanup with module unload.
15138 run_test 183 "No crash or request leak in case of strange dispositions ========"
15140 # test suite 184 is for LU-2016, LU-2017
15142 check_swap_layouts_support
15144 dir0=$DIR/$tdir/$testnum
15145 test_mkdir -p -c1 $dir0
15150 $LFS setstripe -c1 $file1
15152 $LFS setstripe -c2 $file2
15154 gen1=$($LFS getstripe -g $file1)
15155 gen2=$($LFS getstripe -g $file2)
15157 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
15158 gen=$($LFS getstripe -g $file1)
15159 [[ $gen1 != $gen ]] ||
15160 "Layout generation on $file1 does not change"
15161 gen=$($LFS getstripe -g $file2)
15162 [[ $gen2 != $gen ]] ||
15163 "Layout generation on $file2 does not change"
15165 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
15166 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
15168 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
15170 run_test 184a "Basic layout swap"
15173 check_swap_layouts_support
15175 dir0=$DIR/$tdir/$testnum
15176 mkdir -p $dir0 || error "creating dir $dir0"
15183 $LFS setstripe -c1 $file1
15184 $LFS setstripe -c2 $file2
15185 $LFS setstripe -c1 $file3
15186 chown $RUNAS_ID $file3
15187 gen1=$($LFS getstripe -g $file1)
15188 gen2=$($LFS getstripe -g $file2)
15190 $LFS swap_layouts $dir1 $dir2 &&
15191 error "swap of directories layouts should fail"
15192 $LFS swap_layouts $dir1 $file1 &&
15193 error "swap of directory and file layouts should fail"
15194 $RUNAS $LFS swap_layouts $file1 $file2 &&
15195 error "swap of file we cannot write should fail"
15196 $LFS swap_layouts $file1 $file3 &&
15197 error "swap of file with different owner should fail"
15198 /bin/true # to clear error code
15200 run_test 184b "Forbidden layout swap (will generate errors)"
15203 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
15204 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
15205 check_swap_layouts_support
15207 local dir0=$DIR/$tdir/$testnum
15208 mkdir -p $dir0 || error "creating dir $dir0"
15210 local ref1=$dir0/ref1
15211 local ref2=$dir0/ref2
15212 local file1=$dir0/file1
15213 local file2=$dir0/file2
15214 # create a file large enough for the concurrent test
15215 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
15216 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
15217 echo "ref file size: ref1($(stat -c %s $ref1))," \
15218 "ref2($(stat -c %s $ref2))"
15221 dd if=$ref1 of=$file1 bs=16k &
15224 # Make sure dd starts to copy file
15225 while [ ! -f $file1 ]; do sleep 0.1; done
15227 $LFS swap_layouts $file1 $file2
15230 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
15231 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
15233 # how many bytes copied before swapping layout
15234 local copied=$(stat -c %s $file2)
15235 local remaining=$(stat -c %s $ref1)
15236 remaining=$((remaining - copied))
15237 echo "Copied $copied bytes before swapping layout..."
15239 cmp -n $copied $file1 $ref2 | grep differ &&
15240 error "Content mismatch [0, $copied) of ref2 and file1"
15241 cmp -n $copied $file2 $ref1 ||
15242 error "Content mismatch [0, $copied) of ref1 and file2"
15243 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
15244 error "Content mismatch [$copied, EOF) of ref1 and file1"
15247 rm -f $ref1 $ref2 $file1 $file2
15249 run_test 184c "Concurrent write and layout swap"
15252 check_swap_layouts_support
15253 [ -z "$(which getfattr 2>/dev/null)" ] &&
15254 skip_env "no getfattr command"
15256 local file1=$DIR/$tdir/$tfile-1
15257 local file2=$DIR/$tdir/$tfile-2
15258 local file3=$DIR/$tdir/$tfile-3
15262 mkdir -p $DIR/$tdir
15263 touch $file1 || error "create $file1 failed"
15264 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
15265 error "create $file2 failed"
15266 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
15267 error "create $file3 failed"
15268 lovea1=$(get_layout_param $file1)
15270 $LFS swap_layouts $file2 $file3 ||
15271 error "swap $file2 $file3 layouts failed"
15272 $LFS swap_layouts $file1 $file2 ||
15273 error "swap $file1 $file2 layouts failed"
15275 lovea2=$(get_layout_param $file2)
15278 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
15280 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
15281 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
15283 run_test 184d "allow stripeless layouts swap"
15286 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
15287 skip "Need MDS version at least 2.6.94"
15288 check_swap_layouts_support
15289 [ -z "$(which getfattr 2>/dev/null)" ] &&
15290 skip_env "no getfattr command"
15292 local file1=$DIR/$tdir/$tfile-1
15293 local file2=$DIR/$tdir/$tfile-2
15294 local file3=$DIR/$tdir/$tfile-3
15297 mkdir -p $DIR/$tdir
15298 touch $file1 || error "create $file1 failed"
15299 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
15300 error "create $file2 failed"
15301 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
15302 error "create $file3 failed"
15304 $LFS swap_layouts $file1 $file2 ||
15305 error "swap $file1 $file2 layouts failed"
15307 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
15308 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
15310 echo 123 > $file1 || error "Should be able to write into $file1"
15312 $LFS swap_layouts $file1 $file3 ||
15313 error "swap $file1 $file3 layouts failed"
15315 echo 123 > $file1 || error "Should be able to write into $file1"
15317 rm -rf $file1 $file2 $file3
15319 run_test 184e "Recreate layout after stripeless layout swaps"
15322 # Create a file with name longer than sizeof(struct stat) ==
15323 # 144 to see if we can get chars from the file name to appear
15324 # in the returned striping. Note that 'f' == 0x66.
15325 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
15327 mkdir -p $DIR/$tdir
15328 mcreate $DIR/$tdir/$file
15329 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
15330 error "IOC_MDC_GETFILEINFO returned garbage striping"
15333 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
15335 test_185() { # LU-2441
15336 # LU-3553 - no volatile file support in old servers
15337 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
15338 skip "Need MDS version at least 2.3.60"
15340 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15341 touch $DIR/$tdir/spoo
15342 local mtime1=$(stat -c "%Y" $DIR/$tdir)
15343 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
15344 error "cannot create/write a volatile file"
15345 [ "$FILESET" == "" ] &&
15346 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
15347 error "FID is still valid after close"
15349 multiop_bg_pause $DIR/$tdir vVw4096_c
15356 # assume that the next FID for this client is sequential, since stdout
15357 # is unfortunately eaten by multiop_bg_pause
15358 local n=$((${fidv[1]} + 1))
15359 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
15360 if [ "$FILESET" == "" ]; then
15361 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
15362 error "FID is missing before close"
15364 kill -USR1 $multi_pid
15365 # 1 second delay, so if mtime change we will see it
15367 local mtime2=$(stat -c "%Y" $DIR/$tdir)
15368 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
15370 run_test 185 "Volatile file support"
15372 function create_check_volatile() {
15376 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
15379 local FID=$(cat /tmp/${tfile}.fid)
15380 [ "$FID" == "" ] && error "can't get FID for volatile"
15381 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
15382 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
15383 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
15387 cancel_lru_locks mdc # flush opencache
15388 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
15393 # LU-12516 - volatile creation via .lustre
15394 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
15395 skip "Need MDS version at least 2.3.55"
15397 create_check_volatile 0
15398 [ $MDSCOUNT -lt 2 ] && return 0
15401 create_check_volatile 1
15405 run_test 185a "Volatile file creation in .lustre/fid/"
15408 remote_mds_nodsh && skip "remote MDS with nodsh"
15409 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15410 skip "Need MDS version at least 2.3.0"
15412 local dir0=$DIR/$tdir/$testnum
15413 mkdir -p $dir0 || error "creating dir $dir0"
15415 local file=$dir0/file1
15416 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
15417 local dv1=$($LFS data_version $file)
15418 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
15419 local dv2=$($LFS data_version $file)
15420 [[ $dv1 != $dv2 ]] ||
15421 error "data version did not change on write $dv1 == $dv2"
15426 run_test 187a "Test data version change"
15429 remote_mds_nodsh && skip "remote MDS with nodsh"
15430 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15431 skip "Need MDS version at least 2.3.0"
15433 local dir0=$DIR/$tdir/$testnum
15434 mkdir -p $dir0 || error "creating dir $dir0"
15436 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
15437 [[ ${DV[0]} != ${DV[1]} ]] ||
15438 error "data version did not change on write"\
15439 " ${DV[0]} == ${DV[1]}"
15444 run_test 187b "Test data version change on volatile file"
15447 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15448 remote_mgs_nodsh && skip "remote MGS with nodsh"
15449 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
15451 local POOL=${POOL:-cea1}
15452 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
15453 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
15456 local last_ost=$(($OSTCOUNT - 1))
15458 local ost_list=$(seq $first_ost $ost_step $last_ost)
15459 local ost_range="$first_ost $last_ost $ost_step"
15460 local test_path=$POOL_ROOT/$POOL_DIR_NAME
15461 local file_dir=$POOL_ROOT/file_tst
15462 local subdir=$test_path/subdir
15466 # former test_200a test_200b
15467 pool_add $POOL || { rc=$? ; break; }
15468 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
15469 # former test_200c test_200d
15470 mkdir -p $test_path
15471 pool_set_dir $POOL $test_path || { rc=$? ; break; }
15472 pool_check_dir $POOL $test_path || { rc=$? ; break; }
15474 pool_check_dir $POOL $subdir || { rc=$? ; break; }
15475 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
15476 || { rc=$? ; break; }
15477 # former test_200e test_200f
15478 local files=$((OSTCOUNT*3))
15479 pool_alloc_files $POOL $test_path $files "$ost_list" \
15480 || { rc=$? ; break; }
15481 pool_create_files $POOL $file_dir $files "$ost_list" \
15482 || { rc=$? ; break; }
15483 # former test_200g test_200h
15484 pool_lfs_df $POOL || { rc=$? ; break; }
15485 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
15487 # former test_201a test_201b test_201c
15488 pool_remove_first_target $POOL || { rc=$? ; break; }
15490 local f=$test_path/$tfile
15491 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
15492 pool_remove $POOL $f || { rc=$? ; break; }
15500 run_test 200 "OST pools"
15502 # usage: default_attr <count | size | offset>
15504 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
15507 # usage: check_default_stripe_attr
15508 check_default_stripe_attr() {
15509 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
15512 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
15514 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
15518 error "unknown getstripe attr '$1'"
15521 [ $ACTUAL == $EXPECTED ] ||
15522 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
15526 test_mkdir $DIR/$tdir
15527 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
15529 check_default_stripe_attr --stripe-count
15530 check_default_stripe_attr --stripe-size
15531 check_default_stripe_attr --stripe-index
15533 run_test 204a "Print default stripe attributes"
15536 test_mkdir $DIR/$tdir
15537 $LFS setstripe --stripe-count 1 $DIR/$tdir
15539 check_default_stripe_attr --stripe-size
15540 check_default_stripe_attr --stripe-index
15542 run_test 204b "Print default stripe size and offset"
15545 test_mkdir $DIR/$tdir
15546 $LFS setstripe --stripe-size 65536 $DIR/$tdir
15548 check_default_stripe_attr --stripe-count
15549 check_default_stripe_attr --stripe-index
15551 run_test 204c "Print default stripe count and offset"
15554 test_mkdir $DIR/$tdir
15555 $LFS setstripe --stripe-index 0 $DIR/$tdir
15557 check_default_stripe_attr --stripe-count
15558 check_default_stripe_attr --stripe-size
15560 run_test 204d "Print default stripe count and size"
15563 test_mkdir $DIR/$tdir
15564 $LFS setstripe -d $DIR/$tdir
15566 check_default_stripe_attr --stripe-count --raw
15567 check_default_stripe_attr --stripe-size --raw
15568 check_default_stripe_attr --stripe-index --raw
15570 run_test 204e "Print raw stripe attributes"
15573 test_mkdir $DIR/$tdir
15574 $LFS setstripe --stripe-count 1 $DIR/$tdir
15576 check_default_stripe_attr --stripe-size --raw
15577 check_default_stripe_attr --stripe-index --raw
15579 run_test 204f "Print raw stripe size and offset"
15582 test_mkdir $DIR/$tdir
15583 $LFS setstripe --stripe-size 65536 $DIR/$tdir
15585 check_default_stripe_attr --stripe-count --raw
15586 check_default_stripe_attr --stripe-index --raw
15588 run_test 204g "Print raw stripe count and offset"
15591 test_mkdir $DIR/$tdir
15592 $LFS setstripe --stripe-index 0 $DIR/$tdir
15594 check_default_stripe_attr --stripe-count --raw
15595 check_default_stripe_attr --stripe-size --raw
15597 run_test 204h "Print raw stripe count and size"
15599 # Figure out which job scheduler is being used, if any,
15600 # or use a fake one
15601 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
15602 JOBENV=SLURM_JOB_ID
15603 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
15605 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
15607 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
15608 JOBENV=LOADL_STEP_ID
15609 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
15612 $LCTL list_param jobid_name > /dev/null 2>&1
15613 if [ $? -eq 0 ]; then
15619 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
15621 verify_jobstats() {
15626 # we don't really need to clear the stats for this test to work, since each
15627 # command has a unique jobid, but it makes debugging easier if needed.
15628 # for facet in $facets; do
15629 # local dev=$(convert_facet2label $facet)
15630 # # clear old jobstats
15631 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
15634 # use a new JobID for each test, or we might see an old one
15635 [ "$JOBENV" = "FAKE_JOBID" ] &&
15636 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
15638 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
15640 [ "$JOBENV" = "nodelocal" ] && {
15641 FAKE_JOBID=id.$testnum.%e.$RANDOM
15642 $LCTL set_param jobid_name=$FAKE_JOBID
15643 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
15646 log "Test: ${cmd[*]}"
15647 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
15649 if [ $JOBENV = "FAKE_JOBID" ]; then
15650 FAKE_JOBID=$JOBVAL ${cmd[*]}
15655 # all files are created on OST0000
15656 for facet in $facets; do
15657 local stats="*.$(convert_facet2label $facet).job_stats"
15659 # strip out libtool wrappers for in-tree executables
15660 if [ $(do_facet $facet lctl get_param $stats |
15661 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
15662 do_facet $facet lctl get_param $stats
15663 error "No jobstats for $JOBVAL found on $facet::$stats"
15669 local new_jobenv=$1
15671 set_persistent_param_and_check client "jobid_var" \
15672 "$FSNAME.sys.jobid_var" $new_jobenv
15675 test_205a() { # Job stats
15676 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15677 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
15678 skip "Need MDS version with at least 2.7.1"
15679 remote_mgs_nodsh && skip "remote MGS with nodsh"
15680 remote_mds_nodsh && skip "remote MDS with nodsh"
15681 remote_ost_nodsh && skip "remote OST with nodsh"
15682 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
15683 skip "Server doesn't support jobstats"
15684 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
15686 local old_jobenv=$($LCTL get_param -n jobid_var)
15687 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
15689 if [[ $PERM_CMD == *"set_param -P"* ]]; then
15690 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
15692 stack_trap "do_facet mgs $PERM_CMD \
15693 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
15697 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
15698 mdt.*.job_cleanup_interval | head -n 1)
15699 local new_interval=5
15700 do_facet $SINGLEMDS \
15701 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
15702 stack_trap "do_facet $SINGLEMDS \
15703 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
15704 local start=$SECONDS
15708 cmd="mkdir $DIR/$tdir"
15709 verify_jobstats "$cmd" "$SINGLEMDS"
15711 cmd="rmdir $DIR/$tdir"
15712 verify_jobstats "$cmd" "$SINGLEMDS"
15713 # mkdir on secondary MDT
15714 if [ $MDSCOUNT -gt 1 ]; then
15715 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
15716 verify_jobstats "$cmd" "mds2"
15719 cmd="mknod $DIR/$tfile c 1 3"
15720 verify_jobstats "$cmd" "$SINGLEMDS"
15722 cmd="rm -f $DIR/$tfile"
15723 verify_jobstats "$cmd" "$SINGLEMDS"
15724 # create all files on OST0000 so verify_jobstats can find OST stats
15726 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
15727 verify_jobstats "$cmd" "$SINGLEMDS"
15729 cmd="touch $DIR/$tfile"
15730 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15732 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
15733 verify_jobstats "$cmd" "ost1"
15735 cancel_lru_locks osc
15736 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
15737 verify_jobstats "$cmd" "ost1"
15739 cmd="$TRUNCATE $DIR/$tfile 0"
15740 verify_jobstats "$cmd" "$SINGLEMDS ost1"
15742 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
15743 verify_jobstats "$cmd" "$SINGLEMDS"
15744 # jobstats expiry - sleep until old stats should be expired
15745 local left=$((new_interval + 5 - (SECONDS - start)))
15746 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
15747 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
15749 cmd="mkdir $DIR/$tdir.expire"
15750 verify_jobstats "$cmd" "$SINGLEMDS"
15751 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
15752 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
15754 # Ensure that jobid are present in changelog (if supported by MDS)
15755 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
15756 changelog_dump | tail -10
15757 jobids=$(changelog_dump | tail -9 | grep -c "j=")
15758 [ $jobids -eq 9 ] ||
15759 error "Wrong changelog jobid count $jobids != 9"
15763 jobstats_set $JOBENV
15765 changelog_dump | grep $tfile
15766 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
15767 [ $jobids -eq 0 ] ||
15768 error "Unexpected jobids when jobid_var=$JOBENV"
15771 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
15772 JOBENV="JOBCOMPLEX"
15773 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
15775 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
15777 run_test 205a "Verify job stats"
15781 $LCTL set_param jobid_var=USER jobid_name="%e.%u"
15782 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
15783 do_facet $SINGLEMDS $LCTL get_param mdt.*.job_stats |
15784 grep job_id: | grep foolish &&
15785 error "Unexpected jobid found"
15788 run_test 205b "Verify job stats jobid parsing"
15790 # LU-1480, LU-1773 and LU-1657
15792 mkdir -p $DIR/$tdir
15793 $LFS setstripe -c -1 $DIR/$tdir
15794 #define OBD_FAIL_LOV_INIT 0x1403
15795 $LCTL set_param fail_loc=0xa0001403
15796 $LCTL set_param fail_val=1
15797 touch $DIR/$tdir/$tfile || true
15799 run_test 206 "fail lov_init_raid0() doesn't lbug"
15802 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15803 local fsz=`stat -c %s $DIR/$tfile`
15804 cancel_lru_locks mdc
15806 # do not return layout in getattr intent
15807 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
15808 $LCTL set_param fail_loc=0x170
15809 local sz=`stat -c %s $DIR/$tfile`
15811 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
15815 run_test 207a "can refresh layout at glimpse"
15818 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
15819 local cksum=`md5sum $DIR/$tfile`
15820 local fsz=`stat -c %s $DIR/$tfile`
15821 cancel_lru_locks mdc
15822 cancel_lru_locks osc
15824 # do not return layout in getattr intent
15825 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
15826 $LCTL set_param fail_loc=0x171
15828 # it will refresh layout after the file is opened but before read issues
15829 echo checksum is "$cksum"
15830 echo "$cksum" |md5sum -c --quiet || error "file differs"
15834 run_test 207b "can refresh layout at open"
15837 # FIXME: in this test suite, only RD lease is used. This is okay
15838 # for now as only exclusive open is supported. After generic lease
15839 # is done, this test suite should be revised. - Jinshan
15841 remote_mds_nodsh && skip "remote MDS with nodsh"
15842 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
15843 skip "Need MDS version at least 2.4.52"
15845 echo "==== test 1: verify get lease work"
15846 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
15848 echo "==== test 2: verify lease can be broken by upcoming open"
15849 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15853 $MULTIOP $DIR/$tfile oO_RDONLY:c
15854 kill -USR1 $PID && wait $PID || error "break lease error"
15856 echo "==== test 3: verify lease can't be granted if an open already exists"
15857 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
15861 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
15862 kill -USR1 $PID && wait $PID || error "open file error"
15864 echo "==== test 4: lease can sustain over recovery"
15865 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
15871 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
15873 echo "==== test 5: lease broken can't be regained by replay"
15874 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
15878 # open file to break lease and then recovery
15879 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
15882 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
15886 run_test 208 "Exclusive open"
15889 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
15890 skip_env "must have disp_stripe"
15893 sync; sleep 5; sync;
15895 echo 3 > /proc/sys/vm/drop_caches
15896 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15898 # open/close 500 times
15899 for i in $(seq 500); do
15903 echo 3 > /proc/sys/vm/drop_caches
15904 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15906 echo "before: $req_before, after: $req_after"
15907 [ $((req_after - req_before)) -ge 300 ] &&
15908 error "open/close requests are not freed"
15911 run_test 209 "read-only open/close requests should be freed promptly"
15915 size=$((size % 8192 + 1))
15916 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
15917 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
15918 rm -f $DIR/f212 $DIR/f212.xyz
15920 run_test 212 "Sendfile test ============================================"
15923 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
15924 cancel_lru_locks osc
15925 lctl set_param fail_loc=0x8000040f
15926 # generate a read lock
15927 cat $DIR/$tfile > /dev/null
15928 # write to the file, it will try to cancel the above read lock.
15929 cat /etc/hosts >> $DIR/$tfile
15931 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
15933 test_214() { # for bug 20133
15934 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
15935 for (( i=0; i < 340; i++ )) ; do
15936 touch $DIR/$tdir/d214c/a$i
15939 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
15940 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
15941 ls $DIR/d214c || error "ls $DIR/d214c failed"
15942 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
15943 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
15945 run_test 214 "hash-indexed directory test - bug 20133"
15947 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
15948 create_lnet_proc_files() {
15949 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
15952 # counterpart of create_lnet_proc_files
15953 remove_lnet_proc_files() {
15954 rm -f $TMP/lnet_$1.sys
15957 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15958 # 3rd arg as regexp for body
15959 check_lnet_proc_stats() {
15960 local l=$(cat "$TMP/lnet_$1" |wc -l)
15961 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
15963 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
15966 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15967 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
15968 # optional and can be regexp for 2nd line (lnet.routes case)
15969 check_lnet_proc_entry() {
15970 local blp=2 # blp stands for 'position of 1st line of body'
15971 [ -z "$5" ] || blp=3 # lnet.routes case
15973 local l=$(cat "$TMP/lnet_$1" |wc -l)
15974 # subtracting one from $blp because the body can be empty
15975 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
15977 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
15978 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
15980 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
15981 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
15983 # bail out if any unexpected line happened
15984 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
15985 [ "$?" != 0 ] || error "$2 misformatted"
15988 test_215() { # for bugs 18102, 21079, 21517
15989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15991 local N='(0|[1-9][0-9]*)' # non-negative numeric
15992 local P='[1-9][0-9]*' # positive numeric
15993 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
15994 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
15995 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
15996 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
15998 local L1 # regexp for 1st line
15999 local L2 # regexp for 2nd line (optional)
16000 local BR # regexp for the rest (body)
16002 # lnet.stats should look as 11 space-separated non-negative numerics
16003 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
16004 create_lnet_proc_files "stats"
16005 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
16006 remove_lnet_proc_files "stats"
16008 # lnet.routes should look like this:
16009 # Routing disabled/enabled
16010 # net hops priority state router
16011 # where net is a string like tcp0, hops > 0, priority >= 0,
16012 # state is up/down,
16013 # router is a string like 192.168.1.1@tcp2
16014 L1="^Routing (disabled|enabled)$"
16015 L2="^net +hops +priority +state +router$"
16016 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
16017 create_lnet_proc_files "routes"
16018 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
16019 remove_lnet_proc_files "routes"
16021 # lnet.routers should look like this:
16022 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
16023 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
16024 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
16025 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
16026 L1="^ref +rtr_ref +alive +router$"
16027 BR="^$P +$P +(up|down) +$NID$"
16028 create_lnet_proc_files "routers"
16029 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
16030 remove_lnet_proc_files "routers"
16032 # lnet.peers should look like this:
16033 # nid refs state last max rtr min tx min queue
16034 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
16035 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
16036 # numeric (0 or >0 or <0), queue >= 0.
16037 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
16038 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
16039 create_lnet_proc_files "peers"
16040 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
16041 remove_lnet_proc_files "peers"
16043 # lnet.buffers should look like this:
16044 # pages count credits min
16045 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
16046 L1="^pages +count +credits +min$"
16047 BR="^ +$N +$N +$I +$I$"
16048 create_lnet_proc_files "buffers"
16049 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
16050 remove_lnet_proc_files "buffers"
16052 # lnet.nis should look like this:
16053 # nid status alive refs peer rtr max tx min
16054 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
16055 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
16056 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
16057 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
16058 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
16059 create_lnet_proc_files "nis"
16060 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
16061 remove_lnet_proc_files "nis"
16063 # can we successfully write to lnet.stats?
16064 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
16066 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
16068 test_216() { # bug 20317
16069 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16070 remote_ost_nodsh && skip "remote OST with nodsh"
16073 local facets=$(get_facets OST)
16074 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16076 save_lustre_params client "osc.*.contention_seconds" > $p
16077 save_lustre_params $facets \
16078 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
16079 save_lustre_params $facets \
16080 "ldlm.namespaces.filter-*.contended_locks" >> $p
16081 save_lustre_params $facets \
16082 "ldlm.namespaces.filter-*.contention_seconds" >> $p
16083 clear_stats osc.*.osc_stats
16085 # agressive lockless i/o settings
16086 do_nodes $(comma_list $(osts_nodes)) \
16087 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
16088 ldlm.namespaces.filter-*.contended_locks=0 \
16089 ldlm.namespaces.filter-*.contention_seconds=60"
16090 lctl set_param -n osc.*.contention_seconds=60
16092 $DIRECTIO write $DIR/$tfile 0 10 4096
16093 $CHECKSTAT -s 40960 $DIR/$tfile
16095 # disable lockless i/o
16096 do_nodes $(comma_list $(osts_nodes)) \
16097 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
16098 ldlm.namespaces.filter-*.contended_locks=32 \
16099 ldlm.namespaces.filter-*.contention_seconds=0"
16100 lctl set_param -n osc.*.contention_seconds=0
16101 clear_stats osc.*.osc_stats
16103 dd if=/dev/zero of=$DIR/$tfile count=0
16104 $CHECKSTAT -s 0 $DIR/$tfile
16106 restore_lustre_params <$p
16110 run_test 216 "check lockless direct write updates file size and kms correctly"
16112 test_217() { # bug 22430
16113 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16118 for node in $(nodes_list); do
16119 nid=$(host_nids_address $node $NETTYPE)
16120 if [[ $nid = *-* ]] ; then
16121 echo "lctl ping $(h2nettype $nid)"
16122 lctl ping $(h2nettype $nid)
16124 echo "skipping $node (no hyphen detected)"
16128 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
16131 # do directio so as not to populate the page cache
16132 log "creating a 10 Mb file"
16133 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
16134 log "starting reads"
16135 dd if=$DIR/$tfile of=/dev/null bs=4096 &
16136 log "truncating the file"
16137 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
16139 kill %+ || true # reads might have finished
16140 echo "wait until dd is finished"
16142 log "removing the temporary file"
16143 rm -rf $DIR/$tfile || error "tmp file removal failed"
16145 run_test 218 "parallel read and truncate should not deadlock"
16148 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16150 # write one partial page
16151 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
16152 # set no grant so vvp_io_commit_write will do sync write
16153 $LCTL set_param fail_loc=0x411
16154 # write a full page at the end of file
16155 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
16157 $LCTL set_param fail_loc=0
16158 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
16159 $LCTL set_param fail_loc=0x411
16160 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
16163 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
16164 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
16166 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
16168 test_220() { #LU-325
16169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16170 remote_ost_nodsh && skip "remote OST with nodsh"
16171 remote_mds_nodsh && skip "remote MDS with nodsh"
16172 remote_mgs_nodsh && skip "remote MGS with nodsh"
16176 # create on MDT0000 so the last_id and next_id are correct
16178 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
16182 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
16183 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
16184 osp.$mdtosc_proc1.prealloc_last_id)
16185 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
16186 osp.$mdtosc_proc1.prealloc_next_id)
16190 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
16191 #define OBD_FAIL_OST_ENOINO 0x229
16192 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
16193 create_pool $FSNAME.$TESTNAME || return 1
16194 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
16196 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
16198 MDSOBJS=$((last_id - next_id))
16199 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
16201 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
16202 echo "OST still has $count kbytes free"
16204 echo "create $MDSOBJS files @next_id..."
16205 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
16207 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
16208 osp.$mdtosc_proc1.prealloc_last_id)
16209 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
16210 osp.$mdtosc_proc1.prealloc_next_id)
16212 echo "after creation, last_id=$last_id2, next_id=$next_id2"
16217 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
16218 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
16220 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
16221 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
16222 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
16223 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
16224 echo "unlink $MDSOBJS files @$next_id..."
16225 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
16227 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
16230 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16232 dd if=`which date` of=$MOUNT/date oflag=sync
16233 chmod +x $MOUNT/date
16235 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
16236 $LCTL set_param fail_loc=0x80001401
16238 $MOUNT/date > /dev/null
16241 run_test 221 "make sure fault and truncate race to not cause OOM"
16244 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16247 test_mkdir $DIR/$tdir
16248 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16249 createmany -o $DIR/$tdir/$tfile 10
16250 cancel_lru_locks mdc
16251 cancel_lru_locks osc
16252 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
16253 $LCTL set_param fail_loc=0x31a
16254 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
16255 $LCTL set_param fail_loc=0
16258 run_test 222a "AGL for ls should not trigger CLIO lock failure"
16261 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16264 test_mkdir $DIR/$tdir
16265 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16266 createmany -o $DIR/$tdir/$tfile 10
16267 cancel_lru_locks mdc
16268 cancel_lru_locks osc
16269 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
16270 $LCTL set_param fail_loc=0x31a
16271 rm -r $DIR/$tdir || error "AGL for rmdir failed"
16272 $LCTL set_param fail_loc=0
16274 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
16277 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16280 test_mkdir $DIR/$tdir
16281 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16282 createmany -o $DIR/$tdir/$tfile 10
16283 cancel_lru_locks mdc
16284 cancel_lru_locks osc
16285 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
16286 $LCTL set_param fail_loc=0x31b
16287 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
16288 $LCTL set_param fail_loc=0
16291 run_test 223 "osc reenqueue if without AGL lock granted ======================="
16293 test_224a() { # LU-1039, MRP-303
16294 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16296 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
16297 $LCTL set_param fail_loc=0x508
16298 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
16299 $LCTL set_param fail_loc=0
16302 run_test 224a "Don't panic on bulk IO failure"
16304 test_224b() { # LU-1039, MRP-303
16305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16307 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
16308 cancel_lru_locks osc
16309 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
16310 $LCTL set_param fail_loc=0x515
16311 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
16312 $LCTL set_param fail_loc=0
16315 run_test 224b "Don't panic on bulk IO failure"
16317 test_224c() { # LU-6441
16318 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16319 remote_mds_nodsh && skip "remote MDS with nodsh"
16321 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16322 save_writethrough $p
16323 set_cache writethrough on
16325 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
16326 local at_max=$($LCTL get_param -n at_max)
16327 local timeout=$($LCTL get_param -n timeout)
16328 local test_at="at_max"
16329 local param_at="$FSNAME.sys.at_max"
16330 local test_timeout="timeout"
16331 local param_timeout="$FSNAME.sys.timeout"
16333 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
16335 set_persistent_param_and_check client "$test_at" "$param_at" 0
16336 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
16338 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
16339 do_facet ost1 "$LCTL set_param fail_loc=0x520"
16340 $LFS setstripe -c 1 -i 0 $DIR/$tfile
16341 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
16343 do_facet ost1 "$LCTL set_param fail_loc=0"
16345 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
16346 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
16349 $LCTL set_param -n $pages_per_rpc
16350 restore_lustre_params < $p
16353 run_test 224c "Don't hang if one of md lost during large bulk RPC"
16355 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
16357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16358 if [ -z ${MDSSURVEY} ]; then
16359 skip_env "mds-survey not found"
16361 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16362 skip "Need MDS version at least 2.2.51"
16364 local mds=$(facet_host $SINGLEMDS)
16365 local target=$(do_nodes $mds 'lctl dl' |
16366 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
16368 local cmd1="file_count=1000 thrhi=4"
16369 local cmd2="dir_count=2 layer=mdd stripe_count=0"
16370 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16371 local cmd="$cmd1 $cmd2 $cmd3"
16373 rm -f ${TMP}/mds_survey*
16375 eval $cmd || error "mds-survey with zero-stripe failed"
16376 cat ${TMP}/mds_survey*
16377 rm -f ${TMP}/mds_survey*
16379 run_test 225a "Metadata survey sanity with zero-stripe"
16382 if [ -z ${MDSSURVEY} ]; then
16383 skip_env "mds-survey not found"
16385 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16386 skip "Need MDS version at least 2.2.51"
16387 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16388 remote_mds_nodsh && skip "remote MDS with nodsh"
16389 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
16390 skip_env "Need to mount OST to test"
16393 local mds=$(facet_host $SINGLEMDS)
16394 local target=$(do_nodes $mds 'lctl dl' |
16395 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
16397 local cmd1="file_count=1000 thrhi=4"
16398 local cmd2="dir_count=2 layer=mdd stripe_count=1"
16399 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16400 local cmd="$cmd1 $cmd2 $cmd3"
16402 rm -f ${TMP}/mds_survey*
16404 eval $cmd || error "mds-survey with stripe_count failed"
16405 cat ${TMP}/mds_survey*
16406 rm -f ${TMP}/mds_survey*
16408 run_test 225b "Metadata survey sanity with stripe_count = 1"
16410 mcreate_path2fid () {
16416 local path=$DIR/$tdir/$name
16421 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
16422 error "cannot create $desc"
16424 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
16426 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
16428 fid_path=$($LFS fid2path $MOUNT $fid)
16430 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
16432 [ "$path" == "$fid_path" ] ||
16433 error "fid2path returned $fid_path, expected $path"
16435 echo "pass with $path and $fid"
16440 mkdir -p $DIR/$tdir
16442 mcreate_path2fid 0010666 0 0 fifo "FIFO"
16443 mcreate_path2fid 0020666 1 3 null "character special file (null)"
16444 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
16445 mcreate_path2fid 0040666 0 0 dir "directory"
16446 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
16447 mcreate_path2fid 0100666 0 0 file "regular file"
16448 mcreate_path2fid 0120666 0 0 link "symbolic link"
16449 mcreate_path2fid 0140666 0 0 sock "socket"
16451 run_test 226a "call path2fid and fid2path on files of all type"
16454 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16459 mkdir -p $DIR/$tdir
16460 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
16461 error "create remote directory failed"
16462 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
16463 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
16464 "character special file (null)"
16465 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
16466 "character special file (no device)"
16467 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
16468 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
16469 "block special file (loop)"
16470 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
16471 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
16472 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
16474 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
16476 # LU-1299 Executing or running ldd on a truncated executable does not
16477 # cause an out-of-memory condition.
16479 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16480 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
16482 dd if=$(which date) of=$MOUNT/date bs=1k count=1
16483 chmod +x $MOUNT/date
16485 $MOUNT/date > /dev/null
16486 ldd $MOUNT/date > /dev/null
16489 run_test 227 "running truncated executable does not cause OOM"
16491 # LU-1512 try to reuse idle OI blocks
16493 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16494 remote_mds_nodsh && skip "remote MDS with nodsh"
16495 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16497 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16498 local myDIR=$DIR/$tdir
16501 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16502 $LCTL set_param fail_loc=0x80001002
16503 createmany -o $myDIR/t- 10000
16504 $LCTL set_param fail_loc=0
16505 # The guard is current the largest FID holder
16507 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16509 local IDX=$(($SEQ % 64))
16511 do_facet $SINGLEMDS sync
16512 # Make sure journal flushed.
16514 local blk1=$(do_facet $SINGLEMDS \
16515 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16516 grep Blockcount | awk '{print $4}')
16518 # Remove old files, some OI blocks will become idle.
16519 unlinkmany $myDIR/t- 10000
16520 # Create new files, idle OI blocks should be reused.
16521 createmany -o $myDIR/t- 2000
16522 do_facet $SINGLEMDS sync
16523 # Make sure journal flushed.
16525 local blk2=$(do_facet $SINGLEMDS \
16526 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16527 grep Blockcount | awk '{print $4}')
16529 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16531 run_test 228a "try to reuse idle OI blocks"
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 createmany -o $myDIR/t- 10000
16545 $LCTL set_param fail_loc=0
16546 # The guard is current the largest FID holder
16548 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16550 local IDX=$(($SEQ % 64))
16552 do_facet $SINGLEMDS sync
16553 # Make sure journal flushed.
16555 local blk1=$(do_facet $SINGLEMDS \
16556 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16557 grep Blockcount | awk '{print $4}')
16559 # Remove old files, some OI blocks will become idle.
16560 unlinkmany $myDIR/t- 10000
16563 stop $SINGLEMDS || error "Fail to stop MDT."
16565 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
16567 df $MOUNT || error "Fail to df."
16568 # Create new files, idle OI blocks should be reused.
16569 createmany -o $myDIR/t- 2000
16570 do_facet $SINGLEMDS sync
16571 # Make sure journal flushed.
16573 local blk2=$(do_facet $SINGLEMDS \
16574 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16575 grep Blockcount | awk '{print $4}')
16577 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16579 run_test 228b "idle OI blocks can be reused after MDT restart"
16583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16584 remote_mds_nodsh && skip "remote MDS with nodsh"
16585 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
16587 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
16588 local myDIR=$DIR/$tdir
16591 #define OBD_FAIL_SEQ_EXHAUST 0x1002
16592 $LCTL set_param fail_loc=0x80001002
16593 # 20000 files can guarantee there are index nodes in the OI file
16594 createmany -o $myDIR/t- 20000
16595 $LCTL set_param fail_loc=0
16596 # The guard is current the largest FID holder
16598 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
16600 local IDX=$(($SEQ % 64))
16602 do_facet $SINGLEMDS sync
16603 # Make sure journal flushed.
16605 local blk1=$(do_facet $SINGLEMDS \
16606 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16607 grep Blockcount | awk '{print $4}')
16609 # Remove old files, some OI blocks will become idle.
16610 unlinkmany $myDIR/t- 20000
16612 # The OI file should become empty now
16614 # Create new files, idle OI blocks should be reused.
16615 createmany -o $myDIR/t- 2000
16616 do_facet $SINGLEMDS sync
16617 # Make sure journal flushed.
16619 local blk2=$(do_facet $SINGLEMDS \
16620 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
16621 grep Blockcount | awk '{print $4}')
16623 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
16625 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
16627 test_229() { # LU-2482, LU-3448
16628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16629 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
16630 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
16631 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
16635 # Create a file with a released layout and stripe count 2.
16636 $MULTIOP $DIR/$tfile H2c ||
16637 error "failed to create file with released layout"
16639 $LFS getstripe -v $DIR/$tfile
16641 local pattern=$($LFS getstripe -L $DIR/$tfile)
16642 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
16644 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
16646 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
16647 stat $DIR/$tfile || error "failed to stat released file"
16649 chown $RUNAS_ID $DIR/$tfile ||
16650 error "chown $RUNAS_ID $DIR/$tfile failed"
16652 chgrp $RUNAS_ID $DIR/$tfile ||
16653 error "chgrp $RUNAS_ID $DIR/$tfile failed"
16655 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
16656 rm $DIR/$tfile || error "failed to remove released file"
16658 run_test 229 "getstripe/stat/rm/attr changes work on released files"
16661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16662 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16663 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16664 skip "Need MDS version at least 2.11.52"
16668 test_mkdir $DIR/$tdir
16669 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
16670 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
16671 [ $mdt_idx -ne 0 ] &&
16672 error "create local directory on wrong MDT $mdt_idx"
16674 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
16675 error "create remote directory failed"
16676 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
16677 [ $mdt_idx -ne $MDTIDX ] &&
16678 error "create remote directory on wrong MDT $mdt_idx"
16680 createmany -o $DIR/$tdir/test_230/t- 10 ||
16681 error "create files on remote directory failed"
16682 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
16683 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
16684 rm -r $DIR/$tdir || error "unlink remote directory failed"
16686 run_test 230a "Create remote directory and files under the remote directory"
16689 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16690 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16691 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16692 skip "Need MDS version at least 2.11.52"
16700 local migrate_dir=$DIR/$tdir/migrate_dir
16701 local other_dir=$DIR/$tdir/other_dir
16703 test_mkdir $DIR/$tdir
16704 test_mkdir -i0 -c1 $migrate_dir
16705 test_mkdir -i0 -c1 $other_dir
16706 for ((i=0; i<10; i++)); do
16707 mkdir -p $migrate_dir/dir_${i}
16708 createmany -o $migrate_dir/dir_${i}/f 10 ||
16709 error "create files under remote dir failed $i"
16712 cp /etc/passwd $migrate_dir/$tfile
16713 cp /etc/passwd $other_dir/$tfile
16714 chattr +SAD $migrate_dir
16715 chattr +SAD $migrate_dir/$tfile
16717 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16718 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16719 local old_dir_mode=$(stat -c%f $migrate_dir)
16720 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
16722 mkdir -p $migrate_dir/dir_default_stripe2
16723 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
16724 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
16726 mkdir -p $other_dir
16727 ln $migrate_dir/$tfile $other_dir/luna
16728 ln $migrate_dir/$tfile $migrate_dir/sofia
16729 ln $other_dir/$tfile $migrate_dir/david
16730 ln -s $migrate_dir/$tfile $other_dir/zachary
16731 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
16732 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
16738 for len in 58 59 60; do
16739 lnktgt=$(str_repeat 'l' $len)
16740 touch $migrate_dir/$lnktgt
16741 ln -s $lnktgt $migrate_dir/${len}char_ln
16745 for len in 4094 4095; do
16746 lnktgt=$(str_repeat 'l' $len)
16747 ln -s $lnktgt $migrate_dir/${len}char_ln
16751 for len in 254 255; do
16752 touch $migrate_dir/$(str_repeat 'l' $len)
16755 $LFS migrate -m $MDTIDX $migrate_dir ||
16756 error "fails on migrating remote dir to MDT1"
16758 echo "migratate to MDT1, then checking.."
16759 for ((i = 0; i < 10; i++)); do
16760 for file in $(find $migrate_dir/dir_${i}); do
16761 mdt_index=$($LFS getstripe -m $file)
16762 # broken symlink getstripe will fail
16763 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
16764 error "$file is not on MDT${MDTIDX}"
16768 # the multiple link file should still in MDT0
16769 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
16770 [ $mdt_index == 0 ] ||
16771 error "$file is not on MDT${MDTIDX}"
16773 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16774 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16775 error " expect $old_dir_flag get $new_dir_flag"
16777 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16778 [ "$old_file_flag" = "$new_file_flag" ] ||
16779 error " expect $old_file_flag get $new_file_flag"
16781 local new_dir_mode=$(stat -c%f $migrate_dir)
16782 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16783 error "expect mode $old_dir_mode get $new_dir_mode"
16785 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16786 [ "$old_file_mode" = "$new_file_mode" ] ||
16787 error "expect mode $old_file_mode get $new_file_mode"
16789 diff /etc/passwd $migrate_dir/$tfile ||
16790 error "$tfile different after migration"
16792 diff /etc/passwd $other_dir/luna ||
16793 error "luna different after migration"
16795 diff /etc/passwd $migrate_dir/sofia ||
16796 error "sofia different after migration"
16798 diff /etc/passwd $migrate_dir/david ||
16799 error "david different after migration"
16801 diff /etc/passwd $other_dir/zachary ||
16802 error "zachary different after migration"
16804 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16805 error "${tfile}_ln different after migration"
16807 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16808 error "${tfile}_ln_other different after migration"
16810 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
16811 [ $stripe_count = 2 ] ||
16812 error "dir strpe_count $d != 2 after migration."
16814 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
16815 [ $stripe_count = 2 ] ||
16816 error "file strpe_count $d != 2 after migration."
16818 #migrate back to MDT0
16821 $LFS migrate -m $MDTIDX $migrate_dir ||
16822 error "fails on migrating remote dir to MDT0"
16824 echo "migrate back to MDT0, checking.."
16825 for file in $(find $migrate_dir); do
16826 mdt_index=$($LFS getstripe -m $file)
16827 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
16828 error "$file is not on MDT${MDTIDX}"
16831 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
16832 [ "$old_dir_flag" = "$new_dir_flag" ] ||
16833 error " expect $old_dir_flag get $new_dir_flag"
16835 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
16836 [ "$old_file_flag" = "$new_file_flag" ] ||
16837 error " expect $old_file_flag get $new_file_flag"
16839 local new_dir_mode=$(stat -c%f $migrate_dir)
16840 [ "$old_dir_mode" = "$new_dir_mode" ] ||
16841 error "expect mode $old_dir_mode get $new_dir_mode"
16843 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
16844 [ "$old_file_mode" = "$new_file_mode" ] ||
16845 error "expect mode $old_file_mode get $new_file_mode"
16847 diff /etc/passwd ${migrate_dir}/$tfile ||
16848 error "$tfile different after migration"
16850 diff /etc/passwd ${other_dir}/luna ||
16851 error "luna different after migration"
16853 diff /etc/passwd ${migrate_dir}/sofia ||
16854 error "sofia different after migration"
16856 diff /etc/passwd ${other_dir}/zachary ||
16857 error "zachary different after migration"
16859 diff /etc/passwd $migrate_dir/${tfile}_ln ||
16860 error "${tfile}_ln different after migration"
16862 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
16863 error "${tfile}_ln_other different after migration"
16865 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
16866 [ $stripe_count = 2 ] ||
16867 error "dir strpe_count $d != 2 after migration."
16869 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
16870 [ $stripe_count = 2 ] ||
16871 error "file strpe_count $d != 2 after migration."
16873 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16875 run_test 230b "migrate directory"
16878 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16879 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16880 remote_mds_nodsh && skip "remote MDS with nodsh"
16881 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16882 skip "Need MDS version at least 2.11.52"
16888 local migrate_dir=$DIR/$tdir/migrate_dir
16890 #If migrating directory fails in the middle, all entries of
16891 #the directory is still accessiable.
16892 test_mkdir $DIR/$tdir
16893 test_mkdir -i0 -c1 $migrate_dir
16894 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
16896 createmany -o $migrate_dir/f $total ||
16897 error "create files under ${migrate_dir} failed"
16899 # fail after migrating top dir, and this will fail only once, so the
16900 # first sub file migration will fail (currently f3), others succeed.
16901 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
16902 do_facet mds1 lctl set_param fail_loc=0x1801
16903 local t=$(ls $migrate_dir | wc -l)
16904 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
16905 error "migrate should fail"
16906 local u=$(ls $migrate_dir | wc -l)
16907 [ "$u" == "$t" ] || error "$u != $t during migration"
16909 # add new dir/file should succeed
16910 mkdir $migrate_dir/dir ||
16911 error "mkdir failed under migrating directory"
16912 touch $migrate_dir/file ||
16913 error "create file failed under migrating directory"
16915 # add file with existing name should fail
16916 for file in $migrate_dir/f*; do
16917 stat $file > /dev/null || error "stat $file failed"
16918 $OPENFILE -f O_CREAT:O_EXCL $file &&
16919 error "open(O_CREAT|O_EXCL) $file should fail"
16920 $MULTIOP $file m && error "create $file should fail"
16921 touch $DIR/$tdir/remote_dir/$tfile ||
16922 error "touch $tfile failed"
16923 ln $DIR/$tdir/remote_dir/$tfile $file &&
16924 error "link $file should fail"
16925 mdt_index=$($LFS getstripe -m $file)
16926 if [ $mdt_index == 0 ]; then
16927 # file failed to migrate is not allowed to rename to
16928 mv $DIR/$tdir/remote_dir/$tfile $file &&
16929 error "rename to $file should fail"
16931 mv $DIR/$tdir/remote_dir/$tfile $file ||
16932 error "rename to $file failed"
16934 echo hello >> $file || error "write $file failed"
16937 # resume migration with different options should fail
16938 $LFS migrate -m 0 $migrate_dir &&
16939 error "migrate -m 0 $migrate_dir should fail"
16941 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
16942 error "migrate -c 2 $migrate_dir should fail"
16944 # resume migration should succeed
16945 $LFS migrate -m $MDTIDX $migrate_dir ||
16946 error "migrate $migrate_dir failed"
16948 echo "Finish migration, then checking.."
16949 for file in $(find $migrate_dir); do
16950 mdt_index=$($LFS getstripe -m $file)
16951 [ $mdt_index == $MDTIDX ] ||
16952 error "$file is not on MDT${MDTIDX}"
16955 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16957 run_test 230c "check directory accessiblity if migration failed"
16960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16961 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16962 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16963 skip "Need MDS version at least 2.11.52"
16965 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
16967 local migrate_dir=$DIR/$tdir/migrate_dir
16977 old_index=$((RANDOM % MDSCOUNT))
16978 old_count=$((MDSCOUNT - old_index))
16979 new_index=$((RANDOM % MDSCOUNT))
16980 new_count=$((MDSCOUNT - new_index))
16981 new_hash="all_char"
16983 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
16984 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
16986 test_mkdir $DIR/$tdir
16987 test_mkdir -i $old_index -c $old_count $migrate_dir
16989 for ((i=0; i<100; i++)); do
16990 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
16991 createmany -o $migrate_dir/dir_${i}/f 100 ||
16992 error "create files under remote dir failed $i"
16995 echo -n "Migrate from MDT$old_index "
16996 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
16997 echo -n "to MDT$new_index"
16998 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
17001 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
17002 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
17003 error "migrate remote dir error"
17005 echo "Finish migration, then checking.."
17006 for file in $(find $migrate_dir); do
17007 mdt_index=$($LFS getstripe -m $file)
17008 if [ $mdt_index -lt $new_index ] ||
17009 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
17010 error "$file is on MDT$mdt_index"
17014 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17016 run_test 230d "check migrate big directory"
17019 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17020 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17021 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17022 skip "Need MDS version at least 2.11.52"
17029 mkdir -p $DIR/$tdir
17030 mkdir $DIR/$tdir/migrate_dir
17031 mkdir $DIR/$tdir/other_dir
17032 touch $DIR/$tdir/migrate_dir/a
17033 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
17034 ls $DIR/$tdir/other_dir
17036 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17037 error "migrate dir fails"
17039 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
17040 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
17042 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17043 [ $mdt_index == 0 ] || error "a is not on MDT0"
17045 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
17046 error "migrate dir fails"
17048 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
17049 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
17051 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17052 [ $mdt_index == 1 ] || error "a is not on MDT1"
17054 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
17055 [ $mdt_index == 1 ] || error "b is not on MDT1"
17057 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
17058 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
17060 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
17062 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17064 run_test 230e "migrate mulitple local link files"
17067 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17068 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17069 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17070 skip "Need MDS version at least 2.11.52"
17075 mkdir -p $DIR/$tdir
17076 mkdir $DIR/$tdir/migrate_dir
17077 $LFS mkdir -i1 $DIR/$tdir/other_dir
17078 touch $DIR/$tdir/migrate_dir/a
17079 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
17080 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
17081 ls $DIR/$tdir/other_dir
17083 # a should be migrated to MDT1, since no other links on MDT0
17084 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17085 error "#1 migrate dir fails"
17086 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
17087 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
17088 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17089 [ $mdt_index == 1 ] || error "a is not on MDT1"
17091 # a should stay on MDT1, because it is a mulitple link file
17092 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
17093 error "#2 migrate dir fails"
17094 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17095 [ $mdt_index == 1 ] || error "a is not on MDT1"
17097 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17098 error "#3 migrate dir fails"
17100 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
17101 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
17102 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
17104 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
17105 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
17107 # a should be migrated to MDT0, since no other links on MDT1
17108 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
17109 error "#4 migrate dir fails"
17110 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17111 [ $mdt_index == 0 ] || error "a is not on MDT0"
17113 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17115 run_test 230f "migrate mulitple remote link files"
17118 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17119 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17120 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17121 skip "Need MDS version at least 2.11.52"
17123 mkdir -p $DIR/$tdir/migrate_dir
17125 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
17126 error "migrating dir to non-exist MDT succeeds"
17129 run_test 230g "migrate dir to non-exist MDT"
17132 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17133 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17134 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17135 skip "Need MDS version at least 2.11.52"
17139 mkdir -p $DIR/$tdir/migrate_dir
17141 $LFS migrate -m1 $DIR &&
17142 error "migrating mountpoint1 should fail"
17144 $LFS migrate -m1 $DIR/$tdir/.. &&
17145 error "migrating mountpoint2 should fail"
17148 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
17149 error "migrating $tdir/migrate_dir/.. should fail"
17153 run_test 230h "migrate .. and root"
17156 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17157 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17158 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17159 skip "Need MDS version at least 2.11.52"
17161 mkdir -p $DIR/$tdir/migrate_dir
17163 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
17164 error "migration fails with a tailing slash"
17166 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
17167 error "migration fails with two tailing slashes"
17169 run_test 230i "lfs migrate -m tolerates trailing slashes"
17172 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17173 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17174 skip "Need MDS version at least 2.11.52"
17176 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
17177 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
17178 error "create $tfile failed"
17179 cat /etc/passwd > $DIR/$tdir/$tfile
17181 $LFS migrate -m 1 $DIR/$tdir
17183 cmp /etc/passwd $DIR/$tdir/$tfile ||
17184 error "DoM file mismatch after migration"
17186 run_test 230j "DoM file data not changed after dir migration"
17189 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
17190 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17191 skip "Need MDS version at least 2.11.56"
17194 local files_on_starting_mdt=0
17196 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
17197 $LFS getdirstripe $DIR/$tdir
17198 for i in $(seq $total); do
17199 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
17200 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
17201 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17204 echo "$files_on_starting_mdt files on MDT0"
17206 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
17207 $LFS getdirstripe $DIR/$tdir
17209 files_on_starting_mdt=0
17210 for i in $(seq $total); do
17211 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
17212 error "file $tfile.$i mismatch after migration"
17213 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
17214 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17217 echo "$files_on_starting_mdt files on MDT1 after migration"
17218 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
17220 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
17221 $LFS getdirstripe $DIR/$tdir
17223 files_on_starting_mdt=0
17224 for i in $(seq $total); do
17225 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
17226 error "file $tfile.$i mismatch after 2nd migration"
17227 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
17228 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17231 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
17232 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
17236 run_test 230k "file data not changed after dir migration"
17239 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17240 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17241 skip "Need MDS version at least 2.11.56"
17243 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
17244 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
17245 error "create files under remote dir failed $i"
17246 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
17248 run_test 230l "readdir between MDTs won't crash"
17251 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17252 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17253 skip "Need MDS version at least 2.11.56"
17256 local mig_dir=$DIR/$tdir/migrate_dir
17257 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
17261 echo "Creating files and dirs with xattrs"
17262 test_mkdir $DIR/$tdir
17263 test_mkdir -i0 -c1 $mig_dir
17265 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
17266 error "cannot set xattr attr1 on dir"
17267 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
17268 error "cannot set xattr attr2 on dir"
17269 touch $mig_dir/dir/f0
17270 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
17271 error "cannot set xattr attr1 on file"
17272 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
17273 error "cannot set xattr attr2 on file"
17274 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
17275 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
17276 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
17277 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
17278 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
17279 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
17280 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
17281 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
17282 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
17284 echo "Migrating to MDT1"
17285 $LFS migrate -m $MDTIDX $mig_dir ||
17286 error "fails on migrating dir to MDT1"
17288 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
17289 echo "Checking xattrs"
17290 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
17291 [ "$val" = $longstr ] ||
17292 error "expecting xattr1 $longstr on dir, found $val"
17293 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
17294 [ "$val" = $shortstr ] ||
17295 error "expecting xattr2 $shortstr on dir, found $val"
17296 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
17297 [ "$val" = $longstr ] ||
17298 error "expecting xattr1 $longstr on file, found $val"
17299 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
17300 [ "$val" = $shortstr ] ||
17301 error "expecting xattr2 $shortstr on file, found $val"
17303 run_test 230m "xattrs not changed after dir migration"
17307 # For simplicity this test assumes that max_pages_per_rpc
17308 # is the same across all OSCs
17309 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
17310 local bulk_size=$((max_pages * PAGE_SIZE))
17311 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
17314 mkdir -p $DIR/$tdir
17315 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
17316 error "failed to set stripe with -S ${brw_size}M option"
17318 # clear the OSC stats
17319 $LCTL set_param osc.*.stats=0 &>/dev/null
17322 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
17323 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
17324 oflag=direct &>/dev/null || error "dd failed"
17326 sync; sleep 1; sync # just to be safe
17327 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
17328 if [ x$nrpcs != "x1" ]; then
17329 $LCTL get_param osc.*.stats
17330 error "found $nrpcs ost_write RPCs, not 1 as expected"
17334 # Drop the OSC cache, otherwise we will read from it
17335 cancel_lru_locks osc
17337 # clear the OSC stats
17338 $LCTL set_param osc.*.stats=0 &>/dev/null
17340 # Client reads $bulk_size.
17341 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
17342 iflag=direct &>/dev/null || error "dd failed"
17344 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
17345 if [ x$nrpcs != "x1" ]; then
17346 $LCTL get_param osc.*.stats
17347 error "found $nrpcs ost_read RPCs, not 1 as expected"
17350 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
17353 mkdir -p $DIR/$tdir
17355 for i in {0..1023}; do
17356 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
17357 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
17358 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
17362 run_test 231b "must not assert on fully utilized OST request buffer"
17365 mkdir -p $DIR/$tdir
17366 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
17368 #define OBD_FAIL_LDLM_OST_LVB 0x31c
17369 do_facet ost1 $LCTL set_param fail_loc=0x31c
17371 # ignore dd failure
17372 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
17374 do_facet ost1 $LCTL set_param fail_loc=0
17375 umount_client $MOUNT || error "umount failed"
17376 mount_client $MOUNT || error "mount failed"
17377 stop ost1 || error "cannot stop ost1"
17378 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
17380 run_test 232a "failed lock should not block umount"
17383 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
17384 skip "Need MDS version at least 2.10.58"
17386 mkdir -p $DIR/$tdir
17387 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
17388 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
17390 cancel_lru_locks osc
17392 #define OBD_FAIL_LDLM_OST_LVB 0x31c
17393 do_facet ost1 $LCTL set_param fail_loc=0x31c
17396 $LFS data_version $DIR/$tdir/$tfile || true
17398 do_facet ost1 $LCTL set_param fail_loc=0
17399 umount_client $MOUNT || error "umount failed"
17400 mount_client $MOUNT || error "mount failed"
17401 stop ost1 || error "cannot stop ost1"
17402 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
17404 run_test 232b "failed data version lock should not block umount"
17407 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
17408 skip "Need MDS version at least 2.3.64"
17409 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
17411 local fid=$($LFS path2fid $MOUNT)
17413 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17414 error "cannot access $MOUNT using its FID '$fid'"
17416 run_test 233a "checking that OBF of the FS root succeeds"
17419 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
17420 skip "Need MDS version at least 2.5.90"
17421 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
17423 local fid=$($LFS path2fid $MOUNT/.lustre)
17425 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17426 error "cannot access $MOUNT/.lustre using its FID '$fid'"
17428 fid=$($LFS path2fid $MOUNT/.lustre/fid)
17429 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
17430 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
17432 run_test 233b "checking that OBF of the FS .lustre succeeds"
17435 local p="$TMP/sanityN-$TESTNAME.parameters"
17436 save_lustre_params client "llite.*.xattr_cache" > $p
17437 lctl set_param llite.*.xattr_cache 1 ||
17438 skip_env "xattr cache is not supported"
17440 mkdir -p $DIR/$tdir || error "mkdir failed"
17441 touch $DIR/$tdir/$tfile || error "touch failed"
17442 # OBD_FAIL_LLITE_XATTR_ENOMEM
17443 $LCTL set_param fail_loc=0x1405
17444 getfattr -n user.attr $DIR/$tdir/$tfile &&
17445 error "getfattr should have failed with ENOMEM"
17446 $LCTL set_param fail_loc=0x0
17449 restore_lustre_params < $p
17452 run_test 234 "xattr cache should not crash on ENOMEM"
17455 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
17456 skip "Need MDS version at least 2.4.52"
17458 flock_deadlock $DIR/$tfile
17463 124) error "process hangs on a deadlock"
17465 *) error "error executing flock_deadlock $DIR/$tfile"
17469 run_test 235 "LU-1715: flock deadlock detection does not work properly"
17473 check_swap_layouts_support
17475 local ref1=/etc/passwd
17476 local ref2=/etc/group
17477 local file1=$DIR/$tdir/f1
17478 local file2=$DIR/$tdir/f2
17480 test_mkdir -c1 $DIR/$tdir
17481 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
17482 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
17483 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
17484 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
17485 local fd=$(free_fd)
17486 local cmd="exec $fd<>$file2"
17489 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
17490 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
17493 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
17498 run_test 236 "Layout swap on open unlinked file"
17500 # LU-4659 linkea consistency
17502 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
17503 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
17504 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
17505 skip "Need MDS version at least 2.5.58 or 2.5.2+"
17508 ln $DIR/$tfile $DIR/$tfile.lnk
17509 touch $DIR/$tfile.new
17510 mv $DIR/$tfile.new $DIR/$tfile
17511 local fid1=$($LFS path2fid $DIR/$tfile)
17512 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
17513 local path1=$($LFS fid2path $FSNAME "$fid1")
17514 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
17515 local path2=$($LFS fid2path $FSNAME "$fid2")
17516 [ $tfile.lnk == $path2 ] ||
17517 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
17520 run_test 238 "Verify linkea consistency"
17522 test_239A() { # was test_239
17523 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
17524 skip "Need MDS version at least 2.5.60"
17526 local list=$(comma_list $(mdts_nodes))
17528 mkdir -p $DIR/$tdir
17529 createmany -o $DIR/$tdir/f- 5000
17530 unlinkmany $DIR/$tdir/f- 5000
17531 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
17532 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
17533 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
17534 osp.*MDT*.sync_in_flight" | calc_sum)
17535 [ "$changes" -eq 0 ] || error "$changes not synced"
17537 run_test 239A "osp_sync test"
17539 test_239a() { #LU-5297
17540 remote_mds_nodsh && skip "remote MDS with nodsh"
17543 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
17544 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
17545 chgrp $RUNAS_GID $DIR/$tfile
17546 wait_delete_completed
17548 run_test 239a "process invalid osp sync record correctly"
17550 test_239b() { #LU-5297
17551 remote_mds_nodsh && skip "remote MDS with nodsh"
17554 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
17555 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
17556 chgrp $RUNAS_GID $DIR/$tfile1
17557 wait_delete_completed
17558 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
17560 chgrp $RUNAS_GID $DIR/$tfile2
17561 wait_delete_completed
17563 run_test 239b "process osp sync record with ENOMEM error correctly"
17566 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17567 remote_mds_nodsh && skip "remote MDS with nodsh"
17569 mkdir -p $DIR/$tdir
17571 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
17572 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
17573 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
17574 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
17576 umount_client $MOUNT || error "umount failed"
17577 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
17578 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
17579 mount_client $MOUNT || error "failed to mount client"
17581 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
17582 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
17584 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
17590 for LOOP in $(seq $count); do
17591 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
17592 cancel_lru_locks $OSC || true
17600 for LOOP in $(seq $1); do
17601 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
17606 test_241a() { # was test_241
17607 local bsize=$PAGE_SIZE
17609 (( bsize < 40960 )) && bsize=40960
17610 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17612 cancel_lru_locks $OSC
17613 test_241_bio 1000 $bsize &
17615 test_241_dio 1000 $bsize
17618 run_test 241a "bio vs dio"
17621 local bsize=$PAGE_SIZE
17623 (( bsize < 40960 )) && bsize=40960
17624 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
17626 test_241_dio 1000 $bsize &
17628 test_241_dio 1000 $bsize
17631 run_test 241b "dio vs dio"
17634 remote_mds_nodsh && skip "remote MDS with nodsh"
17636 mkdir -p $DIR/$tdir
17637 touch $DIR/$tdir/$tfile
17639 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
17640 do_facet mds1 lctl set_param fail_loc=0x105
17641 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
17643 do_facet mds1 lctl set_param fail_loc=0
17644 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
17646 run_test 242 "mdt_readpage failure should not cause directory unreadable"
17650 test_mkdir $DIR/$tdir
17651 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
17653 run_test 243 "various group lock tests"
17657 test_mkdir $DIR/$tdir
17658 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
17659 sendfile_grouplock $DIR/$tdir/$tfile || \
17660 error "sendfile+grouplock failed"
17663 run_test 244a "sendfile with group lock tests"
17667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
17670 local size=$((1024*1024))
17672 test_mkdir $DIR/$tdir
17673 for i in $(seq 1 $threads); do
17674 local file=$DIR/$tdir/file_$((i / 10))
17675 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
17678 for i in $(seq 1 $threads); do
17682 run_test 244b "multi-threaded write with group lock"
17685 local flagname="multi_mod_rpcs"
17686 local connect_data_name="max_mod_rpcs"
17689 # check if multiple modify RPCs flag is set
17690 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
17691 grep "connect_flags:")
17694 echo "$out" | grep -qw $flagname
17695 if [ $? -ne 0 ]; then
17696 echo "connect flag $flagname is not set"
17700 # check if multiple modify RPCs data is set
17701 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
17704 echo "$out" | grep -qw $connect_data_name ||
17705 error "import should have connect data $connect_data_name"
17707 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
17713 umount_client $submount
17718 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17720 skip_env "Fileset feature is not supported"
17722 local submount=${MOUNT}_$tdir
17725 mkdir -p $submount || error "mkdir $submount failed"
17726 FILESET="$FILESET/$tdir" mount_client $submount ||
17727 error "mount $submount failed"
17728 trap "cleanup_247 $submount" EXIT
17729 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
17730 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
17731 error "read $MOUNT/$tdir/$tfile failed"
17732 cleanup_247 $submount
17734 run_test 247a "mount subdir as fileset"
17737 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17738 skip_env "Fileset feature is not supported"
17740 local submount=${MOUNT}_$tdir
17742 rm -rf $MOUNT/$tdir
17743 mkdir -p $submount || error "mkdir $submount failed"
17745 FILESET="$FILESET/$tdir" mount_client $submount &&
17746 error "mount $submount should fail"
17749 run_test 247b "mount subdir that dose not exist"
17752 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17753 skip_env "Fileset feature is not supported"
17755 local submount=${MOUNT}_$tdir
17757 mkdir -p $MOUNT/$tdir/dir1
17758 mkdir -p $submount || error "mkdir $submount failed"
17759 trap "cleanup_247 $submount" EXIT
17760 FILESET="$FILESET/$tdir" mount_client $submount ||
17761 error "mount $submount failed"
17762 local fid=$($LFS path2fid $MOUNT/)
17763 $LFS fid2path $submount $fid && error "fid2path should fail"
17764 cleanup_247 $submount
17766 run_test 247c "running fid2path outside root"
17769 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
17770 skip "Fileset feature is not supported"
17772 local submount=${MOUNT}_$tdir
17774 mkdir -p $MOUNT/$tdir/dir1
17775 mkdir -p $submount || error "mkdir $submount failed"
17776 FILESET="$FILESET/$tdir" mount_client $submount ||
17777 error "mount $submount failed"
17778 trap "cleanup_247 $submount" EXIT
17779 local fid=$($LFS path2fid $submount/dir1)
17780 $LFS fid2path $submount $fid || error "fid2path should succeed"
17781 cleanup_247 $submount
17783 run_test 247d "running fid2path inside root"
17787 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
17789 skip "Fileset feature is not supported"
17791 local submount=${MOUNT}_$tdir
17794 mkdir -p $submount || error "mkdir $submount failed"
17795 FILESET="$FILESET/.." mount_client $submount &&
17796 error "mount $submount should fail"
17799 run_test 247e "mount .. as fileset"
17802 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
17803 [ -z "$fast_read_sav" ] && skip "no fast read support"
17805 # create a large file for fast read verification
17806 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
17808 # make sure the file is created correctly
17809 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
17810 { rm -f $DIR/$tfile; skip "file creation error"; }
17812 echo "Test 1: verify that fast read is 4 times faster on cache read"
17814 # small read with fast read enabled
17815 $LCTL set_param -n llite.*.fast_read=1
17816 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17817 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17818 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17819 # small read with fast read disabled
17820 $LCTL set_param -n llite.*.fast_read=0
17821 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
17822 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17823 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17825 # verify that fast read is 4 times faster for cache read
17826 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
17827 error_not_in_vm "fast read was not 4 times faster: " \
17828 "$t_fast vs $t_slow"
17830 echo "Test 2: verify the performance between big and small read"
17831 $LCTL set_param -n llite.*.fast_read=1
17833 # 1k non-cache read
17834 cancel_lru_locks osc
17835 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17836 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17837 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17839 # 1M non-cache read
17840 cancel_lru_locks osc
17841 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
17842 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
17843 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
17845 # verify that big IO is not 4 times faster than small IO
17846 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
17847 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
17849 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
17852 run_test 248a "fast read verification"
17855 # Default short_io_bytes=16384, try both smaller and larger sizes.
17856 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
17857 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
17858 echo "bs=53248 count=113 normal buffered write"
17859 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
17860 error "dd of initial data file failed"
17861 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
17863 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
17864 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
17865 error "dd with sync normal writes failed"
17866 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
17868 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
17869 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
17870 error "dd with sync small writes failed"
17871 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
17873 cancel_lru_locks osc
17875 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
17876 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
17877 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
17878 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
17879 iflag=direct || error "dd with O_DIRECT small read failed"
17880 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
17881 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
17882 error "compare $TMP/$tfile.1 failed"
17884 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
17885 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
17887 # just to see what the maximum tunable value is, and test parsing
17888 echo "test invalid parameter 2MB"
17889 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
17890 error "too-large short_io_bytes allowed"
17891 echo "test maximum parameter 512KB"
17892 # if we can set a larger short_io_bytes, run test regardless of version
17893 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
17894 # older clients may not allow setting it this large, that's OK
17895 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
17896 skip "Need at least client version 2.13.50"
17897 error "medium short_io_bytes failed"
17899 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
17900 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
17902 echo "test large parameter 64KB"
17903 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
17904 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
17906 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
17907 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
17908 error "dd with sync large writes failed"
17909 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
17911 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
17912 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
17913 num=$((113 * 4096 / PAGE_SIZE))
17914 echo "bs=$size count=$num oflag=direct large write $tfile.3"
17915 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
17916 error "dd with O_DIRECT large writes failed"
17917 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
17918 error "compare $DIR/$tfile.3 failed"
17920 cancel_lru_locks osc
17922 echo "bs=$size count=$num iflag=direct large read $tfile.2"
17923 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
17924 error "dd with O_DIRECT large read failed"
17925 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
17926 error "compare $TMP/$tfile.2 failed"
17928 echo "bs=$size count=$num iflag=direct large read $tfile.3"
17929 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
17930 error "dd with O_DIRECT large read failed"
17931 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
17932 error "compare $TMP/$tfile.3 failed"
17934 run_test 248b "test short_io read and write for both small and large sizes"
17936 test_249() { # LU-7890
17937 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
17938 skip "Need at least version 2.8.54"
17941 $LFS setstripe -c 1 $DIR/$tfile
17942 # Offset 2T == 4k * 512M
17943 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
17944 error "dd to 2T offset failed"
17946 run_test 249 "Write above 2T file size"
17949 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
17950 && skip "no 16TB file size limit on ZFS"
17952 $LFS setstripe -c 1 $DIR/$tfile
17953 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
17954 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
17955 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
17956 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
17957 conv=notrunc,fsync && error "append succeeded"
17960 run_test 250 "Write above 16T limit"
17963 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
17965 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
17966 #Skip once - writing the first stripe will succeed
17967 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17968 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
17969 error "short write happened"
17971 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17972 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
17973 error "short read happened"
17977 run_test 251 "Handling short read and write correctly"
17980 remote_mds_nodsh && skip "remote MDS with nodsh"
17981 remote_ost_nodsh && skip "remote OST with nodsh"
17982 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
17983 skip_env "ldiskfs only test"
17993 # check lr_reader on OST0000
17995 dev=$(facet_device $tgt)
17996 out=$(do_facet $tgt $LR_READER $dev)
17997 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17999 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
18000 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
18001 error "Invalid uuid returned by $LR_READER on target $tgt"
18002 echo -e "uuid returned by $LR_READER is '$uuid'\n"
18004 # check lr_reader -c on MDT0000
18006 dev=$(facet_device $tgt)
18007 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
18008 skip "$LR_READER does not support additional options"
18010 out=$(do_facet $tgt $LR_READER -c $dev)
18011 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18013 num=$(echo "$out" | grep -c "mdtlov")
18014 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
18015 error "Invalid number of mdtlov clients returned by $LR_READER"
18016 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
18018 # check lr_reader -cr on MDT0000
18019 out=$(do_facet $tgt $LR_READER -cr $dev)
18020 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18022 echo "$out" | grep -q "^reply_data:$" ||
18023 error "$LR_READER should have returned 'reply_data' section"
18024 num=$(echo "$out" | grep -c "client_generation")
18025 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
18027 run_test 252 "check lr_reader tool"
18030 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18031 remote_mds_nodsh && skip "remote MDS with nodsh"
18032 remote_mgs_nodsh && skip "remote MGS with nodsh"
18036 local ost_name=$(ostname_from_index $ostidx)
18039 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
18040 do_facet $SINGLEMDS $LCTL get_param -n \
18041 osp.$mdtosc_proc1.reserved_mb_high ||
18042 skip "remote MDS does not support reserved_mb_high"
18046 wait_delete_completed
18049 pool_add $TESTNAME || error "Pool creation failed"
18050 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
18052 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
18053 error "Setstripe failed"
18055 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
18057 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
18059 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
18061 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
18062 osp.$mdtosc_proc1.prealloc_status)
18063 echo "prealloc_status $oa_status"
18065 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
18066 error "File creation should fail"
18068 #object allocation was stopped, but we still able to append files
18069 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
18070 oflag=append || error "Append failed"
18072 rm -f $DIR/$tdir/$tfile.0
18074 # For this test, we want to delete the files we created to go out of
18075 # space but leave the watermark, so we remain nearly out of space
18076 ost_watermarks_enospc_delete_files $tfile $ostidx
18078 wait_delete_completed
18082 for i in $(seq 10 12); do
18083 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
18084 2>/dev/null || error "File creation failed after rm"
18087 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
18088 osp.$mdtosc_proc1.prealloc_status)
18089 echo "prealloc_status $oa_status"
18091 if (( oa_status != 0 )); then
18092 error "Object allocation still disable after rm"
18095 run_test 253 "Check object allocation limit"
18098 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18099 remote_mds_nodsh && skip "remote MDS with nodsh"
18100 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
18101 skip "MDS does not support changelog_size"
18104 local MDT0=$(facet_svc $SINGLEMDS)
18106 changelog_register || error "changelog_register failed"
18108 changelog_clear 0 || error "changelog_clear failed"
18110 local size1=$(do_facet $SINGLEMDS \
18111 $LCTL get_param -n mdd.$MDT0.changelog_size)
18112 echo "Changelog size $size1"
18115 $LFS mkdir -i 0 $DIR/$tdir
18117 mkdir -p $DIR/$tdir/pics/2008/zachy
18118 touch $DIR/$tdir/pics/2008/zachy/timestamp
18119 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
18120 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
18121 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
18122 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
18123 rm $DIR/$tdir/pics/desktop.jpg
18125 local size2=$(do_facet $SINGLEMDS \
18126 $LCTL get_param -n mdd.$MDT0.changelog_size)
18127 echo "Changelog size after work $size2"
18129 (( $size2 > $size1 )) ||
18130 error "new Changelog size=$size2 less than old size=$size1"
18132 run_test 254 "Check changelog size"
18139 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
18140 awk -F: '{print $2}' | grep $type > /dev/null
18141 if [ $? -ne 0 ]; then
18151 lfs ladvise -a willread $file > /dev/null 2>&1
18152 if [ $? -eq 0 ]; then
18156 lfs ladvise -a willread $file 2>&1 |
18157 grep "Inappropriate ioctl for device" > /dev/null
18158 if [ $? -eq 0 ]; then
18165 bc <<<"scale=2; ($1 - $2) * 100 / $2"
18168 # run a random read IO workload
18169 # usage: random_read_iops <filename> <filesize> <iosize>
18170 random_read_iops() {
18173 local iosize=${3:-4096}
18175 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
18176 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
18179 drop_file_oss_cache() {
18183 $LFS ladvise -a dontneed $file 2>/dev/null ||
18184 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
18187 ladvise_willread_performance()
18190 local average_origin=0
18191 local average_cache=0
18192 local average_ladvise=0
18194 for ((i = 1; i <= $repeat; i++)); do
18195 echo "Iter $i/$repeat: reading without willread hint"
18196 cancel_lru_locks osc
18197 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
18198 local speed_origin=$(random_read_iops $DIR/$tfile $size)
18199 echo "Iter $i/$repeat: uncached speed: $speed_origin"
18200 average_origin=$(bc <<<"$average_origin + $speed_origin")
18202 cancel_lru_locks osc
18203 local speed_cache=$(random_read_iops $DIR/$tfile $size)
18204 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
18205 average_cache=$(bc <<<"$average_cache + $speed_cache")
18207 cancel_lru_locks osc
18208 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
18209 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
18210 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
18211 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
18212 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
18214 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
18215 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
18216 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
18218 speedup_cache=$(percent $average_cache $average_origin)
18219 speedup_ladvise=$(percent $average_ladvise $average_origin)
18221 echo "Average uncached read: $average_origin"
18222 echo "Average speedup with OSS cached read: " \
18223 "$average_cache = +$speedup_cache%"
18224 echo "Average speedup with ladvise willread: " \
18225 "$average_ladvise = +$speedup_ladvise%"
18227 local lowest_speedup=20
18228 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
18229 echo "Speedup with OSS cached read less than $lowest_speedup%," \
18230 "got $average_cache%. Skipping ladvise willread check."
18234 # the test won't work on ZFS until it supports 'ladvise dontneed', but
18235 # it is still good to run until then to exercise 'ladvise willread'
18236 ! $LFS ladvise -a dontneed $DIR/$tfile &&
18237 [ "$ost1_FSTYPE" = "zfs" ] &&
18238 echo "osd-zfs does not support dontneed or drop_caches" &&
18241 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
18242 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
18243 error_not_in_vm "Speedup with willread is less than " \
18244 "$lowest_speedup%, got $average_ladvise%"
18248 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
18249 skip "lustre < 2.8.54 does not support ladvise "
18250 remote_ost_nodsh && skip "remote OST with nodsh"
18252 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
18254 ladvise_no_type willread $DIR/$tfile &&
18255 skip "willread ladvise is not supported"
18257 ladvise_no_ioctl $DIR/$tfile &&
18258 skip "ladvise ioctl is not supported"
18261 local size=$((size_mb * 1048576))
18262 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
18263 error "dd to $DIR/$tfile failed"
18265 lfs ladvise -a willread $DIR/$tfile ||
18266 error "Ladvise failed with no range argument"
18268 lfs ladvise -a willread -s 0 $DIR/$tfile ||
18269 error "Ladvise failed with no -l or -e argument"
18271 lfs ladvise -a willread -e 1 $DIR/$tfile ||
18272 error "Ladvise failed with only -e argument"
18274 lfs ladvise -a willread -l 1 $DIR/$tfile ||
18275 error "Ladvise failed with only -l argument"
18277 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
18278 error "End offset should not be smaller than start offset"
18280 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
18281 error "End offset should not be equal to start offset"
18283 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
18284 error "Ladvise failed with overflowing -s argument"
18286 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
18287 error "Ladvise failed with overflowing -e argument"
18289 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
18290 error "Ladvise failed with overflowing -l argument"
18292 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
18293 error "Ladvise succeeded with conflicting -l and -e arguments"
18295 echo "Synchronous ladvise should wait"
18297 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
18298 do_nodes $(comma_list $(osts_nodes)) \
18299 $LCTL set_param fail_val=$delay fail_loc=0x237
18301 local start_ts=$SECONDS
18302 lfs ladvise -a willread $DIR/$tfile ||
18303 error "Ladvise failed with no range argument"
18304 local end_ts=$SECONDS
18305 local inteval_ts=$((end_ts - start_ts))
18307 if [ $inteval_ts -lt $(($delay - 1)) ]; then
18308 error "Synchronous advice didn't wait reply"
18311 echo "Asynchronous ladvise shouldn't wait"
18312 local start_ts=$SECONDS
18313 lfs ladvise -a willread -b $DIR/$tfile ||
18314 error "Ladvise failed with no range argument"
18315 local end_ts=$SECONDS
18316 local inteval_ts=$((end_ts - start_ts))
18318 if [ $inteval_ts -gt $(($delay / 2)) ]; then
18319 error "Asynchronous advice blocked"
18322 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
18323 ladvise_willread_performance
18325 run_test 255a "check 'lfs ladvise -a willread'"
18331 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
18335 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
18336 skip "lustre < 2.8.54 does not support ladvise "
18337 remote_ost_nodsh && skip "remote OST with nodsh"
18339 lfs setstripe -c 1 -i 0 $DIR/$tfile
18341 ladvise_no_type dontneed $DIR/$tfile &&
18342 skip "dontneed ladvise is not supported"
18344 ladvise_no_ioctl $DIR/$tfile &&
18345 skip "ladvise ioctl is not supported"
18347 ! $LFS ladvise -a dontneed $DIR/$tfile &&
18348 [ "$ost1_FSTYPE" = "zfs" ] &&
18349 skip "zfs-osd does not support 'ladvise dontneed'"
18352 local size=$((size_mb * 1048576))
18353 # In order to prevent disturbance of other processes, only check 3/4
18354 # of the memory usage
18355 local kibibytes=$((size_mb * 1024 * 3 / 4))
18357 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
18358 error "dd to $DIR/$tfile failed"
18360 #force write to complete before dropping OST cache & checking memory
18363 local total=$(facet_meminfo ost1 MemTotal)
18364 echo "Total memory: $total KiB"
18366 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
18367 local before_read=$(facet_meminfo ost1 Cached)
18368 echo "Cache used before read: $before_read KiB"
18370 lfs ladvise -a willread $DIR/$tfile ||
18371 error "Ladvise willread failed"
18372 local after_read=$(facet_meminfo ost1 Cached)
18373 echo "Cache used after read: $after_read KiB"
18375 lfs ladvise -a dontneed $DIR/$tfile ||
18376 error "Ladvise dontneed again failed"
18377 local no_read=$(facet_meminfo ost1 Cached)
18378 echo "Cache used after dontneed ladvise: $no_read KiB"
18380 if [ $total -lt $((before_read + kibibytes)) ]; then
18381 echo "Memory is too small, abort checking"
18385 if [ $((before_read + kibibytes)) -gt $after_read ]; then
18386 error "Ladvise willread should use more memory" \
18387 "than $kibibytes KiB"
18390 if [ $((no_read + kibibytes)) -gt $after_read ]; then
18391 error "Ladvise dontneed should release more memory" \
18392 "than $kibibytes KiB"
18395 run_test 255b "check 'lfs ladvise -a dontneed'"
18398 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
18399 skip "lustre < 2.10.50 does not support lockahead"
18407 test_mkdir -p $DIR/$tdir
18408 $LFS setstripe -i 0 -c 1 $DIR/$tdir
18410 #test 10 returns only success/failure
18412 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18414 if [ $rc -eq 255 ]; then
18415 error "Ladvise test${i} failed, ${rc}"
18418 #test 11 counts lock enqueue requests, all others count new locks
18420 count=$(do_facet ost1 \
18421 $LCTL get_param -n ost.OSS.ost.stats)
18422 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
18424 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18426 if [ $rc -eq 255 ]; then
18427 error "Ladvise test${i} failed, ${rc}"
18430 new_count=$(do_facet ost1 \
18431 $LCTL get_param -n ost.OSS.ost.stats)
18432 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
18433 awk '{ print $2 }')
18435 difference="$((new_count - count))"
18436 if [ $difference -ne $rc ]; then
18437 error "Ladvise test${i}, bad enqueue count, returned " \
18438 "${rc}, actual ${difference}"
18441 for i in $(seq 12 21); do
18442 # If we do not do this, we run the risk of having too many
18443 # locks and starting lock cancellation while we are checking
18445 cancel_lru_locks osc
18447 count=$($LCTL get_param -n \
18448 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
18450 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18452 if [ $rc -eq 255 ]; then
18453 error "Ladvise test ${i} failed, ${rc}"
18456 new_count=$($LCTL get_param -n \
18457 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
18458 difference="$((new_count - count))"
18460 # Test 15 output is divided by 100 to map down to valid return
18461 if [ $i -eq 15 ]; then
18465 if [ $difference -ne $rc ]; then
18466 error "Ladvise test ${i}, bad lock count, returned " \
18467 "${rc}, actual ${difference}"
18471 #test 22 returns only success/failure
18473 lockahead_test -d $DIR/$tdir -t $i -f $tfile
18475 if [ $rc -eq 255 ]; then
18476 error "Ladvise test${i} failed, ${rc}"
18479 run_test 255c "suite of ladvise lockahead tests"
18482 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18483 remote_mds_nodsh && skip "remote MDS with nodsh"
18484 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18485 changelog_users $SINGLEMDS | grep "^cl" &&
18486 skip "active changelog user"
18492 mdt_dev=$(mdsdevname 1)
18495 changelog_register || error "changelog_register failed"
18498 mkdir -p $DIR/$tdir
18500 changelog_clear 0 || error "changelog_clear failed"
18503 touch $DIR/$tdir/{1..10}
18506 stop $SINGLEMDS || error "Fail to stop MDT"
18510 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
18512 #after mount new plainllog is used
18513 touch $DIR/$tdir/{11..19}
18514 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
18515 stack_trap "rm -f $tmpfile"
18516 cat_sl=$(do_facet $SINGLEMDS "sync; \
18517 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
18518 llog_reader $tmpfile | grep -c type=1064553b")
18519 do_facet $SINGLEMDS llog_reader $tmpfile
18521 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
18523 changelog_clear 0 || error "changelog_clear failed"
18525 cat_sl=$(do_facet $SINGLEMDS "sync; \
18526 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
18527 llog_reader $tmpfile | grep -c type=1064553b")
18529 if (( cat_sl == 2 )); then
18530 error "Empty plain llog was not deleted from changelog catalog"
18531 elif (( cat_sl != 1 )); then
18532 error "Active plain llog shouldn't be deleted from catalog"
18535 run_test 256 "Check llog delete for empty and not full state"
18538 remote_mds_nodsh && skip "remote MDS with nodsh"
18539 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
18540 skip "Need MDS version at least 2.8.55"
18542 test_mkdir $DIR/$tdir
18544 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
18545 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
18548 #define OBD_FAIL_MDS_XATTR_REP 0x161
18549 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18550 local facet=mds$((mdtidx + 1))
18551 set_nodes_failloc $(facet_active_host $facet) 0x80000161
18552 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
18554 stop $facet || error "stop MDS failed"
18555 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
18556 error "start MDS fail"
18557 wait_recovery_complete $facet
18559 run_test 257 "xattr locks are not lost"
18561 # Verify we take the i_mutex when security requires it
18563 #define OBD_FAIL_IMUTEX_SEC 0x141c
18564 $LCTL set_param fail_loc=0x141c
18566 chmod u+s $DIR/$tfile
18567 chmod a+rwx $DIR/$tfile
18568 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18570 if [ $RC -ne 0 ]; then
18571 error "error, failed to take i_mutex, rc=$?"
18575 run_test 258a "verify i_mutex security behavior when suid attributes is set"
18577 # Verify we do NOT take the i_mutex in the normal case
18579 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
18580 $LCTL set_param fail_loc=0x141d
18583 chmod a+rw $DIR/$tfile
18584 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
18586 if [ $RC -ne 0 ]; then
18587 error "error, took i_mutex unnecessarily, rc=$?"
18592 run_test 258b "verify i_mutex security behavior"
18595 local file=$DIR/$tfile
18599 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
18601 stack_trap "rm -f $file" EXIT
18603 wait_delete_completed
18604 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18605 echo "before: $before"
18607 $LFS setstripe -i 0 -c 1 $file
18608 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
18610 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18611 echo "after write: $after"
18613 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
18614 do_facet ost1 $LCTL set_param fail_loc=0x2301
18616 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18617 echo "after truncate: $after"
18620 do_facet ost1 $LCTL set_param fail_loc=0
18621 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18623 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
18624 echo "after restart: $after"
18625 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
18626 error "missing truncate?"
18630 run_test 259 "crash at delayed truncate"
18633 #define OBD_FAIL_MDC_CLOSE 0x806
18634 $LCTL set_param fail_loc=0x80000806
18638 run_test 260 "Check mdc_close fail"
18640 ### Data-on-MDT sanity tests ###
18642 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18643 skip "Need MDS version at least 2.10.55 for DoM"
18646 local dom=$DIR/$tdir/dom_file
18647 local tmp=$DIR/$tdir/tmp_file
18649 mkdir -p $DIR/$tdir
18651 # basic checks for DoM component creation
18652 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
18653 error "Can set MDT layout to non-first entry"
18655 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
18656 error "Can define multiple entries as MDT layout"
18658 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
18660 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
18661 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
18662 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
18664 local mdtidx=$($LFS getstripe -m $dom)
18665 local mdtname=MDT$(printf %04x $mdtidx)
18666 local facet=mds$((mdtidx + 1))
18667 local space_check=1
18669 # Skip free space checks with ZFS
18670 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
18674 local size_tmp=$((65536 * 3))
18675 local mdtfree1=$(do_facet $facet \
18676 lctl get_param -n osd*.*$mdtname.kbytesfree)
18678 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18679 # check also direct IO along write
18680 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
18681 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18683 cmp $tmp $dom || error "file data is different"
18684 [ $(stat -c%s $dom) == $size_tmp ] ||
18685 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18686 if [ $space_check == 1 ]; then
18687 local mdtfree2=$(do_facet $facet \
18688 lctl get_param -n osd*.*$mdtname.kbytesfree)
18690 # increase in usage from by $size_tmp
18691 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18692 error "MDT free space wrong after write: " \
18693 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18697 local size_dom=10000
18699 $TRUNCATE $dom $size_dom
18700 [ $(stat -c%s $dom) == $size_dom ] ||
18701 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
18702 if [ $space_check == 1 ]; then
18703 mdtfree1=$(do_facet $facet \
18704 lctl get_param -n osd*.*$mdtname.kbytesfree)
18705 # decrease in usage from $size_tmp to new $size_dom
18706 [ $(($mdtfree1 - $mdtfree2)) -ge \
18707 $(((size_tmp - size_dom) / 1024)) ] ||
18708 error "MDT free space is wrong after truncate: " \
18709 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
18715 size_dom=$((size_dom + size_tmp))
18716 [ $(stat -c%s $dom) == $size_dom ] ||
18717 error "bad size after append: $(stat -c%s $dom) != $size_dom"
18718 if [ $space_check == 1 ]; then
18719 mdtfree2=$(do_facet $facet \
18720 lctl get_param -n osd*.*$mdtname.kbytesfree)
18721 # increase in usage by $size_tmp from previous
18722 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
18723 error "MDT free space is wrong after append: " \
18724 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
18729 if [ $space_check == 1 ]; then
18730 mdtfree1=$(do_facet $facet \
18731 lctl get_param -n osd*.*$mdtname.kbytesfree)
18732 # decrease in usage by $size_dom from previous
18733 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
18734 error "MDT free space is wrong after removal: " \
18735 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
18738 # combined striping
18739 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
18740 error "Can't create DoM + OST striping"
18742 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
18743 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
18744 # check also direct IO along write
18745 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
18747 cmp $tmp $dom || error "file data is different"
18748 [ $(stat -c%s $dom) == $size_tmp ] ||
18749 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
18754 run_test 270a "DoM: basic functionality tests"
18757 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18758 skip "Need MDS version at least 2.10.55"
18760 local dom=$DIR/$tdir/dom_file
18761 local max_size=1048576
18763 mkdir -p $DIR/$tdir
18764 $LFS setstripe -E $max_size -L mdt $dom
18766 # truncate over the limit
18767 $TRUNCATE $dom $(($max_size + 1)) &&
18768 error "successful truncate over the maximum size"
18769 # write over the limit
18770 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
18771 error "successful write over the maximum size"
18772 # append over the limit
18773 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
18774 echo "12345" >> $dom && error "successful append over the maximum size"
18779 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
18782 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18783 skip "Need MDS version at least 2.10.55"
18785 mkdir -p $DIR/$tdir
18786 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18788 # check files inherit DoM EA
18789 touch $DIR/$tdir/first
18790 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
18791 error "bad pattern"
18792 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
18793 error "bad stripe count"
18794 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
18795 error "bad stripe size"
18797 # check directory inherits DoM EA and uses it as default
18798 mkdir $DIR/$tdir/subdir
18799 touch $DIR/$tdir/subdir/second
18800 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
18801 error "bad pattern in sub-directory"
18802 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
18803 error "bad stripe count in sub-directory"
18804 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
18805 error "bad stripe size in sub-directory"
18808 run_test 270c "DoM: DoM EA inheritance tests"
18811 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18812 skip "Need MDS version at least 2.10.55"
18814 mkdir -p $DIR/$tdir
18815 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18817 # inherit default DoM striping
18818 mkdir $DIR/$tdir/subdir
18819 touch $DIR/$tdir/subdir/f1
18821 # change default directory striping
18822 $LFS setstripe -c 1 $DIR/$tdir/subdir
18823 touch $DIR/$tdir/subdir/f2
18824 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
18825 error "wrong default striping in file 2"
18826 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
18827 error "bad pattern in file 2"
18830 run_test 270d "DoM: change striping from DoM to RAID0"
18833 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18834 skip "Need MDS version at least 2.10.55"
18836 mkdir -p $DIR/$tdir/dom
18837 mkdir -p $DIR/$tdir/norm
18840 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
18841 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
18843 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
18844 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
18846 # find DoM files by layout
18847 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
18848 [ $NUM -eq $DOMFILES ] ||
18849 error "lfs find -L: found $NUM, expected $DOMFILES"
18850 echo "Test 1: lfs find 20 DOM files by layout: OK"
18852 # there should be 1 dir with default DOM striping
18853 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
18855 error "lfs find -L: found $NUM, expected 1 dir"
18856 echo "Test 2: lfs find 1 DOM dir by layout: OK"
18858 # find DoM files by stripe size
18859 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
18860 [ $NUM -eq $DOMFILES ] ||
18861 error "lfs find -S: found $NUM, expected $DOMFILES"
18862 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
18864 # find files by stripe offset except DoM files
18865 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
18866 [ $NUM -eq $NORMFILES ] ||
18867 error "lfs find -i: found $NUM, expected $NORMFILES"
18868 echo "Test 5: lfs find no DOM files by stripe index: OK"
18871 run_test 270e "DoM: lfs find with DoM files test"
18874 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18875 skip "Need MDS version at least 2.10.55"
18877 local mdtname=${FSNAME}-MDT0000-mdtlov
18878 local dom=$DIR/$tdir/dom_file
18879 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
18880 lod.$mdtname.dom_stripesize)
18881 local dom_limit=131072
18883 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
18884 local dom_current=$(do_facet mds1 $LCTL get_param -n \
18885 lod.$mdtname.dom_stripesize)
18886 [ ${dom_limit} -eq ${dom_current} ] ||
18887 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
18889 $LFS mkdir -i 0 -c 1 $DIR/$tdir
18890 $LFS setstripe -d $DIR/$tdir
18891 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
18892 error "Can't set directory default striping"
18894 # exceed maximum stripe size
18895 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18896 error "Can't create file with $((dom_limit * 2)) DoM stripe"
18897 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
18898 error "Able to create DoM component size more than LOD limit"
18900 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
18901 dom_current=$(do_facet mds1 $LCTL get_param -n \
18902 lod.$mdtname.dom_stripesize)
18903 [ 0 -eq ${dom_current} ] ||
18904 error "Can't set zero DoM stripe limit"
18907 # attempt to create DoM file on server with disabled DoM should
18908 # remove DoM entry from layout and be succeed
18909 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
18910 error "Can't create DoM file (DoM is disabled)"
18911 [ $($LFS getstripe -L $dom) == "mdt" ] &&
18912 error "File has DoM component while DoM is disabled"
18915 # attempt to create DoM file with only DoM stripe should return error
18916 $LFS setstripe -E $dom_limit -L mdt $dom &&
18917 error "Able to create DoM-only file while DoM is disabled"
18919 # too low values to be aligned with smallest stripe size 64K
18920 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
18921 dom_current=$(do_facet mds1 $LCTL get_param -n \
18922 lod.$mdtname.dom_stripesize)
18923 [ 30000 -eq ${dom_current} ] &&
18924 error "Can set too small DoM stripe limit"
18926 # 64K is a minimal stripe size in Lustre, expect limit of that size
18927 [ 65536 -eq ${dom_current} ] ||
18928 error "Limit is not set to 64K but ${dom_current}"
18930 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
18931 dom_current=$(do_facet mds1 $LCTL get_param -n \
18932 lod.$mdtname.dom_stripesize)
18934 [ 2147483648 -eq ${dom_current} ] &&
18935 error "Can set too large DoM stripe limit"
18937 do_facet mds1 $LCTL set_param -n \
18938 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
18939 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18940 error "Can't create DoM component size after limit change"
18941 do_facet mds1 $LCTL set_param -n \
18942 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
18943 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
18944 error "Can't create DoM file after limit decrease"
18945 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
18946 error "Can create big DoM component after limit decrease"
18947 touch ${dom}_def ||
18948 error "Can't create file with old default layout"
18950 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
18953 run_test 270f "DoM: maximum DoM stripe size checks"
18956 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18957 skip "Need MDS version at least 2.10.55"
18959 local dom=$DIR/$tdir/dom
18961 mkdir -p $DIR/$tdir
18963 $LFS setstripe -E 1024K -L mdt $dom
18965 lctl set_param -n mdc.*.stats=clear
18966 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18967 cat $dom > /dev/null
18968 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
18969 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
18973 run_test 271a "DoM: data is cached for read after write"
18976 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18977 skip "Need MDS version at least 2.10.55"
18979 local dom=$DIR/$tdir/dom
18981 mkdir -p $DIR/$tdir
18983 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18985 lctl set_param -n mdc.*.stats=clear
18986 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18987 cancel_lru_locks mdc
18988 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
18989 # second stat to check size is cached on client
18990 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
18991 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18992 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
18995 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
18998 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18999 skip "Need MDS version at least 2.10.55"
19001 local dom=$DIR/$tdir/dom
19003 mkdir -p $DIR/$tdir
19005 $LFS setstripe -E 1024K -L mdt -E EOF $dom
19007 lctl set_param -n mdc.*.stats=clear
19008 lctl set_param -n osc.*.stats=clear
19009 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
19010 cancel_lru_locks mdc
19011 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
19012 # second stat to check size is cached on client
19013 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
19014 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
19015 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
19016 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
19017 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
19020 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
19026 local mdt=MDT$(printf %04x $mdtidx)
19028 if [ -z $param ]; then
19029 lctl get_param -n mdc.*$mdt*.stats
19031 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
19036 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19037 skip "Need MDS version at least 2.10.55"
19039 local dom=$DIR/$tdir/dom
19041 mkdir -p $DIR/$tdir
19043 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19045 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
19046 local facet=mds$((mdtidx + 1))
19048 cancel_lru_locks mdc
19049 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
19050 createmany -o $dom 1000
19051 lctl set_param -n mdc.*.stats=clear
19052 smalliomany -w $dom 1000 200
19053 get_mdc_stats $mdtidx
19054 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
19055 # Each file has 1 open, 1 IO enqueues, total 2000
19056 # but now we have also +1 getxattr for security.capability, total 3000
19057 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
19058 unlinkmany $dom 1000
19060 cancel_lru_locks mdc
19061 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
19062 createmany -o $dom 1000
19063 lctl set_param -n mdc.*.stats=clear
19064 smalliomany -w $dom 1000 200
19065 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
19066 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
19067 # for OPEN and IO lock.
19068 [ $((enq - enq_2)) -ge 1000 ] ||
19069 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
19070 unlinkmany $dom 1000
19073 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
19075 cleanup_271def_tests() {
19081 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
19082 skip "Need MDS version at least 2.10.57"
19084 local dom=$DIR/$tdir/dom
19085 local tmp=$TMP/$tfile
19086 trap "cleanup_271def_tests $tmp" EXIT
19088 mkdir -p $DIR/$tdir
19090 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19092 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
19094 cancel_lru_locks mdc
19095 dd if=/dev/urandom of=$tmp bs=1000 count=1
19096 dd if=$tmp of=$dom bs=1000 count=1
19097 cancel_lru_locks mdc
19099 cat /etc/hosts >> $tmp
19100 lctl set_param -n mdc.*.stats=clear
19102 # append data to the same file it should update local page
19103 echo "Append to the same page"
19104 cat /etc/hosts >> $dom
19105 local num=$(get_mdc_stats $mdtidx ost_read)
19106 local ra=$(get_mdc_stats $mdtidx req_active)
19107 local rw=$(get_mdc_stats $mdtidx req_waittime)
19109 [ -z $num ] || error "$num READ RPC occured"
19110 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19114 cmp $tmp $dom || error "file miscompare"
19116 cancel_lru_locks mdc
19117 lctl set_param -n mdc.*.stats=clear
19119 echo "Open and read file"
19120 cat $dom > /dev/null
19121 local num=$(get_mdc_stats $mdtidx ost_read)
19122 local ra=$(get_mdc_stats $mdtidx req_active)
19123 local rw=$(get_mdc_stats $mdtidx req_waittime)
19125 [ -z $num ] || error "$num READ RPC occured"
19126 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19130 cmp $tmp $dom || error "file miscompare"
19134 run_test 271d "DoM: read on open (1K file in reply buffer)"
19137 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
19138 skip "Need MDS version at least 2.10.57"
19140 local dom=$DIR/$tdir/dom
19141 local tmp=$TMP/$tfile
19142 trap "cleanup_271def_tests $tmp" EXIT
19144 mkdir -p $DIR/$tdir
19146 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19148 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
19150 cancel_lru_locks mdc
19151 dd if=/dev/urandom of=$tmp bs=265000 count=1
19152 dd if=$tmp of=$dom bs=265000 count=1
19153 cancel_lru_locks mdc
19154 cat /etc/hosts >> $tmp
19155 lctl set_param -n mdc.*.stats=clear
19157 echo "Append to the same page"
19158 cat /etc/hosts >> $dom
19159 local num=$(get_mdc_stats $mdtidx ost_read)
19160 local ra=$(get_mdc_stats $mdtidx req_active)
19161 local rw=$(get_mdc_stats $mdtidx req_waittime)
19163 [ -z $num ] || error "$num READ RPC occured"
19164 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19168 cmp $tmp $dom || error "file miscompare"
19170 cancel_lru_locks mdc
19171 lctl set_param -n mdc.*.stats=clear
19173 echo "Open and read file"
19174 cat $dom > /dev/null
19175 local num=$(get_mdc_stats $mdtidx ost_read)
19176 local ra=$(get_mdc_stats $mdtidx req_active)
19177 local rw=$(get_mdc_stats $mdtidx req_waittime)
19179 [ -z $num ] && num=0
19180 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
19181 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19185 cmp $tmp $dom || error "file miscompare"
19189 run_test 271f "DoM: read on open (200K file and read tail)"
19192 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
19193 skip "Skipping due to old client or server version"
19195 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
19197 $CHECKSTAT -t file $DIR1/$tfile
19199 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
19202 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
19203 $LCTL set_param fail_loc=0x80000314
19204 rm $DIR1/$tfile || error "Unlink fails"
19206 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
19207 [ $RC -eq 0 ] || error "Failed write to stale object"
19209 run_test 271g "Discard DoM data vs client flush race"
19212 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19213 skip "Need MDS version at least 2.11.50"
19215 local dom=$DIR/$tdir/dom
19216 mkdir -p $DIR/$tdir
19218 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
19219 dd if=/dev/urandom of=$dom bs=512K count=1 ||
19220 error "failed to write data into $dom"
19221 local old_md5=$(md5sum $dom)
19223 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
19224 error "failed to migrate to the same DoM component"
19226 local new_md5=$(md5sum $dom)
19228 [ "$old_md5" == "$new_md5" ] ||
19229 error "md5sum differ: $old_md5, $new_md5"
19231 [ $($LFS getstripe -c $dom) -eq 2 ] ||
19232 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
19234 run_test 272a "DoM migration: new layout with the same DOM component"
19237 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19238 skip "Need MDS version at least 2.11.50"
19240 local dom=$DIR/$tdir/dom
19241 mkdir -p $DIR/$tdir
19242 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
19244 local mdtidx=$($LFS getstripe -m $dom)
19245 local mdtname=MDT$(printf %04x $mdtidx)
19246 local facet=mds$((mdtidx + 1))
19248 local mdtfree1=$(do_facet $facet \
19249 lctl get_param -n osd*.*$mdtname.kbytesfree)
19250 dd if=/dev/urandom of=$dom bs=2M count=1 ||
19251 error "failed to write data into $dom"
19252 local old_md5=$(md5sum $dom)
19253 cancel_lru_locks mdc
19254 local mdtfree1=$(do_facet $facet \
19255 lctl get_param -n osd*.*$mdtname.kbytesfree)
19257 $LFS migrate -c2 $dom ||
19258 error "failed to migrate to the new composite layout"
19259 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
19260 error "MDT stripe was not removed"
19262 cancel_lru_locks mdc
19263 local new_md5=$(md5sum $dom)
19264 [ "$old_md5" == "$new_md5" ] ||
19265 error "$old_md5 != $new_md5"
19267 # Skip free space checks with ZFS
19268 if [ "$(facet_fstype $facet)" != "zfs" ]; then
19269 local mdtfree2=$(do_facet $facet \
19270 lctl get_param -n osd*.*$mdtname.kbytesfree)
19271 [ $mdtfree2 -gt $mdtfree1 ] ||
19272 error "MDT space is not freed after migration"
19276 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
19279 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19280 skip "Need MDS version at least 2.11.50"
19282 local dom=$DIR/$tdir/$tfile
19283 mkdir -p $DIR/$tdir
19284 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
19286 local mdtidx=$($LFS getstripe -m $dom)
19287 local mdtname=MDT$(printf %04x $mdtidx)
19288 local facet=mds$((mdtidx + 1))
19290 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
19291 error "failed to write data into $dom"
19292 local old_md5=$(md5sum $dom)
19293 cancel_lru_locks mdc
19294 local mdtfree1=$(do_facet $facet \
19295 lctl get_param -n osd*.*$mdtname.kbytesfree)
19297 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
19298 error "failed to migrate to the new composite layout"
19299 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
19300 error "MDT stripe was not removed"
19302 cancel_lru_locks mdc
19303 local new_md5=$(md5sum $dom)
19304 [ "$old_md5" == "$new_md5" ] ||
19305 error "$old_md5 != $new_md5"
19307 # Skip free space checks with ZFS
19308 if [ "$(facet_fstype $facet)" != "zfs" ]; then
19309 local mdtfree2=$(do_facet $facet \
19310 lctl get_param -n osd*.*$mdtname.kbytesfree)
19311 [ $mdtfree2 -gt $mdtfree1 ] ||
19312 error "MDS space is not freed after migration"
19316 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
19319 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
19320 skip "Need MDS version at least 2.12.55"
19322 local dom=$DIR/$tdir/$tfile
19323 mkdir -p $DIR/$tdir
19324 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
19326 local mdtidx=$($LFS getstripe -m $dom)
19327 local mdtname=MDT$(printf %04x $mdtidx)
19328 local facet=mds$((mdtidx + 1))
19330 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
19331 error "failed to write data into $dom"
19332 local old_md5=$(md5sum $dom)
19333 cancel_lru_locks mdc
19334 local mdtfree1=$(do_facet $facet \
19335 lctl get_param -n osd*.*$mdtname.kbytesfree)
19337 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
19338 error "failed mirroring to the new composite layout"
19339 $LFS mirror resync $dom ||
19340 error "failed mirror resync"
19341 $LFS mirror split --mirror-id 1 -d $dom ||
19342 error "failed mirror split"
19344 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
19345 error "MDT stripe was not removed"
19347 cancel_lru_locks mdc
19348 local new_md5=$(md5sum $dom)
19349 [ "$old_md5" == "$new_md5" ] ||
19350 error "$old_md5 != $new_md5"
19352 # Skip free space checks with ZFS
19353 if [ "$(facet_fstype $facet)" != "zfs" ]; then
19354 local mdtfree2=$(do_facet $facet \
19355 lctl get_param -n osd*.*$mdtname.kbytesfree)
19356 [ $mdtfree2 -gt $mdtfree1 ] ||
19357 error "MDS space is not freed after DOM mirror deletion"
19361 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
19364 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
19365 skip "Need MDS version at least 2.12.55"
19367 local dom=$DIR/$tdir/$tfile
19368 mkdir -p $DIR/$tdir
19369 $LFS setstripe -c 2 $dom
19371 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
19372 error "failed to write data into $dom"
19373 local old_md5=$(md5sum $dom)
19374 cancel_lru_locks mdc
19376 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
19377 error "failed mirroring to the DOM layout"
19378 $LFS mirror resync $dom ||
19379 error "failed mirror resync"
19380 $LFS mirror split --mirror-id 1 -d $dom ||
19381 error "failed mirror split"
19383 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
19384 error "MDT stripe was not removed"
19386 cancel_lru_locks mdc
19387 local new_md5=$(md5sum $dom)
19388 [ "$old_md5" == "$new_md5" ] ||
19389 error "$old_md5 != $new_md5"
19393 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
19396 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
19397 skip "Need MDS version at least 2.12.55"
19399 local dom=$DIR/$tdir/$tfile
19400 mkdir -p $DIR/$tdir
19401 $LFS setstripe -c 2 $dom
19403 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
19404 error "failed to write data into $dom"
19405 local old_md5=$(md5sum $dom)
19406 cancel_lru_locks mdc
19408 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
19409 error "failed migrating to the DOM file"
19411 cancel_lru_locks mdc
19412 local new_md5=$(md5sum $dom)
19413 [ "$old_md5" != "$new_md5" ] &&
19414 error "$old_md5 != $new_md5"
19418 run_test 272f "DoM migration: OST-striped file to DOM file"
19421 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
19422 skip "Need MDS version at least 2.11.50"
19424 # Layout swap cannot be done if either file has DOM component,
19425 # this will never be supported, migration should be used instead
19427 local dom=$DIR/$tdir/$tfile
19428 mkdir -p $DIR/$tdir
19430 $LFS setstripe -c2 ${dom}_plain
19431 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
19432 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
19433 error "can swap layout with DoM component"
19434 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
19435 error "can swap layout with DoM component"
19437 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
19438 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
19439 error "can swap layout with DoM component"
19440 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
19441 error "can swap layout with DoM component"
19444 run_test 273a "DoM: layout swapping should fail with DOM"
19447 remote_ost_nodsh && skip "remote OST with nodsh"
19448 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
19449 skip "Need OST version >= 2.10.57"
19451 local file=$DIR/$tfile
19454 oss=$(comma_list $(osts_nodes))
19456 dd if=/dev/urandom of=$file bs=1M count=2 ||
19457 error "failed to create a file"
19458 cancel_lru_locks osc
19461 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
19462 error "failed to read a file"
19464 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
19465 $LCTL set_param fail_loc=0x8000031f
19467 cancel_lru_locks osc &
19470 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
19471 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
19472 #IO takes another lock, but matches the PENDING one
19473 #and places it to the IO RPC
19474 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
19475 error "failed to read a file with PENDING lock"
19477 run_test 275 "Read on a canceled duplicate lock"
19480 remote_ost_nodsh && skip "remote OST with nodsh"
19483 do_facet ost1 "(while true; do \
19484 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
19485 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
19488 for LOOP in $(seq 20); do
19490 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
19493 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
19494 rm $TMP/sanity_276_pid"
19496 run_test 276 "Race between mount and obd_statfs"
19499 $LCTL set_param ldlm.namespaces.*.lru_size=0
19500 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
19501 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
19502 grep ^used_mb | awk '{print $2}')
19503 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
19504 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
19505 oflag=direct conv=notrunc
19506 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
19507 grep ^used_mb | awk '{print $2}')
19508 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
19510 run_test 277 "Direct IO shall drop page cache"
19513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
19514 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19515 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
19516 skip "needs the same host for mdt1 mdt2" && return
19521 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
19522 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
19528 echo "Starting MDTs"
19529 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
19531 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
19533 do_facet mds2 $LCTL set_param fail_loc=0
19535 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
19536 wait_recovery_complete mds2
19538 run_test 278 "Race starting MDS between MDTs stop/start"
19540 cleanup_test_300() {
19544 test_striped_dir() {
19549 mkdir -p $DIR/$tdir
19551 SAVE_UMASK=$(umask)
19552 trap cleanup_test_300 RETURN EXIT
19554 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
19555 $DIR/$tdir/striped_dir ||
19556 error "set striped dir error"
19558 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
19559 [ "$mode" = "755" ] || error "expect 755 got $mode"
19561 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
19562 error "getdirstripe failed"
19563 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
19564 if [ "$stripe_count" != "2" ]; then
19565 error "1:stripe_count is $stripe_count, expect 2"
19567 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
19568 if [ "$stripe_count" != "2" ]; then
19569 error "2:stripe_count is $stripe_count, expect 2"
19572 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
19573 if [ "$stripe_index" != "$mdt_index" ]; then
19574 error "stripe_index is $stripe_index, expect $mdt_index"
19577 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
19578 error "nlink error after create striped dir"
19580 mkdir $DIR/$tdir/striped_dir/a
19581 mkdir $DIR/$tdir/striped_dir/b
19583 stat $DIR/$tdir/striped_dir/a ||
19584 error "create dir under striped dir failed"
19585 stat $DIR/$tdir/striped_dir/b ||
19586 error "create dir under striped dir failed"
19588 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
19589 error "nlink error after mkdir"
19591 rmdir $DIR/$tdir/striped_dir/a
19592 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
19593 error "nlink error after rmdir"
19595 rmdir $DIR/$tdir/striped_dir/b
19596 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
19597 error "nlink error after rmdir"
19599 chattr +i $DIR/$tdir/striped_dir
19600 createmany -o $DIR/$tdir/striped_dir/f 10 &&
19601 error "immutable flags not working under striped dir!"
19602 chattr -i $DIR/$tdir/striped_dir
19604 rmdir $DIR/$tdir/striped_dir ||
19605 error "rmdir striped dir error"
19613 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19614 skip "skipped for lustre < 2.7.0"
19615 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19616 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19618 test_striped_dir 0 || error "failed on striped dir on MDT0"
19619 test_striped_dir 1 || error "failed on striped dir on MDT0"
19621 run_test 300a "basic striped dir sanity test"
19624 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19625 skip "skipped for lustre < 2.7.0"
19626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19627 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19634 test_mkdir $DIR/$tdir || error "mkdir fail"
19635 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19636 error "set striped dir error"
19637 for i in {0..9}; do
19638 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
19640 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
19641 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
19642 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
19644 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
19645 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
19646 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
19650 run_test 300b "check ctime/mtime for striped dir"
19653 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19654 skip "skipped for lustre < 2.7.0"
19655 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19656 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19660 mkdir -p $DIR/$tdir
19661 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
19662 error "set striped dir error"
19664 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
19665 error "chown striped dir failed"
19667 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
19668 error "create 5k files failed"
19670 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
19672 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
19676 run_test 300c "chown && check ls under striped directory"
19679 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
19680 skip "skipped for lustre < 2.7.0"
19681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19682 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19687 mkdir -p $DIR/$tdir
19688 $LFS setstripe -c 2 $DIR/$tdir
19690 #local striped directory
19691 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19692 error "set striped dir error"
19693 #look at the directories for debug purposes
19695 $LFS getdirstripe $DIR/$tdir
19696 ls -l $DIR/$tdir/striped_dir
19697 $LFS getdirstripe $DIR/$tdir/striped_dir
19698 createmany -o $DIR/$tdir/striped_dir/f 10 ||
19699 error "create 10 files failed"
19701 #remote striped directory
19702 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
19703 error "set striped dir error"
19704 #look at the directories for debug purposes
19706 $LFS getdirstripe $DIR/$tdir
19707 ls -l $DIR/$tdir/remote_striped_dir
19708 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
19709 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
19710 error "create 10 files failed"
19712 for file in $(find $DIR/$tdir); do
19713 stripe_count=$($LFS getstripe -c $file)
19714 [ $stripe_count -eq 2 ] ||
19715 error "wrong stripe $stripe_count for $file"
19720 run_test 300d "check default stripe under striped directory"
19723 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19724 skip "Need MDS version at least 2.7.55"
19725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19726 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19731 mkdir -p $DIR/$tdir
19733 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19734 error "set striped dir error"
19736 touch $DIR/$tdir/striped_dir/a
19737 touch $DIR/$tdir/striped_dir/b
19738 touch $DIR/$tdir/striped_dir/c
19740 mkdir $DIR/$tdir/striped_dir/dir_a
19741 mkdir $DIR/$tdir/striped_dir/dir_b
19742 mkdir $DIR/$tdir/striped_dir/dir_c
19744 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
19745 error "set striped adir under striped dir error"
19747 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
19748 error "set striped bdir under striped dir error"
19750 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
19751 error "set striped cdir under striped dir error"
19753 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
19754 error "rename dir under striped dir fails"
19756 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
19757 error "rename dir under different stripes fails"
19759 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
19760 error "rename file under striped dir should succeed"
19762 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
19763 error "rename dir under striped dir should succeed"
19767 run_test 300e "check rename under striped directory"
19770 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19771 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19772 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19773 skip "Need MDS version at least 2.7.55"
19779 mkdir -p $DIR/$tdir
19781 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
19782 error "set striped dir error"
19784 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
19785 error "set striped dir error"
19787 touch $DIR/$tdir/striped_dir/a
19788 mkdir $DIR/$tdir/striped_dir/dir_a
19789 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
19790 error "create striped dir under striped dir fails"
19792 touch $DIR/$tdir/striped_dir1/b
19793 mkdir $DIR/$tdir/striped_dir1/dir_b
19794 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
19795 error "create striped dir under striped dir fails"
19797 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
19798 error "rename dir under different striped dir should fail"
19800 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
19801 error "rename striped dir under diff striped dir should fail"
19803 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
19804 error "rename file under diff striped dirs fails"
19808 run_test 300f "check rename cross striped directory"
19810 test_300_check_default_striped_dir()
19813 local default_count=$2
19814 local default_index=$3
19817 local dir_stripe_index
19820 echo "checking $dirname $default_count $default_index"
19821 $LFS setdirstripe -D -c $default_count -i $default_index \
19822 -t all_char $DIR/$tdir/$dirname ||
19823 error "set default stripe on striped dir error"
19824 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
19825 [ $stripe_count -eq $default_count ] ||
19826 error "expect $default_count get $stripe_count for $dirname"
19828 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
19829 [ $stripe_index -eq $default_index ] ||
19830 error "expect $default_index get $stripe_index for $dirname"
19832 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
19833 error "create dirs failed"
19835 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
19836 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
19837 for dir in $(find $DIR/$tdir/$dirname/*); do
19838 stripe_count=$($LFS getdirstripe -c $dir)
19839 [ $stripe_count -eq $default_count ] ||
19840 [ $stripe_count -eq 0 ] || [ $default_count -eq 1 ] ||
19841 error "stripe count $default_count != $stripe_count for $dir"
19843 stripe_index=$($LFS getdirstripe -i $dir)
19844 [ $default_index -eq -1 ] ||
19845 [ $stripe_index -eq $default_index ] ||
19846 error "$stripe_index != $default_index for $dir"
19848 #check default stripe
19849 stripe_count=$($LFS getdirstripe -D -c $dir)
19850 [ $stripe_count -eq $default_count ] ||
19851 error "default count $default_count != $stripe_count for $dir"
19853 stripe_index=$($LFS getdirstripe -D -i $dir)
19854 [ $stripe_index -eq $default_index ] ||
19855 error "default index $default_index != $stripe_index for $dir"
19857 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
19861 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19862 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19863 skip "Need MDS version at least 2.7.55"
19870 mkdir $DIR/$tdir/normal_dir
19872 #Checking when client cache stripe index
19873 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
19874 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
19875 error "create striped_dir failed"
19877 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
19878 error "create dir0 fails"
19879 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
19880 [ $stripe_index -eq 0 ] ||
19881 error "dir0 expect index 0 got $stripe_index"
19883 mkdir $DIR/$tdir/striped_dir/dir1 ||
19884 error "create dir1 fails"
19885 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
19886 [ $stripe_index -eq 1 ] ||
19887 error "dir1 expect index 1 got $stripe_index"
19889 #check default stripe count/stripe index
19890 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
19891 test_300_check_default_striped_dir normal_dir 1 0
19892 test_300_check_default_striped_dir normal_dir 2 1
19893 test_300_check_default_striped_dir normal_dir 2 -1
19895 #delete default stripe information
19896 echo "delete default stripeEA"
19897 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
19898 error "set default stripe on striped dir error"
19900 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
19901 for dir in $(find $DIR/$tdir/normal_dir/*); do
19902 stripe_count=$($LFS getdirstripe -c $dir)
19903 [ $stripe_count -eq 0 ] ||
19904 error "expect 1 get $stripe_count for $dir"
19905 stripe_index=$($LFS getdirstripe -i $dir)
19906 [ $stripe_index -eq 0 ] ||
19907 error "expect 0 get $stripe_index for $dir"
19910 run_test 300g "check default striped directory for normal directory"
19913 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19914 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19915 skip "Need MDS version at least 2.7.55"
19921 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19922 error "set striped dir error"
19924 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
19925 test_300_check_default_striped_dir striped_dir 1 0
19926 test_300_check_default_striped_dir striped_dir 2 1
19927 test_300_check_default_striped_dir striped_dir 2 -1
19929 #delete default stripe information
19930 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
19931 error "set default stripe on striped dir error"
19933 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
19934 for dir in $(find $DIR/$tdir/striped_dir/*); do
19935 stripe_count=$($LFS getdirstripe -c $dir)
19936 [ $stripe_count -eq 0 ] ||
19937 error "expect 1 get $stripe_count for $dir"
19940 run_test 300h "check default striped directory for striped directory"
19943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19944 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19945 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19946 skip "Need MDS version at least 2.7.55"
19953 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
19954 error "set striped dir error"
19956 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
19957 error "create files under striped dir failed"
19959 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
19960 error "set striped hashdir error"
19962 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
19963 error "create dir0 under hash dir failed"
19964 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
19965 error "create dir1 under hash dir failed"
19967 # unfortunately, we need to umount to clear dir layout cache for now
19968 # once we fully implement dir layout, we can drop this
19969 umount_client $MOUNT || error "umount failed"
19970 mount_client $MOUNT || error "mount failed"
19972 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
19973 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
19974 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
19976 #set the stripe to be unknown hash type
19977 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
19978 $LCTL set_param fail_loc=0x1901
19979 for ((i = 0; i < 10; i++)); do
19980 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
19981 error "stat f-$i failed"
19982 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
19985 touch $DIR/$tdir/striped_dir/f0 &&
19986 error "create under striped dir with unknown hash should fail"
19988 $LCTL set_param fail_loc=0
19990 umount_client $MOUNT || error "umount failed"
19991 mount_client $MOUNT || error "mount failed"
19995 run_test 300i "client handle unknown hash type striped directory"
19998 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19999 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20000 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20001 skip "Need MDS version at least 2.7.55"
20008 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
20009 $LCTL set_param fail_loc=0x1702
20010 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
20011 error "set striped dir error"
20013 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
20014 error "create files under striped dir failed"
20016 $LCTL set_param fail_loc=0
20018 rm -rf $DIR/$tdir || error "unlink striped dir fails"
20022 run_test 300j "test large update record"
20025 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20026 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20027 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20028 skip "Need MDS version at least 2.7.55"
20030 # this test needs a huge transaction
20032 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
20033 osd*.$FSNAME-MDT0000.kbytestotal")
20034 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
20041 #define OBD_FAIL_LARGE_STRIPE 0x1703
20042 $LCTL set_param fail_loc=0x1703
20043 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
20044 error "set striped dir error"
20045 $LCTL set_param fail_loc=0
20047 $LFS getdirstripe $DIR/$tdir/striped_dir ||
20048 error "getstripeddir fails"
20049 rm -rf $DIR/$tdir/striped_dir ||
20050 error "unlink striped dir fails"
20054 run_test 300k "test large striped directory"
20057 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20058 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20059 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20060 skip "Need MDS version at least 2.7.55"
20064 test_mkdir -p $DIR/$tdir/striped_dir
20065 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
20066 error "chown $RUNAS_ID failed"
20067 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
20068 error "set default striped dir failed"
20070 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
20071 $LCTL set_param fail_loc=0x80000158
20072 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
20074 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
20075 [ $stripe_index -eq 1 ] ||
20076 error "expect 1 get $stripe_index for $dir"
20078 run_test 300l "non-root user to create dir under striped dir with stale layout"
20081 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20082 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
20083 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20084 skip "Need MDS version at least 2.7.55"
20086 mkdir -p $DIR/$tdir/striped_dir
20087 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
20088 error "set default stripes dir error"
20090 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
20092 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
20093 [ $stripe_count -eq 0 ] ||
20094 error "expect 0 get $stripe_count for a"
20096 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
20097 error "set default stripes dir error"
20099 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
20101 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
20102 [ $stripe_count -eq 0 ] ||
20103 error "expect 0 get $stripe_count for b"
20105 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
20106 error "set default stripes dir error"
20108 mkdir $DIR/$tdir/striped_dir/c &&
20109 error "default stripe_index is invalid, mkdir c should fails"
20111 rm -rf $DIR/$tdir || error "rmdir fails"
20113 run_test 300m "setstriped directory on single MDT FS"
20116 local list=$(comma_list $(mdts_nodes))
20119 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20123 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20124 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20125 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20126 skip "Need MDS version at least 2.7.55"
20127 remote_mds_nodsh && skip "remote MDS with nodsh"
20130 local list=$(comma_list $(mdts_nodes))
20132 trap cleanup_300n RETURN EXIT
20133 mkdir -p $DIR/$tdir
20134 chmod 777 $DIR/$tdir
20135 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
20136 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
20137 error "create striped dir succeeds with gid=0"
20139 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
20140 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
20141 error "create striped dir fails with gid=-1"
20143 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20144 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
20145 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
20146 error "set default striped dir succeeds with gid=0"
20149 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
20150 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
20151 error "set default striped dir fails with gid=-1"
20154 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20155 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
20156 error "create test_dir fails"
20157 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
20158 error "create test_dir1 fails"
20159 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
20160 error "create test_dir2 fails"
20163 run_test 300n "non-root user to create dir under striped dir with default EA"
20166 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20167 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20168 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20169 skip "Need MDS version at least 2.7.55"
20174 mkdir -p $DIR/$tdir
20176 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
20177 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
20178 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
20179 skip "not enough free inodes $numfree1 $numfree2"
20182 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
20183 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
20184 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
20185 skip "not enough free space $numfree1 $numfree2"
20188 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
20189 error "setdirstripe fails"
20191 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
20192 error "create dirs fails"
20194 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
20195 ls $DIR/$tdir/striped_dir > /dev/null ||
20196 error "ls striped dir fails"
20197 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
20198 error "unlink big striped dir fails"
20200 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
20203 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20204 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20205 remote_mds_nodsh && skip "remote MDS with nodsh"
20207 mkdir -p $DIR/$tdir
20209 #define OBD_FAIL_OUT_ENOSPC 0x1704
20210 do_facet mds2 lctl set_param fail_loc=0x80001704
20211 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
20212 && error "create striped directory should fail"
20214 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
20216 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
20219 run_test 300p "create striped directory without space"
20222 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20223 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20225 local fd=$(free_fd)
20226 local cmd="exec $fd<$tdir"
20228 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
20231 trap "eval $cmd" EXIT
20232 cd $tdir || error "cd $tdir fails"
20233 rmdir ../$tdir || error "rmdir $tdir fails"
20234 mkdir local_dir && error "create dir succeeds"
20235 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
20239 run_test 300q "create remote directory under orphan directory"
20242 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20243 skip "Need MDS version at least 2.7.55" && return
20244 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
20248 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
20249 error "set striped dir error"
20251 $LFS getdirstripe $DIR/$tdir/striped_dir ||
20252 error "getstripeddir fails"
20255 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
20256 awk '/lmv_stripe_count:/ { print $2 }')
20258 [ $MDSCOUNT -ne $stripe_count ] &&
20259 error "wrong stripe count $stripe_count expected $MDSCOUNT"
20261 rm -rf $DIR/$tdir/striped_dir ||
20262 error "unlink striped dir fails"
20264 run_test 300r "test -1 striped directory"
20266 prepare_remote_file() {
20267 mkdir $DIR/$tdir/src_dir ||
20268 error "create remote source failed"
20270 cp /etc/hosts $DIR/$tdir/src_dir/a ||
20271 error "cp to remote source failed"
20272 touch $DIR/$tdir/src_dir/a
20274 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
20275 error "create remote target dir failed"
20277 touch $DIR/$tdir/tgt_dir/b
20279 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
20280 error "rename dir cross MDT failed!"
20282 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
20283 error "src_child still exists after rename"
20285 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
20286 error "missing file(a) after rename"
20288 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
20289 error "diff after rename"
20293 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
20294 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20296 local remote_file=$DIR/$tdir/tgt_dir/b
20298 mkdir -p $DIR/$tdir
20300 prepare_remote_file || error "prepare remote file failed"
20303 $OPENUNLINK $remote_file $remote_file ||
20304 error "openunlink $remote_file failed"
20305 $CHECKSTAT -a $remote_file || error "$remote_file exists"
20307 run_test 310a "open unlink remote file"
20310 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
20311 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20313 local remote_file=$DIR/$tdir/tgt_dir/b
20315 mkdir -p $DIR/$tdir
20317 prepare_remote_file || error "prepare remote file failed"
20319 ln $remote_file $DIR/$tfile || error "link failed for remote file"
20320 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
20321 $CHECKSTAT -t file $remote_file || error "check file failed"
20323 run_test 310b "unlink remote file with multiple links while open"
20326 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20327 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
20329 local remote_file=$DIR/$tdir/tgt_dir/b
20331 mkdir -p $DIR/$tdir
20333 prepare_remote_file || error "prepare remote file failed"
20335 ln $remote_file $DIR/$tfile || error "link failed for remote file"
20336 multiop_bg_pause $remote_file O_uc ||
20337 error "mulitop failed for remote file"
20339 $MULTIOP $DIR/$tfile Ouc
20340 kill -USR1 $MULTIPID
20343 run_test 310c "open-unlink remote file with multiple links"
20347 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20348 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
20349 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
20350 skip "lustre < 2.8.54 does not contain LU-4825 fix"
20351 remote_mds_nodsh && skip "remote MDS with nodsh"
20353 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
20354 local mdts=$(comma_list $(mdts_nodes))
20356 mkdir -p $DIR/$tdir
20357 $LFS setstripe -i 0 -c 1 $DIR/$tdir
20358 createmany -o $DIR/$tdir/$tfile. 1000
20360 # statfs data is not real time, let's just calculate it
20361 old_iused=$((old_iused + 1000))
20363 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
20364 osp.*OST0000*MDT0000.create_count")
20365 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
20366 osp.*OST0000*MDT0000.max_create_count")
20367 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
20369 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
20370 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
20371 [ $index -ne 0 ] || error "$tfile stripe index is 0"
20373 unlinkmany $DIR/$tdir/$tfile. 1000
20375 do_nodes $mdts "$LCTL set_param -n \
20376 osp.*OST0000*.max_create_count=$max_count"
20377 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
20378 do_nodes $mdts "$LCTL set_param -n \
20379 osp.*OST0000*.create_count=$count"
20380 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
20381 grep "=0" && error "create_count is zero"
20384 for i in $(seq 120); do
20385 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
20386 # system may be too busy to destroy all objs in time, use
20387 # a somewhat small value to not fail autotest
20388 [ $((old_iused - new_iused)) -gt 400 ] && break
20392 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
20393 [ $((old_iused - new_iused)) -gt 400 ] ||
20394 error "objs not destroyed after unlink"
20396 run_test 311 "disable OSP precreate, and unlink should destroy objs"
20403 local vdevdir=$(dirname $(facet_vdevice $ost))
20404 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
20405 local zfs_zapid=$(do_facet $ost $cmd |
20406 grep -w "/O/0/d$((objid%32))" -C 5 |
20407 awk '/Object/{getline; print $1}')
20408 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
20409 awk "/$objid = /"'{printf $3}')
20414 zfs_object_blksz() {
20418 local vdevdir=$(dirname $(facet_vdevice $ost))
20419 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
20420 local blksz=$(do_facet $ost $cmd $objid |
20421 awk '/dblk/{getline; printf $4}')
20423 case "${blksz: -1}" in
20424 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
20425 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
20432 test_312() { # LU-4856
20433 remote_ost_nodsh && skip "remote OST with nodsh"
20434 [ "$ost1_FSTYPE" = "zfs" ] ||
20435 skip_env "the test only applies to zfs"
20437 local max_blksz=$(do_facet ost1 \
20438 $ZFS get -p recordsize $(facet_device ost1) |
20439 awk '!/VALUE/{print $3}')
20441 # to make life a little bit easier
20442 $LFS mkdir -c 1 -i 0 $DIR/$tdir
20443 $LFS setstripe -c 1 -i 0 $DIR/$tdir
20445 local tf=$DIR/$tdir/$tfile
20447 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
20449 # Get ZFS object id
20450 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
20451 # block size change by sequential overwrite
20454 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
20455 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
20457 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
20458 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
20462 # block size change by sequential append write
20463 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
20464 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
20465 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
20468 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
20469 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
20470 oflag=sync conv=notrunc
20472 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20473 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
20474 error "blksz error, actual $blksz, " \
20475 "expected: 2 * $count * $PAGE_SIZE"
20481 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
20482 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
20484 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
20485 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20486 [ $blksz -eq $PAGE_SIZE ] ||
20487 error "blksz error: $blksz, expected: $PAGE_SIZE"
20489 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
20490 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20491 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
20493 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
20494 blksz=$(zfs_object_blksz ost1 $zfs_objid)
20495 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
20497 run_test 312 "make sure ZFS adjusts its block size by write pattern"
20500 remote_ost_nodsh && skip "remote OST with nodsh"
20502 local file=$DIR/$tfile
20505 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
20507 # define OBD_FAIL_TGT_RCVD_EIO 0x720
20508 do_facet ost1 "$LCTL set_param fail_loc=0x720"
20509 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
20510 error "write should failed"
20511 do_facet ost1 "$LCTL set_param fail_loc=0"
20514 run_test 313 "io should fail after last_rcvd update fail"
20517 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
20519 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
20520 do_facet ost1 "$LCTL set_param fail_loc=0x720"
20522 wait_delete_completed
20523 do_facet ost1 "$LCTL set_param fail_loc=0"
20525 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
20527 test_315() { # LU-618
20528 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
20530 local file=$DIR/$tfile
20533 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
20534 error "multiop file write failed"
20535 $MULTIOP $file oO_RDONLY:r4063232_c &
20540 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
20543 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
20546 run_test 315 "read should be accounted"
20549 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20550 large_xattr_enabled || skip_env "ea_inode feature disabled"
20552 rm -rf $DIR/$tdir/d
20553 mkdir -p $DIR/$tdir/d
20554 chown nobody $DIR/$tdir/d
20555 touch $DIR/$tdir/d/file
20557 $LFS mv -m1 $DIR/$tdir/d || error "lfs mv failed"
20559 run_test 316 "lfs mv"
20562 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
20563 skip "Need MDS version at least 2.11.53"
20564 if [ "$ost1_FSTYPE" == "zfs" ]; then
20565 skip "LU-10370: no implementation for ZFS"
20569 local grant_blk_size
20571 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
20572 awk '/grant_block_size:/ { print $2; exit; }')
20574 # Create File of size 5M. Truncate it to below size's and verify
20577 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
20578 error "Create file $DIR/$tfile failed"
20579 stack_trap "rm -f $DIR/$tfile" EXIT
20581 for trunc_sz in 2097152 4097 4000 509 0; do
20582 $TRUNCATE $DIR/$tfile $trunc_sz ||
20583 error "truncate $tfile to $trunc_sz failed"
20584 local sz=$(stat --format=%s $DIR/$tfile)
20585 local blk=$(stat --format=%b $DIR/$tfile)
20586 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
20587 grant_blk_size) * 8))
20589 if [[ $blk -ne $trunc_blk ]]; then
20590 $(which stat) $DIR/$tfile
20591 error "Expected Block $trunc_blk got $blk for $tfile"
20594 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
20595 error "Expected Size $trunc_sz got $sz for $tfile"
20600 # Create file with a hole and write actual two blocks. Block count
20603 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
20604 conv=fsync || error "Create file : $DIR/$tfile"
20606 # Calculate the final truncate size.
20607 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
20610 # truncate to size $trunc_sz bytes. Strip the last block
20611 # The block count must drop to 8
20613 $TRUNCATE $DIR/$tfile $trunc_sz ||
20614 error "truncate $tfile to $trunc_sz failed"
20616 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
20617 sz=$(stat --format=%s $DIR/$tfile)
20618 blk=$(stat --format=%b $DIR/$tfile)
20620 if [[ $blk -ne $trunc_bsz ]]; then
20621 $(which stat) $DIR/$tfile
20622 error "Expected Block $trunc_bsz got $blk for $tfile"
20625 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
20626 error "Expected Size $trunc_sz got $sz for $tfile"
20628 run_test 317 "Verify blocks get correctly update after truncate"
20631 local old_max_active=$($LCTL get_param -n \
20632 llite.*.max_read_ahead_async_active 2>/dev/null)
20634 $LCTL set_param llite.*.max_read_ahead_async_active=256
20635 local max_active=$($LCTL get_param -n \
20636 llite.*.max_read_ahead_async_active 2>/dev/null)
20637 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
20639 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
20640 error "set max_read_ahead_async_active should succeed"
20642 $LCTL set_param llite.*.max_read_ahead_async_active=512
20643 max_active=$($LCTL get_param -n \
20644 llite.*.max_read_ahead_async_active 2>/dev/null)
20645 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
20647 # restore @max_active
20648 [ $old_max_active -ne 0 ] && $LCTL set_param \
20649 llite.*.max_read_ahead_async_active=$old_max_active
20651 local old_threshold=$($LCTL get_param -n \
20652 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
20653 local max_per_file_mb=$($LCTL get_param -n \
20654 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
20656 local invalid=$(($max_per_file_mb + 1))
20658 llite.*.read_ahead_async_file_threshold_mb=$invalid\
20659 && error "set $invalid should fail"
20661 local valid=$(($invalid - 1))
20663 llite.*.read_ahead_async_file_threshold_mb=$valid ||
20664 error "set $valid should succeed"
20665 local threshold=$($LCTL get_param -n \
20666 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
20667 [ $threshold -eq $valid ] || error \
20668 "expect threshold $valid got $threshold"
20670 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
20672 run_test 318 "Verify async readahead tunables"
20675 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
20677 local before=$(date +%s)
20679 local mdir=$DIR/$tdir
20680 local file=$mdir/xxx
20682 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
20685 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
20686 $LCTL set_param fail_val=5 fail_loc=0x8000032c
20687 $LFS mv -m1 $file &
20690 dd if=$file of=/dev/null
20692 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
20693 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
20695 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
20697 run_test 319 "lost lease lock on migrate error"
20699 test_398a() { # LU-4198
20700 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20701 $LCTL set_param ldlm.namespaces.*.lru_size=clear
20703 # request a new lock on client
20704 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
20706 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
20707 local lock_count=$($LCTL get_param -n \
20708 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
20709 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
20711 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
20713 # no lock cached, should use lockless IO and not enqueue new lock
20714 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
20715 lock_count=$($LCTL get_param -n \
20716 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
20717 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
20719 run_test 398a "direct IO should cancel lock otherwise lockless"
20721 test_398b() { # LU-4198
20722 which fio || skip_env "no fio installed"
20723 $LFS setstripe -c -1 $DIR/$tfile
20726 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
20729 echo "mix direct rw ${size}M to OST0 by fio with $njobs jobs..."
20730 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
20731 --numjobs=$njobs --fallocate=none \
20732 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
20733 --filename=$DIR/$tfile &
20736 echo "mix buffer rw ${size}M to OST0 by fio with $njobs jobs..."
20737 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE \
20738 --numjobs=$njobs --fallocate=none \
20739 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
20740 --filename=$DIR/$tfile || true
20745 run_test 398b "DIO and buffer IO race"
20747 test_398c() { # LU-4198
20748 which fio || skip_env "no fio installed"
20750 saved_debug=$($LCTL get_param -n debug)
20751 $LCTL set_param debug=0
20753 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
20754 ((size /= 1024)) # by megabytes
20755 ((size /= 2)) # write half of the OST at most
20756 [ $size -gt 40 ] && size=40 #reduce test time anyway
20758 $LFS setstripe -c 1 $DIR/$tfile
20760 # it seems like ldiskfs reserves more space than necessary if the
20761 # writing blocks are not mapped, so it extends the file firstly
20762 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
20763 cancel_lru_locks osc
20765 # clear and verify rpc_stats later
20766 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
20769 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
20770 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
20771 --numjobs=$njobs --fallocate=none --ioengine=libaio \
20772 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
20773 --filename=$DIR/$tfile
20774 [ $? -eq 0 ] || error "fio write error"
20776 [ $($LCTL get_param -n \
20777 ldlm.namespaces.${FSNAME}-OST0000-osc-ffff*.lock_count) -eq 0 ] ||
20778 error "Locks were requested while doing AIO"
20780 # get the percentage of 1-page I/O
20781 pct=$($LCTL get_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats |
20782 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
20784 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
20786 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
20787 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
20788 --numjobs=$njobs --fallocate=none --ioengine=libaio \
20789 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
20790 --filename=$DIR/$tfile
20791 [ $? -eq 0 ] || error "fio mixed read write error"
20794 $LCTL set_param debug="$saved_debug"
20796 run_test 398c "run fio to test AIO"
20799 local read_write=$1
20800 if [ "$read_write" = "write" ]; then
20801 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
20802 elif [ "$read_write" = "read" ]; then
20803 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
20805 error "argument error"
20808 # turn off debug for performance testing
20809 local saved_debug=$($LCTL get_param -n debug)
20810 $LCTL set_param debug=0
20812 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20814 # get ost1 size - $FSNAME-OST0000
20815 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
20816 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
20817 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
20819 if [ "$read_write" = "read" ]; then
20820 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
20823 local start_time=$(date +%s.%N)
20824 $dd_cmd bs=1M count=$blocks oflag=sync ||
20825 error "real dd $read_write error"
20826 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
20828 if [ "$read_write" = "write" ]; then
20832 # define OBD_FAIL_OST_FAKE_RW 0x238
20833 do_facet ost1 $LCTL set_param fail_loc=0x238
20835 local start_time=$(date +%s.%N)
20836 $dd_cmd bs=1M count=$blocks oflag=sync ||
20837 error "fake dd $read_write error"
20838 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
20840 if [ "$read_write" = "write" ]; then
20842 cancel_lru_locks osc
20843 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
20844 error "$tfile size not $blocks MB"
20846 do_facet ost1 $LCTL set_param fail_loc=0
20848 echo "fake $read_write $duration_fake vs. normal $read_write" \
20849 "$duration in seconds"
20850 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
20851 error_not_in_vm "fake write is slower"
20853 $LCTL set_param -n debug="$saved_debug"
20856 test_399a() { # LU-7655 for OST fake write
20857 remote_ost_nodsh && skip "remote OST with nodsh"
20861 run_test 399a "fake write should not be slower than normal write"
20863 test_399b() { # LU-8726 for OST fake read
20864 remote_ost_nodsh && skip "remote OST with nodsh"
20865 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
20866 skip_env "ldiskfs only test"
20871 run_test 399b "fake read should not be slower than normal read"
20873 test_400a() { # LU-1606, was conf-sanity test_74
20874 if ! which $CC > /dev/null 2>&1; then
20875 skip_env "$CC is not installed"
20878 local extra_flags=''
20879 local out=$TMP/$tfile
20880 local prefix=/usr/include/lustre
20883 # Oleg removes c files in his test rig so test if any c files exist
20884 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
20885 skip_env "Needed c test files are missing"
20887 if ! [[ -d $prefix ]]; then
20888 # Assume we're running in tree and fixup the include path.
20889 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
20890 extra_flags+=" -L$LUSTRE/utils/.lib"
20893 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
20894 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
20895 error "client api broken"
20899 run_test 400a "Lustre client api program can compile and link"
20901 test_400b() { # LU-1606, LU-5011
20903 local out=$TMP/$tfile
20904 local prefix=/usr/include/linux/lustre
20906 # We use a hard coded prefix so that this test will not fail
20907 # when run in tree. There are headers in lustre/include/lustre/
20908 # that are not packaged (like lustre_idl.h) and have more
20909 # complicated include dependencies (like config.h and lnet/types.h).
20910 # Since this test about correct packaging we just skip them when
20911 # they don't exist (see below) rather than try to fixup cppflags.
20913 if ! which $CC > /dev/null 2>&1; then
20914 skip_env "$CC is not installed"
20917 for header in $prefix/*.h; do
20918 if ! [[ -f "$header" ]]; then
20922 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
20923 continue # lustre_ioctl.h is internal header
20926 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
20927 error "cannot compile '$header'"
20931 run_test 400b "packaged headers can be compiled"
20933 test_401a() { #LU-7437
20934 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
20935 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
20937 #count the number of parameters by "list_param -R"
20938 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
20939 #count the number of parameters by listing proc files
20940 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
20941 echo "proc_dirs='$proc_dirs'"
20942 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
20943 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
20946 [ $params -eq $procs ] ||
20947 error "found $params parameters vs. $procs proc files"
20949 # test the list_param -D option only returns directories
20950 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
20951 #count the number of parameters by listing proc directories
20952 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
20955 [ $params -eq $procs ] ||
20956 error "found $params parameters vs. $procs proc files"
20958 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
20961 local save=$($LCTL get_param -n jobid_var)
20964 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
20965 error "no error returned when setting bad parameters"
20967 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
20968 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
20970 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
20971 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
20972 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
20974 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
20977 local jobid_var_old=$($LCTL get_param -n jobid_var)
20978 local jobid_var_new
20980 $LCTL set_param jobid_var= &&
20981 error "no error returned for 'set_param a='"
20983 jobid_var_new=$($LCTL get_param -n jobid_var)
20984 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20985 error "jobid_var was changed by setting without value"
20987 $LCTL set_param jobid_var &&
20988 error "no error returned for 'set_param a'"
20990 jobid_var_new=$($LCTL get_param -n jobid_var)
20991 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
20992 error "jobid_var was changed by setting without value"
20994 run_test 401c "Verify 'lctl set_param' without value fails in either format."
20997 local jobid_var_old=$($LCTL get_param -n jobid_var)
20998 local jobid_var_new
20999 local new_value="foo=bar"
21001 $LCTL set_param jobid_var=$new_value ||
21002 error "'set_param a=b' did not accept a value containing '='"
21004 jobid_var_new=$($LCTL get_param -n jobid_var)
21005 [[ "$jobid_var_new" == "$new_value" ]] ||
21006 error "'set_param a=b' failed on a value containing '='"
21008 # Reset the jobid_var to test the other format
21009 $LCTL set_param jobid_var=$jobid_var_old
21010 jobid_var_new=$($LCTL get_param -n jobid_var)
21011 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
21012 error "failed to reset jobid_var"
21014 $LCTL set_param jobid_var $new_value ||
21015 error "'set_param a b' did not accept a value containing '='"
21017 jobid_var_new=$($LCTL get_param -n jobid_var)
21018 [[ "$jobid_var_new" == "$new_value" ]] ||
21019 error "'set_param a b' failed on a value containing '='"
21021 $LCTL set_param jobid_var $jobid_var_old
21022 jobid_var_new=$($LCTL get_param -n jobid_var)
21023 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
21024 error "failed to reset jobid_var"
21026 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
21029 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
21030 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
21031 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
21032 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
21033 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
21034 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
21035 remote_mds_nodsh && skip "remote MDS with nodsh"
21037 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
21038 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
21039 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
21040 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
21041 echo "Touch failed - OK"
21043 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
21046 local file1=$DIR/$tfile.1
21047 local file2=$DIR/$tfile.2
21048 local tfile=$TMP/$tfile
21050 rm -f $file1 $file2 $tfile
21055 # 30 sec OBD_TIMEOUT in ll_getattr()
21056 # right before populating st_nlink
21057 $LCTL set_param fail_loc=0x80001409
21058 stat -c %h $file1 > $tfile &
21060 # create an alias, drop all locks and reclaim the dentry
21062 cancel_lru_locks mdc
21063 cancel_lru_locks osc
21064 sysctl -w vm.drop_caches=2
21068 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
21070 rm -f $tfile $file1 $file2
21072 run_test 403 "i_nlink should not drop to zero due to aliasing"
21074 test_404() { # LU-6601
21075 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
21076 skip "Need server version newer than 2.8.52"
21077 remote_mds_nodsh && skip "remote MDS with nodsh"
21079 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
21080 awk '/osp .*-osc-MDT/ { print $4}')
21083 for osp in $mosps; do
21084 echo "Deactivate: " $osp
21085 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
21086 local stat=$(do_facet $SINGLEMDS $LCTL dl |
21087 awk -vp=$osp '$4 == p { print $2 }')
21088 [ $stat = IN ] || {
21089 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
21090 error "deactivate error"
21092 echo "Activate: " $osp
21093 do_facet $SINGLEMDS $LCTL --device %$osp activate
21094 local stat=$(do_facet $SINGLEMDS $LCTL dl |
21095 awk -vp=$osp '$4 == p { print $2 }')
21096 [ $stat = UP ] || {
21097 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
21098 error "activate error"
21102 run_test 404 "validate manual {de}activated works properly for OSPs"
21105 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
21106 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
21107 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
21108 skip "Layout swap lock is not supported"
21110 check_swap_layouts_support
21112 test_mkdir $DIR/$tdir
21113 swap_lock_test -d $DIR/$tdir ||
21114 error "One layout swap locked test failed"
21116 run_test 405 "Various layout swap lock tests"
21119 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21120 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
21121 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
21122 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21123 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
21124 skip "Need MDS version at least 2.8.50"
21126 local def_stripe_size=$($LFS getstripe -S $MOUNT)
21127 local test_pool=$TESTNAME
21129 pool_add $test_pool || error "pool_add failed"
21130 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
21131 error "pool_add_targets failed"
21133 save_layout_restore_at_exit $MOUNT
21135 # parent set default stripe count only, child will stripe from both
21136 # parent and fs default
21137 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
21138 error "setstripe $MOUNT failed"
21139 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
21140 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
21141 for i in $(seq 10); do
21142 local f=$DIR/$tdir/$tfile.$i
21143 touch $f || error "touch failed"
21144 local count=$($LFS getstripe -c $f)
21145 [ $count -eq $OSTCOUNT ] ||
21146 error "$f stripe count $count != $OSTCOUNT"
21147 local offset=$($LFS getstripe -i $f)
21148 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
21149 local size=$($LFS getstripe -S $f)
21150 [ $size -eq $((def_stripe_size * 2)) ] ||
21151 error "$f stripe size $size != $((def_stripe_size * 2))"
21152 local pool=$($LFS getstripe -p $f)
21153 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
21156 # change fs default striping, delete parent default striping, now child
21157 # will stripe from new fs default striping only
21158 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
21159 error "change $MOUNT default stripe failed"
21160 $LFS setstripe -c 0 $DIR/$tdir ||
21161 error "delete $tdir default stripe failed"
21162 for i in $(seq 11 20); do
21163 local f=$DIR/$tdir/$tfile.$i
21164 touch $f || error "touch $f failed"
21165 local count=$($LFS getstripe -c $f)
21166 [ $count -eq 1 ] || error "$f stripe count $count != 1"
21167 local offset=$($LFS getstripe -i $f)
21168 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
21169 local size=$($LFS getstripe -S $f)
21170 [ $size -eq $def_stripe_size ] ||
21171 error "$f stripe size $size != $def_stripe_size"
21172 local pool=$($LFS getstripe -p $f)
21173 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
21176 unlinkmany $DIR/$tdir/$tfile. 1 20
21178 local f=$DIR/$tdir/$tfile
21179 pool_remove_all_targets $test_pool $f
21180 pool_remove $test_pool $f
21182 run_test 406 "DNE support fs default striping"
21185 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21186 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
21187 skip "Need MDS version at least 2.8.55"
21188 remote_mds_nodsh && skip "remote MDS with nodsh"
21190 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
21191 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
21192 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
21193 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
21194 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
21196 #define OBD_FAIL_DT_TXN_STOP 0x2019
21197 for idx in $(seq $MDSCOUNT); do
21198 do_facet mds$idx "lctl set_param fail_loc=0x2019"
21200 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
21201 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
21202 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
21205 run_test 407 "transaction fail should cause operation fail"
21208 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
21210 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
21211 lctl set_param fail_loc=0x8000040a
21212 # let ll_prepare_partial_page() fail
21213 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
21217 # create at least 100 unused inodes so that
21218 # shrink_icache_memory(0) should not return 0
21219 touch $DIR/$tfile-{0..100}
21220 rm -f $DIR/$tfile-{0..100}
21223 echo 2 > /proc/sys/vm/drop_caches
21225 run_test 408 "drop_caches should not hang due to page leaks"
21229 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21231 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
21232 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
21233 touch $DIR/$tdir/guard || error "(2) Fail to create"
21235 local PREFIX=$(str_repeat 'A' 128)
21236 echo "Create 1K hard links start at $(date)"
21237 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
21238 error "(3) Fail to hard link"
21240 echo "Links count should be right although linkEA overflow"
21241 stat $DIR/$tdir/guard || error "(4) Fail to stat"
21242 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
21243 [ $linkcount -eq 1001 ] ||
21244 error "(5) Unexpected hard links count: $linkcount"
21246 echo "List all links start at $(date)"
21247 ls -l $DIR/$tdir/foo > /dev/null ||
21248 error "(6) Fail to list $DIR/$tdir/foo"
21250 echo "Unlink hard links start at $(date)"
21251 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
21252 error "(7) Fail to unlink"
21253 echo "Unlink hard links finished at $(date)"
21255 run_test 409 "Large amount of cross-MDTs hard links on the same file"
21259 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
21260 skip "Need client version at least 2.9.59"
21262 # Create a file, and stat it from the kernel
21263 local testfile=$DIR/$tfile
21266 local run_id=$RANDOM
21267 local my_ino=$(stat --format "%i" $testfile)
21269 # Try to insert the module. This will always fail as the
21270 # module is designed to not be inserted.
21271 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
21274 # Anything but success is a test failure
21276 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
21277 error "no inode match"
21279 run_test 410 "Test inode number returned from kernel thread"
21281 cleanup_test411_cgroup() {
21287 local cg_basedir=/sys/fs/cgroup/memory
21289 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
21290 skip "no setup for cgroup"
21292 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
21293 error "test file creation failed"
21294 cancel_lru_locks osc
21296 # Create a very small memory cgroup to force a slab allocation error
21297 local cgdir=$cg_basedir/osc_slab_alloc
21298 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
21299 trap "cleanup_test411_cgroup $cgdir" EXIT
21300 echo 2M > $cgdir/memory.kmem.limit_in_bytes
21301 echo 1M > $cgdir/memory.limit_in_bytes
21303 # Should not LBUG, just be killed by oom-killer
21304 # dd will return 0 even allocation failure in some environment.
21305 # So don't check return value
21306 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
21307 cleanup_test411_cgroup $cgdir
21311 run_test 411 "Slab allocation error with cgroup does not LBUG"
21314 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21315 if [ $MDS1_VERSION -lt $(version_code 2.10.55) ]; then
21316 skip "Need server version at least 2.10.55"
21319 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
21320 error "mkdir failed"
21321 $LFS getdirstripe $DIR/$tdir
21322 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
21323 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
21324 error "expect $((MDSCOUT - 1)) get $stripe_index"
21325 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
21326 [ $stripe_count -eq 2 ] ||
21327 error "expect 2 get $stripe_count"
21329 run_test 412 "mkdir on specific MDTs"
21333 local stripe_count=$2
21334 local mdts=$(comma_list $(mdts_nodes))
21337 local lmv_qos_prio_free
21338 local lmv_qos_threshold_rr
21339 local lmv_qos_maxage
21340 local lod_qos_prio_free
21341 local lod_qos_threshold_rr
21342 local lod_qos_maxage
21346 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
21347 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
21348 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
21350 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
21351 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
21352 stack_trap "$LCTL set_param \
21353 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null" EXIT
21354 stack_trap "$LCTL set_param \
21355 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
21356 stack_trap "$LCTL set_param \
21357 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" EXIT
21359 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
21360 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
21361 lod_qos_prio_free=${lod_qos_prio_free%%%}
21362 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
21363 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
21364 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
21365 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
21366 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
21367 stack_trap "do_nodes $mdts $LCTL set_param \
21368 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null" EXIT
21369 stack_trap "do_nodes $mdts $LCTL set_param \
21370 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null" \
21372 stack_trap "do_nodes $mdts $LCTL set_param \
21373 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" EXIT
21376 echo "Mkdir (stripe_count $stripe_count) roundrobin:"
21378 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
21379 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
21381 testdir=$DIR/$tdir-s$stripe_count/rr
21383 for i in $(seq $((100 * MDSCOUNT))); do
21384 eval $mkdir_cmd $testdir/subdir$i ||
21385 error "$mkdir_cmd subdir$i failed"
21388 for i in $(seq $MDSCOUNT); do
21389 count=$($LFS getdirstripe -i $testdir/* |
21390 grep ^$((i - 1))$ | wc -l)
21391 echo "$count directories created on MDT$((i - 1))"
21392 [ $count -eq 100 ] || error "subdirs are not evenly distributed"
21394 if [ $stripe_count -gt 1 ]; then
21395 count=$($LFS getdirstripe $testdir/* |
21396 grep -P "^\s+$((i - 1))\t" | wc -l)
21397 echo "$count stripes created on MDT$((i - 1))"
21398 # deviation should < 5% of average
21399 [ $count -lt $((95 * stripe_count)) ] ||
21400 [ $count -gt $((105 * stripe_count)) ] &&
21401 error "stripes are not evenly distributed"
21405 $LCTL set_param lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null
21406 do_nodes $mdts $LCTL set_param \
21407 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null
21410 echo "Check for uneven MDTs: "
21420 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
21421 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
21422 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
21424 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
21425 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
21428 for ((i = 1; i < ${#ffree[@]}; i++)); do
21429 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
21430 if [ $tmp -gt $max ]; then
21434 if [ $tmp -lt $min ]; then
21440 [ ${ffree[min_index]} -eq 0 ] &&
21441 skip "no free files in MDT$min_index"
21442 [ ${ffree[min_index]} -gt 100000000 ] &&
21443 skip "too much free files in MDT$min_index"
21445 # Check if we need to generate uneven MDTs
21447 local diff=$(((max - min) * 100 / min))
21448 local value="$(generate_string 1024)"
21450 while [ $diff -lt $threshold ]; do
21451 # generate uneven MDTs, create till $threshold% diff
21452 echo -n "weight diff=$diff% must be > $threshold% ..."
21453 count=$((${ffree[min_index]} / 10))
21454 # 50 sec per 10000 files in vm
21455 [ $count -gt 40000 ] && [ "$SLOW" = "no" ] &&
21456 skip "$count files to create"
21457 echo "Fill MDT$min_index with $count files"
21458 [ -d $DIR/$tdir-MDT$min_index ] ||
21459 $LFS mkdir -i $min_index $DIR/$tdir-MDT$min_index ||
21460 error "mkdir $tdir-MDT$min_index failed"
21461 for i in $(seq $count); do
21462 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE \
21463 $DIR/$tdir-MDT$min_index/f$j_$i > /dev/null ||
21464 error "create f$j_$i failed"
21465 setfattr -n user.413b -v $value \
21466 $DIR/$tdir-MDT$min_index/f$j_$i ||
21467 error "setfattr f$j_$i failed"
21470 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
21471 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
21472 max=$(((${ffree[max_index]} >> 8) * \
21473 (${bavail[max_index]} * bsize >> 16)))
21474 min=$(((${ffree[min_index]} >> 8) * \
21475 (${bavail[min_index]} * bsize >> 16)))
21476 diff=$(((max - min) * 100 / min))
21479 echo "MDT filesfree available: ${ffree[@]}"
21480 echo "MDT blocks available: ${bavail[@]}"
21481 echo "weight diff=$diff%"
21484 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
21486 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
21487 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
21488 # decrease statfs age, so that it can be updated in time
21489 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
21490 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
21494 testdir=$DIR/$tdir-s$stripe_count/qos
21496 for i in $(seq $((100 * MDSCOUNT))); do
21497 eval $mkdir_cmd $testdir/subdir$i ||
21498 error "$mkdir_cmd subdir$i failed"
21501 for i in $(seq $MDSCOUNT); do
21502 count=$($LFS getdirstripe -i $testdir/* | grep ^$((i - 1))$ |
21504 echo "$count directories created on MDT$((i - 1))"
21506 if [ $stripe_count -gt 1 ]; then
21507 count=$($LFS getdirstripe $testdir/* |
21508 grep -P "^\s+$((i - 1))\t" | wc -l)
21509 echo "$count stripes created on MDT$((i - 1))"
21513 max=$($LFS getdirstripe -i $testdir/* | grep ^$max_index$ | wc -l)
21514 min=$($LFS getdirstripe -i $testdir/* | grep ^$min_index$ | wc -l)
21516 # D-value should > 10% of averge
21517 [ $((max - min)) -lt 10 ] &&
21518 error "subdirs shouldn't be evenly distributed"
21521 if [ $stripe_count -gt 1 ]; then
21522 max=$($LFS getdirstripe $testdir/* |
21523 grep -P "^\s+$max_index\t" | wc -l)
21524 min=$($LFS getdirstripe $testdir/* |
21525 grep -P "^\s+$min_index\t" | wc -l)
21526 [ $((max - min)) -le $((10 * stripe_count)) ] &&
21527 error "stripes shouldn't be evenly distributed"|| true
21532 [ $MDSCOUNT -lt 2 ] &&
21533 skip "We need at least 2 MDTs for this test"
21535 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
21536 skip "Need server version at least 2.12.52"
21540 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
21541 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
21542 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
21543 mkdir $DIR/$tdir-s$stripe_count/qos || error "mkdir failed"
21544 test_qos_mkdir "$LFS mkdir -c $stripe_count" $stripe_count
21547 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
21550 [ $MDSCOUNT -lt 2 ] &&
21551 skip "We need at least 2 MDTs for this test"
21553 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
21554 skip "Need server version at least 2.12.52"
21558 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
21559 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
21560 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
21561 mkdir $DIR/$tdir-s$stripe_count/qos || error "mkdir failed"
21562 $LFS setdirstripe -D -c $stripe_count \
21563 $DIR/$tdir-s$stripe_count/rr ||
21564 error "setdirstripe failed"
21565 $LFS setdirstripe -D -c $stripe_count \
21566 $DIR/$tdir-s$stripe_count/qos ||
21567 error "setdirstripe failed"
21568 test_qos_mkdir "mkdir" $stripe_count
21571 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
21574 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
21575 $LCTL set_param fail_loc=0x80000521
21576 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
21579 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
21582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21583 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21584 skip "Need server version at least 2.11.52"
21594 # this test may be slow on ZFS
21595 [ "$mds1_FSTYPE" == "zfs" ] && total=100
21597 # though this test is designed for striped directory, let's test normal
21598 # directory too since lock is always saved as CoS lock.
21599 test_mkdir $DIR/$tdir || error "mkdir $tdir"
21600 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
21609 start_time=$(date +%s)
21610 for i in $(seq $total); do
21611 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
21614 end_time=$(date +%s)
21615 duration=$((end_time - start_time))
21617 kill -9 $setattr_pid
21619 echo "rename $total files took $duration sec"
21620 [ $duration -lt 100 ] || error "rename took $duration sec"
21622 run_test 415 "lock revoke is not missing"
21625 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
21626 skip "Need server version at least 2.11.55"
21628 # define OBD_FAIL_OSD_TXN_START 0x19a
21629 do_facet mds1 lctl set_param fail_loc=0x19a
21631 lfs mkdir -c $MDSCOUNT $DIR/$tdir
21635 run_test 416 "transaction start failure won't cause system hung"
21639 do_nodes $(comma_list $(mdts_nodes)) \
21640 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
21641 do_nodes $(comma_list $(mdts_nodes)) \
21642 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
21643 do_nodes $(comma_list $(mdts_nodes)) \
21644 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
21648 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21649 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
21650 skip "Need MDS version at least 2.11.56"
21652 trap cleanup_417 RETURN EXIT
21654 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
21655 do_nodes $(comma_list $(mdts_nodes)) \
21656 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
21657 $LFS migrate -m 0 $DIR/$tdir.1 &&
21658 error "migrate dir $tdir.1 should fail"
21660 do_nodes $(comma_list $(mdts_nodes)) \
21661 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
21662 $LFS mkdir -i 1 $DIR/$tdir.2 &&
21663 error "create remote dir $tdir.2 should fail"
21665 do_nodes $(comma_list $(mdts_nodes)) \
21666 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
21667 $LFS mkdir -c 2 $DIR/$tdir.3 &&
21668 error "create striped dir $tdir.3 should fail"
21671 run_test 417 "disable remote dir, striped dir and dir migration"
21673 # Checks that the outputs of df [-i] and lfs df [-i] match
21675 # usage: check_lfs_df <blocks | inodes> <mountpoint>
21685 [ "$1" == "blocks" ] && inodes= || inodes="-i"
21687 for count in {1..100}; do
21691 # read the lines of interest
21692 df_out=($(df -P $inodes $dir | tail -n +2)) ||
21693 error "df $inodes $dir | tail -n +2 failed"
21694 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
21695 error "lfs df $inodes $dir | grep summary: failed"
21697 # skip first substrings of each output as they are different
21698 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
21699 # compare the two outputs
21701 for i in {1..5}; do
21702 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
21710 lfs df $inodes $dir
21711 error "df and lfs df $1 output mismatch: " \
21712 "df ${inodes}: ${df_out[*]}, " \
21713 "lfs df ${inodes}: ${lfs_df_out[*]}"
21718 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21720 local dir=$DIR/$tdir
21721 local numfiles=$((RANDOM % 4096 + 2))
21722 local numblocks=$((RANDOM % 256 + 1))
21724 wait_delete_completed
21727 # check block output
21728 check_lfs_df blocks $dir
21729 # check inode output
21730 check_lfs_df inodes $dir
21732 # create a single file and retest
21733 echo "Creating a single file and testing"
21734 createmany -o $dir/$tfile- 1 &>/dev/null ||
21735 error "creating 1 file in $dir failed"
21736 check_lfs_df blocks $dir
21737 check_lfs_df inodes $dir
21739 # create a random number of files
21740 echo "Creating $((numfiles - 1)) files and testing"
21741 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
21742 error "creating $((numfiles - 1)) files in $dir failed"
21744 # write a random number of blocks to the first test file
21745 echo "Writing $numblocks 4K blocks and testing"
21746 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
21747 count=$numblocks &>/dev/null ||
21748 error "dd to $dir/${tfile}-0 failed"
21751 check_lfs_df blocks $dir
21752 check_lfs_df inodes $dir
21754 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
21755 error "unlinking $numfiles files in $dir failed"
21757 run_test 418 "df and lfs df outputs match"
21761 local dir=$DIR/$tdir
21766 cancel_lru_locks mdc
21768 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
21769 $LCTL set_param fail_loc=0x1410
21771 $LCTL set_param fail_loc=0
21774 run_test 419 "Verify open file by name doesn't crash kernel"
21778 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
21779 skip "Need MDS version at least 2.12.53"
21781 local SAVE_UMASK=$(umask)
21782 local dir=$DIR/$tdir
21783 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
21787 mkdir -m03777 $dir/testdir
21788 ls -dn $dir/testdir
21789 # Need to remove trailing '.' when SELinux is enabled
21790 local dirperms=$(ls -dn $dir/testdir |
21791 awk '{ sub(/\.$/, "", $1); print $1}')
21792 [ $dirperms == "drwxrwsrwt" ] ||
21793 error "incorrect perms on $dir/testdir"
21795 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
21796 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
21797 ls -n $dir/testdir/testfile
21798 local fileperms=$(ls -n $dir/testdir/testfile |
21799 awk '{ sub(/\.$/, "", $1); print $1}')
21800 [ $fileperms == "-rwxr-xr-x" ] ||
21801 error "incorrect perms on $dir/testdir/testfile"
21805 run_test 420 "clear SGID bit on non-directories for non-members"
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 3
21817 cnt=$(ls -1 $DIR/$tdir | wc -l)
21818 [ $cnt != 3 ] && error "unexpected #files: $cnt"
21820 fid1=$(lfs path2fid $DIR/$tdir/f1)
21821 fid2=$(lfs path2fid $DIR/$tdir/f2)
21822 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
21824 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
21825 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
21827 cnt=$(ls -1 $DIR/$tdir | wc -l)
21828 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
21830 rm -f $DIR/$tdir/f3 || error "can't remove f3"
21831 createmany -o $DIR/$tdir/f 3
21832 cnt=$(ls -1 $DIR/$tdir | wc -l)
21833 [ $cnt != 3 ] && error "unexpected #files: $cnt"
21835 fid1=$(lfs path2fid $DIR/$tdir/f1)
21836 fid2=$(lfs path2fid $DIR/$tdir/f2)
21837 echo "remove using fsname $FSNAME"
21838 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
21840 cnt=$(ls -1 $DIR/$tdir | wc -l)
21841 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
21843 run_test 421a "simple rm by fid"
21850 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21851 skip "Need MDS version at least 2.12.54"
21853 test_mkdir $DIR/$tdir
21854 createmany -o $DIR/$tdir/f 3
21855 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
21858 FID1=$(lfs path2fid $DIR/$tdir/f1)
21859 FID2=$(lfs path2fid $DIR/$tdir/f2)
21860 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
21862 kill -USR1 $MULTIPID
21865 cnt=$(ls $DIR/$tdir | wc -l)
21866 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
21868 run_test 421b "rm by fid on open file"
21874 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21875 skip "Need MDS version at least 2.12.54"
21877 test_mkdir $DIR/$tdir
21878 createmany -o $DIR/$tdir/f 3
21879 touch $DIR/$tdir/$tfile
21880 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
21881 cnt=$(ls -1 $DIR/$tdir | wc -l)
21882 [ $cnt != 184 ] && error "unexpected #files: $cnt"
21884 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
21885 $LFS rmfid $DIR $FID1 || error "rmfid failed"
21887 cnt=$(ls $DIR/$tdir | wc -l)
21888 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
21890 run_test 421c "rm by fid against hardlinked files"
21896 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21897 skip "Need MDS version at least 2.12.54"
21899 test_mkdir $DIR/$tdir
21900 createmany -o $DIR/$tdir/f 4097
21901 cnt=$(ls -1 $DIR/$tdir | wc -l)
21902 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
21904 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
21905 $LFS rmfid $DIR $FIDS || error "rmfid failed"
21907 cnt=$(ls $DIR/$tdir | wc -l)
21909 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21911 run_test 421d "rmfid en masse"
21917 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21918 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21919 skip "Need MDS version at least 2.12.54"
21921 mkdir -p $DIR/$tdir
21922 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
21923 createmany -o $DIR/$tdir/striped_dir/f 512
21924 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
21925 [ $cnt != 512 ] && error "unexpected #files: $cnt"
21927 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
21928 sed "s/[/][^:]*://g")
21929 $LFS rmfid $DIR $FIDS || error "rmfid failed"
21931 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
21933 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
21935 run_test 421e "rmfid in DNE"
21941 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
21942 skip "Need MDS version at least 2.12.54"
21944 test_mkdir $DIR/$tdir
21946 cnt=$(ls -1 $DIR/$tdir | wc -l)
21947 [ $cnt != 1 ] && error "unexpected #files: $cnt"
21949 FID=$(lfs path2fid $DIR/$tdir/f)
21950 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
21951 # rmfid should fail
21952 cnt=$(ls -1 $DIR/$tdir | wc -l)
21953 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
21955 chmod a+rw $DIR/$tdir
21957 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
21958 # rmfid should fail
21959 cnt=$(ls -1 $DIR/$tdir | wc -l)
21960 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
21963 $RUNAS touch $DIR/$tdir/f
21964 FID=$(lfs path2fid $DIR/$tdir/f)
21965 echo "rmfid as root"
21966 $LFS rmfid $DIR $FID || error "rmfid as root failed"
21967 cnt=$(ls -1 $DIR/$tdir | wc -l)
21968 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
21971 $RUNAS touch $DIR/$tdir/f
21972 cnt=$(ls -1 $DIR/$tdir | wc -l)
21973 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
21974 FID=$(lfs path2fid $DIR/$tdir/f)
21975 # rmfid w/o user_fid2path mount option should fail
21976 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
21977 cnt=$(ls -1 $DIR/$tdir | wc -l)
21978 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
21980 umount_client $MOUNT || error "failed to umount client"
21981 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
21982 error "failed to mount client'"
21984 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
21985 # rmfid should succeed
21986 cnt=$(ls -1 $DIR/$tdir | wc -l)
21987 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
21989 # rmfid shouldn't allow to remove files due to dir's permission
21990 chmod a+rwx $DIR/$tdir
21993 FID=$(lfs path2fid $DIR/$tdir/f)
21994 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
21996 umount_client $MOUNT || error "failed to umount client"
21997 mount_client $MOUNT "$MOUNT_OPTS" ||
21998 error "failed to mount client'"
22001 run_test 421f "rmfid checks permissions"
22007 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22008 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22009 skip "Need MDS version at least 2.12.54"
22011 mkdir -p $DIR/$tdir
22012 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
22013 createmany -o $DIR/$tdir/striped_dir/f 512
22014 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22015 [ $cnt != 512 ] && error "unexpected #files: $cnt"
22017 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
22018 sed "s/[/][^:]*://g")
22020 rm -f $DIR/$tdir/striped_dir/f1*
22021 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22022 removed=$((512 - cnt))
22024 # few files have been just removed, so we expect
22025 # rmfid to fail on their fids
22026 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
22027 [ $removed != $errors ] && error "$errors != $removed"
22029 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
22031 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
22033 run_test 421g "rmfid to return errors properly"
22036 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
22037 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
22038 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
22039 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
22040 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
22042 local amc=$(at_max_get client)
22043 local amo=$(at_max_get mds1)
22044 local timeout=`lctl get_param -n timeout`
22046 at_max_set 0 client
22049 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
22050 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
22051 fail_val=$(((2*timeout + 10)*1000))
22052 touch $DIR/$tdir/d3/file &
22054 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
22055 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
22056 fail_val=$((2*timeout + 5))
22057 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
22061 sleep $((2 * timeout))
22065 touch $DIR/$tdir/d2/file3
22066 touch $DIR/$tdir/d2/file4
22067 touch $DIR/$tdir/d2/file5
22070 at_max_set $amc client
22071 at_max_set $amo mds1
22073 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
22074 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
22075 error "Watchdog is always throttled"
22077 run_test 422 "kill a process with RPC in progress"
22090 # ensure statfs cache is expired
22093 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
22094 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
22098 run_test 423 "statfs should return a right data"
22101 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
22102 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
22103 skip "Need server version at least 2.9.55"
22105 start_full_debug_logging
22109 stop_full_debug_logging
22113 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
22114 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
22115 awk '/The barrier for/ { print $7 }')
22118 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
22123 barrier_expired() {
22126 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
22127 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
22128 awk '/will be expired/ { print $7 }')
22130 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
22139 echo "Start barrier_freeze at: $(date)"
22140 #define OBD_FAIL_BARRIER_DELAY 0x2202
22141 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
22142 # Do not reduce barrier time - See LU-11873
22143 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
22146 local b_status=$(barrier_stat)
22147 echo "Got barrier status at: $(date)"
22148 [ "$b_status" = "'freezing_p1'" ] ||
22149 error "(1) unexpected barrier status $b_status"
22151 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
22153 b_status=$(barrier_stat)
22154 [ "$b_status" = "'frozen'" ] ||
22155 error "(2) unexpected barrier status $b_status"
22157 local expired=$(barrier_expired)
22158 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
22159 sleep $((expired + 3))
22161 b_status=$(barrier_stat)
22162 [ "$b_status" = "'expired'" ] ||
22163 error "(3) unexpected barrier status $b_status"
22165 # Do not reduce barrier time - See LU-11873
22166 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
22167 error "(4) fail to freeze barrier"
22169 b_status=$(barrier_stat)
22170 [ "$b_status" = "'frozen'" ] ||
22171 error "(5) unexpected barrier status $b_status"
22173 echo "Start barrier_thaw at: $(date)"
22174 #define OBD_FAIL_BARRIER_DELAY 0x2202
22175 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
22176 do_facet mgs $LCTL barrier_thaw $FSNAME &
22179 b_status=$(barrier_stat)
22180 echo "Got barrier status at: $(date)"
22181 [ "$b_status" = "'thawing'" ] ||
22182 error "(6) unexpected barrier status $b_status"
22184 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
22186 b_status=$(barrier_stat)
22187 [ "$b_status" = "'thawed'" ] ||
22188 error "(7) unexpected barrier status $b_status"
22190 #define OBD_FAIL_BARRIER_FAILURE 0x2203
22191 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
22192 do_facet mgs $LCTL barrier_freeze $FSNAME
22194 b_status=$(barrier_stat)
22195 [ "$b_status" = "'failed'" ] ||
22196 error "(8) unexpected barrier status $b_status"
22198 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
22199 do_facet mgs $LCTL barrier_thaw $FSNAME
22203 run_test 801a "write barrier user interfaces and stat machine"
22208 mkdir $DIR/$tdir || error "(1) fail to mkdir"
22209 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
22210 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
22211 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
22212 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
22214 cancel_lru_locks mdc
22216 # 180 seconds should be long enough
22217 do_facet mgs $LCTL barrier_freeze $FSNAME 180
22219 local b_status=$(barrier_stat)
22220 [ "$b_status" = "'frozen'" ] ||
22221 error "(6) unexpected barrier status $b_status"
22223 mkdir $DIR/$tdir/d0/d10 &
22226 touch $DIR/$tdir/d1/f13 &
22229 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
22232 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
22235 rm -f $DIR/$tdir/d4/f12 &
22238 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
22240 # To guarantee taht the 'stat' is not blocked
22241 b_status=$(barrier_stat)
22242 [ "$b_status" = "'frozen'" ] ||
22243 error "(8) unexpected barrier status $b_status"
22245 # let above commands to run at background
22248 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
22249 ps -p $touch_pid || error "(10) touch should be blocked"
22250 ps -p $ln_pid || error "(11) link should be blocked"
22251 ps -p $mv_pid || error "(12) rename should be blocked"
22252 ps -p $rm_pid || error "(13) unlink should be blocked"
22254 b_status=$(barrier_stat)
22255 [ "$b_status" = "'frozen'" ] ||
22256 error "(14) unexpected barrier status $b_status"
22258 do_facet mgs $LCTL barrier_thaw $FSNAME
22259 b_status=$(barrier_stat)
22260 [ "$b_status" = "'thawed'" ] ||
22261 error "(15) unexpected barrier status $b_status"
22263 wait $mkdir_pid || error "(16) mkdir should succeed"
22264 wait $touch_pid || error "(17) touch should succeed"
22265 wait $ln_pid || error "(18) link should succeed"
22266 wait $mv_pid || error "(19) rename should succeed"
22267 wait $rm_pid || error "(20) unlink should succeed"
22271 run_test 801b "modification will be blocked by write barrier"
22274 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
22278 stop mds2 || error "(1) Fail to stop mds2"
22280 do_facet mgs $LCTL barrier_freeze $FSNAME 30
22282 local b_status=$(barrier_stat)
22283 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
22284 do_facet mgs $LCTL barrier_thaw $FSNAME
22285 error "(2) unexpected barrier status $b_status"
22288 do_facet mgs $LCTL barrier_rescan $FSNAME ||
22289 error "(3) Fail to rescan barrier bitmap"
22291 # Do not reduce barrier time - See LU-11873
22292 do_facet mgs $LCTL barrier_freeze $FSNAME 20
22294 b_status=$(barrier_stat)
22295 [ "$b_status" = "'frozen'" ] ||
22296 error "(4) unexpected barrier status $b_status"
22298 do_facet mgs $LCTL barrier_thaw $FSNAME
22299 b_status=$(barrier_stat)
22300 [ "$b_status" = "'thawed'" ] ||
22301 error "(5) unexpected barrier status $b_status"
22303 local devname=$(mdsdevname 2)
22305 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
22307 do_facet mgs $LCTL barrier_rescan $FSNAME ||
22308 error "(7) Fail to rescan barrier bitmap"
22312 run_test 801c "rescan barrier bitmap"
22314 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
22315 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
22316 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
22317 saved_MOUNT_OPTS=$MOUNT_OPTS
22323 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
22324 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
22325 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
22326 MOUNT_OPTS=$saved_MOUNT_OPTS
22331 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
22332 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
22333 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
22334 skip "Need server version at least 2.9.55"
22336 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
22338 mkdir $DIR/$tdir || error "(1) fail to mkdir"
22340 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
22341 error "(2) Fail to copy"
22343 trap cleanup_802a EXIT
22345 # sync by force before remount as readonly
22346 sync; sync_all_data; sleep 3; sync_all_data
22350 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
22351 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
22352 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
22354 echo "Mount the server as read only"
22355 setupall server_only || error "(3) Fail to start servers"
22357 echo "Mount client without ro should fail"
22358 mount_client $MOUNT &&
22359 error "(4) Mount client without 'ro' should fail"
22361 echo "Mount client with ro should succeed"
22362 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
22363 mount_client $MOUNT ||
22364 error "(5) Mount client with 'ro' should succeed"
22366 echo "Modify should be refused"
22367 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
22369 echo "Read should be allowed"
22370 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
22371 error "(7) Read should succeed under ro mode"
22375 run_test 802a "simulate readonly device"
22378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22379 remote_mds_nodsh && skip "remote MDS with nodsh"
22381 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
22382 skip "readonly option not available"
22384 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
22386 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
22387 error "(2) Fail to copy"
22389 # write back all cached data before setting MDT to readonly
22393 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
22394 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
22396 echo "Modify should be refused"
22397 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
22399 echo "Read should be allowed"
22400 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
22401 error "(7) Read should succeed under ro mode"
22404 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
22406 run_test 802b "be able to set MDTs to readonly"
22409 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
22410 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
22411 skip "MDS needs to be newer than 2.10.54"
22413 mkdir -p $DIR/$tdir
22414 # Create some objects on all MDTs to trigger related logs objects
22415 for idx in $(seq $MDSCOUNT); do
22416 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
22417 $DIR/$tdir/dir${idx} ||
22418 error "Fail to create $DIR/$tdir/dir${idx}"
22422 wait_delete_completed # ensure old test cleanups are finished
22423 echo "before create:"
22425 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
22427 for i in {1..10}; do
22428 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
22429 error "Fail to create $DIR/$tdir/foo$i"
22433 echo "after create:"
22435 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
22437 # allow for an llog to be cleaned up during the test
22438 [ $after_used -ge $((before_used + 10 - 1)) ] ||
22439 error "before ($before_used) + 10 > after ($after_used)"
22441 for i in {1..10}; do
22442 rm -rf $DIR/$tdir/foo$i ||
22443 error "Fail to remove $DIR/$tdir/foo$i"
22446 sleep 3 # avoid MDT return cached statfs
22447 wait_delete_completed
22448 echo "after unlink:"
22450 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
22452 # allow for an llog to be created during the test
22453 [ $after_used -le $((before_used + 1)) ] ||
22454 error "after ($after_used) > before ($before_used) + 1"
22456 run_test 803 "verify agent object for remote object"
22459 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
22460 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
22461 skip "MDS needs to be newer than 2.10.54"
22462 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
22464 mkdir -p $DIR/$tdir
22465 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
22466 error "Fail to create $DIR/$tdir/dir0"
22468 local fid=$($LFS path2fid $DIR/$tdir/dir0)
22469 local dev=$(mdsdevname 2)
22471 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
22472 grep ${fid} || error "NOT found agent entry for dir0"
22474 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
22475 error "Fail to create $DIR/$tdir/dir1"
22477 touch $DIR/$tdir/dir1/foo0 ||
22478 error "Fail to create $DIR/$tdir/dir1/foo0"
22479 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
22482 for idx in $(seq $MDSCOUNT); do
22483 dev=$(mdsdevname $idx)
22484 do_facet mds${idx} \
22485 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
22486 grep ${fid} && rc=$idx
22489 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
22490 error "Fail to rename foo0 to foo1"
22491 if [ $rc -eq 0 ]; then
22492 for idx in $(seq $MDSCOUNT); do
22493 dev=$(mdsdevname $idx)
22494 do_facet mds${idx} \
22495 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
22496 grep ${fid} && rc=$idx
22500 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
22501 error "Fail to rename foo1 to foo2"
22502 if [ $rc -eq 0 ]; then
22503 for idx in $(seq $MDSCOUNT); do
22504 dev=$(mdsdevname $idx)
22505 do_facet mds${idx} \
22506 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
22507 grep ${fid} && rc=$idx
22511 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
22513 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
22514 error "Fail to link to $DIR/$tdir/dir1/foo2"
22515 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
22516 error "Fail to rename foo2 to foo0"
22517 unlink $DIR/$tdir/dir1/foo0 ||
22518 error "Fail to unlink $DIR/$tdir/dir1/foo0"
22519 rm -rf $DIR/$tdir/dir0 ||
22520 error "Fail to rm $DIR/$tdir/dir0"
22522 for idx in $(seq $MDSCOUNT); do
22523 dev=$(mdsdevname $idx)
22527 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
22529 start mds${idx} $dev $MDS_MOUNT_OPTS ||
22530 error "mount mds$idx failed"
22531 df $MOUNT > /dev/null 2>&1
22533 # e2fsck should not return error
22535 error "e2fsck detected error on MDT${idx}: rc=$rc"
22538 run_test 804 "verify agent entry for remote entry"
22541 do_facet $SINGLEMDS zfs set quota=$old $fsset
22542 unlinkmany $DIR/$tdir/f- 1000000
22547 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
22548 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
22549 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
22550 skip "netfree not implemented before 0.7"
22551 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
22552 skip "Need MDS version at least 2.10.57"
22559 local pref="osd-zfs.$FSNAME-MDT0000."
22561 # limit available space on MDS dataset to meet nospace issue
22562 # quickly. then ZFS 0.7.2 can use reserved space if asked
22563 # properly (using netfree flag in osd_declare_destroy()
22564 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
22565 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
22567 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
22568 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
22569 let "usedkb=usedkb-freekb"
22570 let "freekb=freekb/2"
22571 if let "freekb > 5000"; then
22574 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
22575 trap cleanup_805 EXIT
22577 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
22578 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
22579 rm -rf $DIR/$tdir || error "not able to remove"
22580 do_facet $SINGLEMDS zfs set quota=$old $fsset
22583 run_test 805 "ZFS can remove from full fs"
22589 local size=$($LFS getsom -s $file)
22590 local expect=$(stat -c %s $file)
22592 [[ $size == $expect ]] ||
22593 error "$file expected size: $expect, got: $size"
22595 local blocks=$($LFS getsom -b $file)
22596 expect=$(stat -c %b $file)
22597 [[ $blocks == $expect ]] ||
22598 error "$file expected blocks: $expect, got: $blocks"
22603 local size=$($LFS getsom -s $1)
22606 [[ $size == $expect ]] ||
22607 error "$file expected size: $expect, got: $size"
22611 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22612 skip "Need MDS version at least 2.11.52"
22616 touch $DIR/$tfile || error "touch $tfile failed"
22618 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22619 save_lustre_params client "llite.*.xattr_cache" > $save
22620 lctl set_param llite.*.xattr_cache=0
22621 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22623 # single-threaded write
22624 echo "Test SOM for single-threaded write"
22625 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
22626 error "write $tfile failed"
22627 check_lsom_size $DIR/$tfile $bs
22630 local size=$(($num * $bs))
22634 echo "Test SOM for single client multi-threaded($num) write"
22635 $TRUNCATE $DIR/$tfile 0
22636 for ((i = 0; i < $num; i++)); do
22637 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22639 offset=$((offset + $bs))
22641 for (( i=0; i < $num; i++ )); do
22644 check_lsom_size $DIR/$tfile $size
22646 $TRUNCATE $DIR/$tfile 0
22647 for ((i = 0; i < $num; i++)); do
22648 offset=$((offset - $bs))
22649 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22652 for (( i=0; i < $num; i++ )); do
22655 check_lsom_size $DIR/$tfile $size
22657 # multi-client writes
22658 num=$(get_node_count ${CLIENTS//,/ })
22659 size=$(($num * $bs))
22663 echo "Test SOM for multi-client ($num) writes"
22664 $TRUNCATE $DIR/$tfile 0
22665 for client in ${CLIENTS//,/ }; do
22666 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22669 offset=$((offset + $bs))
22671 for (( i=0; i < $num; i++ )); do
22674 check_lsom_size $DIR/$tfile $offset
22677 $TRUNCATE $DIR/$tfile 0
22678 for client in ${CLIENTS//,/ }; do
22679 offset=$((offset - $bs))
22680 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22684 for (( i=0; i < $num; i++ )); do
22687 check_lsom_size $DIR/$tfile $size
22690 echo "Test SOM for truncate"
22691 $TRUNCATE $DIR/$tfile 1048576
22692 check_lsom_size $DIR/$tfile 1048576
22693 $TRUNCATE $DIR/$tfile 1234
22694 check_lsom_size $DIR/$tfile 1234
22696 # verify SOM blocks count
22697 echo "Verify SOM block count"
22698 $TRUNCATE $DIR/$tfile 0
22699 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
22700 error "failed to write file $tfile"
22701 check_lsom_data $DIR/$tfile
22703 run_test 806 "Verify Lazy Size on MDS"
22706 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
22707 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22708 skip "Need MDS version at least 2.11.52"
22710 # Registration step
22711 changelog_register || error "changelog_register failed"
22712 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
22713 changelog_users $SINGLEMDS | grep -q $cl_user ||
22714 error "User $cl_user not found in changelog_users"
22716 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
22717 save_lustre_params client "llite.*.xattr_cache" > $save
22718 lctl set_param llite.*.xattr_cache=0
22719 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
22721 rm -rf $DIR/$tdir || error "rm $tdir failed"
22722 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
22723 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
22724 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
22725 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
22726 error "truncate $tdir/trunc failed"
22729 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
22730 error "write $tfile failed"
22732 # multi-client wirtes
22733 local num=$(get_node_count ${CLIENTS//,/ })
22737 echo "Test SOM for multi-client ($num) writes"
22738 touch $DIR/$tfile || error "touch $tfile failed"
22739 $TRUNCATE $DIR/$tfile 0
22740 for client in ${CLIENTS//,/ }; do
22741 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
22744 offset=$((offset + $bs))
22746 for (( i=0; i < $num; i++ )); do
22751 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
22752 check_lsom_data $DIR/$tdir/trunc
22753 check_lsom_data $DIR/$tdir/single_dd
22754 check_lsom_data $DIR/$tfile
22757 # Deregistration step
22758 changelog_deregister || error "changelog_deregister failed"
22760 run_test 807 "verify LSOM syncing tool"
22762 check_som_nologged()
22764 local lines=$($LFS changelog $FSNAME-MDT0000 |
22765 grep 'x=trusted.som' | wc -l)
22766 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
22770 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
22771 skip "Need MDS version at least 2.11.55"
22773 # Registration step
22774 changelog_register || error "changelog_register failed"
22776 touch $DIR/$tfile || error "touch $tfile failed"
22779 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
22780 error "write $tfile failed"
22783 $TRUNCATE $DIR/$tfile 1234
22786 $TRUNCATE $DIR/$tfile 1048576
22789 # Deregistration step
22790 changelog_deregister || error "changelog_deregister failed"
22792 run_test 808 "Check trusted.som xattr not logged in Changelogs"
22797 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
22801 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22802 skip "Need MDS version at least 2.11.56"
22804 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
22805 error "failed to create DoM-only file $DIR/$tfile"
22806 touch $DIR/$tfile || error "touch $tfile failed"
22807 check_som_nodata $DIR/$tfile
22809 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
22810 error "write $tfile failed"
22811 check_som_nodata $DIR/$tfile
22813 $TRUNCATE $DIR/$tfile 1234
22814 check_som_nodata $DIR/$tfile
22816 $TRUNCATE $DIR/$tfile 4097
22817 check_som_nodata $DIR/$file
22819 run_test 809 "Verify no SOM xattr store for DoM-only files"
22822 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22823 $GSS && skip_env "could not run with gss"
22824 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
22825 skip "OST < 2.12.58 doesn't align checksum"
22828 stack_trap "set_checksums $ORIG_CSUM" EXIT
22829 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
22834 for csum in $CKSUM_TYPES; do
22835 #define OBD_FAIL_OSC_NO_GRANT 0x411
22836 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
22837 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
22839 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
22840 before=$(md5sum $DIR/$tfile)
22841 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
22842 after=$(md5sum $DIR/$tfile)
22843 [ "$before" == "$after" ] ||
22844 error "$csum: $before != $after bs=$1 seek=$2"
22848 run_test 810 "partial page writes on ZFS (LU-11663)"
22851 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
22852 skip "Need MDS version at least 2.11.56"
22854 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
22855 do_facet mds1 $LCTL set_param fail_loc=0x165
22856 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
22859 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
22861 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
22862 error "MDD orphan cleanup thread not quit"
22864 run_test 811 "orphan name stub can be cleaned up in startup"
22867 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
22868 skip "OST < 2.12.51 doesn't support this fail_loc"
22869 [ "$SHARED_KEY" = true ] &&
22870 skip "OSC connections never go IDLE with Shared-Keys enabled"
22872 $LFS setstripe -c 1 -i 0 $DIR/$tfile
22873 # ensure ost1 is connected
22874 stat $DIR/$tfile >/dev/null || error "can't stat"
22875 wait_osc_import_state client ost1 FULL
22876 # no locks, no reqs to let the connection idle
22877 cancel_lru_locks osc
22879 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
22880 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
22881 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
22882 wait_osc_import_state client ost1 CONNECTING
22883 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
22885 stat $DIR/$tfile >/dev/null || error "can't stat file"
22887 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
22889 test_812b() { # LU-12378
22890 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
22891 skip "OST < 2.12.51 doesn't support this fail_loc"
22892 [ "$SHARED_KEY" = true ] &&
22893 skip "OSC connections never go IDLE with Shared-Keys enabled"
22895 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
22896 # ensure ost1 is connected
22897 stat $DIR/$tfile >/dev/null || error "can't stat"
22898 wait_osc_import_state client ost1 FULL
22899 # no locks, no reqs to let the connection idle
22900 cancel_lru_locks osc
22902 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
22903 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
22904 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
22905 wait_osc_import_state client ost1 CONNECTING
22906 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
22908 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
22909 wait_osc_import_state client ost1 IDLE
22911 run_test 812b "do not drop no resend request for idle connect"
22914 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
22915 [ -z "$file_heat_sav" ] && skip "no file heat support"
22926 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
22927 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
22929 $LCTL set_param -n llite.*.file_heat=1
22930 echo "Turn on file heat"
22931 echo "Period second: $period_second, Decay percentage: $decay_pct"
22933 echo "QQQQ" > $DIR/$tfile
22934 echo "QQQQ" > $DIR/$tfile
22935 echo "QQQQ" > $DIR/$tfile
22936 cat $DIR/$tfile > /dev/null
22937 cat $DIR/$tfile > /dev/null
22938 cat $DIR/$tfile > /dev/null
22939 cat $DIR/$tfile > /dev/null
22941 local out=$($LFS heat_get $DIR/$tfile)
22943 $LFS heat_get $DIR/$tfile
22944 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22945 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22946 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22947 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22949 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
22950 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
22951 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
22952 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
22954 sleep $((period_second + 3))
22955 echo "Sleep $((period_second + 3)) seconds..."
22956 # The recursion formula to calculate the heat of the file f is as
22958 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
22959 # Where Hi is the heat value in the period between time points i*I and
22960 # (i+1)*I; Ci is the access count in the period; the symbol P refers
22961 # to the weight of Ci.
22962 out=$($LFS heat_get $DIR/$tfile)
22963 $LFS heat_get $DIR/$tfile
22964 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22965 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22966 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22967 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22969 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
22970 error "read sample ($readsample) is wrong"
22971 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
22972 error "write sample ($writesample) is wrong"
22973 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
22974 error "read bytes ($readbyte) is wrong"
22975 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
22976 error "write bytes ($writebyte) is wrong"
22978 echo "QQQQ" > $DIR/$tfile
22979 echo "QQQQ" > $DIR/$tfile
22980 echo "QQQQ" > $DIR/$tfile
22981 cat $DIR/$tfile > /dev/null
22982 cat $DIR/$tfile > /dev/null
22983 cat $DIR/$tfile > /dev/null
22984 cat $DIR/$tfile > /dev/null
22986 sleep $((period_second + 3))
22987 echo "Sleep $((period_second + 3)) seconds..."
22989 out=$($LFS heat_get $DIR/$tfile)
22990 $LFS heat_get $DIR/$tfile
22991 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
22992 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
22993 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
22994 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
22996 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
22997 4 * $decay_pct) / 100") -eq 1 ] ||
22998 error "read sample ($readsample1) is wrong"
22999 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
23000 3 * $decay_pct) / 100") -eq 1 ] ||
23001 error "write sample ($writesample1) is wrong"
23002 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
23003 20 * $decay_pct) / 100") -eq 1 ] ||
23004 error "read bytes ($readbyte1) is wrong"
23005 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
23006 15 * $decay_pct) / 100") -eq 1 ] ||
23007 error "write bytes ($writebyte1) is wrong"
23009 echo "Turn off file heat for the file $DIR/$tfile"
23010 $LFS heat_set -o $DIR/$tfile
23012 echo "QQQQ" > $DIR/$tfile
23013 echo "QQQQ" > $DIR/$tfile
23014 echo "QQQQ" > $DIR/$tfile
23015 cat $DIR/$tfile > /dev/null
23016 cat $DIR/$tfile > /dev/null
23017 cat $DIR/$tfile > /dev/null
23018 cat $DIR/$tfile > /dev/null
23020 out=$($LFS heat_get $DIR/$tfile)
23021 $LFS heat_get $DIR/$tfile
23022 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23023 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23024 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23025 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23027 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
23028 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
23029 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
23030 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
23032 echo "Trun on file heat for the file $DIR/$tfile"
23033 $LFS heat_set -O $DIR/$tfile
23035 echo "QQQQ" > $DIR/$tfile
23036 echo "QQQQ" > $DIR/$tfile
23037 echo "QQQQ" > $DIR/$tfile
23038 cat $DIR/$tfile > /dev/null
23039 cat $DIR/$tfile > /dev/null
23040 cat $DIR/$tfile > /dev/null
23041 cat $DIR/$tfile > /dev/null
23043 out=$($LFS heat_get $DIR/$tfile)
23044 $LFS heat_get $DIR/$tfile
23045 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23046 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23047 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23048 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23050 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
23051 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
23052 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
23053 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
23055 $LFS heat_set -c $DIR/$tfile
23056 $LCTL set_param -n llite.*.file_heat=0
23057 echo "Turn off file heat support for the Lustre filesystem"
23059 echo "QQQQ" > $DIR/$tfile
23060 echo "QQQQ" > $DIR/$tfile
23061 echo "QQQQ" > $DIR/$tfile
23062 cat $DIR/$tfile > /dev/null
23063 cat $DIR/$tfile > /dev/null
23064 cat $DIR/$tfile > /dev/null
23065 cat $DIR/$tfile > /dev/null
23067 out=$($LFS heat_get $DIR/$tfile)
23068 $LFS heat_get $DIR/$tfile
23069 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23070 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23071 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23072 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23074 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
23075 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
23076 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
23077 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
23079 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
23082 run_test 813 "File heat verfication"
23086 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
23087 echo -n y >> $DIR/$tfile
23088 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
23089 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
23091 run_test 814 "sparse cp works as expected (LU-12361)"
23095 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
23096 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
23098 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
23101 [ "$SHARED_KEY" = true ] &&
23102 skip "OSC connections never go IDLE with Shared-Keys enabled"
23104 $LFS setstripe -c 1 -i 0 $DIR/$tfile
23105 # ensure ost1 is connected
23106 stat $DIR/$tfile >/dev/null || error "can't stat"
23107 wait_osc_import_state client ost1 FULL
23108 # no locks, no reqs to let the connection idle
23109 cancel_lru_locks osc
23110 lru_resize_disable osc
23113 before=$($LCTL get_param -n \
23114 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
23116 wait_osc_import_state client ost1 IDLE
23117 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
23118 now=$($LCTL get_param -n \
23119 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
23120 [ $before == $now ] || error "lru_size changed $before != $now"
23122 run_test 816 "do not reset lru_resize on idle reconnect"
23126 exportfs -u localhost:$DIR/nfsexp
23131 systemctl restart nfs-server.service || skip "failed to restart nfsd"
23133 mkdir -p $DIR/nfsexp
23134 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
23135 error "failed to export nfs"
23137 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
23138 stack_trap cleanup_817 EXIT
23140 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
23141 error "failed to mount nfs to $tmpdir"
23143 cp /bin/true $tmpdir
23144 $DIR/nfsexp/true || error "failed to execute 'true' command"
23146 run_test 817 "nfsd won't cache write lock for exec file"
23150 $LFS setstripe -c1 -i0 $DIR/$tfile
23151 $LFS setstripe -c1 -i1 $DIR/$tfile
23153 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
23154 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
23155 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
23156 error "start $SINGLEMDS failed"
23159 run_test 818 "unlink with failed llog"
23162 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23163 cancel_lru_locks osc
23164 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
23165 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
23166 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
23169 run_test 819a "too big niobuf in read"
23172 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
23173 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
23174 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23175 cancel_lru_locks osc
23179 run_test 819b "too big niobuf in write"
23182 function test_820_start_ost() {
23185 for num in $(seq $OSTCOUNT); do
23186 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
23191 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23194 umount_client $MOUNT || error "umount failed"
23195 for num in $(seq $OSTCOUNT); do
23199 # mount client with no active OSTs
23200 # so that the client can't initialize max LOV EA size
23201 # from OSC notifications
23202 mount_client $MOUNT || error "mount failed"
23203 # delay OST starting to keep this 0 max EA size for a while
23204 test_820_start_ost &
23206 # create a directory on MDS2
23207 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
23208 error "Failed to create directory"
23209 # open intent should update default EA size
23210 # see mdc_update_max_ea_from_body()
23211 # notice this is the very first RPC to MDS2
23212 cp /etc/services $DIR/$tdir/mds2 ||
23213 error "Failed to copy files to mds$n"
23215 run_test 820 "update max EA from open intent"
23218 # tests that do cleanup/setup should be run at the end
23222 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23225 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
23226 $LCTL set_param fail_loc=0x903
23228 cancel_lru_locks MGC
23230 FAIL_ON_ERROR=true cleanup
23231 FAIL_ON_ERROR=true setup
23233 run_test 900 "umount should not race with any mgc requeue thread"
23235 # LUS-6253/LU-11185
23241 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23243 # some get_param have a bug to handle dot in param name
23244 cancel_lru_locks MGC
23245 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
23246 olds=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
23247 umount_client $MOUNT || error "umount failed"
23248 mount_client $MOUNT || error "mount failed"
23249 cancel_lru_locks MGC
23250 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
23251 news=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
23253 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
23254 [ $olds -lt $news ] && error "mgs lock leak ($olds != $news)"
23258 run_test 901 "don't leak a mgc lock on client umount"
23261 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
23262 check_and_cleanup_lustre
23263 if [ "$I_MOUNTED" != "yes" ]; then
23264 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true