3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # Check Grants after these tests
12 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c 64d"
17 CREATETEST=${CREATETEST:-createtest}
18 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
19 OPENFILE=${OPENFILE:-openfile}
20 OPENUNLINK=${OPENUNLINK:-openunlink}
21 READS=${READS:-"reads"}
22 MUNLINK=${MUNLINK:-munlink}
23 SOCKETSERVER=${SOCKETSERVER:-socketserver}
24 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
25 MEMHOG=${MEMHOG:-memhog}
26 DIRECTIO=${DIRECTIO:-directio}
27 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
31 export PARALLEL=${PARALLEL:-"no"}
34 LUSTRE=${LUSTRE:-$(dirname $0)/..}
35 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
36 . $LUSTRE/tests/test-framework.sh
41 ALWAYS_EXCEPT="$SANITY_EXCEPT "
42 # bug number for skipped test: LU-9693 LU-6493 LU-9693
43 ALWAYS_EXCEPT+=" 42a 42b 42c "
44 # bug number: LU-8411 LU-9054 LU-13314
45 ALWAYS_EXCEPT+=" 407 312 56ob"
48 # bug number: LU-9795 LU-9795 LU-9795 LU-9795
49 ALWAYS_EXCEPT+=" 17n 60a 133g 300f"
52 selinux_status=$(getenforce)
53 if [ "$selinux_status" != "Disabled" ]; then
58 # skip the grant tests for ARM until they are fixed
59 if [[ $(uname -m) = aarch64 ]]; then
60 # bug number: LU-11596
61 ALWAYS_EXCEPT+=" $GRANT_CHECK_LIST"
62 # bug number: LU-11671 LU-11667
63 ALWAYS_EXCEPT+=" 45 317"
66 # skip nfs tests on kernels >= 4.14.0 until they are fixed
67 if [ $LINUX_VERSION_CODE -ge $(version_code 4.14.0) ]; then
68 # bug number: LU-12661
71 # skip cgroup tests on RHEL8.1 kernels until they are fixed
72 if (( $LINUX_VERSION_CODE >= $(version_code 4.18.0) &&
73 $LINUX_VERSION_CODE < $(version_code 5.4.0) )); then
74 # bug number: LU-13063
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 135 136 300o"
81 if [ "$mds1_FSTYPE" = "zfs" ]; then
82 # bug number for skipped test:
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
85 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
88 # Get the SLES distro version
90 # Returns a version string that should only be used in comparing
91 # strings returned by version_code()
94 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
96 # All SuSE Linux versions have one decimal. version_code expects two
97 local sles_version=$version.0
98 version_code $sles_version
101 # Check if we are running on Ubuntu or SLES so we can make decisions on
103 if [ -r /etc/SuSE-release ]; then
104 sles_version=$(sles_version_code)
105 [ $sles_version -lt $(version_code 11.4.0) ] &&
106 # bug number for skipped test: LU-4341
107 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
108 [ $sles_version -lt $(version_code 12.0.0) ] &&
109 # bug number for skipped test: LU-3703
110 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
111 elif [ -r /etc/os-release ]; then
112 if grep -qi ubuntu /etc/os-release; then
113 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
114 -e 's/^VERSION=//p' \
118 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
119 # bug number for skipped test:
121 ALWAYS_EXCEPT+=" 103a 410"
131 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
132 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
141 check_swap_layouts_support()
143 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
144 skip "Does not support layout lock."
147 check_and_setup_lustre
151 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
153 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
154 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
155 rm -rf $DIR/[Rdfs][0-9]*
157 # $RUNAS_ID may get set incorrectly somewhere else
158 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
159 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
161 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
163 if [ "${ONLY}" = "MOUNT" ] ; then
164 echo "Lustre is up, please go on"
168 echo "preparing for tests involving mounts"
169 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
171 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
172 echo # add a newline after mke2fs.
176 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
177 lctl set_param debug=-1 2> /dev/null || true
180 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
182 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
184 run_test 0a "touch; rm ====================="
187 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
188 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
190 run_test 0b "chmod 0755 $DIR ============================="
193 $LCTL get_param mdc.*.import | grep "state: FULL" ||
194 error "import not FULL"
195 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
198 run_test 0c "check import proc"
200 test_0d() { # LU-3397
201 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
202 skip "proc exports not supported before 2.10.57"
204 local mgs_exp="mgs.MGS.exports"
205 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
207 local exp_client_version
210 local temp_imp=$DIR/$tfile.import
211 local temp_exp=$DIR/$tfile.export
213 # save mgc import file to $temp_imp
214 $LCTL get_param mgc.*.import | tee $temp_imp
215 # Check if client uuid is found in MGS export
216 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
217 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
221 # save mgs export file to $temp_exp
222 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
224 # Compare the value of field "connect_flags"
225 imp_val=$(grep "connect_flags" $temp_imp)
226 exp_val=$(grep "connect_flags" $temp_exp)
227 [ "$exp_val" == "$imp_val" ] ||
228 error "export flags '$exp_val' != import flags '$imp_val'"
230 # Compare the value of client version
231 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
232 exp_val=$(version_code $exp_client_version)
233 imp_val=$CLIENT_VERSION
234 [ "$exp_val" == "$imp_val" ] ||
235 error "export client version '$exp_val' != '$imp_val'"
237 run_test 0d "check export proc ============================="
240 test_mkdir $DIR/$tdir
241 test_mkdir $DIR/$tdir/d2
242 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
243 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
246 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
248 run_test 1 "mkdir; remkdir; rmdir"
251 test_mkdir $DIR/$tdir
252 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
253 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
255 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
257 run_test 2 "mkdir; touch; rmdir; check file"
260 test_mkdir $DIR/$tdir
261 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
262 touch $DIR/$tdir/$tfile
263 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
265 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
267 run_test 3 "mkdir; touch; rmdir; check dir"
269 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
271 test_mkdir -i 1 $DIR/$tdir
273 touch $DIR/$tdir/$tfile ||
274 error "Create file under remote directory failed"
277 error "Expect error removing in-use dir $DIR/$tdir"
279 test -d $DIR/$tdir || error "Remote directory disappeared"
281 rm -rf $DIR/$tdir || error "remove remote dir error"
283 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
286 test_mkdir $DIR/$tdir
287 test_mkdir $DIR/$tdir/d2
288 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
289 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
290 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
292 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
295 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
296 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
297 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
298 error "$tfile does not have perm 0666 or UID $UID"
299 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
300 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
301 error "$tfile should be 0666 and owned by UID $UID"
303 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
306 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
309 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
310 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
311 error "$tfile should be owned by UID $RUNAS_ID"
312 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
313 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
314 error "$tfile should be owned by UID $RUNAS_ID"
316 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
319 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
322 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
323 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
324 error "$tfile should be owned by GID $UID"
325 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
326 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
327 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
329 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
332 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
334 test_mkdir $DIR/$tdir
335 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
336 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
337 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
338 test_mkdir $DIR/$tdir/d/subdir
339 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
340 error "$tdir/d/subdir should be GID $RUNAS_GID"
341 if [[ $MDSCOUNT -gt 1 ]]; then
342 # check remote dir sgid inherite
343 $LFS mkdir -i 0 $DIR/$tdir.local ||
344 error "mkdir $tdir.local failed"
345 chmod g+s $DIR/$tdir.local ||
346 error "chmod $tdir.local failed"
347 chgrp $RUNAS_GID $DIR/$tdir.local ||
348 error "chgrp $tdir.local failed"
349 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
350 error "mkdir $tdir.remote failed"
351 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
352 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
353 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
354 error "$tdir.remote should be mode 02755"
357 run_test 6g "verify new dir in sgid dir inherits group"
359 test_6h() { # bug 7331
360 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
362 touch $DIR/$tfile || error "touch failed"
363 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
364 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
365 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
366 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
367 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
369 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
372 test_mkdir $DIR/$tdir
373 $MCREATE $DIR/$tdir/$tfile
374 chmod 0666 $DIR/$tdir/$tfile
375 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
376 error "$tdir/$tfile should be mode 0666"
378 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
381 if [ ! -d $DIR/$tdir ]; then
382 test_mkdir $DIR/$tdir
384 $MCREATE $DIR/$tdir/$tfile
385 echo -n foo > $DIR/$tdir/$tfile
386 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
387 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
389 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
392 test_mkdir $DIR/$tdir
393 touch $DIR/$tdir/$tfile
394 chmod 0666 $DIR/$tdir/$tfile
395 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
396 error "$tfile mode not 0666"
398 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
401 test_mkdir $DIR/$tdir
402 test_mkdir $DIR/$tdir/d2
403 test_mkdir $DIR/$tdir/d2/d3
404 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
406 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
409 test_mkdir $DIR/$tdir
410 test_mkdir $DIR/$tdir/d2
411 touch $DIR/$tdir/d2/$tfile
412 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
413 error "$tdir/d2/$tfile not a file"
415 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
418 test_mkdir $DIR/$tdir
419 test_mkdir $DIR/$tdir/d2
420 chmod 0666 $DIR/$tdir/d2
421 chmod 0705 $DIR/$tdir/d2
422 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
423 error "$tdir/d2 mode not 0705"
425 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
428 test_mkdir $DIR/$tdir
429 touch $DIR/$tdir/$tfile
430 chmod 0666 $DIR/$tdir/$tfile
431 chmod 0654 $DIR/$tdir/$tfile
432 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
433 error "$tdir/d2 mode not 0654"
435 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
438 test_mkdir $DIR/$tdir
439 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
441 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
442 error "$tdir/$tfile size not 0 after truncate"
444 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
447 test_mkdir $DIR/$tdir
448 touch $DIR/$tdir/$tfile
450 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
452 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
455 test_mkdir $DIR/$tdir
456 touch $DIR/$tdir/$tfile
457 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
458 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
459 error "$tdir/${tfile_2} not a file after rename"
460 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
462 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
465 test_mkdir $DIR/$tdir
466 touch $DIR/$tdir/$tfile
467 rm -rf $DIR/$tdir/$tfile
468 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
470 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
473 test_mkdir $DIR/$tdir
474 touch $DIR/$tdir/$tfile
475 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
477 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
478 error "$tdir/l-exist not a symlink"
479 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
480 error "$tdir/l-exist not referencing a file"
481 rm -f $DIR/$tdir/l-exist
482 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
484 run_test 17a "symlinks: create, remove (real)"
487 test_mkdir $DIR/$tdir
488 ln -s no-such-file $DIR/$tdir/l-dangle
490 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
491 error "$tdir/l-dangle not referencing no-such-file"
492 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
493 error "$tdir/l-dangle not referencing non-existent file"
494 rm -f $DIR/$tdir/l-dangle
495 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
497 run_test 17b "symlinks: create, remove (dangling)"
499 test_17c() { # bug 3440 - don't save failed open RPC for replay
500 test_mkdir $DIR/$tdir
501 ln -s foo $DIR/$tdir/$tfile
502 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
504 run_test 17c "symlinks: open dangling (should return error)"
507 test_mkdir $DIR/$tdir
508 ln -s foo $DIR/$tdir/$tfile
509 touch $DIR/$tdir/$tfile || error "creating to new symlink"
511 run_test 17d "symlinks: create dangling"
514 test_mkdir $DIR/$tdir
515 local foo=$DIR/$tdir/$tfile
516 ln -s $foo $foo || error "create symlink failed"
517 ls -l $foo || error "ls -l failed"
518 ls $foo && error "ls not failed" || true
520 run_test 17e "symlinks: create recursive symlink (should return error)"
523 test_mkdir $DIR/$tdir
524 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
525 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
526 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
527 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
528 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
529 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
532 run_test 17f "symlinks: long and very long symlink name"
534 # str_repeat(S, N) generate a string that is string S repeated N times
539 while [ $((n -= 1)) -ge 0 ]; do
545 # Long symlinks and LU-2241
547 test_mkdir $DIR/$tdir
548 local TESTS="59 60 61 4094 4095"
550 # Fix for inode size boundary in 2.1.4
551 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
554 # Patch not applied to 2.2 or 2.3 branches
555 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
556 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
560 local SYMNAME=$(str_repeat 'x' $i)
561 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
562 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
565 run_test 17g "symlinks: really long symlink name and inode boundaries"
567 test_17h() { #bug 17378
568 [ $PARALLEL == "yes" ] && skip "skip parallel run"
569 remote_mds_nodsh && skip "remote MDS with nodsh"
573 test_mkdir $DIR/$tdir
574 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
575 $LFS setstripe -c -1 $DIR/$tdir
576 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
577 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
578 touch $DIR/$tdir/$tfile || true
580 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
582 test_17i() { #bug 20018
583 [ $PARALLEL == "yes" ] && skip "skip parallel run"
584 remote_mds_nodsh && skip "remote MDS with nodsh"
586 local foo=$DIR/$tdir/$tfile
589 test_mkdir -c1 $DIR/$tdir
590 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
591 ln -s $foo $foo || error "create symlink failed"
592 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
593 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
594 ls -l $foo && error "error not detected"
597 run_test 17i "don't panic on short symlink (should return error)"
599 test_17k() { #bug 22301
600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
601 [[ -z "$(which rsync 2>/dev/null)" ]] &&
602 skip "no rsync command"
603 rsync --help | grep -q xattr ||
604 skip_env "$(rsync --version | head -n1) does not support xattrs"
605 test_mkdir $DIR/$tdir
606 test_mkdir $DIR/$tdir.new
607 touch $DIR/$tdir/$tfile
608 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
609 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
610 error "rsync failed with xattrs enabled"
612 run_test 17k "symlinks: rsync with xattrs enabled"
614 test_17l() { # LU-279
615 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
616 skip "no getfattr command"
618 test_mkdir $DIR/$tdir
619 touch $DIR/$tdir/$tfile
620 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
621 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
622 # -h to not follow symlinks. -m '' to list all the xattrs.
623 # grep to remove first line: '# file: $path'.
624 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
626 lgetxattr_size_check $path $xattr ||
627 error "lgetxattr_size_check $path $xattr failed"
631 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
635 [ $PARALLEL == "yes" ] && skip "skip parallel run"
636 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
637 remote_mds_nodsh && skip "remote MDS with nodsh"
638 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
639 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
640 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
642 local short_sym="0123456789"
643 local wdir=$DIR/$tdir
648 # create a long symlink file
649 for ((i = 0; i < 4; ++i)); do
650 long_sym=${long_sym}${long_sym}
653 echo "create 512 short and long symlink files under $wdir"
654 for ((i = 0; i < 256; ++i)); do
655 ln -sf ${long_sym}"a5a5" $wdir/long-$i
656 ln -sf ${short_sym}"a5a5" $wdir/short-$i
662 wait_delete_completed
664 echo "recreate the 512 symlink files with a shorter string"
665 for ((i = 0; i < 512; ++i)); do
666 # rewrite the symlink file with a shorter string
667 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
668 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
671 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
672 local devname=$(mdsdevname $mds_index)
674 echo "stop and checking mds${mds_index}:"
675 # e2fsck should not return error
677 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
680 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
681 error "start mds${mds_index} failed"
682 df $MOUNT > /dev/null 2>&1
684 error "e2fsck detected error for short/long symlink: rc=$rc"
687 run_test 17m "run e2fsck against MDT which contains short/long symlink"
689 check_fs_consistency_17n() {
693 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
694 # so it only check MDT1/MDT2 instead of all of MDTs.
695 for mdt_index in 1 2; do
696 local devname=$(mdsdevname $mdt_index)
697 # e2fsck should not return error
699 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
702 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
703 error "mount mds$mdt_index failed"
704 df $MOUNT > /dev/null 2>&1
710 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
711 [ $PARALLEL == "yes" ] && skip "skip parallel run"
712 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
713 remote_mds_nodsh && skip "remote MDS with nodsh"
714 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
715 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
716 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
720 test_mkdir $DIR/$tdir
721 for ((i=0; i<10; i++)); do
722 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
723 error "create remote dir error $i"
724 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
725 error "create files under remote dir failed $i"
728 check_fs_consistency_17n ||
729 error "e2fsck report error after create files under remote dir"
731 for ((i = 0; i < 10; i++)); do
732 rm -rf $DIR/$tdir/remote_dir_${i} ||
733 error "destroy remote dir error $i"
736 check_fs_consistency_17n ||
737 error "e2fsck report error after unlink files under remote dir"
739 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
740 skip "lustre < 2.4.50 does not support migrate mv"
742 for ((i = 0; i < 10; i++)); do
743 mkdir -p $DIR/$tdir/remote_dir_${i}
744 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
745 error "create files under remote dir failed $i"
746 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
747 error "migrate remote dir error $i"
749 check_fs_consistency_17n || error "e2fsck report error after migration"
751 for ((i = 0; i < 10; i++)); do
752 rm -rf $DIR/$tdir/remote_dir_${i} ||
753 error "destroy remote dir error $i"
756 check_fs_consistency_17n || error "e2fsck report error after unlink"
758 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
761 remote_mds_nodsh && skip "remote MDS with nodsh"
762 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
763 skip "Need MDS version at least 2.3.64"
765 local wdir=$DIR/${tdir}o
771 mdt_index=$($LFS getstripe -m $wdir/$tfile)
772 mdt_index=$((mdt_index + 1))
775 #fail mds will wait the failover finish then set
776 #following fail_loc to avoid interfer the recovery process.
779 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
780 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
781 ls -l $wdir/$tfile && rc=1
782 do_facet mds${mdt_index} lctl set_param fail_loc=0
783 [[ $rc -eq 0 ]] || error "stat file should fail"
785 run_test 17o "stat file with incompat LMA feature"
788 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
789 ls $DIR || error "Failed to ls $DIR: $?"
791 run_test 18 "touch .../f ; ls ... =============================="
797 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
799 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
802 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
804 run_test 19b "ls -l .../f19 (should return error) =============="
807 [ $RUNAS_ID -eq $UID ] &&
808 skip_env "RUNAS_ID = UID = $UID -- skipping"
810 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
812 run_test 19c "$RUNAS touch .../f19 (should return error) =="
815 cat $DIR/f19 && error || true
817 run_test 19d "cat .../f19 (should return error) =============="
826 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
828 run_test 20 "touch .../f ; ls -l ..."
831 test_mkdir $DIR/$tdir
832 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
833 ln -s dangle $DIR/$tdir/link
834 echo foo >> $DIR/$tdir/link
835 cat $DIR/$tdir/dangle
836 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
837 $CHECKSTAT -f -t file $DIR/$tdir/link ||
838 error "$tdir/link not linked to a file"
840 run_test 21 "write to dangling link"
843 local wdir=$DIR/$tdir
845 chown $RUNAS_ID:$RUNAS_GID $wdir
846 (cd $wdir || error "cd $wdir failed";
847 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
849 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
850 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
851 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
852 error "checkstat -u failed"
854 run_test 22 "unpack tar archive as non-root user"
858 test_mkdir $DIR/$tdir
859 local file=$DIR/$tdir/$tfile
861 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
862 openfile -f O_CREAT:O_EXCL $file &&
863 error "$file recreate succeeded" || true
865 run_test 23a "O_CREAT|O_EXCL in subdir"
867 test_23b() { # bug 18988
868 test_mkdir $DIR/$tdir
869 local file=$DIR/$tdir/$tfile
872 echo foo > $file || error "write filed"
873 echo bar >> $file || error "append filed"
874 $CHECKSTAT -s 8 $file || error "wrong size"
877 run_test 23b "O_APPEND check"
879 # LU-9409, size with O_APPEND and tiny writes
881 local file=$DIR/$tfile
884 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
885 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
889 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
890 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
892 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
895 #racing tiny & normal writes
896 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
897 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
899 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
902 #racing tiny & normal writes 2, ugly numbers
903 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
904 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
906 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
909 run_test 23c "O_APPEND size checks for tiny writes"
911 # LU-11069 file offset is correct after appending writes
913 local file=$DIR/$tfile
916 echo CentaurHauls > $file
917 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
918 if ((offset != 26)); then
919 error "wrong offset, expected 26, got '$offset'"
922 run_test 23d "file offset is correct after appending writes"
926 echo '-- same directory rename'
927 test_mkdir $DIR/$tdir
928 touch $DIR/$tdir/$tfile.1
929 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
930 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
932 run_test 24a "rename file to non-existent target"
935 test_mkdir $DIR/$tdir
936 touch $DIR/$tdir/$tfile.{1,2}
937 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
938 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
939 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
941 run_test 24b "rename file to existing target"
944 test_mkdir $DIR/$tdir
945 test_mkdir $DIR/$tdir/d$testnum.1
946 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
947 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
948 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
950 run_test 24c "rename directory to non-existent target"
953 test_mkdir -c1 $DIR/$tdir
954 test_mkdir -c1 $DIR/$tdir/d$testnum.1
955 test_mkdir -c1 $DIR/$tdir/d$testnum.2
956 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
957 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
958 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
960 run_test 24d "rename directory to existing target"
963 echo '-- cross directory renames --'
967 mv $DIR/R5a/f $DIR/R5b/g
968 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
969 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
971 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
976 touch $DIR/R6a/f $DIR/R6b/g
977 mv $DIR/R6a/f $DIR/R6b/g
978 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
979 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
981 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
986 test_mkdir $DIR/R7a/d
987 mv $DIR/R7a/d $DIR/R7b/e
988 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
989 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
991 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
994 test_mkdir -c1 $DIR/R8a
995 test_mkdir -c1 $DIR/R8b
996 test_mkdir -c1 $DIR/R8a/d
997 test_mkdir -c1 $DIR/R8b/e
998 mrename $DIR/R8a/d $DIR/R8b/e
999 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1000 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1002 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1005 echo "-- rename error cases"
1007 test_mkdir $DIR/R9/a
1009 mrename $DIR/R9/f $DIR/R9/a
1010 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1011 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1012 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1014 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1018 mrename $DIR/R10/f $DIR/R10/g
1019 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1020 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1021 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1023 run_test 24j "source does not exist ============================"
1026 test_mkdir $DIR/R11a
1027 test_mkdir $DIR/R11a/d
1029 mv $DIR/R11a/f $DIR/R11a/d
1030 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1031 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1033 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1035 # bug 2429 - rename foo foo foo creates invalid file
1038 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1040 run_test 24l "Renaming a file to itself ========================"
1044 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1045 # on ext3 this does not remove either the source or target files
1046 # though the "expected" operation would be to remove the source
1047 $CHECKSTAT -t file ${f} || error "${f} missing"
1048 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1050 run_test 24m "Renaming a file to a hard link to itself ========="
1054 # this stats the old file after it was renamed, so it should fail
1056 $CHECKSTAT ${f} || error "${f} missing"
1058 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1059 $CHECKSTAT -a ${f} || error "${f} exists"
1061 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1064 test_mkdir $DIR/$tdir
1065 rename_many -s random -v -n 10 $DIR/$tdir
1067 run_test 24o "rename of files during htree split"
1070 test_mkdir $DIR/R12a
1071 test_mkdir $DIR/R12b
1072 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1073 mrename $DIR/R12a $DIR/R12b
1074 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1075 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1076 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1077 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1079 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1081 cleanup_multiop_pause() {
1083 kill -USR1 $MULTIPID
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1089 test_mkdir $DIR/R13a
1090 test_mkdir $DIR/R13b
1091 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1092 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1095 trap cleanup_multiop_pause EXIT
1096 mrename $DIR/R13a $DIR/R13b
1097 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1098 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1099 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1100 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1101 cleanup_multiop_pause
1102 wait $MULTIPID || error "multiop close failed"
1104 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1106 test_24r() { #bug 3789
1107 test_mkdir $DIR/R14a
1108 test_mkdir $DIR/R14a/b
1109 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1110 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1111 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1113 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1116 test_mkdir $DIR/R15a
1117 test_mkdir $DIR/R15a/b
1118 test_mkdir $DIR/R15a/b/c
1119 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1120 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1121 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1123 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1125 test_mkdir $DIR/R16a
1126 test_mkdir $DIR/R16a/b
1127 test_mkdir $DIR/R16a/b/c
1128 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1129 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1130 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1132 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1134 test_24u() { # bug12192
1135 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1136 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1138 run_test 24u "create stripe file"
1140 simple_cleanup_common() {
1143 [ -z "$DIR" ] || [ -z "$tdir" ] && return 0
1145 local start=$SECONDS
1148 wait_delete_completed
1149 echo "cleanup time $((SECONDS - start))"
1153 max_pages_per_rpc() {
1154 local mdtname="$(printf "MDT%04x" ${1:-0})"
1155 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1161 local nrfiles=${COUNT:-100000}
1162 local fname="$DIR/$tdir/$tfile"
1164 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1165 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1167 test_mkdir "$(dirname $fname)"
1168 # assume MDT0000 has the fewest inodes
1169 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1170 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1171 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1173 trap simple_cleanup_common EXIT
1175 createmany -m "$fname" $nrfiles
1177 cancel_lru_locks mdc
1178 lctl set_param mdc.*.stats clear
1180 # was previously test_24D: LU-6101
1181 # readdir() returns correct number of entries after cursor reload
1182 local num_ls=$(ls $DIR/$tdir | wc -l)
1183 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1184 local num_all=$(ls -a $DIR/$tdir | wc -l)
1185 if [ $num_ls -ne $nrfiles ] || [ $num_uniq -ne $nrfiles ] ||
1186 [ $num_all -ne $((nrfiles + 2)) ]; then
1187 error "Expected $nrfiles files, got $num_ls " \
1188 "($num_uniq unique $num_all .&..)"
1190 # LU-5 large readdir
1191 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1192 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1193 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1194 # take into account of overhead in lu_dirpage header and end mark in
1195 # each page, plus one in rpc_num calculation.
1196 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1197 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1198 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1199 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1200 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1201 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1202 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1203 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1204 error "large readdir doesn't take effect: " \
1205 "$mds_readpage should be about $rpc_max"
1207 simple_cleanup_common
1209 run_test 24v "list large directory (test hash collision, b=17560)"
1211 test_24w() { # bug21506
1213 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1214 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1215 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1216 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1217 [[ "$SZ1" -eq "$SZ2" ]] ||
1218 error "Error reading at the end of the file $tfile"
1220 run_test 24w "Reading a file larger than 4Gb"
1223 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1225 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1226 skip "Need MDS version at least 2.7.56"
1229 local remote_dir=$DIR/$tdir/remote_dir
1231 test_mkdir $DIR/$tdir
1232 $LFS mkdir -i $MDTIDX $remote_dir ||
1233 error "create remote directory failed"
1235 test_mkdir $DIR/$tdir/src_dir
1236 touch $DIR/$tdir/src_file
1237 test_mkdir $remote_dir/tgt_dir
1238 touch $remote_dir/tgt_file
1240 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1241 error "rename dir cross MDT failed!"
1243 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1244 error "rename file cross MDT failed!"
1246 touch $DIR/$tdir/ln_file
1247 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1248 error "ln file cross MDT failed"
1250 rm -rf $DIR/$tdir || error "Can not delete directories"
1252 run_test 24x "cross MDT rename/link"
1255 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1258 local remote_dir=$DIR/$tdir/remote_dir
1261 test_mkdir $DIR/$tdir
1262 $LFS mkdir -i $mdtidx $remote_dir ||
1263 error "create remote directory failed"
1265 test_mkdir $remote_dir/src_dir
1266 touch $remote_dir/src_file
1267 test_mkdir $remote_dir/tgt_dir
1268 touch $remote_dir/tgt_file
1270 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1271 error "rename subdir in the same remote dir failed!"
1273 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1274 error "rename files in the same remote dir failed!"
1276 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1277 error "link files in the same remote dir failed!"
1279 rm -rf $DIR/$tdir || error "Can not delete directories"
1281 run_test 24y "rename/link on the same dir should succeed"
1284 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1285 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1286 skip "Need MDS version at least 2.12.51"
1290 for index in 0 1; do
1291 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1292 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1295 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1297 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1298 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1300 local mdts=$(comma_list $(mdts_nodes))
1302 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1303 stack_trap "do_nodes $mdts $LCTL \
1304 set_param mdt.*.enable_remote_rename=1" EXIT
1306 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1308 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1309 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1311 run_test 24z "cross-MDT rename is done as cp"
1313 test_24A() { # LU-3182
1317 test_mkdir $DIR/$tdir
1318 trap simple_cleanup_common EXIT
1319 createmany -m $DIR/$tdir/$tfile $NFILES
1320 local t=$(ls $DIR/$tdir | wc -l)
1321 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1322 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1323 if [ $t -ne $NFILES ] || [ $u -ne $NFILES ] ||
1324 [ $v -ne $((NFILES + 2)) ] ; then
1325 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1328 simple_cleanup_common || error "Can not delete directories"
1330 run_test 24A "readdir() returns correct number of entries."
1332 test_24B() { # LU-4805
1333 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1337 test_mkdir $DIR/$tdir
1338 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1339 error "create striped dir failed"
1341 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1342 [ $count -eq 2 ] || error "Expected 2, got $count"
1344 touch $DIR/$tdir/striped_dir/a
1346 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1347 [ $count -eq 3 ] || error "Expected 3, got $count"
1349 touch $DIR/$tdir/striped_dir/.f
1351 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1352 [ $count -eq 4 ] || error "Expected 4, got $count"
1354 rm -rf $DIR/$tdir || error "Can not delete directories"
1356 run_test 24B "readdir for striped dir return correct number of entries"
1359 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1365 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1366 error "create striped dir failed"
1368 cd $DIR/$tdir/d0/striped_dir
1370 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1371 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1372 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1374 [ "$d0_ino" = "$parent_ino" ] ||
1375 error ".. wrong, expect $d0_ino, get $parent_ino"
1377 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1378 error "mv striped dir failed"
1380 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1382 [ "$d1_ino" = "$parent_ino" ] ||
1383 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1385 run_test 24C "check .. in striped dir"
1388 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1389 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1392 mkdir $DIR/$tdir/src_dir
1393 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1394 error "create remote source failed"
1396 touch $DIR/$tdir/src_dir/src_child/a
1398 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1399 error "create remote target dir failed"
1401 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1402 error "create remote target child failed"
1404 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1405 error "rename dir cross MDT failed!"
1409 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1410 error "src_child still exists after rename"
1412 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1413 error "missing file(a) after rename"
1415 rm -rf $DIR/$tdir || error "Can not delete directories"
1417 run_test 24E "cross MDT rename/link"
1420 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1423 [ "$SLOW" = "no" ] && repeats=100
1427 echo "$repeats repeats"
1428 for ((i = 0; i < repeats; i++)); do
1429 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1430 touch $DIR/$tdir/test/a || error "touch fails"
1431 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1432 rm -rf $DIR/$tdir/test || error "rmdir fails"
1437 run_test 24F "hash order vs readdir (LU-11330)"
1440 echo '== symlink sanity ============================================='
1444 touch $DIR/s25/foo ||
1445 error "File creation in symlinked directory failed"
1447 run_test 25a "create file in symlinked directory ==============="
1450 [ ! -d $DIR/d25 ] && test_25a
1451 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1453 run_test 25b "lookup file in symlinked directory ==============="
1457 test_mkdir $DIR/d26/d26-2
1458 ln -s d26/d26-2 $DIR/s26
1459 touch $DIR/s26/foo || error "File creation failed"
1461 run_test 26a "multiple component symlink ======================="
1464 test_mkdir -p $DIR/$tdir/d26-2
1465 ln -s $tdir/d26-2/foo $DIR/s26-2
1466 touch $DIR/s26-2 || error "File creation failed"
1468 run_test 26b "multiple component symlink at end of lookup ======"
1471 test_mkdir $DIR/d26.2
1472 touch $DIR/d26.2/foo
1473 ln -s d26.2 $DIR/s26.2-1
1474 ln -s s26.2-1 $DIR/s26.2-2
1475 ln -s s26.2-2 $DIR/s26.2-3
1476 chmod 0666 $DIR/s26.2-3/foo
1478 run_test 26c "chain of symlinks"
1480 # recursive symlinks (bug 439)
1482 ln -s d26-3/foo $DIR/d26-3
1484 run_test 26d "create multiple component recursive symlink"
1487 [ ! -h $DIR/d26-3 ] && test_26d
1490 run_test 26e "unlink multiple component recursive symlink"
1492 # recursive symlinks (bug 7022)
1494 test_mkdir $DIR/$tdir
1495 test_mkdir $DIR/$tdir/$tfile
1496 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1497 test_mkdir -p lndir/bar1
1498 test_mkdir $DIR/$tdir/$tfile/$tfile
1499 cd $tfile || error "cd $tfile failed"
1500 ln -s .. dotdot || error "ln dotdot failed"
1501 ln -s dotdot/lndir lndir || error "ln lndir failed"
1502 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1503 output=`ls $tfile/$tfile/lndir/bar1`
1504 [ "$output" = bar1 ] && error "unexpected output"
1505 rm -r $tfile || error "rm $tfile failed"
1506 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1508 run_test 26f "rm -r of a directory which has recursive symlink"
1511 test_mkdir $DIR/$tdir
1512 $LFS getstripe $DIR/$tdir
1513 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1514 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1515 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1517 run_test 27a "one stripe file"
1520 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1522 test_mkdir $DIR/$tdir
1523 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1524 $LFS getstripe -c $DIR/$tdir/$tfile
1525 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1526 error "two-stripe file doesn't have two stripes"
1528 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1530 run_test 27b "create and write to two stripe file"
1532 # 27c family tests specific striping, setstripe -o
1534 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1535 test_mkdir -p $DIR/$tdir
1538 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1539 $LFS getstripe -i $DIR/$tdir/$tfile
1540 [ $($LFS getstripe -i $DIR/$tdir/$tfile ) -eq $osts ] ||
1541 error "stripe not on specified OST"
1543 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1545 run_test 27ca "one stripe on specified OST"
1548 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1549 test_mkdir -p $DIR/$tdir
1551 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1552 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1555 # Strip getstripe output to a space separated list of OSTs
1556 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1557 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1558 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1559 error "stripes not on specified OSTs"
1561 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1563 run_test 27cb "two stripes on specified OSTs"
1566 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1567 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1568 skip "server does not support overstriping"
1570 test_mkdir -p $DIR/$tdir
1572 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1573 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1576 # Strip getstripe output to a space separated list of OSTs
1577 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1578 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1579 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1580 error "stripes not on specified OSTs"
1582 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1584 run_test 27cc "two stripes on the same OST"
1587 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test"
1588 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1589 skip "server does not support overstriping"
1590 test_mkdir -p $DIR/$tdir
1591 local osts="0,1,1,0"
1592 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1593 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1596 # Strip getstripe output to a space separated list of OSTs
1597 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1598 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1599 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1600 error "stripes not on specified OSTs"
1602 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1604 run_test 27cd "four stripes on two OSTs"
1607 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
1608 skip_env "too many osts, skipping"
1609 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
1610 skip "server does not support overstriping"
1611 # We do one more stripe than we have OSTs
1612 [ $OSTCOUNT -ge 159 ] || large_xattr_enabled ||
1613 skip_env "ea_inode feature disabled"
1615 test_mkdir -p $DIR/$tdir
1617 for i in $(seq 0 $OSTCOUNT);
1620 if [ $i -ne $OSTCOUNT ]; then
1624 $LFS setstripe -o $osts $DIR/$tdir/$tfile || error "setstripe failed"
1625 local getstripe=$($LFS getstripe $DIR/$tdir/$tfile)
1628 # Strip getstripe output to a space separated list of OSTs
1629 local getstripe_osts=$(echo "$getstripe" | sed -e '1,/obdidx/d' |\
1630 awk '{print $1}' | tr '\n' '\ ' | sed -e 's/[[:space:]]*$//')
1631 [ "$getstripe_osts" = "${osts//,/ }" ] ||
1632 error "stripes not on specified OSTs"
1634 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 || error "dd failed"
1636 run_test 27ce "more stripes than OSTs with -o"
1639 local osp_proc="osp.$FSNAME-OST0000-osc-MDT000*.active"
1642 test_mkdir -p $DIR/$tdir || error "failed to mkdir $DIR/$tdir"
1643 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=0"
1644 stack_trap "do_facet $SINGLEMDS $LCTL set_param -n $osp_proc=1" EXIT
1645 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 1" ||
1646 error "failed to set $osp_proc=0"
1648 $LFS setstripe -o 0 $DIR/$tdir/$tfile &
1651 do_facet $SINGLEMDS "$LCTL set_param -n $osp_proc=1"
1652 wait_update_facet $SINGLEMDS "$LCTL get_param -n $osp_proc | grep 0" ||
1653 error "failed to set $osp_proc=1"
1656 error "should return error due to $osp_proc=0"
1658 run_test 27cf "'setstripe -o' on inactive OSTs should return error"
1661 test_mkdir $DIR/$tdir
1662 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1663 error "setstripe failed"
1664 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1665 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1667 run_test 27d "create file with default settings"
1670 # LU-5839 adds check for existed layout before setting it
1671 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1672 skip "Need MDS version at least 2.7.56"
1674 test_mkdir $DIR/$tdir
1675 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1676 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1677 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1679 run_test 27e "setstripe existing file (should return error)"
1682 test_mkdir $DIR/$tdir
1683 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1684 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1685 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1686 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1687 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1688 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1690 run_test 27f "setstripe with bad stripe size (should return error)"
1693 test_mkdir $DIR/$tdir
1694 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1695 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1696 error "$DIR/$tdir/$tfile has object"
1698 run_test 27g "$LFS getstripe with no objects"
1701 test_mkdir $DIR/$tdir
1702 touch $DIR/$tdir/$tfile || error "touch failed"
1703 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1704 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1706 (( rc == 2 )) || error "getstripe did not return ENOENT"
1708 run_test 27ga "$LFS getstripe with missing file (should return error)"
1711 test_mkdir $DIR/$tdir
1712 touch $DIR/$tdir/$tfile || error "touch failed"
1713 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1714 error "missing objects"
1716 run_test 27i "$LFS getstripe with some objects"
1719 test_mkdir $DIR/$tdir
1720 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1721 error "setstripe failed" || true
1723 run_test 27j "setstripe with bad stripe offset (should return error)"
1725 test_27k() { # bug 2844
1726 test_mkdir $DIR/$tdir
1727 local file=$DIR/$tdir/$tfile
1728 local ll_max_blksize=$((4 * 1024 * 1024))
1729 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1730 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1731 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1732 dd if=/dev/zero of=$file bs=4k count=1
1733 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1734 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1736 run_test 27k "limit i_blksize for broken user apps"
1739 mcreate $DIR/$tfile || error "creating file"
1740 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1741 error "setstripe should have failed" || true
1743 run_test 27l "check setstripe permissions (should return error)"
1746 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1748 [ -n "$RCLIENTS" -o -n "$MOUNT_2" ] &&
1749 skip_env "multiple clients -- skipping"
1751 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1753 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1754 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1756 trap simple_cleanup_common EXIT
1757 test_mkdir $DIR/$tdir
1758 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1759 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1760 error "dd should fill OST0"
1762 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1764 [ $i -gt 256 ] && break
1767 touch $DIR/$tdir/$tfile.$i
1768 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1769 awk '{print $1}'| grep -w "0") ] &&
1770 error "OST0 was full but new created file still use it"
1772 touch $DIR/$tdir/$tfile.$i
1773 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1774 awk '{print $1}'| grep -w "0") ] &&
1775 error "OST0 was full but new created file still use it"
1776 simple_cleanup_common
1778 run_test 27m "create file while OST0 was full"
1780 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1781 # if the OST isn't full anymore.
1783 local ostidx=${1:-""}
1788 local list=$(comma_list $(osts_nodes))
1789 [ "$ostidx" ] && list=$(facet_host ost$((ostidx + 1)))
1791 do_nodes $list lctl set_param fail_loc=0
1792 wait_delete_completed # initiate all OST_DESTROYs from MDS to OST
1793 delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1794 awk '{print $1 * 2;exit;}')
1795 get_prealloc="$LCTL get_param -n osc.*MDT*.prealloc_status |
1797 wait_update_facet $SINGLEMDS "$get_prealloc" "" $delay
1800 __exhaust_precreations() {
1803 local FAILIDX=${3:-$OSTIDX}
1804 local ofacet=ost$((OSTIDX + 1))
1806 test_mkdir -p -c1 $DIR/$tdir
1807 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1808 local mfacet=mds$((mdtidx + 1))
1809 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1811 local OST=$(ostname_from_index $OSTIDX)
1814 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1815 local last_id=$(do_facet $mfacet lctl get_param -n \
1816 osp.$mdtosc_proc1.prealloc_last_id)
1817 local next_id=$(do_facet $mfacet lctl get_param -n \
1818 osp.$mdtosc_proc1.prealloc_next_id)
1820 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1821 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1823 test_mkdir -p $DIR/$tdir/${OST}
1824 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1825 #define OBD_FAIL_OST_ENOSPC 0x215
1826 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1827 echo "Creating to objid $last_id on ost $OST..."
1828 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1829 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1830 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1833 exhaust_precreations() {
1834 __exhaust_precreations $1 $2 $3
1838 exhaust_all_precreations() {
1840 for (( i=0; i < OSTCOUNT; i++ )) ; do
1841 __exhaust_precreations $i $1 -1
1847 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1848 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1849 remote_mds_nodsh && skip "remote MDS with nodsh"
1850 remote_ost_nodsh && skip "remote OST with nodsh"
1853 rm -f $DIR/$tdir/$tfile
1854 exhaust_precreations 0 0x80000215
1855 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1856 touch $DIR/$tdir/$tfile || error "touch failed"
1857 $LFS getstripe $DIR/$tdir/$tfile
1860 run_test 27n "create file with some full OSTs"
1863 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1864 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1865 remote_mds_nodsh && skip "remote MDS with nodsh"
1866 remote_ost_nodsh && skip "remote OST with nodsh"
1869 rm -f $DIR/$tdir/$tfile
1870 exhaust_all_precreations 0x215
1872 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1877 run_test 27o "create file with all full OSTs (should error)"
1880 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1882 remote_mds_nodsh && skip "remote MDS with nodsh"
1883 remote_ost_nodsh && skip "remote OST with nodsh"
1886 rm -f $DIR/$tdir/$tfile
1887 test_mkdir $DIR/$tdir
1889 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1890 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1891 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1893 exhaust_precreations 0 0x80000215
1894 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1895 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1896 $LFS getstripe $DIR/$tdir/$tfile
1900 run_test 27p "append to a truncated file with some full OSTs"
1903 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1905 remote_mds_nodsh && skip "remote MDS with nodsh"
1906 remote_ost_nodsh && skip "remote OST with nodsh"
1909 rm -f $DIR/$tdir/$tfile
1911 test_mkdir $DIR/$tdir
1912 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1913 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1914 error "truncate $DIR/$tdir/$tfile failed"
1915 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1917 exhaust_all_precreations 0x215
1919 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1920 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1924 run_test 27q "append to truncated file with all OSTs full (should error)"
1927 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1928 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1929 remote_mds_nodsh && skip "remote MDS with nodsh"
1930 remote_ost_nodsh && skip "remote OST with nodsh"
1933 rm -f $DIR/$tdir/$tfile
1934 exhaust_precreations 0 0x80000215
1936 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1940 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1942 test_27s() { # bug 10725
1943 test_mkdir $DIR/$tdir
1944 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1945 local stripe_count=0
1946 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1947 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1948 error "stripe width >= 2^32 succeeded" || true
1951 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1953 test_27t() { # bug 10864
1958 $WLFS getstripe $tfile
1961 run_test 27t "check that utils parse path correctly"
1963 test_27u() { # bug 4900
1964 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1965 remote_mds_nodsh && skip "remote MDS with nodsh"
1968 local list=$(comma_list $(mdts_nodes))
1970 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1971 do_nodes $list $LCTL set_param fail_loc=0x139
1972 test_mkdir -p $DIR/$tdir
1973 trap simple_cleanup_common EXIT
1974 createmany -o $DIR/$tdir/t- 1000
1975 do_nodes $list $LCTL set_param fail_loc=0
1977 TLOG=$TMP/$tfile.getstripe
1978 $LFS getstripe $DIR/$tdir > $TLOG
1979 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1980 unlinkmany $DIR/$tdir/t- 1000
1982 [[ $OBJS -gt 0 ]] &&
1983 error "$OBJS objects created on OST-0. See $TLOG" ||
1986 run_test 27u "skip object creation on OSC w/o objects"
1988 test_27v() { # bug 4900
1989 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1990 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1991 remote_mds_nodsh && skip "remote MDS with nodsh"
1992 remote_ost_nodsh && skip "remote OST with nodsh"
1994 exhaust_all_precreations 0x215
1997 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1999 touch $DIR/$tdir/$tfile
2000 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
2002 for (( i=1; i < OSTCOUNT; i++ )); do
2003 do_facet ost$i lctl set_param fail_loc=0x705
2005 local START=`date +%s`
2006 createmany -o $DIR/$tdir/$tfile 32
2008 local FINISH=`date +%s`
2009 local TIMEOUT=`lctl get_param -n timeout`
2010 local PROCESS=$((FINISH - START))
2011 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
2012 error "$FINISH - $START >= $TIMEOUT / 2"
2013 sleep $((TIMEOUT / 2 - PROCESS))
2016 run_test 27v "skip object creation on slow OST"
2018 test_27w() { # bug 10997
2019 test_mkdir $DIR/$tdir
2020 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
2021 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
2022 error "stripe size $size != 65536" || true
2023 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
2024 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
2026 run_test 27w "check $LFS setstripe -S and getstrip -d options"
2029 [[ $OSTCOUNT -lt 2 ]] &&
2030 skip_env "skipping multiple stripe count/offset test"
2032 test_mkdir $DIR/$tdir
2033 for i in $(seq 1 $OSTCOUNT); do
2035 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
2036 error "setstripe -c $i -i $offset failed"
2037 count=$($LFS getstripe -c $DIR/$tdir/f$i)
2038 index=$($LFS getstripe -i $DIR/$tdir/f$i)
2039 [ $count -ne $i ] && error "stripe count $count != $i" || true
2040 [ $index -ne $offset ] &&
2041 error "stripe offset $index != $offset" || true
2044 run_test 27wa "check $LFS setstripe -c -i options"
2047 remote_ost_nodsh && skip "remote OST with nodsh"
2048 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2051 OFFSET=$(($OSTCOUNT - 1))
2053 local OST=$(ostname_from_index $OSTIDX)
2055 test_mkdir $DIR/$tdir
2056 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
2057 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
2059 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
2060 for i in $(seq 0 $OFFSET); do
2061 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
2062 awk '{print $1}' | grep -w "$OSTIDX") ] &&
2063 error "OST0 was degraded but new created file still use it"
2065 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
2067 run_test 27x "create files while OST0 is degraded"
2070 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2071 remote_mds_nodsh && skip "remote MDS with nodsh"
2072 remote_ost_nodsh && skip "remote OST with nodsh"
2073 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2075 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
2076 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
2077 osp.$mdtosc.prealloc_last_id)
2078 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
2079 osp.$mdtosc.prealloc_next_id)
2080 local fcount=$((last_id - next_id))
2081 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
2082 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
2084 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
2085 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
2086 local OST_DEACTIVE_IDX=-1
2091 for OSC in $MDS_OSCS; do
2092 OST=$(osc_to_ost $OSC)
2093 OSTIDX=$(index_from_ostuuid $OST)
2094 if [ $OST_DEACTIVE_IDX == -1 ]; then
2095 OST_DEACTIVE_IDX=$OSTIDX
2097 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
2098 echo $OSC "is Deactivated:"
2099 do_facet $SINGLEMDS lctl --device %$OSC deactivate
2103 OSTIDX=$(index_from_ostuuid $OST)
2104 test_mkdir $DIR/$tdir
2105 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
2107 for OSC in $MDS_OSCS; do
2108 OST=$(osc_to_ost $OSC)
2109 OSTIDX=$(index_from_ostuuid $OST)
2110 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2111 echo $OST "is degraded:"
2112 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2113 obdfilter.$OST.degraded=1
2118 createmany -o $DIR/$tdir/$tfile $fcount
2120 for OSC in $MDS_OSCS; do
2121 OST=$(osc_to_ost $OSC)
2122 OSTIDX=$(index_from_ostuuid $OST)
2123 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
2124 echo $OST "is recovered from degraded:"
2125 do_facet ost$((OSTIDX+1)) lctl set_param -n \
2126 obdfilter.$OST.degraded=0
2128 do_facet $SINGLEMDS lctl --device %$OSC activate
2132 # all osp devices get activated, hence -1 stripe count restored
2133 local stripe_count=0
2135 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2136 # devices get activated.
2138 $LFS setstripe -c -1 $DIR/$tfile
2139 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2141 [ $stripe_count -ne $OSTCOUNT ] &&
2142 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2145 run_test 27y "create files while OST0 is degraded and the rest inactive"
2151 lmm_count=$($LFS getstripe -c $1)
2152 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
2153 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
2155 local old_ifs="$IFS"
2157 fid=($($LFS path2fid $1))
2160 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2161 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2163 # compare lmm_seq and lu_fid->f_seq
2164 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2165 # compare lmm_object_id and lu_fid->oid
2166 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2168 # check the trusted.fid attribute of the OST objects of the file
2169 local have_obdidx=false
2171 $LFS getstripe $1 | while read obdidx oid hex seq; do
2172 # skip lines up to and including "obdidx"
2173 [ -z "$obdidx" ] && break
2174 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2175 $have_obdidx || continue
2177 local ost=$((obdidx + 1))
2178 local dev=$(ostdevname $ost)
2181 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2183 seq=$(echo $seq | sed -e "s/^0x//g")
2184 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2185 oid_hex=$(echo $oid)
2187 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2189 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2193 # Don't unmount/remount the OSTs if we don't need to do that.
2194 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2195 # update too, until that use mount/ll_decode_filter_fid/mount.
2196 # Re-enable when debugfs will understand new filter_fid.
2198 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2199 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2200 $dev 2>/dev/null" | grep "parent=")
2202 if [ -z "$ff" ]; then
2204 mount_fstype ost$ost
2205 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2206 $(facet_mntpt ost$ost)/$obj_file)
2207 unmount_fstype ost$ost
2208 start ost$ost $dev $OST_MOUNT_OPTS
2212 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2214 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2216 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2217 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2219 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2220 # stripe_size=1048576 component_id=1 component_start=0 \
2221 # component_end=33554432
2222 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2223 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2224 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2226 if grep -q 'stripe=' <<<$ff; then
2227 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2229 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2230 # into f_ver in this case. See comment on ff_parent.
2231 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2234 # compare lmm_seq and filter_fid->ff_parent.f_seq
2235 [ $ff_pseq = $lmm_seq ] ||
2236 error "FF parent SEQ $ff_pseq != $lmm_seq"
2237 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2238 [ $ff_poid = $lmm_oid ] ||
2239 error "FF parent OID $ff_poid != $lmm_oid"
2240 (($ff_pstripe == $stripe_nr)) ||
2241 error "FF stripe $ff_pstripe != $stripe_nr"
2243 stripe_nr=$((stripe_nr + 1))
2244 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2246 if grep -q 'stripe_count=' <<<$ff; then
2247 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2248 -e 's/ .*//' <<<$ff)
2249 [ $lmm_count = $ff_scnt ] ||
2250 error "FF stripe count $lmm_count != $ff_scnt"
2256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2257 remote_ost_nodsh && skip "remote OST with nodsh"
2259 test_mkdir $DIR/$tdir
2260 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2261 { error "setstripe -c -1 failed"; return 1; }
2262 # We need to send a write to every object to get parent FID info set.
2263 # This _should_ also work for setattr, but does not currently.
2264 # touch $DIR/$tdir/$tfile-1 ||
2265 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2266 { error "dd $tfile-1 failed"; return 2; }
2267 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2268 { error "setstripe -c -1 failed"; return 3; }
2269 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2270 { error "dd $tfile-2 failed"; return 4; }
2272 # make sure write RPCs have been sent to OSTs
2275 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2276 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2278 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2280 test_27A() { # b=19102
2281 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2283 save_layout_restore_at_exit $MOUNT
2284 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2285 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2286 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2287 local default_size=$($LFS getstripe -S $MOUNT)
2288 local default_offset=$($LFS getstripe -i $MOUNT)
2289 local dsize=$(do_facet $SINGLEMDS \
2290 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2291 [ $default_size -eq $dsize ] ||
2292 error "stripe size $default_size != $dsize"
2293 [ $default_offset -eq -1 ] ||
2294 error "stripe offset $default_offset != -1"
2296 run_test 27A "check filesystem-wide default LOV EA values"
2298 test_27B() { # LU-2523
2299 test_mkdir $DIR/$tdir
2300 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2302 # open f1 with O_LOV_DELAY_CREATE
2304 # call setstripe ioctl on open file descriptor for f1
2306 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2310 # open f1 with O_LOV_DELAY_CREATE
2312 # call setstripe ioctl on open file descriptor for f1
2314 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2316 # Allow multiop to fail in imitation of NFS's busted semantics.
2319 run_test 27B "call setstripe on open unlinked file/rename victim"
2321 # 27C family tests full striping and overstriping
2322 test_27Ca() { #LU-2871
2323 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2331 test_mkdir $DIR/$tdir
2333 for i in $(seq 0 $((OSTCOUNT - 1))); do
2334 # set stripe across all OSTs starting from OST$i
2335 $LFS setstripe -i $i -c -1 $tfile$i
2336 # get striping information
2337 ost_idx=($($LFS getstripe $tfile$i |
2338 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2342 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2343 error "${#ost_idx[@]} != $OSTCOUNT"
2345 for index in $(seq 0 $((OSTCOUNT - 1))); do
2347 for j in $(echo ${ost_idx[@]}); do
2348 if [ $index -eq $j ]; then
2354 error "Can not find $index in ${ost_idx[@]}"
2358 run_test 27Ca "check full striping across all OSTs"
2361 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2362 skip "server does not support overstriping"
2363 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2364 skip_env "too many osts, skipping"
2366 test_mkdir -p $DIR/$tdir
2367 local setcount=$(($OSTCOUNT * 2))
2368 [ $setcount -ge 160 ] || large_xattr_enabled ||
2369 skip_env "ea_inode feature disabled"
2371 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2372 error "setstripe failed"
2374 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2375 [ $count -eq $setcount ] ||
2376 error "stripe count $count, should be $setcount"
2378 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2379 error "overstriped should be set in pattern"
2381 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2384 run_test 27Cb "more stripes than OSTs with -C"
2387 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2388 skip "server does not support overstriping"
2389 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2391 test_mkdir -p $DIR/$tdir
2392 local setcount=$(($OSTCOUNT - 1))
2394 [ $setcount -ge 160 ] || large_xattr_enabled ||
2395 skip_env "ea_inode feature disabled"
2397 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2398 error "setstripe failed"
2400 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2401 [ $count -eq $setcount ] ||
2402 error "stripe count $count, should be $setcount"
2404 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" &&
2405 error "overstriped should not be set in pattern"
2407 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2410 run_test 27Cc "fewer stripes than OSTs does not set overstriping"
2413 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2414 skip "server does not support overstriping"
2415 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2416 large_xattr_enabled || skip_env "ea_inode feature disabled"
2418 test_mkdir -p $DIR/$tdir
2419 local setcount=$LOV_MAX_STRIPE_COUNT
2421 $LFS setstripe -C $setcount $DIR/$tdir/$tfile ||
2422 error "setstripe failed"
2424 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2425 [ $count -eq $setcount ] ||
2426 error "stripe count $count, should be $setcount"
2428 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2429 error "overstriped should be set in pattern"
2431 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2434 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2436 run_test 27Cd "test maximum stripe count"
2439 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2440 skip "server does not support overstriping"
2441 test_mkdir -p $DIR/$tdir
2443 pool_add $TESTNAME || error "Pool creation failed"
2444 pool_add_targets $TESTNAME 0 || error "pool_add_targets failed"
2448 $LFS setstripe -C $setcount -p "$TESTNAME" $DIR/$tdir/$tfile ||
2449 error "setstripe failed"
2451 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2452 [ $count -eq $setcount ] ||
2453 error "stripe count $count, should be $setcount"
2455 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2456 error "overstriped should be set in pattern"
2458 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2461 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2463 run_test 27Ce "test pool with overstriping"
2466 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
2467 skip "server does not support overstriping"
2468 [[ $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2469 skip_env "too many osts, skipping"
2471 test_mkdir -p $DIR/$tdir
2473 local setcount=$(($OSTCOUNT * 2))
2474 [ $setcount -ge 160 ] || large_xattr_enabled ||
2475 skip_env "ea_inode feature disabled"
2477 $LFS setstripe -C $setcount $DIR/$tdir/ ||
2478 error "setstripe failed"
2480 echo 1 > $DIR/$tdir/$tfile
2482 local count=$($LFS getstripe -c $DIR/$tdir/$tfile)
2483 [ $count -eq $setcount ] ||
2484 error "stripe count $count, should be $setcount"
2486 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "overstriped" ||
2487 error "overstriped should be set in pattern"
2489 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=4 conv=notrunc ||
2492 rm -f $DIR/$tdir/$tfile || error "Delete $tfile failed"
2494 run_test 27Cf "test default inheritance with overstriping"
2497 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2498 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2499 remote_mds_nodsh && skip "remote MDS with nodsh"
2501 local POOL=${POOL:-testpool}
2503 local last_ost=$(($OSTCOUNT - 1))
2505 local ost_list=$(seq $first_ost $ost_step $last_ost)
2506 local ost_range="$first_ost $last_ost $ost_step"
2508 test_mkdir $DIR/$tdir
2509 pool_add $POOL || error "pool_add failed"
2510 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2513 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2515 [ $MDS1_VERSION -lt $(version_code 2.9.55) ] ||
2516 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2517 skip27D+=" -s 30,31"
2518 [[ ! $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ||
2519 $OSTCOUNT -ge $(($LOV_MAX_STRIPE_COUNT / 2)) ]] &&
2520 skip27D+=" -s 32,33"
2521 [[ $MDS_VERSION -lt $(version_code $SEL_VER) ]] &&
2523 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2524 error "llapi_layout_test failed"
2526 destroy_test_pools || error "destroy test pools failed"
2528 run_test 27D "validate llapi_layout API"
2530 # Verify that default_easize is increased from its initial value after
2531 # accessing a widely striped file.
2533 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2534 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2535 skip "client does not have LU-3338 fix"
2537 # 72 bytes is the minimum space required to store striping
2538 # information for a file striped across one OST:
2539 # (sizeof(struct lov_user_md_v3) +
2540 # sizeof(struct lov_user_ost_data_v1))
2542 $LCTL set_param -n llite.*.default_easize $min_easize ||
2543 error "lctl set_param failed"
2544 local easize=$($LCTL get_param -n llite.*.default_easize)
2546 [ $easize -eq $min_easize ] ||
2547 error "failed to set default_easize"
2549 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2550 error "setstripe failed"
2551 # In order to ensure stat() call actually talks to MDS we need to
2552 # do something drastic to this file to shake off all lock, e.g.
2553 # rename it (kills lookup lock forcing cache cleaning)
2554 mv $DIR/$tfile $DIR/${tfile}-1
2555 ls -l $DIR/${tfile}-1
2558 easize=$($LCTL get_param -n llite.*.default_easize)
2560 [ $easize -gt $min_easize ] ||
2561 error "default_easize not updated"
2563 run_test 27E "check that default extended attribute size properly increases"
2565 test_27F() { # LU-5346/LU-7975
2566 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2567 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2568 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2569 skip "Need MDS version at least 2.8.51"
2570 remote_ost_nodsh && skip "remote OST with nodsh"
2572 test_mkdir $DIR/$tdir
2574 $LFS setstripe -c 2 $DIR/$tdir
2576 # stop all OSTs to reproduce situation for LU-7975 ticket
2577 for num in $(seq $OSTCOUNT); do
2581 # open/create f0 with O_LOV_DELAY_CREATE
2582 # truncate f0 to a non-0 size
2584 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2586 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2587 # open/write it again to force delayed layout creation
2588 cat /etc/hosts > $DIR/$tdir/f0 &
2592 for num in $(seq $OSTCOUNT); do
2593 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2594 error "ost$num failed to start"
2597 wait $catpid || error "cat failed"
2599 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2600 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2601 error "wrong stripecount"
2604 run_test 27F "Client resend delayed layout creation with non-zero size"
2606 test_27G() { #LU-10629
2607 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2608 skip "Need MDS version at least 2.11.51"
2609 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2610 remote_mds_nodsh && skip "remote MDS with nodsh"
2611 local POOL=${POOL:-testpool}
2612 local ostrange="0 0 1"
2614 test_mkdir $DIR/$tdir
2615 touch $DIR/$tdir/$tfile.nopool
2616 pool_add $POOL || error "pool_add failed"
2617 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2618 $LFS setstripe -p $POOL $DIR/$tdir
2620 local pool=$($LFS getstripe -p $DIR/$tdir)
2622 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2623 touch $DIR/$tdir/$tfile.default
2624 $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl
2625 $LFS find $DIR/$tdir -type f --pool $POOL
2626 local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l)
2627 [[ "$found" == "2" ]] ||
2628 error "found $found != 2 files in '$DIR/$tdir' in '$POOL'"
2630 $LFS setstripe -d $DIR/$tdir
2632 pool=$($LFS getstripe -p -d $DIR/$tdir)
2634 [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'"
2636 run_test 27G "Clear OST pool from stripe"
2639 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2640 skip "Need MDS version newer than 2.11.54"
2641 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2642 test_mkdir $DIR/$tdir
2643 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2644 touch $DIR/$tdir/$tfile
2645 $LFS getstripe -c $DIR/$tdir/$tfile
2646 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2647 error "two-stripe file doesn't have two stripes"
2649 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2650 $LFS getstripe -y $DIR/$tdir/$tfile
2651 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2652 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2653 error "expected l_ost_idx: [02]$ not matched"
2655 # make sure ost list has been cleared
2656 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2657 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2658 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2660 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2662 run_test 27H "Set specific OSTs stripe"
2665 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2666 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2667 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2668 skip "Need MDS version newer than 2.12.52"
2669 local pool=$TESTNAME
2670 local ostrange="1 1 1"
2672 save_layout_restore_at_exit $MOUNT
2673 $LFS setstripe -c 2 -i 0 $MOUNT
2674 pool_add $pool || error "pool_add failed"
2675 pool_add_targets $pool $ostrange || "pool_add_targets failed"
2676 test_mkdir $DIR/$tdir
2677 $LFS setstripe -p $pool $DIR/$tdir
2678 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2679 $LFS getstripe $DIR/$tdir/$tfile
2681 run_test 27I "check that root dir striping does not break parent dir one"
2684 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2685 skip "Need MDS version newer than 2.12.51"
2687 test_mkdir $DIR/$tdir
2688 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2689 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2691 # create foreign file (raw way)
2692 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2693 -t 1 -F 0xda08 || error "create_foreign_file failed"
2695 # verify foreign file (raw way)
2696 parse_foreign_file -f $DIR/$tdir/$tfile |
2697 grep "lov_foreign_magic: 0x0BD70BD0" ||
2698 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2699 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2700 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2701 parse_foreign_file -f $DIR/$tdir/$tfile |
2702 grep "lov_foreign_size: 73" ||
2703 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2704 parse_foreign_file -f $DIR/$tdir/$tfile |
2705 grep "lov_foreign_type: 1" ||
2706 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2707 parse_foreign_file -f $DIR/$tdir/$tfile |
2708 grep "lov_foreign_flags: 0x0000DA08" ||
2709 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2710 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2711 grep "lov_foreign_value: 0x" |
2712 sed -e 's/lov_foreign_value: 0x//')
2713 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2714 [[ $lov = ${lov2// /} ]] ||
2715 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2717 # create foreign file (lfs + API)
2718 $LFS setstripe --foreign=daos --flags 0xda08 \
2719 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2720 error "$DIR/$tdir/${tfile}2: create failed"
2722 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2723 grep "lfm_magic:.*0x0BD70BD0" ||
2724 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2725 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2726 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2727 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2728 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
2729 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2730 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2731 grep "lfm_flags:.*0x0000DA08" ||
2732 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2733 $LFS getstripe $DIR/$tdir/${tfile}2 |
2734 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2735 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2737 # modify striping should fail
2738 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2739 error "$DIR/$tdir/$tfile: setstripe should fail"
2740 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2741 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2744 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2745 cat $DIR/$tdir/${tfile}2 &&
2746 error "$DIR/$tdir/${tfile}2: read should fail"
2747 cat /etc/passwd > $DIR/$tdir/$tfile &&
2748 error "$DIR/$tdir/$tfile: write should fail"
2749 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2750 error "$DIR/$tdir/${tfile}2: write should fail"
2753 chmod 222 $DIR/$tdir/$tfile ||
2754 error "$DIR/$tdir/$tfile: chmod failed"
2755 chmod 222 $DIR/$tdir/${tfile}2 ||
2756 error "$DIR/$tdir/${tfile}2: chmod failed"
2759 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2760 error "$DIR/$tdir/$tfile: chown failed"
2761 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2762 error "$DIR/$tdir/${tfile}2: chown failed"
2764 # rename should work
2765 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2766 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2767 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2768 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2770 #remove foreign file
2771 rm $DIR/$tdir/${tfile}.new ||
2772 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2773 rm $DIR/$tdir/${tfile}2.new ||
2774 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2776 run_test 27J "basic ops on file with foreign LOV"
2779 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2780 skip "Need MDS version newer than 2.12.49"
2782 test_mkdir $DIR/$tdir
2783 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2784 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2786 # create foreign dir (raw way)
2787 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2788 error "create_foreign_dir FAILED"
2790 # verify foreign dir (raw way)
2791 parse_foreign_dir -d $DIR/$tdir/$tdir |
2792 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2793 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2794 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2795 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2796 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2797 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2798 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
2799 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2800 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2801 grep "lmv_foreign_value: 0x" |
2802 sed 's/lmv_foreign_value: 0x//')
2803 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2805 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2807 # create foreign dir (lfs + API)
2808 $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2809 $DIR/$tdir/${tdir}2 ||
2810 error "$DIR/$tdir/${tdir}2: create failed"
2812 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2813 grep "lfm_magic:.*0x0CD50CD0" ||
2814 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2815 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2816 # - sizeof(lfm_type) - sizeof(lfm_flags)
2817 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2818 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2819 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
2820 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2821 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2822 grep "lfm_flags:.*0x0000DA05" ||
2823 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2824 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2825 grep "lfm_value.*${uuid1}@${uuid2}" ||
2826 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2828 # file create in dir should fail
2829 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2830 touch $DIR/$tdir/${tdir}2/$tfile &&
2831 "$DIR/${tdir}2: file create should fail"
2834 chmod 777 $DIR/$tdir/$tdir ||
2835 error "$DIR/$tdir: chmod failed"
2836 chmod 777 $DIR/$tdir/${tdir}2 ||
2837 error "$DIR/${tdir}2: chmod failed"
2840 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2841 error "$DIR/$tdir: chown failed"
2842 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2843 error "$DIR/${tdir}2: chown failed"
2845 # rename should work
2846 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2847 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2848 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2849 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2852 rmdir $DIR/$tdir/${tdir}.new ||
2853 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2854 rmdir $DIR/$tdir/${tdir}2.new ||
2855 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2857 run_test 27K "basic ops on dir with foreign LMV"
2860 remote_mds_nodsh && skip "remote MDS with nodsh"
2862 local POOL=${POOL:-$TESTNAME}
2864 pool_add $POOL || error "pool_add failed"
2866 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2867 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2868 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2870 run_test 27L "lfs pool_list gives correct pool name"
2873 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2874 skip "Need MDS version >= than 2.12.57"
2875 remote_mds_nodsh && skip "remote MDS with nodsh"
2876 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2878 test_mkdir $DIR/$tdir
2880 # Set default striping on directory
2881 $LFS setstripe -C 4 $DIR/$tdir
2883 echo 1 > $DIR/$tdir/${tfile}.1
2884 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2886 [ $count -eq $setcount ] ||
2887 error "(1) stripe count $count, should be $setcount"
2889 # Capture existing append_stripe_count setting for restore
2890 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2891 local mdts=$(comma_list $(mdts_nodes))
2892 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2894 local appendcount=$orig_count
2895 echo 1 >> $DIR/$tdir/${tfile}.2_append
2896 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2897 [ $count -eq $appendcount ] ||
2898 error "(2)stripe count $count, should be $appendcount for append"
2900 # Disable O_APPEND striping, verify it works
2901 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2903 # Should now get the default striping, which is 4
2905 echo 1 >> $DIR/$tdir/${tfile}.3_append
2906 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2907 [ $count -eq $setcount ] ||
2908 error "(3) stripe count $count, should be $setcount"
2910 # Try changing the stripe count for append files
2911 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2913 # Append striping is now 2 (directory default is still 4)
2915 echo 1 >> $DIR/$tdir/${tfile}.4_append
2916 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2917 [ $count -eq $appendcount ] ||
2918 error "(4) stripe count $count, should be $appendcount for append"
2920 # Test append stripe count of -1
2921 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2922 appendcount=$OSTCOUNT
2923 echo 1 >> $DIR/$tdir/${tfile}.5
2924 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2925 [ $count -eq $appendcount ] ||
2926 error "(5) stripe count $count, should be $appendcount for append"
2928 # Set append striping back to default of 1
2929 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2931 # Try a new default striping, PFL + DOM
2932 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2934 # Create normal DOM file, DOM returns stripe count == 0
2936 touch $DIR/$tdir/${tfile}.6
2937 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2938 [ $count -eq $setcount ] ||
2939 error "(6) stripe count $count, should be $setcount"
2943 echo 1 >> $DIR/$tdir/${tfile}.7_append
2944 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2945 [ $count -eq $appendcount ] ||
2946 error "(7) stripe count $count, should be $appendcount for append"
2948 # Clean up DOM layout
2949 $LFS setstripe -d $DIR/$tdir
2951 # Now test that append striping works when layout is from root
2952 $LFS setstripe -c 2 $MOUNT
2953 # Make a special directory for this
2954 mkdir $DIR/${tdir}/${tdir}.2
2955 stack_trap "$LFS setstripe -d $MOUNT" EXIT
2957 # Verify for normal file
2959 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2960 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2961 [ $count -eq $setcount ] ||
2962 error "(8) stripe count $count, should be $setcount"
2965 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2966 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2967 [ $count -eq $appendcount ] ||
2968 error "(9) stripe count $count, should be $appendcount for append"
2970 # Now test O_APPEND striping with pools
2971 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2972 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
2975 pool_add $TESTNAME || error "pool creation failed"
2976 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2978 echo 1 >> $DIR/$tdir/${tfile}.10_append
2980 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
2981 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
2983 # Check that count is still correct
2985 echo 1 >> $DIR/$tdir/${tfile}.11_append
2986 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
2987 [ $count -eq $appendcount ] ||
2988 error "(11) stripe count $count, should be $appendcount for append"
2990 # Disable O_APPEND stripe count, verify pool works separately
2991 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2993 echo 1 >> $DIR/$tdir/${tfile}.12_append
2995 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
2996 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
2998 # Remove pool setting, verify it's not applied
2999 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
3001 echo 1 >> $DIR/$tdir/${tfile}.13_append
3003 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
3004 [ "$pool" = "" ] || error "(13) pool found: $pool"
3006 run_test 27M "test O_APPEND striping"
3009 combined_mgs_mds && skip "needs separate MGS/MDT"
3011 pool_add $TESTNAME || error "pool_add failed"
3012 do_facet mgs "$LCTL pool_list $FSNAME" |
3013 grep -Fx "${FSNAME}.${TESTNAME}" ||
3014 error "lctl pool_list on MGS failed"
3016 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3018 # createtest also checks that device nodes are created and
3019 # then visible correctly (#2091)
3020 test_28() { # bug 2091
3022 $CREATETEST $DIR/d28/ct || error "createtest failed"
3024 run_test 28 "create/mknod/mkdir with bad file types ============"
3027 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3029 sync; sleep 1; sync # flush out any dirty pages from previous tests
3036 declare -i LOCKCOUNTORIG=0
3037 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3038 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3040 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3042 declare -i LOCKUNUSEDCOUNTORIG=0
3043 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3044 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3051 declare -i LOCKCOUNTCURRENT=0
3052 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3053 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3056 declare -i LOCKUNUSEDCOUNTCURRENT=0
3057 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3058 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3061 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3062 $LCTL set_param -n ldlm.dump_namespaces ""
3063 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3064 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3065 log "dumped log to $TMP/test_29.dk (bug 5793)"
3068 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3069 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3070 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3071 log "dumped log to $TMP/test_29.dk (bug 5793)"
3075 run_test 29 "IT_GETATTR regression ============================"
3077 test_30a() { # was test_30
3078 cp $(which ls) $DIR || cp /bin/ls $DIR
3079 $DIR/ls / || error "Can't execute binary from lustre"
3082 run_test 30a "execute binary from Lustre (execve) =============="
3085 cp `which ls` $DIR || cp /bin/ls $DIR
3087 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3090 run_test 30b "execute binary from Lustre as non-root ==========="
3092 test_30c() { # b=22376
3093 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3095 cp $(which ls) $DIR || cp /bin/ls $DIR
3097 cancel_lru_locks mdc
3098 cancel_lru_locks osc
3099 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3102 run_test 30c "execute binary from Lustre without read perms ===="
3105 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3107 for i in {1..10}; do
3108 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3111 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3112 wait $PID || error "executing dd from Lustre failed"
3118 run_test 30d "execute binary from Lustre while clear locks"
3121 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3122 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3124 run_test 31a "open-unlink file =================================="
3127 touch $DIR/f31 || error "touch $DIR/f31 failed"
3128 ln $DIR/f31 $DIR/f31b || error "ln failed"
3129 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3130 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3132 run_test 31b "unlink file with multiple links while open ======="
3135 touch $DIR/f31 || error "touch $DIR/f31 failed"
3136 ln $DIR/f31 $DIR/f31c || error "ln failed"
3137 multiop_bg_pause $DIR/f31 O_uc ||
3138 error "multiop_bg_pause for $DIR/f31 failed"
3140 $MULTIOP $DIR/f31c Ouc
3141 kill -USR1 $MULTIPID
3144 run_test 31c "open-unlink file with multiple links ============="
3147 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3148 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3150 run_test 31d "remove of open directory ========================="
3152 test_31e() { # bug 2904
3153 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3155 run_test 31e "remove of open non-empty directory ==============="
3157 test_31f() { # bug 4554
3158 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3161 test_mkdir $DIR/d31f
3162 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3163 cp /etc/hosts $DIR/d31f
3165 $LFS getstripe $DIR/d31f/hosts
3166 multiop_bg_pause $DIR/d31f D_c || return 1
3169 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3170 test_mkdir $DIR/d31f
3171 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3172 cp /etc/hosts $DIR/d31f
3174 $LFS getstripe $DIR/d31f/hosts
3175 multiop_bg_pause $DIR/d31f D_c || return 1
3178 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3179 wait $MULTIPID || error "first opendir $MULTIPID failed"
3183 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3184 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3187 run_test 31f "remove of open directory with open-unlink file ==="
3190 echo "-- cross directory link --"
3191 test_mkdir -c1 $DIR/${tdir}ga
3192 test_mkdir -c1 $DIR/${tdir}gb
3193 touch $DIR/${tdir}ga/f
3194 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3195 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3196 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3197 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3198 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3200 run_test 31g "cross directory link==============="
3203 echo "-- cross directory link --"
3204 test_mkdir -c1 $DIR/${tdir}
3205 test_mkdir -c1 $DIR/${tdir}/dir
3206 touch $DIR/${tdir}/f
3207 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3208 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3209 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3210 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3211 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3213 run_test 31h "cross directory link under child==============="
3216 echo "-- cross directory link --"
3217 test_mkdir -c1 $DIR/$tdir
3218 test_mkdir -c1 $DIR/$tdir/dir
3219 touch $DIR/$tdir/dir/f
3220 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3221 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3222 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3223 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3224 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3226 run_test 31i "cross directory link under parent==============="
3229 test_mkdir -c1 -p $DIR/$tdir
3230 test_mkdir -c1 -p $DIR/$tdir/dir1
3231 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3232 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3233 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3234 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3237 run_test 31j "link for directory==============="
3240 test_mkdir -c1 -p $DIR/$tdir
3242 touch $DIR/$tdir/exist
3243 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3244 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3245 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3246 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3247 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3248 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3249 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3252 run_test 31k "link to file: the same, non-existing, dir==============="
3258 touch $DIR/d31m2/exist
3259 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3260 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3261 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3262 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3263 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3264 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3267 run_test 31m "link to file: the same, non-existing, dir==============="
3270 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3271 nlink=$(stat --format=%h $DIR/$tfile)
3272 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3274 local cmd="exec $fd<$DIR/$tfile"
3277 trap "eval $cmd" EXIT
3278 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3279 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3280 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3281 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3282 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3285 run_test 31n "check link count of unlinked file"
3288 local tempfile=$(mktemp $1_XXXXXX)
3289 mlink $tempfile $1 2> /dev/null &&
3290 echo "$BASHPID: link $tempfile to $1 succeeded"
3294 test_31o() { # LU-2901
3295 test_mkdir $DIR/$tdir
3296 for LOOP in $(seq 100); do
3297 rm -f $DIR/$tdir/$tfile*
3298 for THREAD in $(seq 8); do
3299 link_one $DIR/$tdir/$tfile.$LOOP &
3302 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3303 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3304 error "$LINKS duplicate links to $tfile.$LOOP" &&
3308 run_test 31o "duplicate hard links with same filename"
3311 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3313 test_mkdir $DIR/$tdir
3314 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3315 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3317 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3318 error "open unlink test1 failed"
3319 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3320 error "open unlink test2 failed"
3322 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3323 error "test1 still exists"
3324 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3325 error "test2 still exists"
3327 run_test 31p "remove of open striped directory"
3329 cleanup_test32_mount() {
3332 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3333 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3334 losetup -d $loopdev || true
3340 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3342 echo "== more mountpoints and symlinks ================="
3343 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3344 trap cleanup_test32_mount EXIT
3345 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3346 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3347 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3348 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3349 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3350 cleanup_test32_mount
3352 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3355 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3357 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3358 trap cleanup_test32_mount EXIT
3359 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3360 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3361 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3362 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3363 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3364 cleanup_test32_mount
3366 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3369 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3371 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3372 trap cleanup_test32_mount EXIT
3373 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3374 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3375 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3376 test_mkdir -p $DIR/$tdir/d2/test_dir
3377 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3378 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3379 cleanup_test32_mount
3381 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3386 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3387 trap cleanup_test32_mount EXIT
3388 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3389 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3390 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3391 test_mkdir -p $DIR/$tdir/d2/test_dir
3392 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3393 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3394 cleanup_test32_mount
3396 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3400 test_mkdir -p $DIR/$tdir/tmp
3401 local tmp_dir=$DIR/$tdir/tmp
3402 ln -s $DIR/$tdir $tmp_dir/symlink11
3403 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3404 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3405 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3407 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3411 test_mkdir -p $DIR/$tdir/tmp
3412 local tmp_dir=$DIR/$tdir/tmp
3413 ln -s $DIR/$tdir $tmp_dir/symlink11
3414 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3415 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3416 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3418 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3421 local tmp_dir=$DIR/$tdir/tmp
3422 test_mkdir -p $tmp_dir
3423 test_mkdir $DIR/${tdir}2
3424 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3425 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3426 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3427 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3428 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3429 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3431 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3434 rm -fr $DIR/$tdir $DIR/${tdir}2
3435 tmp_dir=$DIR/$tdir/tmp
3436 test_mkdir -p $tmp_dir
3437 test_mkdir $DIR/${tdir}2
3438 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3439 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3440 ls $tmp_dir/symlink12 || error "listing symlink12"
3441 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3443 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3446 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3448 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3449 trap cleanup_test32_mount EXIT
3450 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3451 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3452 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3453 touch $DIR/$tdir/test_file
3454 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3455 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3456 cleanup_test32_mount
3458 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3461 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3463 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3464 trap cleanup_test32_mount EXIT
3465 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3466 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3467 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3468 touch $DIR/$tdir/test_file
3469 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3470 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3471 cleanup_test32_mount
3473 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3476 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3479 trap cleanup_test32_mount EXIT
3480 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3481 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3482 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3483 test_mkdir -p $DIR/$tdir/d2
3484 touch $DIR/$tdir/d2/test_file || error "touch failed"
3485 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3486 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3487 cleanup_test32_mount
3489 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3495 trap cleanup_test32_mount EXIT
3496 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3497 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3498 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3499 test_mkdir -p $DIR/$tdir/d2
3500 touch $DIR/$tdir/d2/test_file || error "touch failed"
3501 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3502 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3503 cleanup_test32_mount
3505 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3509 test_mkdir -p $DIR/d32m/tmp
3510 TMP_DIR=$DIR/d32m/tmp
3511 ln -s $DIR $TMP_DIR/symlink11
3512 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3513 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3514 error "symlink11 not a link"
3515 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3516 error "symlink01 not a link"
3518 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3522 test_mkdir -p $DIR/d32n/tmp
3523 TMP_DIR=$DIR/d32n/tmp
3524 ln -s $DIR $TMP_DIR/symlink11
3525 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3526 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3527 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3529 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3533 test_mkdir -p $DIR/d32o/tmp
3534 TMP_DIR=$DIR/d32o/tmp
3535 ln -s $DIR/$tfile $TMP_DIR/symlink12
3536 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3537 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3538 error "symlink12 not a link"
3539 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3540 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3541 error "$DIR/d32o/tmp/symlink12 not file type"
3542 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3543 error "$DIR/d32o/symlink02 not file type"
3545 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3555 test_mkdir -p $DIR/d32p/tmp
3557 TMP_DIR=$DIR/d32p/tmp
3559 ln -s $DIR/$tfile $TMP_DIR/symlink12
3561 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3563 cat $DIR/d32p/tmp/symlink12 ||
3564 error "Can't open $DIR/d32p/tmp/symlink12"
3566 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3569 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3572 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3574 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3575 trap cleanup_test32_mount EXIT
3576 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3577 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3578 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3579 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3580 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3581 cleanup_test32_mount
3583 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3586 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3588 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3589 trap cleanup_test32_mount EXIT
3590 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3591 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3592 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3593 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3594 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3595 cleanup_test32_mount
3597 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3602 chmod 444 $DIR/$tfile
3603 chown $RUNAS_ID $DIR/$tfile
3605 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3608 run_test 33aa "write file with mode 444 (should return error)"
3612 test_mkdir $DIR/$tdir
3613 chown $RUNAS_ID $DIR/$tdir
3614 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3615 error "$RUNAS create $tdir/$tfile failed"
3616 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3617 error "open RDWR" || true
3619 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3623 test_mkdir $DIR/$tdir
3624 chown $RUNAS_ID $DIR/$tdir
3625 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3627 run_test 33b "test open file with malformed flags (No panic)"
3630 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3631 remote_ost_nodsh && skip "remote OST with nodsh"
3640 test_mkdir $DIR/$tdir
3641 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3644 for ostnum in $(seq $OSTCOUNT); do
3645 # test-framework's OST numbering is one-based, while Lustre's
3647 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3648 # Parsing llobdstat's output sucks; we could grep the /proc
3649 # path, but that's likely to not be as portable as using the
3650 # llobdstat utility. So we parse lctl output instead.
3651 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3652 obdfilter/$ostname/stats |
3653 awk '/^write_bytes/ {print $7}' )
3654 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3655 if (( ${write_bytes:-0} > 0 ))
3662 $all_zeros || return 0
3665 echo foo > $DIR/$tdir/bar
3669 # Total up write_bytes after writing. We'd better find non-zeros.
3670 for ostnum in $(seq $OSTCOUNT); do
3671 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3672 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3673 obdfilter/$ostname/stats |
3674 awk '/^write_bytes/ {print $7}' )
3675 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3676 if (( ${write_bytes:-0} > 0 ))
3685 for ostnum in $(seq $OSTCOUNT); do
3686 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3687 echo "Check that write_bytes is present in obdfilter/*/stats:"
3688 do_facet ost$ostnum lctl get_param -n \
3689 obdfilter/$ostname/stats
3691 error "OST not keeping write_bytes stats (b22312)"
3694 run_test 33c "test llobdstat and write_bytes"
3697 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3701 local remote_dir=$DIR/$tdir/remote_dir
3703 test_mkdir $DIR/$tdir
3704 $LFS mkdir -i $MDTIDX $remote_dir ||
3705 error "create remote directory failed"
3707 touch $remote_dir/$tfile
3708 chmod 444 $remote_dir/$tfile
3709 chown $RUNAS_ID $remote_dir/$tfile
3711 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3713 chown $RUNAS_ID $remote_dir
3714 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3715 error "create" || true
3716 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3717 error "open RDWR" || true
3718 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3720 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3723 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3727 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3728 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3729 mkdir $DIR/$tdir/local_dir
3731 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3732 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3733 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3735 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3736 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3738 rmdir $DIR/$tdir/* || error "rmdir failed"
3741 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3742 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3743 mkdir $DIR/$tdir/local_dir
3745 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3746 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3747 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3749 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3750 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3752 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3755 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3756 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3757 mkdir $DIR/$tdir/local_dir
3759 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3760 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3761 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3763 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3764 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3766 run_test 33e "mkdir and striped directory should have same mode"
3770 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3774 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3775 remote_mds_nodsh && skip "remote MDS with nodsh"
3778 chmod go+rwx $DIR/$tdir
3779 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3780 trap cleanup_33f EXIT
3782 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3783 error "cannot create striped directory"
3785 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3786 error "cannot create files in striped directory"
3788 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3789 error "cannot remove files in striped directory"
3791 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3792 error "cannot remove striped directory"
3796 run_test 33f "nonroot user can create, access, and remove a striped directory"
3799 mkdir -p $DIR/$tdir/dir2
3801 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3803 [[ $err =~ "exists" ]] || error "Not exists error"
3805 run_test 33g "nonroot user create already existing root created file"
3808 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3809 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
3810 skip "Need MDS version at least 2.13.50"
3812 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir ||
3813 error "mkdir $tdir failed"
3814 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
3816 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
3819 for fname in $DIR/$tdir/$tfile.bak \
3820 $DIR/$tdir/$tfile.SAV \
3821 $DIR/$tdir/$tfile.orig \
3822 $DIR/$tdir/$tfile~; do
3823 touch $fname || error "touch $fname failed"
3824 index2=$($LFS getstripe -m $fname)
3825 [ $index -eq $index2 ] ||
3826 error "$fname MDT index mismatch $index != $index2"
3830 for i in {1..50}; do
3831 for fname in $(mktemp -u $DIR/$tdir/.$tfile.XXXXXX) \
3832 $(mktemp $DIR/$tdir/$tfile.XXXXXXXX); do
3833 touch $fname || error "touch $fname failed"
3834 index2=$($LFS getstripe -m $fname)
3835 if [[ $index != $index2 ]]; then
3836 failed=$((failed + 1))
3837 echo "$fname MDT index mismatch $index != $index2"
3841 echo "$failed MDT index mismatches"
3842 (( failed < 4 )) || error "MDT index mismatch $failed times"
3845 run_test 33h "temp file is located on the same MDT as target"
3847 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3850 $MCREATE $DIR/f34 || error "mcreate failed"
3851 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3852 error "getstripe failed"
3853 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3854 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3855 error "getstripe failed"
3856 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3857 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3859 run_test 34a "truncate file that has not been opened ==========="
3862 [ ! -f $DIR/f34 ] && test_34a
3863 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3864 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3865 $OPENFILE -f O_RDONLY $DIR/f34
3866 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3867 error "getstripe failed"
3868 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3869 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3871 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3874 [ ! -f $DIR/f34 ] && test_34a
3875 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3876 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3877 $OPENFILE -f O_RDWR $DIR/f34
3878 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3879 error "$LFS getstripe failed"
3880 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3881 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3883 run_test 34c "O_RDWR opening file-with-size works =============="
3886 [ ! -f $DIR/f34 ] && test_34a
3887 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3889 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3890 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3893 run_test 34d "write to sparse file ============================="
3897 $MCREATE $DIR/f34e || error "mcreate failed"
3898 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3899 $CHECKSTAT -s 1000 $DIR/f34e ||
3900 error "Size of $DIR/f34e not equal to 1000 bytes"
3901 $OPENFILE -f O_RDWR $DIR/f34e
3902 $CHECKSTAT -s 1000 $DIR/f34e ||
3903 error "Size of $DIR/f34e not equal to 1000 bytes"
3905 run_test 34e "create objects, some with size and some without =="
3907 test_34f() { # bug 6242, 6243
3908 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3912 $MCREATE $DIR/f34f || error "mcreate failed"
3913 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3914 dd if=$DIR/f34f of=$TMP/f34f
3915 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3916 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3917 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3918 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3919 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3921 run_test 34f "read from a file with no objects until EOF ======="
3924 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3926 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3928 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3929 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3930 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3931 cancel_lru_locks osc
3932 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3933 error "wrong size after lock cancel"
3935 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3936 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3937 error "expanding truncate failed"
3938 cancel_lru_locks osc
3939 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3940 error "wrong expanded size after lock cancel"
3942 run_test 34g "truncate long file ==============================="
3945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3950 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3951 sync # Flush the cache so that multiop below does not block on cache
3952 # flush when getting the group lock
3953 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3956 # Since just timed wait is not good enough, let's do a sync write
3957 # that way we are sure enough time for a roundtrip + processing
3958 # passed + 2 seconds of extra margin.
3959 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3963 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3964 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3968 local nsz=`stat -c %s $DIR/$tfile`
3969 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3971 run_test 34h "ftruncate file under grouplock should not block"
3974 cp /bin/sh $DIR/f35a
3976 chown $RUNAS_ID $DIR/f35a
3977 $RUNAS $DIR/f35a && error || true
3980 run_test 35a "exec file with mode 444 (should return and not leak)"
3984 utime $DIR/f36 || error "utime failed for MDS"
3986 run_test 36a "MDS utime check (mknod, utime)"
3990 utime $DIR/f36 || error "utime failed for OST"
3992 run_test 36b "OST utime check (open, utime)"
3997 chown $RUNAS_ID $DIR/d36
3998 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
4000 run_test 36c "non-root MDS utime check (mknod, utime)"
4003 [ ! -d $DIR/d36 ] && test_36c
4004 echo "" > $DIR/d36/f36
4005 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4007 run_test 36d "non-root OST utime check (open, utime)"
4010 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4012 test_mkdir $DIR/$tdir
4013 touch $DIR/$tdir/$tfile
4014 $RUNAS utime $DIR/$tdir/$tfile &&
4015 error "utime worked, expected failure" || true
4017 run_test 36e "utime on non-owned file (should return error)"
4021 local LANG_SAVE=$LANG
4022 local LC_LANG_SAVE=$LC_LANG
4023 export LANG=C LC_LANG=C # for date language
4025 DATESTR="Dec 20 2000"
4026 test_mkdir $DIR/$tdir
4027 lctl set_param fail_loc=$fl
4029 cp /etc/hosts $DIR/$tdir/$tfile
4030 sync & # write RPC generated with "current" inode timestamp, but delayed
4032 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4033 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4034 cancel_lru_locks $OSC
4035 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4037 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4038 echo "BEFORE: $LS_BEFORE" && \
4039 echo "AFTER : $LS_AFTER" && \
4040 echo "WANT : $DATESTR" && \
4041 error "$DIR/$tdir/$tfile timestamps changed" || true
4043 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4049 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4050 subr_36fh "0x80000214"
4052 run_test 36f "utime on file racing with OST BRW write =========="
4055 remote_ost_nodsh && skip "remote OST with nodsh"
4056 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4057 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4058 skip "Need MDS version at least 2.12.51"
4063 local tgt="obdfilter"
4065 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4067 test_mkdir $DIR/$tdir
4068 fmd_max_age=$(do_facet $facet \
4069 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4072 echo "FMD max age: ${fmd_max_age}s"
4073 touch $DIR/$tdir/$tfile
4074 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4075 gawk '{cnt=cnt+$1} END{print cnt}')
4076 echo "FMD before: $fmd"
4078 error "FMD wasn't create by touch"
4079 sleep $((fmd_max_age + 12))
4080 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4081 gawk '{cnt=cnt+$1} END{print cnt}')
4082 echo "FMD after: $fmd"
4084 error "FMD wasn't expired by ping"
4086 run_test 36g "FMD cache expiry ====================="
4089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4091 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4092 subr_36fh "0x80000227"
4094 run_test 36h "utime on file racing with OST BRW write =========="
4097 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4099 test_mkdir $DIR/$tdir
4100 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4102 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4103 local new_mtime=$((mtime + 200))
4105 #change Modify time of striped dir
4106 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4107 error "change mtime failed"
4109 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4111 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4113 run_test 36i "change mtime on striped directory"
4115 # test_37 - duplicate with tests 32q 32r
4118 local file=$DIR/$tfile
4120 openfile -f O_DIRECTORY $file
4123 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4124 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4126 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4128 test_39a() { # was test_39
4130 touch $DIR/${tfile}2
4131 # ls -l $DIR/$tfile $DIR/${tfile}2
4132 # ls -lu $DIR/$tfile $DIR/${tfile}2
4133 # ls -lc $DIR/$tfile $DIR/${tfile}2
4135 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4136 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4138 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4140 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4142 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4143 error "O_TRUNC didn't change timestamps"
4146 run_test 39a "mtime changed on create"
4149 test_mkdir -c1 $DIR/$tdir
4150 cp -p /etc/passwd $DIR/$tdir/fopen
4151 cp -p /etc/passwd $DIR/$tdir/flink
4152 cp -p /etc/passwd $DIR/$tdir/funlink
4153 cp -p /etc/passwd $DIR/$tdir/frename
4154 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4157 echo "aaaaaa" >> $DIR/$tdir/fopen
4158 echo "aaaaaa" >> $DIR/$tdir/flink
4159 echo "aaaaaa" >> $DIR/$tdir/funlink
4160 echo "aaaaaa" >> $DIR/$tdir/frename
4162 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4163 local link_new=`stat -c %Y $DIR/$tdir/flink`
4164 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4165 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4167 cat $DIR/$tdir/fopen > /dev/null
4168 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4169 rm -f $DIR/$tdir/funlink2
4170 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4172 for (( i=0; i < 2; i++ )) ; do
4173 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4174 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4175 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4176 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4178 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4179 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4180 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4181 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4183 cancel_lru_locks $OSC
4184 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4187 run_test 39b "mtime change on open, link, unlink, rename ======"
4189 # this should be set to past
4190 TEST_39_MTIME=`date -d "1 year ago" +%s`
4196 local mtime0=`stat -c %Y $DIR1/$tfile`
4198 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4199 local mtime1=`stat -c %Y $DIR1/$tfile`
4200 [ "$mtime1" = $TEST_39_MTIME ] || \
4201 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4204 echo hello >> $DIR1/$tfile
4206 local mtime2=`stat -c %Y $DIR1/$tfile`
4207 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4208 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4210 mv $DIR1/$tfile $DIR1/$tfile-1
4212 for (( i=0; i < 2; i++ )) ; do
4213 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4214 [ "$mtime2" = "$mtime3" ] || \
4215 error "mtime ($mtime2) changed (to $mtime3) on rename"
4217 cancel_lru_locks $OSC
4218 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4221 run_test 39c "mtime change on rename ==========================="
4225 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4228 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4230 for (( i=0; i < 2; i++ )) ; do
4231 local mtime=`stat -c %Y $DIR1/$tfile`
4232 [ $mtime = $TEST_39_MTIME ] || \
4233 error "mtime($mtime) is not set to $TEST_39_MTIME"
4235 cancel_lru_locks $OSC
4236 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4239 run_test 39d "create, utime, stat =============================="
4243 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4246 local mtime1=`stat -c %Y $DIR1/$tfile`
4248 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4250 for (( i=0; i < 2; i++ )) ; do
4251 local mtime2=`stat -c %Y $DIR1/$tfile`
4252 [ $mtime2 = $TEST_39_MTIME ] || \
4253 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4255 cancel_lru_locks $OSC
4256 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4259 run_test 39e "create, stat, utime, stat ========================"
4263 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4266 mtime1=`stat -c %Y $DIR1/$tfile`
4269 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4271 for (( i=0; i < 2; i++ )) ; do
4272 local mtime2=`stat -c %Y $DIR1/$tfile`
4273 [ $mtime2 = $TEST_39_MTIME ] || \
4274 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4276 cancel_lru_locks $OSC
4277 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4280 run_test 39f "create, stat, sleep, utime, stat ================="
4284 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4286 echo hello >> $DIR1/$tfile
4287 local mtime1=`stat -c %Y $DIR1/$tfile`
4290 chmod o+r $DIR1/$tfile
4292 for (( i=0; i < 2; i++ )) ; do
4293 local mtime2=`stat -c %Y $DIR1/$tfile`
4294 [ "$mtime1" = "$mtime2" ] || \
4295 error "lost mtime: $mtime2, should be $mtime1"
4297 cancel_lru_locks $OSC
4298 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4301 run_test 39g "write, chmod, stat ==============================="
4305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4311 echo hello >> $DIR1/$tfile
4312 local mtime1=`stat -c %Y $DIR1/$tfile`
4314 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4316 if [ "$d1" != "$d2" ]; then
4317 echo "write and touch not within one second"
4319 for (( i=0; i < 2; i++ )) ; do
4320 local mtime2=`stat -c %Y $DIR1/$tfile`
4321 [ "$mtime2" = $TEST_39_MTIME ] || \
4322 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4324 cancel_lru_locks $OSC
4325 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4329 run_test 39h "write, utime within one second, stat ============="
4332 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4337 echo hello >> $DIR1/$tfile
4338 local mtime1=`stat -c %Y $DIR1/$tfile`
4340 mv $DIR1/$tfile $DIR1/$tfile-1
4342 for (( i=0; i < 2; i++ )) ; do
4343 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4345 [ "$mtime1" = "$mtime2" ] || \
4346 error "lost mtime: $mtime2, should be $mtime1"
4348 cancel_lru_locks $OSC
4349 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4352 run_test 39i "write, rename, stat =============================="
4355 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4357 start_full_debug_logging
4361 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4362 lctl set_param fail_loc=0x80000412
4363 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4364 error "multiop failed"
4366 local mtime1=`stat -c %Y $DIR1/$tfile`
4368 mv $DIR1/$tfile $DIR1/$tfile-1
4370 kill -USR1 $multipid
4371 wait $multipid || error "multiop close failed"
4373 for (( i=0; i < 2; i++ )) ; do
4374 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4375 [ "$mtime1" = "$mtime2" ] ||
4376 error "mtime is lost on close: $mtime2, " \
4380 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4382 lctl set_param fail_loc=0
4383 stop_full_debug_logging
4385 run_test 39j "write, rename, close, stat ======================="
4388 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4393 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4395 local mtime1=`stat -c %Y $DIR1/$tfile`
4397 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4399 kill -USR1 $multipid
4400 wait $multipid || error "multiop close failed"
4402 for (( i=0; i < 2; i++ )) ; do
4403 local mtime2=`stat -c %Y $DIR1/$tfile`
4405 [ "$mtime2" = $TEST_39_MTIME ] || \
4406 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4409 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4412 run_test 39k "write, utime, close, stat ========================"
4414 # this should be set to future
4415 TEST_39_ATIME=`date -d "1 year" +%s`
4418 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4419 remote_mds_nodsh && skip "remote MDS with nodsh"
4421 local atime_diff=$(do_facet $SINGLEMDS \
4422 lctl get_param -n mdd.*MDT0000*.atime_diff)
4426 # test setting directory atime to future
4427 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4428 local atime=$(stat -c %X $DIR/$tdir)
4429 [ "$atime" = $TEST_39_ATIME ] ||
4430 error "atime is not set to future: $atime, $TEST_39_ATIME"
4432 # test setting directory atime from future to now
4433 local now=$(date +%s)
4434 touch -a -d @$now $DIR/$tdir
4436 atime=$(stat -c %X $DIR/$tdir)
4437 [ "$atime" -eq "$now" ] ||
4438 error "atime is not updated from future: $atime, $now"
4440 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4443 # test setting directory atime when now > dir atime + atime_diff
4444 local d1=$(date +%s)
4446 local d2=$(date +%s)
4447 cancel_lru_locks mdc
4448 atime=$(stat -c %X $DIR/$tdir)
4449 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4450 error "atime is not updated : $atime, should be $d2"
4452 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4455 # test not setting directory atime when now < dir atime + atime_diff
4457 cancel_lru_locks mdc
4458 atime=$(stat -c %X $DIR/$tdir)
4459 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4460 error "atime is updated to $atime, should remain $d1<atime<$d2"
4462 do_facet $SINGLEMDS \
4463 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4465 run_test 39l "directory atime update ==========================="
4468 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4472 local far_past_mtime=$(date -d "May 29 1953" +%s)
4473 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4475 touch -m -d @$far_past_mtime $DIR1/$tfile
4476 touch -a -d @$far_past_atime $DIR1/$tfile
4478 for (( i=0; i < 2; i++ )) ; do
4479 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4480 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4481 error "atime or mtime set incorrectly"
4483 cancel_lru_locks $OSC
4484 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4487 run_test 39m "test atime and mtime before 1970"
4489 test_39n() { # LU-3832
4490 remote_mds_nodsh && skip "remote MDS with nodsh"
4492 local atime_diff=$(do_facet $SINGLEMDS \
4493 lctl get_param -n mdd.*MDT0000*.atime_diff)
4498 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4501 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4502 atime0=$(stat -c %X $DIR/$tfile)
4505 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4506 atime1=$(stat -c %X $DIR/$tfile)
4509 cancel_lru_locks mdc
4510 cancel_lru_locks osc
4511 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4512 atime2=$(stat -c %X $DIR/$tfile)
4514 do_facet $SINGLEMDS \
4515 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4517 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4518 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4520 run_test 39n "check that O_NOATIME is honored"
4523 TESTDIR=$DIR/$tdir/$tfile
4524 [ -e $TESTDIR ] && rm -rf $TESTDIR
4531 links2=$(stat -c %h .)
4532 [ $(($links1 + 2)) != $links2 ] &&
4533 error "wrong links count $(($links1 + 2)) != $links2"
4535 links3=$(stat -c %h .)
4536 [ $(($links1 + 1)) != $links3 ] &&
4537 error "wrong links count $links1 != $links3"
4540 run_test 39o "directory cached attributes updated after create"
4543 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4546 TESTDIR=$DIR/$tdir/$tdir
4547 [ -e $TESTDIR ] && rm -rf $TESTDIR
4548 test_mkdir -p $TESTDIR
4552 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4553 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4555 links2=$(stat -c %h .)
4556 [ $(($links1 + 2)) != $links2 ] &&
4557 error "wrong links count $(($links1 + 2)) != $links2"
4559 links3=$(stat -c %h .)
4560 [ $(($links1 + 1)) != $links3 ] &&
4561 error "wrong links count $links1 != $links3"
4564 run_test 39p "remote directory cached attributes updated after create ========"
4567 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
4568 skip "no atime update on old OST"
4569 if [ "$ost1_FSTYPE" != ldiskfs ]; then
4570 skip_env "ldiskfs only test"
4574 saved_adiff=$(do_facet ost1 \
4575 lctl get_param -n obdfilter.*OST0000.atime_diff)
4576 stack_trap "do_facet ost1 \
4577 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
4579 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
4581 $LFS setstripe -i 0 $DIR/$tfile
4582 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
4583 error "can't write initial file"
4584 cancel_lru_locks osc
4586 # exceed atime_diff and access file
4588 dd if=$DIR/$tfile of=/dev/null || error "can't udpate atime"
4590 local atime_cli=$(stat -c %X $DIR/$tfile)
4591 echo "client atime: $atime_cli"
4592 # allow atime update to be written to device
4593 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
4596 local ostdev=$(ostdevname 1)
4597 local fid=($(lfs getstripe -y $DIR/$tfile |
4598 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
4599 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
4600 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
4602 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
4603 local atime_ost=$(do_facet ost1 "$cmd" |&
4604 awk -F'[: ]' '/atime:/ { print $4 }')
4605 (( atime_cli == atime_ost )) ||
4606 error "atime on client $atime_cli != ost $atime_ost"
4608 run_test 39r "lazy atime update on OST"
4610 test_39q() { # LU-8041
4611 local testdir=$DIR/$tdir
4613 multiop_bg_pause $testdir D_c || error "multiop failed"
4615 cancel_lru_locks mdc
4616 kill -USR1 $multipid
4617 local atime=$(stat -c %X $testdir)
4618 [ "$atime" -ne 0 ] || error "atime is zero"
4620 run_test 39q "close won't zero out atime"
4623 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4624 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4625 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4626 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4627 error "$tfile is not 4096 bytes in size"
4629 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4633 small_write $DIR/f41 18
4635 run_test 41 "test small file write + fstat ====================="
4637 count_ost_writes() {
4638 lctl get_param -n ${OSC}.*.stats |
4639 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4640 END { printf("%0.0f", writes) }'
4647 BG_DIRTY_RATIO_SAVE=10
4648 MAX_BG_DIRTY_RATIO=25
4652 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4653 # dirty_ratio, dirty_background_ratio
4654 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4655 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4656 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4657 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4659 # if file not here, we are a 2.4 kernel
4660 kill -CONT `pidof kupdated`
4665 # setup the trap first, so someone cannot exit the test at the
4666 # exact wrong time and mess up a machine
4667 trap start_writeback EXIT
4668 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4669 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4670 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4671 sysctl -w vm.dirty_writeback_centisecs=0
4672 sysctl -w vm.dirty_writeback_centisecs=0
4673 # save and increase /proc/sys/vm/dirty_ratio
4674 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4675 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4676 # save and increase /proc/sys/vm/dirty_background_ratio
4677 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4678 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4680 # if file not here, we are a 2.4 kernel
4681 kill -STOP `pidof kupdated`
4685 # ensure that all stripes have some grant before we test client-side cache
4687 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4688 dd if=/dev/zero of=$i bs=4k count=1
4693 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4694 # file truncation, and file removal.
4696 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4699 cancel_lru_locks $OSC
4701 sync; sleep 1; sync # just to be safe
4702 BEFOREWRITES=`count_ost_writes`
4703 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4704 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4705 AFTERWRITES=`count_ost_writes`
4706 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4707 error "$BEFOREWRITES < $AFTERWRITES"
4710 run_test 42a "ensure that we don't flush on close"
4713 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4716 cancel_lru_locks $OSC
4719 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4720 BEFOREWRITES=$(count_ost_writes)
4721 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4722 AFTERWRITES=$(count_ost_writes)
4723 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4724 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4726 BEFOREWRITES=$(count_ost_writes)
4727 sync || error "sync: $?"
4728 AFTERWRITES=$(count_ost_writes)
4729 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4730 error "$BEFOREWRITES < $AFTERWRITES on sync"
4732 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4736 run_test 42b "test destroy of file with cached dirty data ======"
4738 # if these tests just want to test the effect of truncation,
4739 # they have to be very careful. consider:
4740 # - the first open gets a {0,EOF}PR lock
4741 # - the first write conflicts and gets a {0, count-1}PW
4742 # - the rest of the writes are under {count,EOF}PW
4743 # - the open for truncate tries to match a {0,EOF}PR
4744 # for the filesize and cancels the PWs.
4745 # any number of fixes (don't get {0,EOF} on open, match
4746 # composite locks, do smarter file size management) fix
4747 # this, but for now we want these tests to verify that
4748 # the cancellation with truncate intent works, so we
4749 # start the file with a full-file pw lock to match against
4750 # until the truncate.
4755 cancel_lru_locks $OSC
4757 # prime the file with 0,EOF PW to match
4761 # now the real test..
4762 dd if=/dev/zero of=$file bs=1024 count=100
4763 BEFOREWRITES=`count_ost_writes`
4764 $TRUNCATE $file $offset
4765 cancel_lru_locks $OSC
4766 AFTERWRITES=`count_ost_writes`
4771 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4774 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4775 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4778 run_test 42c "test partial truncate of file with cached dirty data"
4781 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4784 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4785 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4788 run_test 42d "test complete truncate of file with cached dirty data"
4790 test_42e() { # bug22074
4791 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4793 local TDIR=$DIR/${tdir}e
4794 local pages=16 # hardcoded 16 pages, don't change it.
4795 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4796 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4800 test_mkdir $DIR/${tdir}e
4801 $LFS setstripe -c 1 $TDIR
4802 createmany -o $TDIR/f $files
4804 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4806 # we assume that with $OSTCOUNT files, at least one of them will
4807 # be allocated on OST0.
4808 warmup_files=$((OSTCOUNT * max_dirty_mb))
4809 createmany -o $TDIR/w $warmup_files
4811 # write a large amount of data into one file and sync, to get good
4812 # avail_grant number from OST.
4813 for ((i=0; i<$warmup_files; i++)); do
4814 idx=$($LFS getstripe -i $TDIR/w$i)
4815 [ $idx -ne 0 ] && continue
4816 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4819 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4821 $LCTL get_param $proc_osc0/cur_dirty_bytes
4822 $LCTL get_param $proc_osc0/cur_grant_bytes
4824 # create as much dirty pages as we can while not to trigger the actual
4825 # RPCs directly. but depends on the env, VFS may trigger flush during this
4826 # period, hopefully we are good.
4827 for ((i=0; i<$warmup_files; i++)); do
4828 idx=$($LFS getstripe -i $TDIR/w$i)
4829 [ $idx -ne 0 ] && continue
4830 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4832 $LCTL get_param $proc_osc0/cur_dirty_bytes
4833 $LCTL get_param $proc_osc0/cur_grant_bytes
4835 # perform the real test
4836 $LCTL set_param $proc_osc0/rpc_stats 0
4837 for ((;i<$files; i++)); do
4838 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
4839 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4842 $LCTL get_param $proc_osc0/rpc_stats
4845 local have_ppr=false
4846 $LCTL get_param $proc_osc0/rpc_stats |
4847 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4848 # skip lines until we are at the RPC histogram data
4849 [ "$PPR" == "pages" ] && have_ppr=true && continue
4850 $have_ppr || continue
4852 # we only want the percent stat for < 16 pages
4853 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4855 percent=$((percent + WPCT))
4856 if [[ $percent -gt 15 ]]; then
4857 error "less than 16-pages write RPCs" \
4864 run_test 42e "verify sub-RPC writes are not done synchronously"
4866 test_43A() { # was test_43
4867 test_mkdir $DIR/$tdir
4868 cp -p /bin/ls $DIR/$tdir/$tfile
4869 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4871 # give multiop a chance to open
4874 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4877 run_test 43A "execution of file opened for write should return -ETXTBSY"
4880 test_mkdir $DIR/$tdir
4881 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4882 $DIR/$tdir/sleep 60 &
4884 # Make sure exec of $tdir/sleep wins race with truncate
4886 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4889 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4892 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4894 test_mkdir $DIR/$tdir
4895 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4896 $DIR/$tdir/sleep 60 &
4898 # Make sure exec of $tdir/sleep wins race with truncate
4900 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4903 run_test 43b "truncate of file being executed should return -ETXTBSY"
4906 local testdir="$DIR/$tdir"
4909 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4910 ( cd $testdir && md5sum -c )
4912 run_test 43c "md5sum of copy into lustre"
4914 test_44A() { # was test_44
4915 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4917 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4918 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4920 run_test 44A "zero length read from a sparse stripe"
4923 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4925 [ -z "$nstripe" ] && skip "can't get stripe info"
4926 [[ $nstripe -gt $OSTCOUNT ]] &&
4927 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4929 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4931 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4932 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4936 OFFSETS="0 $((stride/2)) $((stride-1))"
4937 for offset in $OFFSETS; do
4938 for i in $(seq 0 $((nstripe-1))); do
4939 local GLOBALOFFSETS=""
4941 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4942 local myfn=$DIR/d44a-$size
4943 echo "--------writing $myfn at $size"
4944 ll_sparseness_write $myfn $size ||
4945 error "ll_sparseness_write"
4946 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4947 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4948 error "ll_sparseness_verify $GLOBALOFFSETS"
4950 for j in $(seq 0 $((nstripe-1))); do
4952 size=$((((j + $nstripe )*$stride + $offset)))
4953 ll_sparseness_write $myfn $size ||
4954 error "ll_sparseness_write"
4955 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4957 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4958 error "ll_sparseness_verify $GLOBALOFFSETS"
4963 run_test 44a "test sparse pwrite ==============================="
4967 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4973 before=`dirty_osc_total`
4974 echo executing "\"$*\""
4976 after=`dirty_osc_total`
4977 echo before $before, after $after
4980 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4983 # Obtain grants from OST if it supports it
4984 echo blah > ${f}_grant
4987 do_dirty_record "echo blah > $f"
4988 [[ $before -eq $after ]] && error "write wasn't cached"
4989 do_dirty_record "> $f"
4990 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4991 do_dirty_record "echo blah > $f"
4992 [[ $before -eq $after ]] && error "write wasn't cached"
4993 do_dirty_record "sync"
4994 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4995 do_dirty_record "echo blah > $f"
4996 [[ $before -eq $after ]] && error "write wasn't cached"
4997 do_dirty_record "cancel_lru_locks osc"
4998 [[ $before -gt $after ]] ||
4999 error "lock cancellation didn't lower dirty count"
5002 run_test 45 "osc io page accounting ============================"
5004 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5005 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5006 # objects offset and an assert hit when an rpc was built with 1023's mapped
5007 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5009 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5014 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5016 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5017 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5021 run_test 46 "dirtying a previously written page ================"
5023 # test_47 is removed "Device nodes check" is moved to test_28
5025 test_48a() { # bug 2399
5026 [ "$mds1_FSTYPE" = "zfs" ] &&
5027 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5028 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5030 test_mkdir $DIR/$tdir
5032 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5033 test_mkdir $DIR/$tdir
5034 touch foo || error "'touch foo' failed after recreating cwd"
5036 touch .foo || error "'touch .foo' failed after recreating cwd"
5038 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5039 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5040 cd . || error "'cd .' failed after recreating cwd"
5041 mkdir . && error "'mkdir .' worked after recreating cwd"
5042 rmdir . && error "'rmdir .' worked after recreating cwd"
5043 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5044 cd .. || error "'cd ..' failed after recreating cwd"
5046 run_test 48a "Access renamed working dir (should return errors)="
5048 test_48b() { # bug 2399
5050 test_mkdir $DIR/$tdir
5052 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5053 touch foo && error "'touch foo' worked after removing cwd"
5054 mkdir foo && error "'mkdir foo' worked after removing cwd"
5055 touch .foo && error "'touch .foo' worked after removing cwd"
5056 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5057 ls . > /dev/null && error "'ls .' worked after removing cwd"
5058 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5059 mkdir . && error "'mkdir .' worked after removing cwd"
5060 rmdir . && error "'rmdir .' worked after removing cwd"
5061 ln -s . foo && error "'ln -s .' worked after removing cwd"
5062 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5064 run_test 48b "Access removed working dir (should return errors)="
5066 test_48c() { # bug 2350
5067 #lctl set_param debug=-1
5070 test_mkdir -p $DIR/$tdir/dir
5072 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5073 $TRACE touch foo && error "touch foo worked after removing cwd"
5074 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5075 touch .foo && error "touch .foo worked after removing cwd"
5076 mkdir .foo && error "mkdir .foo worked after removing cwd"
5077 $TRACE ls . && error "'ls .' worked after removing cwd"
5078 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5079 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5080 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5081 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5082 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5084 run_test 48c "Access removed working subdir (should return errors)"
5086 test_48d() { # bug 2350
5087 #lctl set_param debug=-1
5090 test_mkdir -p $DIR/$tdir/dir
5092 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5093 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5094 $TRACE touch foo && error "'touch foo' worked after removing parent"
5095 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5096 touch .foo && error "'touch .foo' worked after removing parent"
5097 mkdir .foo && error "mkdir .foo worked after removing parent"
5098 $TRACE ls . && error "'ls .' worked after removing parent"
5099 $TRACE ls .. && error "'ls ..' worked after removing parent"
5100 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5101 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5102 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5105 run_test 48d "Access removed parent subdir (should return errors)"
5107 test_48e() { # bug 4134
5108 #lctl set_param debug=-1
5111 test_mkdir -p $DIR/$tdir/dir
5113 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5114 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5115 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5116 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5117 # On a buggy kernel addition of "touch foo" after cd .. will
5118 # produce kernel oops in lookup_hash_it
5119 touch ../foo && error "'cd ..' worked after recreate parent"
5121 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5123 run_test 48e "Access to recreated parent subdir (should return errors)"
5125 test_49() { # LU-1030
5126 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5127 remote_ost_nodsh && skip "remote OST with nodsh"
5129 # get ost1 size - $FSNAME-OST0000
5130 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5132 # write 800M at maximum
5133 [[ $ost1_size -lt 2 ]] && ost1_size=2
5134 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5136 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5137 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5140 # change max_pages_per_rpc while writing the file
5141 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5142 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5143 # loop until dd process exits
5144 while ps ax -opid | grep -wq $dd_pid; do
5145 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5146 sleep $((RANDOM % 5 + 1))
5148 # restore original max_pages_per_rpc
5149 $LCTL set_param $osc1_mppc=$orig_mppc
5150 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5152 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5156 test_mkdir $DIR/$tdir
5158 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5160 run_test 50 "special situations: /proc symlinks ==============="
5162 test_51a() { # was test_51
5163 # bug 1516 - create an empty entry right after ".." then split dir
5164 test_mkdir -c1 $DIR/$tdir
5165 touch $DIR/$tdir/foo
5166 $MCREATE $DIR/$tdir/bar
5168 createmany -m $DIR/$tdir/longfile 201
5170 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5171 $MCREATE $DIR/$tdir/longfile$FNUM
5176 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5178 run_test 51a "special situations: split htree with empty entry =="
5180 cleanup_print_lfs_df () {
5187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5189 local dir=$DIR/$tdir
5190 local nrdirs=$((65536 + 100))
5192 # cleanup the directory
5199 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5200 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5201 [[ $numfree -lt $nrdirs ]] &&
5202 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5204 # need to check free space for the directories as well
5205 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5206 numfree=$(( blkfree / $(fs_inode_ksize) ))
5207 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5209 trap cleanup_print_lfs_df EXIT
5212 createmany -d $dir/d $nrdirs || {
5213 unlinkmany $dir/d $nrdirs
5214 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5218 nrdirs=$(ls -U $dir | wc -l)
5220 # unlink all but 100 subdirectories, then check it still works
5222 local delete=$((nrdirs - left))
5227 # for ldiskfs the nlink count should be 1, but this is OSD specific
5228 # and so this is listed for informational purposes only
5229 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5230 unlinkmany -d $dir/d $delete ||
5231 error "unlink of first $delete subdirs failed"
5233 echo "nlink between: $(stat -c %h $dir)"
5234 local found=$(ls -U $dir | wc -l)
5235 [ $found -ne $left ] &&
5236 error "can't find subdirs: found only $found, expected $left"
5238 unlinkmany -d $dir/d $delete $left ||
5239 error "unlink of second $left subdirs failed"
5240 # regardless of whether the backing filesystem tracks nlink accurately
5241 # or not, the nlink count shouldn't be more than "." and ".." here
5242 local after=$(stat -c %h $dir)
5243 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5244 echo "nlink after: $after"
5246 cleanup_print_lfs_df
5248 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5251 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5252 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5254 test_mkdir $DIR/$tdir
5255 createmany -o $DIR/$tdir/t- 1000
5256 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5257 for N in $(seq 0 $((OSTCOUNT - 1))); do
5258 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
5259 END { printf("%0.0f", objs) }' $TMP/$tfile)
5260 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5261 '($1 == '$N') { objs += 1 } \
5262 END { printf("%0.0f", objs) }')
5263 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
5265 unlinkmany $DIR/$tdir/t- 1000
5268 for N in $(seq 1 $((OSTCOUNT - 1))); do
5269 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
5270 error "OST $N has less objects vs OST $NLAST" \
5271 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5272 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
5273 error "OST $N has less objects vs OST $NLAST" \
5274 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5276 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
5277 error "OST $N has less #0 objects vs OST $NLAST" \
5278 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5279 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
5280 error "OST $N has less #0 objects vs OST $NLAST" \
5281 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5286 run_test 51d "check object distribution"
5289 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5290 skip_env "ldiskfs only test"
5293 test_mkdir -c1 $DIR/$tdir
5294 test_mkdir -c1 $DIR/$tdir/d0
5296 touch $DIR/$tdir/d0/foo
5297 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5298 error "file exceed 65000 nlink limit!"
5299 unlinkmany $DIR/$tdir/d0/f- 65001
5302 run_test 51e "check file nlink limit"
5305 test_mkdir $DIR/$tdir
5308 local ulimit_old=$(ulimit -n)
5309 local spare=20 # number of spare fd's for scripts/libraries, etc.
5310 local mdt=$($LFS getstripe -m $DIR/$tdir)
5311 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5313 echo "MDT$mdt numfree=$numfree, max=$max"
5314 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5315 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5316 while ! ulimit -n $((numfree + spare)); do
5317 numfree=$((numfree * 3 / 4))
5319 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5321 echo "left ulimit at $ulimit_old"
5324 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5325 unlinkmany $DIR/$tdir/f $numfree
5326 error "create+open $numfree files in $DIR/$tdir failed"
5328 ulimit -n $ulimit_old
5330 # if createmany exits at 120s there will be fewer than $numfree files
5331 unlinkmany $DIR/$tdir/f $numfree || true
5333 run_test 51f "check many open files limit"
5336 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5337 test_mkdir $DIR/$tdir
5338 touch $DIR/$tdir/foo
5339 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5340 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5341 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5342 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5343 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5345 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5346 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5347 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5349 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5350 cp -r $DIR/$tdir $TMP/
5351 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5353 run_test 52a "append-only flag test (should return errors)"
5356 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5357 test_mkdir $DIR/$tdir
5358 touch $DIR/$tdir/foo
5359 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5360 cat test > $DIR/$tdir/foo && error "cat test worked"
5361 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5362 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5363 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5365 echo foo >> $DIR/$tdir/foo && error "echo worked"
5366 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5367 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5368 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5369 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5371 chattr -i $DIR/$tdir/foo || error "chattr failed"
5373 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5375 run_test 52b "immutable flag test (should return errors) ======="
5378 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5379 remote_mds_nodsh && skip "remote MDS with nodsh"
5380 remote_ost_nodsh && skip "remote OST with nodsh"
5393 local support_last_seq=true
5395 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5396 support_last_seq=false
5399 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5401 for value in $(do_facet $SINGLEMDS \
5402 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5403 param=$(echo ${value[0]} | cut -d "=" -f1)
5404 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5406 if $support_last_seq; then
5407 param_seq=$(echo $param |
5408 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5409 mds_last_seq=$(do_facet $SINGLEMDS \
5410 $LCTL get_param -n $param_seq)
5412 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5414 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5415 node=$(facet_active_host ost$((ostnum+1)))
5416 param="obdfilter.$ostname.last_id"
5417 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5418 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5419 ost_last_id=$ost_last
5421 if $support_last_seq; then
5422 ost_last_id=$(echo $ost_last |
5423 awk -F':' '{print $2}' |
5425 ost_last_seq=$(echo $ost_last |
5426 awk -F':' '{print $1}')
5427 [[ $ost_last_seq = $mds_last_seq ]] || continue
5430 if [[ $ost_last_id != $mds_last ]]; then
5431 error "$ost_last_id != $mds_last"
5438 $found || error "can not match last_seq/last_id for $mdtosc"
5441 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5444 perl -MSocket -e ';' || skip "no Socket perl module installed"
5446 $SOCKETSERVER $DIR/socket ||
5447 error "$SOCKETSERVER $DIR/socket failed: $?"
5448 $SOCKETCLIENT $DIR/socket ||
5449 error "$SOCKETCLIENT $DIR/socket failed: $?"
5450 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5452 run_test 54a "unix domain socket test =========================="
5458 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5460 run_test 54b "char device works in lustre ======================"
5463 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5464 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5465 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5467 for i in $(seq 3 7); do
5468 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5477 loopdev="$DIR/loop54c"
5480 $UMOUNT $DIR/$tdir || rc=$?
5481 losetup -d $loopdev || true
5482 losetup -d $LOOPDEV || true
5483 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5488 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5490 loopdev="$DIR/loop54c"
5493 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5494 trap cleanup_54c EXIT
5495 mknod $loopdev b 7 $LOOPNUM
5496 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5497 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5498 losetup $loopdev $DIR/$tfile ||
5499 error "can't set up $loopdev for $DIR/$tfile"
5500 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5501 test_mkdir $DIR/$tdir
5502 mount -t ext2 $loopdev $DIR/$tdir ||
5503 error "error mounting $loopdev on $DIR/$tdir"
5504 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
5507 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
5511 run_test 54c "block device works in lustre ====================="
5517 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
5519 run_test 54d "fifo device works in lustre ======================"
5524 cp -aL /dev/console $f
5525 echo $string > $f || error "echo $string to $f failed"
5527 run_test 54e "console/tty device works in lustre ======================"
5531 local dir=$DIR/$tdir
5534 test_mkdir -p $dir/dir
5535 for i in $(seq $numfiles); do
5537 touch $dir/dir/file$i
5540 local numcomp=$($LFS getstripe --component-count $dir)
5542 [[ $numcomp == 0 ]] && numcomp=1
5544 # test lfs getstripe with --recursive
5545 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5547 [[ $filenum -eq $((numfiles * 2)) ]] ||
5548 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5549 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5550 [[ $filenum -eq $numfiles ]] ||
5551 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5552 echo "$LFS getstripe showed obdidx or l_ost_idx"
5554 # test lfs getstripe with file instead of dir
5555 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5556 [[ $filenum -eq 1 ]] ||
5557 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5558 echo "$LFS getstripe file1 passed"
5560 #test lfs getstripe with --verbose
5561 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5562 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5563 error "$LFS getstripe --verbose $dir: "\
5564 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5565 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5566 error "$LFS getstripe $dir: showed lmm_magic"
5568 #test lfs getstripe with -v prints lmm_fid
5569 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5570 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5571 error "$LFS getstripe -v $dir: "\
5572 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5573 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5574 error "$LFS getstripe $dir: showed lmm_fid by default"
5575 echo "$LFS getstripe --verbose passed"
5577 #check for FID information
5578 local fid1=$($LFS getstripe --fid $dir/file1)
5579 local fid2=$($LFS getstripe --verbose $dir/file1 |
5580 awk '/lmm_fid: / { print $2; exit; }')
5581 local fid3=$($LFS path2fid $dir/file1)
5583 [ "$fid1" != "$fid2" ] &&
5584 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5585 [ "$fid1" != "$fid3" ] &&
5586 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5587 echo "$LFS getstripe --fid passed"
5589 #test lfs getstripe with --obd
5590 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5591 error "$LFS getstripe --obd wrong_uuid: should return error"
5593 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5596 local obduuid=$(ostuuid_from_index $ostidx)
5597 local found=$($LFS getstripe -r --obd $obduuid $dir |
5598 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5600 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5601 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5603 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5606 [[ $found -eq $filenum ]] ||
5607 error "$LFS getstripe --obd: found $found expect $filenum"
5608 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5609 sed '/^[ ]*'${ostidx}'[ ]/d' |
5610 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5611 error "$LFS getstripe --obd: should not show file on other obd"
5612 echo "$LFS getstripe --obd passed"
5614 run_test 56a "check $LFS getstripe"
5617 local dir=$DIR/$tdir
5621 for i in $(seq $numdirs); do
5622 test_mkdir $dir/dir$i
5625 # test lfs getdirstripe default mode is non-recursion, which is
5626 # different from lfs getstripe
5627 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5629 [[ $dircnt -eq 1 ]] ||
5630 error "$LFS getdirstripe: found $dircnt, not 1"
5631 dircnt=$($LFS getdirstripe --recursive $dir |
5632 grep -c lmv_stripe_count)
5633 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5634 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5636 run_test 56b "check $LFS getdirstripe"
5639 remote_ost_nodsh && skip "remote OST with nodsh"
5642 local ost_name=$(ostname_from_index $ost_idx)
5643 local old_status=$(ost_dev_status $ost_idx)
5644 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
5646 [[ -z "$old_status" ]] ||
5647 skip_env "OST $ost_name is in $old_status status"
5649 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5650 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
5651 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
5652 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
5653 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
5654 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
5657 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
5658 error "$LFS df -v showing inactive devices"
5661 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
5663 [[ "$new_status" =~ "D" ]] ||
5664 error "$ost_name status is '$new_status', missing 'D'"
5665 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
5666 [[ "$new_status" =~ "N" ]] ||
5667 error "$ost_name status is '$new_status', missing 'N'"
5669 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
5670 [[ "$new_status" =~ "f" ]] ||
5671 error "$ost_name status is '$new_status', missing 'f'"
5674 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5675 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
5676 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
5677 [[ -z "$p" ]] && restore_lustre_params < $p || true
5680 new_status=$(ost_dev_status $ost_idx)
5681 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
5682 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
5683 # can't check 'f' as devices may actually be on flash
5685 run_test 56c "check 'lfs df' showing device status"
5688 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
5689 local osts=$($LFS df -v $MOUNT | grep -c OST)
5693 (( mdts == MDSCOUNT )) ||
5694 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
5695 (( osts == OSTCOUNT )) ||
5696 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
5698 run_test 56d "'lfs df -v' prints only configured devices"
5703 local local_tdir="$1"
5704 local local_numfiles="$2"
5705 local local_numdirs="$3"
5706 local dir_params="$4"
5707 local dir_stripe_params="$5"
5709 if [ ! -d "$local_tdir" ] ; then
5710 test_mkdir -p $dir_stripe_params $local_tdir
5711 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5712 for i in $(seq $local_numfiles) ; do
5713 touch $local_tdir/file$i
5715 for i in $(seq $local_numdirs) ; do
5716 test_mkdir $dir_stripe_params $local_tdir/dir$i
5717 for j in $(seq $local_numfiles) ; do
5718 touch $local_tdir/dir$i/file$j
5724 setup_56_special() {
5726 local local_numfiles=$2
5727 local local_numdirs=$3
5729 setup_56 $local_tdir $local_numfiles $local_numdirs
5731 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5732 for i in $(seq $local_numfiles) ; do
5733 mknod $local_tdir/loop${i}b b 7 $i
5734 mknod $local_tdir/null${i}c c 1 3
5735 ln -s $local_tdir/file1 $local_tdir/link${i}
5737 for i in $(seq $local_numdirs) ; do
5738 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5739 mknod $local_tdir/dir$i/null${i}c c 1 3
5740 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5746 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5747 local expected=$(($NUMDIRS + 2))
5749 setup_56 $dir $NUMFILES $NUMDIRS
5751 # test lfs find with -name
5752 for i in $(seq $NUMFILES) ; do
5753 local nums=$($LFS find -name "*$i" $dir | wc -l)
5755 [ $nums -eq $expected ] ||
5756 error "lfs find -name '*$i' $dir wrong: "\
5757 "found $nums, expected $expected"
5760 run_test 56g "check lfs find -name"
5763 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5764 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5766 setup_56 $dir $NUMFILES $NUMDIRS
5768 # test lfs find with ! -name
5769 for i in $(seq $NUMFILES) ; do
5770 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5772 [ $nums -eq $expected ] ||
5773 error "lfs find ! -name '*$i' $dir wrong: "\
5774 "found $nums, expected $expected"
5777 run_test 56h "check lfs find ! -name"
5780 local dir=$DIR/$tdir
5784 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5787 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5789 run_test 56i "check 'lfs find -ost UUID' skips directories"
5792 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5794 setup_56_special $dir $NUMFILES $NUMDIRS
5796 local expected=$((NUMDIRS + 1))
5797 local cmd="$LFS find -type d $dir"
5798 local nums=$($cmd | wc -l)
5800 [ $nums -eq $expected ] ||
5801 error "'$cmd' wrong: found $nums, expected $expected"
5803 run_test 56j "check lfs find -type d"
5806 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5808 setup_56_special $dir $NUMFILES $NUMDIRS
5810 local expected=$(((NUMDIRS + 1) * NUMFILES))
5811 local cmd="$LFS find -type f $dir"
5812 local nums=$($cmd | wc -l)
5814 [ $nums -eq $expected ] ||
5815 error "'$cmd' wrong: found $nums, expected $expected"
5817 run_test 56k "check lfs find -type f"
5820 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5822 setup_56_special $dir $NUMFILES $NUMDIRS
5824 local expected=$((NUMDIRS + NUMFILES))
5825 local cmd="$LFS find -type b $dir"
5826 local nums=$($cmd | wc -l)
5828 [ $nums -eq $expected ] ||
5829 error "'$cmd' wrong: found $nums, expected $expected"
5831 run_test 56l "check lfs find -type b"
5834 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5836 setup_56_special $dir $NUMFILES $NUMDIRS
5838 local expected=$((NUMDIRS + NUMFILES))
5839 local cmd="$LFS find -type c $dir"
5840 local nums=$($cmd | wc -l)
5841 [ $nums -eq $expected ] ||
5842 error "'$cmd' wrong: found $nums, expected $expected"
5844 run_test 56m "check lfs find -type c"
5847 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5848 setup_56_special $dir $NUMFILES $NUMDIRS
5850 local expected=$((NUMDIRS + NUMFILES))
5851 local cmd="$LFS find -type l $dir"
5852 local nums=$($cmd | wc -l)
5854 [ $nums -eq $expected ] ||
5855 error "'$cmd' wrong: found $nums, expected $expected"
5857 run_test 56n "check lfs find -type l"
5860 local dir=$DIR/$tdir
5862 setup_56 $dir $NUMFILES $NUMDIRS
5863 utime $dir/file1 > /dev/null || error "utime (1)"
5864 utime $dir/file2 > /dev/null || error "utime (2)"
5865 utime $dir/dir1 > /dev/null || error "utime (3)"
5866 utime $dir/dir2 > /dev/null || error "utime (4)"
5867 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5868 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5871 local nums=$($LFS find -mtime +0 $dir | wc -l)
5873 [ $nums -eq $expected ] ||
5874 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5877 cmd="$LFS find -mtime 0 $dir"
5878 nums=$($cmd | wc -l)
5879 [ $nums -eq $expected ] ||
5880 error "'$cmd' wrong: found $nums, expected $expected"
5882 run_test 56o "check lfs find -mtime for old files"
5885 local dir=$DIR/$tdir
5889 # just to make sure there is something that won't be found
5891 touch $dir/$tfile.now
5893 for age in year week day hour min; do
5894 count=$((count + 1))
5896 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
5897 touch --date="$count $age ago" -a $dir/$tfile-a.$age
5898 touch --date="$count $age ago" -m $dir/$tfile-m.$age
5900 local cmd="$LFS find $dir -mtime $count${age:0:1}"
5901 local nums=$($cmd | wc -l)
5902 [ $nums -eq $expected ] ||
5903 error "'$cmd' wrong: found $nums, expected $expected"
5905 cmd="$LFS find $dir -atime $count${age:0:1}"
5906 nums=$($cmd | wc -l)
5907 [ $nums -eq $expected ] ||
5908 error "'$cmd' wrong: found $nums, expected $expected"
5912 cmd="$LFS find $dir -ctime +1s -type f"
5913 nums=$($cmd | wc -l)
5914 (( $nums == $count * 2 + 1)) ||
5915 error "'$cmd' wrong: found $nums, expected $((expected*2+1))"
5917 run_test 56ob "check lfs find -atime -mtime -ctime with units"
5919 test_newerXY_base() {
5922 local dir=$DIR/$tdir
5926 if [ $y == "t" ]; then
5927 if [ $x == "b" ]; then
5928 ref="\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\""
5930 ref="\"$(date +"%Y-%m-%d %H:%M:%S")\""
5933 ref=$DIR/$tfile.newer.$x$y
5934 touch $ref || error "touch $ref failed"
5937 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
5939 if [ $y == "t" ]; then
5940 if [ $x == "b" ]; then
5941 negref="\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\""
5943 negref="\"$(date +"%Y-%m-%d %H:%M:%S")\""
5946 negref=$DIR/$tfile.negnewer.$x$y
5947 touch $negref || error "touch $negref failed"
5950 local cmd="$LFS find $dir -newer$x$y $ref"
5951 local nums=$(eval $cmd | wc -l)
5952 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
5954 [ $nums -eq $expected ] ||
5955 error "'$cmd' wrong: found $nums, expected $expected"
5957 cmd="$LFS find $dir ! -newer$x$y $negref"
5958 nums=$(eval $cmd | wc -l)
5959 [ $nums -eq $expected ] ||
5960 error "'$cmd' wrong: found $nums, expected $expected"
5962 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
5963 nums=$(eval $cmd | wc -l)
5964 [ $nums -eq $expected ] ||
5965 error "'$cmd' wrong: found $nums, expected $expected"
5971 test_newerXY_base "b" "t"
5972 test_newerXY_base "a" "a"
5973 test_newerXY_base "a" "m"
5974 test_newerXY_base "a" "c"
5975 test_newerXY_base "m" "a"
5976 test_newerXY_base "m" "m"
5977 test_newerXY_base "m" "c"
5978 test_newerXY_base "c" "a"
5979 test_newerXY_base "c" "m"
5980 test_newerXY_base "c" "c"
5981 test_newerXY_base "b" "b"
5982 test_newerXY_base "a" "t"
5983 test_newerXY_base "m" "t"
5984 test_newerXY_base "c" "t"
5985 test_newerXY_base "b" "t"
5987 run_test 56oc "check lfs find -newerXY work"
5990 local dir=$DIR/$tdir
5995 $LFS find $dir -btime -1d -type f
6002 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
6003 ! btime_supported && skip "btime unsupported on MDS"
6005 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6006 ! btime_supported && skip "btime unsupported on clients"
6008 local dir=$DIR/$tdir
6009 local ref=$DIR/$tfile.ref
6010 local negref=$DIR/$tfile.negref
6012 mkdir $dir || error "mkdir $dir failed"
6013 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6014 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6015 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6016 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6017 touch $ref || error "touch $ref failed"
6018 # sleep 3 seconds at least
6021 local before=$(do_facet mds1 date +%s)
6022 local skew=$(($(date +%s) - before + 1))
6024 if (( skew < 0 && skew > -5 )); then
6025 sleep $((0 - skew + 1))
6029 # Set the dir stripe params to limit files all on MDT0,
6030 # otherwise we need to calc the max clock skew between
6031 # the client and MDTs.
6032 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6034 touch $negref || error "touch $negref failed"
6036 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6037 local nums=$($cmd | wc -l)
6038 local expected=$(((NUMFILES + 1) * NUMDIRS))
6040 [ $nums -eq $expected ] ||
6041 error "'$cmd' wrong: found $nums, expected $expected"
6043 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6044 nums=$($cmd | wc -l)
6045 expected=$((NUMFILES + 1))
6046 [ $nums -eq $expected ] ||
6047 error "'$cmd' wrong: found $nums, expected $expected"
6049 [ $skew -lt 0 ] && return
6051 local after=$(do_facet mds1 date +%s)
6052 local age=$((after - before + 1 + skew))
6054 cmd="$LFS find $dir -btime -${age}s -type f"
6055 nums=$($cmd | wc -l)
6056 expected=$(((NUMFILES + 1) * NUMDIRS))
6058 echo "Clock skew between client and server: $skew, age:$age"
6059 [ $nums -eq $expected ] ||
6060 error "'$cmd' wrong: found $nums, expected $expected"
6062 expected=$(($NUMDIRS + 1))
6063 cmd="$LFS find $dir -btime -${age}s -type d"
6064 nums=$($cmd | wc -l)
6065 [ $nums -eq $expected ] ||
6066 error "'$cmd' wrong: found $nums, expected $expected"
6067 rm -f $ref $negref || error "Failed to remove $ref $negref"
6069 run_test 56od "check lfs find -btime with units"
6072 [ $RUNAS_ID -eq $UID ] &&
6073 skip_env "RUNAS_ID = UID = $UID -- skipping"
6075 local dir=$DIR/$tdir
6077 setup_56 $dir $NUMFILES $NUMDIRS
6078 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6080 local expected=$NUMFILES
6081 local cmd="$LFS find -uid $RUNAS_ID $dir"
6082 local nums=$($cmd | wc -l)
6084 [ $nums -eq $expected ] ||
6085 error "'$cmd' wrong: found $nums, expected $expected"
6087 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6088 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6089 nums=$($cmd | wc -l)
6090 [ $nums -eq $expected ] ||
6091 error "'$cmd' wrong: found $nums, expected $expected"
6093 run_test 56p "check lfs find -uid and ! -uid"
6096 [ $RUNAS_ID -eq $UID ] &&
6097 skip_env "RUNAS_ID = UID = $UID -- skipping"
6099 local dir=$DIR/$tdir
6101 setup_56 $dir $NUMFILES $NUMDIRS
6102 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6104 local expected=$NUMFILES
6105 local cmd="$LFS find -gid $RUNAS_GID $dir"
6106 local nums=$($cmd | wc -l)
6108 [ $nums -eq $expected ] ||
6109 error "'$cmd' wrong: found $nums, expected $expected"
6111 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6112 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6113 nums=$($cmd | wc -l)
6114 [ $nums -eq $expected ] ||
6115 error "'$cmd' wrong: found $nums, expected $expected"
6117 run_test 56q "check lfs find -gid and ! -gid"
6120 local dir=$DIR/$tdir
6122 setup_56 $dir $NUMFILES $NUMDIRS
6125 local cmd="$LFS find -size 0 -type f -lazy $dir"
6126 local nums=$($cmd | wc -l)
6128 [ $nums -eq $expected ] ||
6129 error "'$cmd' wrong: found $nums, expected $expected"
6130 cmd="$LFS find -size 0 -type f $dir"
6131 nums=$($cmd | wc -l)
6132 [ $nums -eq $expected ] ||
6133 error "'$cmd' wrong: found $nums, expected $expected"
6136 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6137 nums=$($cmd | wc -l)
6138 [ $nums -eq $expected ] ||
6139 error "'$cmd' wrong: found $nums, expected $expected"
6140 cmd="$LFS find ! -size 0 -type f $dir"
6141 nums=$($cmd | wc -l)
6142 [ $nums -eq $expected ] ||
6143 error "'$cmd' wrong: found $nums, expected $expected"
6145 echo "test" > $dir/$tfile
6146 echo "test2" > $dir/$tfile.2 && sync
6148 cmd="$LFS find -size 5 -type f -lazy $dir"
6149 nums=$($cmd | wc -l)
6150 [ $nums -eq $expected ] ||
6151 error "'$cmd' wrong: found $nums, expected $expected"
6152 cmd="$LFS find -size 5 -type f $dir"
6153 nums=$($cmd | wc -l)
6154 [ $nums -eq $expected ] ||
6155 error "'$cmd' wrong: found $nums, expected $expected"
6158 cmd="$LFS find -size +5 -type f -lazy $dir"
6159 nums=$($cmd | wc -l)
6160 [ $nums -eq $expected ] ||
6161 error "'$cmd' wrong: found $nums, expected $expected"
6162 cmd="$LFS find -size +5 -type f $dir"
6163 nums=$($cmd | wc -l)
6164 [ $nums -eq $expected ] ||
6165 error "'$cmd' wrong: found $nums, expected $expected"
6168 cmd="$LFS find -size +0 -type f -lazy $dir"
6169 nums=$($cmd | wc -l)
6170 [ $nums -eq $expected ] ||
6171 error "'$cmd' wrong: found $nums, expected $expected"
6172 cmd="$LFS find -size +0 -type f $dir"
6173 nums=$($cmd | wc -l)
6174 [ $nums -eq $expected ] ||
6175 error "'$cmd' wrong: found $nums, expected $expected"
6178 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6179 nums=$($cmd | wc -l)
6180 [ $nums -eq $expected ] ||
6181 error "'$cmd' wrong: found $nums, expected $expected"
6182 cmd="$LFS find ! -size -5 -type f $dir"
6183 nums=$($cmd | wc -l)
6184 [ $nums -eq $expected ] ||
6185 error "'$cmd' wrong: found $nums, expected $expected"
6188 cmd="$LFS find -size -5 -type f -lazy $dir"
6189 nums=$($cmd | wc -l)
6190 [ $nums -eq $expected ] ||
6191 error "'$cmd' wrong: found $nums, expected $expected"
6192 cmd="$LFS find -size -5 -type f $dir"
6193 nums=$($cmd | wc -l)
6194 [ $nums -eq $expected ] ||
6195 error "'$cmd' wrong: found $nums, expected $expected"
6197 run_test 56r "check lfs find -size works"
6204 cancel_lru_locks $OSC
6206 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6207 local nums=$($cmd | wc -l)
6209 [ $nums -eq $expected ] ||
6210 error "'$cmd' wrong: found $nums, expected $expected"
6212 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6214 if (( rpcs_before + glimpses != rpcs_after )); then
6215 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6216 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
6218 if [[ $glimpses == 0 ]]; then
6219 error "'$cmd' should not send glimpse RPCs to OST"
6221 error "'$cmd' should send $glimpses glimpse RPCs to OST"
6227 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6228 skip "MDS < 2.12.58 doesn't return LSOM data"
6229 local dir=$DIR/$tdir
6231 [[ $OSC == "mdc" ]] && skip "DoM files" && return
6233 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6234 # open and close all files to ensure LSOM is updated
6235 cancel_lru_locks $OSC
6236 find $dir -type f | xargs cat > /dev/null
6238 # expect_found glimpse_rpcs command_to_run
6239 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
6240 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
6241 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
6242 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
6244 echo "test" > $dir/$tfile
6245 echo "test2" > $dir/$tfile.2 && sync
6246 cancel_lru_locks $OSC
6247 cat $dir/$tfile $dir/$tfile.2 > /dev/null
6249 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
6250 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
6251 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
6252 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
6254 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
6255 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
6256 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
6257 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
6258 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
6259 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
6261 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6264 local dir=$DIR/$tdir
6265 local tmp=$TMP/$tfile.log
6268 test_mkdir -p $dir || error "failed to mkdir $dir"
6269 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6270 error "failed to setstripe $dir/$tfile"
6271 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6273 stack_trap "rm -f $tmp" EXIT
6274 $LFS find --size +100K --ost 0 $dir 2>&1 | tee $tmp
6275 [ -z "$(cat $tmp | grep "obd_uuid: ")" ] ||
6276 error "failed to find --size +100K --ost 0 $dir"
6277 $LFS find --size +100K --mdt $mdt_idx $dir 2>&1 | tee $tmp
6278 [ -z "$(cat $tmp | grep "obd_uuid: ")" ] ||
6279 error "failed to find --size +100K --mdt $mdt_idx $dir"
6281 run_test 56rb "check lfs find --size --ost/--mdt works"
6283 test_56s() { # LU-611 #LU-9369
6284 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
6286 local dir=$DIR/$tdir
6287 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
6289 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6290 for i in $(seq $NUMDIRS); do
6291 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
6294 local expected=$NUMDIRS
6295 local cmd="$LFS find -c $OSTCOUNT $dir"
6296 local nums=$($cmd | wc -l)
6298 [ $nums -eq $expected ] || {
6299 $LFS getstripe -R $dir
6300 error "'$cmd' wrong: found $nums, expected $expected"
6303 expected=$((NUMDIRS + onestripe))
6304 cmd="$LFS find -stripe-count +0 -type f $dir"
6305 nums=$($cmd | wc -l)
6306 [ $nums -eq $expected ] || {
6307 $LFS getstripe -R $dir
6308 error "'$cmd' wrong: found $nums, expected $expected"
6312 cmd="$LFS find -stripe-count 1 -type f $dir"
6313 nums=$($cmd | wc -l)
6314 [ $nums -eq $expected ] || {
6315 $LFS getstripe -R $dir
6316 error "'$cmd' wrong: found $nums, expected $expected"
6319 cmd="$LFS find -stripe-count -2 -type f $dir"
6320 nums=$($cmd | wc -l)
6321 [ $nums -eq $expected ] || {
6322 $LFS getstripe -R $dir
6323 error "'$cmd' wrong: found $nums, expected $expected"
6327 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
6328 nums=$($cmd | wc -l)
6329 [ $nums -eq $expected ] || {
6330 $LFS getstripe -R $dir
6331 error "'$cmd' wrong: found $nums, expected $expected"
6334 run_test 56s "check lfs find -stripe-count works"
6336 test_56t() { # LU-611 #LU-9369
6337 local dir=$DIR/$tdir
6339 setup_56 $dir 0 $NUMDIRS
6340 for i in $(seq $NUMDIRS); do
6341 $LFS setstripe -S 8M $dir/dir$i/$tfile
6344 local expected=$NUMDIRS
6345 local cmd="$LFS find -S 8M $dir"
6346 local nums=$($cmd | wc -l)
6348 [ $nums -eq $expected ] || {
6349 $LFS getstripe -R $dir
6350 error "'$cmd' wrong: found $nums, expected $expected"
6354 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
6356 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
6358 expected=$(((NUMDIRS + 1) * NUMFILES))
6359 cmd="$LFS find -stripe-size 512k -type f $dir"
6360 nums=$($cmd | wc -l)
6361 [ $nums -eq $expected ] ||
6362 error "'$cmd' wrong: found $nums, expected $expected"
6364 cmd="$LFS find -stripe-size +320k -type f $dir"
6365 nums=$($cmd | wc -l)
6366 [ $nums -eq $expected ] ||
6367 error "'$cmd' wrong: found $nums, expected $expected"
6369 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
6370 cmd="$LFS find -stripe-size +200k -type f $dir"
6371 nums=$($cmd | wc -l)
6372 [ $nums -eq $expected ] ||
6373 error "'$cmd' wrong: found $nums, expected $expected"
6375 cmd="$LFS find -stripe-size -640k -type f $dir"
6376 nums=$($cmd | wc -l)
6377 [ $nums -eq $expected ] ||
6378 error "'$cmd' wrong: found $nums, expected $expected"
6381 cmd="$LFS find -stripe-size 256k -type f $dir"
6382 nums=$($cmd | wc -l)
6383 [ $nums -eq $expected ] ||
6384 error "'$cmd' wrong: found $nums, expected $expected"
6386 cmd="$LFS find -stripe-size -320k -type f $dir"
6387 nums=$($cmd | wc -l)
6388 [ $nums -eq $expected ] ||
6389 error "'$cmd' wrong: found $nums, expected $expected"
6392 cmd="$LFS find -stripe-size 1024k -type f $dir"
6393 nums=$($cmd | wc -l)
6394 [ $nums -eq $expected ] ||
6395 error "'$cmd' wrong: found $nums, expected $expected"
6397 run_test 56t "check lfs find -stripe-size works"
6399 test_56u() { # LU-611
6400 local dir=$DIR/$tdir
6402 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
6404 if [[ $OSTCOUNT -gt 1 ]]; then
6405 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
6411 local expected=$(((NUMDIRS + 1) * NUMFILES))
6412 local cmd="$LFS find -stripe-index 0 -type f $dir"
6413 local nums=$($cmd | wc -l)
6415 [ $nums -eq $expected ] ||
6416 error "'$cmd' wrong: found $nums, expected $expected"
6419 cmd="$LFS find -stripe-index 1 -type f $dir"
6420 nums=$($cmd | wc -l)
6421 [ $nums -eq $expected ] ||
6422 error "'$cmd' wrong: found $nums, expected $expected"
6424 cmd="$LFS find ! -stripe-index 0 -type f $dir"
6425 nums=$($cmd | wc -l)
6426 [ $nums -eq $expected ] ||
6427 error "'$cmd' wrong: found $nums, expected $expected"
6430 # This should produce an error and not return any files
6431 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
6432 nums=$($cmd 2>/dev/null | wc -l)
6433 [ $nums -eq $expected ] ||
6434 error "'$cmd' wrong: found $nums, expected $expected"
6436 if [[ $OSTCOUNT -gt 1 ]]; then
6437 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
6438 cmd="$LFS find -stripe-index 0,1 -type f $dir"
6439 nums=$($cmd | wc -l)
6440 [ $nums -eq $expected ] ||
6441 error "'$cmd' wrong: found $nums, expected $expected"
6444 run_test 56u "check lfs find -stripe-index works"
6448 local dir=$DIR/$tdir
6450 setup_56 $dir $NUMFILES $NUMDIRS
6452 UUID=$(mdtuuid_from_index $mdt_idx $dir)
6453 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
6455 for file in $($LFS find -m $UUID $dir); do
6456 file_midx=$($LFS getstripe -m $file)
6457 [ $file_midx -eq $mdt_idx ] ||
6458 error "lfs find -m $UUID != getstripe -m $file_midx"
6461 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
6464 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6465 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6467 local dir=$DIR/$tdir
6469 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
6471 local stripe_size=$($LFS getstripe -S -d $dir) ||
6472 error "$LFS getstripe -S -d $dir failed"
6473 stripe_size=${stripe_size%% *}
6475 local file_size=$((stripe_size * OSTCOUNT))
6476 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
6477 local required_space=$((file_num * file_size))
6478 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
6480 [[ $free_space -le $((required_space / 1024)) ]] &&
6481 skip_env "need $required_space, have $free_space kbytes"
6484 local dd_count=$((file_size / dd_bs))
6486 # write data into the files
6491 for i in $(seq $NUMFILES); do
6493 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6494 error "write data into $file failed"
6496 for i in $(seq $NUMDIRS); do
6497 for j in $(seq $NUMFILES); do
6498 file=$dir/dir$i/file$j
6499 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6500 error "write data into $file failed"
6504 # $LFS_MIGRATE will fail if hard link migration is unsupported
6505 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
6506 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
6507 error "creating links to $dir/dir1/file1 failed"
6512 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
6515 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
6518 eval $cmd || error "$cmd failed"
6520 check_stripe_count $dir/file1 $expected
6522 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
6524 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
6525 # OST 1 if it is on OST 0. This file is small enough to
6526 # be on only one stripe.
6527 file=$dir/migr_1_ost
6528 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
6529 error "write data into $file failed"
6530 local obdidx=$($LFS getstripe -i $file)
6531 local oldmd5=$(md5sum $file)
6534 [[ $obdidx -eq 0 ]] && newobdidx=1
6535 cmd="$LFS migrate -i $newobdidx $file"
6537 eval $cmd || error "$cmd failed"
6539 local realobdix=$($LFS getstripe -i $file)
6540 local newmd5=$(md5sum $file)
6542 [[ $newobdidx -ne $realobdix ]] &&
6543 error "new OST is different (was=$obdidx, "\
6544 "wanted=$newobdidx, got=$realobdix)"
6545 [[ "$oldmd5" != "$newmd5" ]] &&
6546 error "md5sum differ: $oldmd5, $newmd5"
6550 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
6552 eval $cmd || error "$cmd failed"
6554 for j in $(seq $NUMFILES); do
6555 check_stripe_count $dir/dir1/file$j $expected
6558 # lfs_migrate works with lfs find
6559 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
6560 $LFS_MIGRATE -y -c $expected"
6562 eval $cmd || error "$cmd failed"
6564 for i in $(seq 2 $NUMFILES); do
6565 check_stripe_count $dir/file$i $expected
6567 for i in $(seq 2 $NUMDIRS); do
6568 for j in $(seq $NUMFILES); do
6569 check_stripe_count $dir/dir$i/file$j $expected
6573 run_test 56w "check lfs_migrate -c stripe_count works"
6576 local file1=$DIR/$tdir/file1
6577 local create_pool=false
6578 local initial_pool=$($LFS getstripe -p $DIR)
6582 echo -n "Creating test dir..."
6583 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6586 echo -n "Creating test file..."
6587 touch $file1 || error "cannot create file"
6590 echo -n "Detecting existing pools..."
6591 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
6593 if [ ${#pool_list[@]} -gt 0 ]; then
6594 echo "${pool_list[@]}"
6595 for thispool in "${pool_list[@]}"; do
6596 if [[ -z "$initial_pool" ||
6597 "$initial_pool" != "$thispool" ]]; then
6599 echo "Using existing pool '$pool'"
6604 echo "none detected."
6606 if [ -z "$pool" ]; then
6607 pool=${POOL:-testpool}
6608 [ "$initial_pool" = "$pool" ] && pool="testpool2"
6609 echo -n "Creating pool '$pool'..."
6611 pool_add $pool &> /dev/null ||
6612 error "pool_add failed"
6615 echo -n "Adding target to pool..."
6616 pool_add_targets $pool 0 0 1 &> /dev/null ||
6617 error "pool_add_targets failed"
6621 echo -n "Setting pool using -p option..."
6622 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
6623 error "migrate failed rc = $?"
6626 echo -n "Verifying test file is in pool after migrating..."
6627 [ "$($LFS getstripe -p $file1)" = $pool ] ||
6628 error "file was not migrated to pool $pool"
6631 echo -n "Removing test file from pool '$pool'..."
6632 # "lfs migrate $file" won't remove the file from the pool
6633 # until some striping information is changed.
6634 $LFS migrate -c 1 $file1 &> /dev/null ||
6635 error "cannot remove from pool"
6636 [ "$($LFS getstripe -p $file1)" ] &&
6637 error "pool still set"
6640 echo -n "Setting pool using --pool option..."
6641 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
6642 error "migrate failed rc = $?"
6647 if $create_pool; then
6648 destroy_test_pools 2> /dev/null ||
6649 error "destroy test pools failed"
6652 run_test 56wb "check lfs_migrate pool support"
6655 local file1="$DIR/$tdir/file1"
6662 echo -n "Creating test dir..."
6663 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6664 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
6665 error "cannot set stripe by '-S 1M -c 1'"
6668 echo -n "Setting initial stripe for test file..."
6669 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
6670 error "cannot set stripe"
6671 cur_ssize=$($LFS getstripe -S "$file1")
6672 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
6675 # File currently set to -S 512K -c 1
6677 # Ensure -c and -S options are rejected when -R is set
6678 echo -n "Verifying incompatible options are detected..."
6679 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
6680 error "incompatible -c and -R options not detected"
6681 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
6682 error "incompatible -S and -R options not detected"
6685 # Ensure unrecognized options are passed through to 'lfs migrate'
6686 echo -n "Verifying -S option is passed through to lfs migrate..."
6687 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
6688 error "migration failed"
6689 cur_ssize=$($LFS getstripe -S "$file1")
6690 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
6693 # File currently set to -S 1M -c 1
6695 # Ensure long options are supported
6696 echo -n "Verifying long options supported..."
6697 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
6698 error "long option without argument not supported"
6699 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
6700 error "long option with argument not supported"
6701 cur_ssize=$($LFS getstripe -S "$file1")
6702 [ $cur_ssize -eq 524288 ] ||
6703 error "migrate --stripe-size $cur_ssize != 524288"
6706 # File currently set to -S 512K -c 1
6708 if [ "$OSTCOUNT" -gt 1 ]; then
6709 echo -n "Verifying explicit stripe count can be set..."
6710 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
6711 error "migrate failed"
6712 cur_scount=$($LFS getstripe -c "$file1")
6713 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
6717 # File currently set to -S 512K -c 1 or -S 512K -c 2
6719 # Ensure parent striping is used if -R is set, and no stripe
6720 # count or size is specified
6721 echo -n "Setting stripe for parent directory..."
6722 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6723 error "cannot set stripe '-S 2M -c 1'"
6726 echo -n "Verifying restripe option uses parent stripe settings..."
6727 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
6728 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
6729 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
6730 error "migrate failed"
6731 cur_ssize=$($LFS getstripe -S "$file1")
6732 [ $cur_ssize -eq $parent_ssize ] ||
6733 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
6734 cur_scount=$($LFS getstripe -c "$file1")
6735 [ $cur_scount -eq $parent_scount ] ||
6736 error "migrate -R stripe_count $cur_scount != $parent_scount"
6739 # File currently set to -S 1M -c 1
6741 # Ensure striping is preserved if -R is not set, and no stripe
6742 # count or size is specified
6743 echo -n "Verifying striping size preserved when not specified..."
6744 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
6745 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6746 error "cannot set stripe on parent directory"
6747 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6748 error "migrate failed"
6749 cur_ssize=$($LFS getstripe -S "$file1")
6750 [ $cur_ssize -eq $orig_ssize ] ||
6751 error "migrate by default $cur_ssize != $orig_ssize"
6754 # Ensure file name properly detected when final option has no argument
6755 echo -n "Verifying file name properly detected..."
6756 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6757 error "file name interpreted as option argument"
6763 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
6766 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6768 local file1=$DIR/$tdir/file1
6770 echo -n "Creating test dir..."
6771 test_mkdir $DIR/$tdir || error "cannot create dir"
6774 echo -n "Creating test file..."
6778 # Ensure 'lfs migrate' will fail by using a non-existent option,
6779 # and make sure rsync is not called to recover
6780 echo -n "Make sure --no-rsync option works..."
6781 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
6782 grep -q 'refusing to fall back to rsync' ||
6783 error "rsync was called with --no-rsync set"
6786 # Ensure rsync is called without trying 'lfs migrate' first
6787 echo -n "Make sure --rsync option works..."
6788 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
6789 grep -q 'falling back to rsync' &&
6790 error "lfs migrate was called with --rsync set"
6793 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
6794 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
6795 grep -q 'at the same time' ||
6796 error "--rsync and --no-rsync accepted concurrently"
6802 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
6808 test_mkdir $td || error "cannot create $td"
6809 touch $tf || error "cannot touch $tf"
6811 echo -n "Make sure --non-direct|-D works..."
6812 $LFS_MIGRATE -y --non-direct -v $tf 2>&1 |
6813 grep -q "lfs migrate --non-direct" ||
6814 error "--non-direct option cannot work correctly"
6815 $LFS_MIGRATE -y -D -v $tf 2>&1 |
6816 grep -q "lfs migrate -D" ||
6817 error "-D option cannot work correctly"
6820 run_test 56we "check lfs_migrate --non-direct|-D support"
6823 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6824 check_swap_layouts_support
6826 local dir=$DIR/$tdir
6827 local ref1=/etc/passwd
6828 local file1=$dir/file1
6830 test_mkdir $dir || error "creating dir $dir"
6831 $LFS setstripe -c 2 $file1
6833 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
6834 stripe=$($LFS getstripe -c $file1)
6835 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6836 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6841 run_test 56x "lfs migration support"
6844 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6845 check_swap_layouts_support
6847 local dir=$DIR/$tdir/$testnum
6851 local ref1=/etc/passwd
6852 local file1=$dir/file1
6854 $LFS setstripe -c 2 $file1
6856 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6858 local stripe=$($LFS getstripe -c $file1)
6860 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6861 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6866 run_test 56xa "lfs migration --block support"
6868 check_migrate_links() {
6870 local file1="$dir/file1"
6874 local total_count=$(($begin + $count - 1))
6875 local symlink_count=10
6878 if [ ! -f "$file1" ]; then
6879 echo -n "creating initial file..."
6880 $LFS setstripe -c 1 -S "512k" "$file1" ||
6881 error "cannot setstripe initial file"
6884 echo -n "creating symlinks..."
6885 for s in $(seq 1 $symlink_count); do
6886 ln -s "$file1" "$dir/slink$s" ||
6887 error "cannot create symlinks"
6891 echo -n "creating nonlinked files..."
6892 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6893 error "cannot create nonlinked files"
6898 if [ ! -f "$dir/file$total_count" ]; then
6899 echo -n "creating hard links $begin:$total_count..."
6900 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6901 /dev/null || error "cannot create hard links"
6905 echo -n "checking number of hard links listed in xattrs..."
6906 local fid=$($LFS getstripe -F "$file1")
6907 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6910 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6911 skip "hard link list has unexpected size, skipping test"
6913 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6914 error "link names should exceed xattrs size"
6917 echo -n "migrating files..."
6918 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
6920 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6923 # make sure all links have been properly migrated
6924 echo -n "verifying files..."
6925 fid=$($LFS getstripe -F "$file1") ||
6926 error "cannot get fid for file $file1"
6927 for i in $(seq 2 $total_count); do
6928 local fid2=$($LFS getstripe -F $dir/file$i)
6930 [ "$fid2" == "$fid" ] ||
6931 error "migrated hard link has mismatched FID"
6934 # make sure hard links were properly detected, and migration was
6935 # performed only once for the entire link set; nonlinked files should
6937 local actual=$(grep -c 'done' <<< "$migrate_out")
6938 local expected=$(($uniq_count + 1))
6940 [ "$actual" -eq "$expected" ] ||
6941 error "hard links individually migrated ($actual != $expected)"
6943 # make sure the correct number of hard links are present
6944 local hardlinks=$(stat -c '%h' "$file1")
6946 [ $hardlinks -eq $total_count ] ||
6947 error "num hard links $hardlinks != $total_count"
6954 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6955 skip "Need MDS version at least 2.10.55"
6957 local dir="$DIR/$tdir"
6959 test_mkdir "$dir" || error "cannot create dir $dir"
6961 echo "testing lfs migrate mode when all links fit within xattrs"
6962 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6964 echo "testing rsync mode when all links fit within xattrs"
6965 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6967 echo "testing lfs migrate mode when all links do not fit within xattrs"
6968 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6970 echo "testing rsync mode when all links do not fit within xattrs"
6971 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6973 chown -R $RUNAS_ID $dir
6974 echo "testing non-root lfs migrate mode when not all links are in xattr"
6975 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
6980 run_test 56xb "lfs migration hard link support"
6983 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6985 local dir="$DIR/$tdir"
6987 test_mkdir "$dir" || error "cannot create dir $dir"
6989 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6990 echo -n "Setting initial stripe for 20MB test file..."
6991 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
6992 error "cannot setstripe 20MB file"
6994 echo -n "Sizing 20MB test file..."
6995 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6997 echo -n "Verifying small file autostripe count is 1..."
6998 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
6999 error "cannot migrate 20MB file"
7000 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
7001 error "cannot get stripe for $dir/20mb"
7002 [ $stripe_count -eq 1 ] ||
7003 error "unexpected stripe count $stripe_count for 20MB file"
7007 # Test 2: File is small enough to fit within the available space on
7008 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
7009 # have at least an additional 1KB for each desired stripe for test 3
7010 echo -n "Setting stripe for 1GB test file..."
7011 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
7013 echo -n "Sizing 1GB test file..."
7014 # File size is 1GB + 3KB
7015 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
7018 # need at least 512MB per OST for 1GB file to fit in 2 stripes
7019 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
7020 if (( avail > 524288 * OSTCOUNT )); then
7021 echo -n "Migrating 1GB file..."
7022 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7023 error "cannot migrate 1GB file"
7025 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7026 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7027 error "cannot getstripe for 1GB file"
7028 [ $stripe_count -eq 2 ] ||
7029 error "unexpected stripe count $stripe_count != 2"
7033 # Test 3: File is too large to fit within the available space on
7034 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7035 if [ $OSTCOUNT -ge 3 ]; then
7036 # The required available space is calculated as
7037 # file size (1GB + 3KB) / OST count (3).
7038 local kb_per_ost=349526
7040 echo -n "Migrating 1GB file with limit..."
7041 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7042 error "cannot migrate 1GB file with limit"
7045 stripe_count=$($LFS getstripe -c "$dir/1gb")
7046 echo -n "Verifying 1GB autostripe count with limited space..."
7047 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7048 error "unexpected stripe count $stripe_count (min 3)"
7055 run_test 56xc "lfs migration autostripe"
7058 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7060 local dir=$DIR/$tdir
7061 local f_mgrt=$dir/$tfile.mgrt
7062 local f_yaml=$dir/$tfile.yaml
7063 local f_copy=$dir/$tfile.copy
7064 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7065 local layout_copy="-c 2 -S 2M -i 1"
7066 local yamlfile=$dir/yamlfile
7067 local layout_before;
7070 test_mkdir "$dir" || error "cannot create dir $dir"
7071 $LFS setstripe $layout_yaml $f_yaml ||
7072 error "cannot setstripe $f_yaml with layout $layout_yaml"
7073 $LFS getstripe --yaml $f_yaml > $yamlfile
7074 $LFS setstripe $layout_copy $f_copy ||
7075 error "cannot setstripe $f_copy with layout $layout_copy"
7077 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7079 # 1. test option --yaml
7080 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7081 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7082 layout_before=$(get_layout_param $f_yaml)
7083 layout_after=$(get_layout_param $f_mgrt)
7084 [ "$layout_after" == "$layout_before" ] ||
7085 error "lfs_migrate --yaml: $layout_after != $layout_before"
7087 # 2. test option --copy
7088 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7089 error "cannot migrate $f_mgrt with --copy $f_copy"
7090 layout_before=$(get_layout_param $f_copy)
7091 layout_after=$(get_layout_param $f_mgrt)
7092 [ "$layout_after" == "$layout_before" ] ||
7093 error "lfs_migrate --copy: $layout_after != $layout_before"
7095 run_test 56xd "check lfs_migrate --yaml and --copy support"
7098 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7100 local dir=$DIR/$tdir
7101 local f_comp=$dir/$tfile
7102 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7103 local layout_before=""
7104 local layout_after=""
7106 test_mkdir "$dir" || error "cannot create dir $dir"
7107 $LFS setstripe $layout $f_comp ||
7108 error "cannot setstripe $f_comp with layout $layout"
7109 layout_before=$(get_layout_param $f_comp)
7110 dd if=/dev/zero of=$f_comp bs=1M count=4
7112 # 1. migrate a comp layout file by lfs_migrate
7113 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7114 layout_after=$(get_layout_param $f_comp)
7115 [ "$layout_before" == "$layout_after" ] ||
7116 error "lfs_migrate: $layout_before != $layout_after"
7118 # 2. migrate a comp layout file by lfs migrate
7119 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7120 layout_after=$(get_layout_param $f_comp)
7121 [ "$layout_before" == "$layout_after" ] ||
7122 error "lfs migrate: $layout_before != $layout_after"
7124 run_test 56xe "migrate a composite layout file"
7127 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7129 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7130 skip "Need server version at least 2.13.53"
7132 local dir=$DIR/$tdir
7133 local f_comp=$dir/$tfile
7134 local layout="-E 1M -c1 -E -1 -c2"
7138 test_mkdir "$dir" || error "cannot create dir $dir"
7139 $LFS setstripe $layout $f_comp ||
7140 error "cannot setstripe $f_comp with layout $layout"
7141 fid_before=$($LFS getstripe --fid $f_comp)
7142 dd if=/dev/zero of=$f_comp bs=1M count=4
7144 # 1. migrate a comp layout file to a comp layout
7145 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7146 fid_after=$($LFS getstripe --fid $f_comp)
7147 [ "$fid_before" == "$fid_after" ] ||
7148 error "comp-to-comp migrate: $fid_before != $fid_after"
7150 # 2. migrate a comp layout file to a plain layout
7151 $LFS migrate -c2 $f_comp ||
7152 error "cannot migrate $f_comp by lfs migrate"
7153 fid_after=$($LFS getstripe --fid $f_comp)
7154 [ "$fid_before" == "$fid_after" ] ||
7155 error "comp-to-plain migrate: $fid_before != $fid_after"
7157 # 3. migrate a plain layout file to a comp layout
7158 $LFS migrate $layout $f_comp ||
7159 error "cannot migrate $f_comp by lfs migrate"
7160 fid_after=$($LFS getstripe --fid $f_comp)
7161 [ "$fid_before" == "$fid_after" ] ||
7162 error "plain-to-comp migrate: $fid_before != $fid_after"
7164 run_test 56xf "FID is not lost during migration of a composite layout file"
7167 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
7168 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
7171 local dir=$DIR/$tdir
7175 test_mkdir -p $dir || error "creating dir $dir"
7176 touch $f1 || error "creating std file $f1"
7177 $MULTIOP $f2 H2c || error "creating released file $f2"
7179 # a directory can be raid0, so ask only for files
7180 res=$($LFS find $dir -L raid0 -type f | wc -l)
7181 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
7183 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
7184 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
7186 # only files can be released, so no need to force file search
7187 res=$($LFS find $dir -L released)
7188 [[ $res == $f2 ]] || error "search released: found $res != $f2"
7190 res=$($LFS find $dir -type f \! -L released)
7191 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
7193 run_test 56y "lfs find -L raid0|released"
7195 test_56z() { # LU-4824
7196 # This checks to make sure 'lfs find' continues after errors
7197 # There are two classes of errors that should be caught:
7198 # - If multiple paths are provided, all should be searched even if one
7200 # - If errors are encountered during the search, it should not terminate
7202 local dir=$DIR/$tdir
7206 for i in d{0..9}; do
7208 touch $dir/$i/$tfile
7210 $LFS find $DIR/non_existent_dir $dir &&
7211 error "$LFS find did not return an error"
7212 # Make a directory unsearchable. This should NOT be the last entry in
7213 # directory order. Arbitrarily pick the 6th entry
7214 chmod 700 $($LFS find $dir -type d | sed '6!d')
7216 $RUNAS $LFS find $DIR/non_existent $dir
7217 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
7219 # The user should be able to see 10 directories and 9 files
7220 (( count == 19 )) ||
7221 error "$LFS find found $count != 19 entries after error"
7223 run_test 56z "lfs find should continue after an error"
7225 test_56aa() { # LU-5937
7226 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
7228 local dir=$DIR/$tdir
7231 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
7233 createmany -o $dir/striped_dir/${tfile}- 1024
7234 local dirs=$($LFS find --size +8k $dir/)
7236 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
7238 run_test 56aa "lfs find --size under striped dir"
7240 test_56ab() { # LU-10705
7241 test_mkdir $DIR/$tdir
7242 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
7243 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
7244 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
7245 # Flush writes to ensure valid blocks. Need to be more thorough for
7246 # ZFS, since blocks are not allocated/returned to client immediately.
7248 wait_zfs_commit ost1 2
7249 cancel_lru_locks osc
7252 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
7254 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
7256 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
7257 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
7259 rm -f $DIR/$tdir/$tfile.[123]
7261 run_test 56ab "lfs find --blocks"
7264 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
7265 skip "Need MDS version at least 2.10.50"
7267 # Create composite files with one component
7268 local dir=$DIR/$tdir
7270 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
7271 # Create composite files with three components
7272 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
7273 # Create non-composite files
7274 createmany -o $dir/${tfile}- 10
7276 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
7278 [[ $nfiles == 10 ]] ||
7279 error "lfs find -E 1M found $nfiles != 10 files"
7281 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
7282 [[ $nfiles == 25 ]] ||
7283 error "lfs find ! -E 1M found $nfiles != 25 files"
7285 # All files have a component that starts at 0
7286 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
7287 [[ $nfiles == 35 ]] ||
7288 error "lfs find --component-start 0 - $nfiles != 35 files"
7290 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
7291 [[ $nfiles == 15 ]] ||
7292 error "lfs find --component-start 2M - $nfiles != 15 files"
7294 # All files created here have a componenet that does not starts at 2M
7295 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
7296 [[ $nfiles == 35 ]] ||
7297 error "lfs find ! --component-start 2M - $nfiles != 35 files"
7299 # Find files with a specified number of components
7300 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
7301 [[ $nfiles == 15 ]] ||
7302 error "lfs find --component-count 3 - $nfiles != 15 files"
7304 # Remember non-composite files have a component count of zero
7305 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
7306 [[ $nfiles == 10 ]] ||
7307 error "lfs find --component-count 0 - $nfiles != 10 files"
7309 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
7310 [[ $nfiles == 20 ]] ||
7311 error "lfs find ! --component-count 3 - $nfiles != 20 files"
7313 # All files have a flag called "init"
7314 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
7315 [[ $nfiles == 35 ]] ||
7316 error "lfs find --component-flags init - $nfiles != 35 files"
7318 # Multi-component files will have a component not initialized
7319 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
7320 [[ $nfiles == 15 ]] ||
7321 error "lfs find !--component-flags init - $nfiles != 15 files"
7326 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
7329 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
7330 skip "Need MDS version at least 2.10.57"
7340 # create mirrored directories and mirrored files
7341 mkdir $td || error "mkdir $td failed"
7342 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
7343 createmany -o $tf- 10 || error "create $tf- failed"
7345 for i in $(seq 2); do
7347 mkdir $dir || error "mkdir $dir failed"
7348 $LFS mirror create -N$((3 + i)) $dir ||
7349 error "create mirrored dir $dir failed"
7350 createmany -o $dir/$tfile- 10 ||
7351 error "create $dir/$tfile- failed"
7354 # change the states of some mirrored files
7356 for i in $(seq 2); do
7358 for j in $(seq 4 9); do
7359 echo foo > $dir/$tfile-$j
7363 # find mirrored files with specific mirror count
7364 cmd="$LFS find --mirror-count 3 --type f $td"
7365 nfiles=$($cmd | wc -l)
7366 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
7368 cmd="$LFS find ! --mirror-count 3 --type f $td"
7369 nfiles=$($cmd | wc -l)
7370 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
7372 cmd="$LFS find --mirror-count +2 --type f $td"
7373 nfiles=$($cmd | wc -l)
7374 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7376 cmd="$LFS find --mirror-count -6 --type f $td"
7377 nfiles=$($cmd | wc -l)
7378 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7380 # find mirrored files with specific file state
7381 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
7382 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
7384 cmd="$LFS find --mirror-state=ro --type f $td"
7385 nfiles=$($cmd | wc -l)
7386 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
7388 cmd="$LFS find ! --mirror-state=ro --type f $td"
7389 nfiles=$($cmd | wc -l)
7390 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7392 cmd="$LFS find --mirror-state=wp --type f $td"
7393 nfiles=$($cmd | wc -l)
7394 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7396 cmd="$LFS find ! --mirror-state=sp --type f $td"
7397 nfiles=$($cmd | wc -l)
7398 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7400 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
7403 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7404 # note test will not do anything if MDS is not local
7405 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7406 skip_env "ldiskfs only test"
7408 remote_mds_nodsh && skip "remote MDS with nodsh"
7410 local MNTDEV="osd*.*MDT*.mntdev"
7411 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
7412 [ -z "$DEV" ] && error "can't access $MNTDEV"
7413 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
7414 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
7415 error "can't access $DEV"
7416 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
7417 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
7421 run_test 57a "verify MDS filesystem created with large inodes =="
7424 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7425 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7426 skip_env "ldiskfs only test"
7428 remote_mds_nodsh && skip "remote MDS with nodsh"
7430 local dir=$DIR/$tdir
7433 local fileN=$dir/f$filecount
7435 rm -rf $dir || error "removing $dir"
7437 local mdtidx=$($LFS getstripe -m $dir)
7438 local mdtname=MDT$(printf %04x $mdtidx)
7439 local facet=mds$((mdtidx + 1))
7441 echo "mcreating $filecount files"
7442 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
7444 # verify that files do not have EAs yet
7445 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
7446 error "$file1 has an EA"
7447 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
7448 error "$fileN has an EA"
7452 df $dir #make sure we get new statfs data
7453 local mdsfree=$(do_facet $facet \
7454 lctl get_param -n osd*.*$mdtname.kbytesfree)
7455 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7458 echo "opening files to create objects/EAs"
7459 for file in $(seq -f $dir/f%g 1 $filecount); do
7460 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
7461 error "opening $file"
7464 # verify that files have EAs now
7465 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
7466 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
7468 sleep 1 #make sure we get new statfs data
7470 local mdsfree2=$(do_facet $facet \
7471 lctl get_param -n osd*.*$mdtname.kbytesfree)
7472 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7474 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
7475 if [ "$mdsfree" != "$mdsfree2" ]; then
7476 error "MDC before $mdcfree != after $mdcfree2"
7478 echo "MDC before $mdcfree != after $mdcfree2"
7479 echo "unable to confirm if MDS has large inodes"
7484 run_test 57b "default LOV EAs are stored inside large inodes ==="
7487 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7488 [ -z "$(which wiretest 2>/dev/null)" ] &&
7489 skip_env "could not find wiretest"
7493 run_test 58 "verify cross-platform wire constants =============="
7496 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7498 echo "touch 130 files"
7499 createmany -o $DIR/f59- 130
7501 unlinkmany $DIR/f59- 130
7503 # wait for commitment of removal
7504 wait_delete_completed
7506 run_test 59 "verify cancellation of llog records async ========="
7508 TEST60_HEAD="test_60 run $RANDOM"
7510 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7511 remote_mgs_nodsh && skip "remote MGS with nodsh"
7512 do_facet mgs "! which run-llog.sh &> /dev/null" &&
7513 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
7514 skip_env "missing subtest run-llog.sh"
7516 log "$TEST60_HEAD - from kernel mode"
7517 do_facet mgs "$LCTL dk > /dev/null"
7518 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
7519 do_facet mgs $LCTL dk > $TMP/$tfile
7521 # LU-6388: test llog_reader
7522 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
7523 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
7524 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
7525 skip_env "missing llog_reader"
7526 local fstype=$(facet_fstype mgs)
7527 [ $fstype != ldiskfs -a $fstype != zfs ] &&
7528 skip_env "Only for ldiskfs or zfs type mgs"
7530 local mntpt=$(facet_mntpt mgs)
7531 local mgsdev=$(mgsdevname 1)
7543 #get fid and record list
7544 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
7546 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
7548 #remount mgs as ldiskfs or zfs type
7549 stop mgs || error "stop mgs failed"
7550 mount_fstype mgs || error "remount mgs failed"
7551 for ((i = 0; i < ${#fid_list[@]}; i++)); do
7554 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
7555 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
7560 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
7562 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
7564 echo "obj_file is $obj_file"
7565 do_facet mgs $llog_reader $obj_file
7567 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
7568 awk '{ print $3 }' | sed -e "s/^type=//g")
7569 if [ $rec_type != $rec ]; then
7570 echo "FAILED test_60a wrong record type $rec_type," \
7576 #check obj path if record type is LLOG_LOGID_MAGIC
7577 if [ "$rec" == "1064553b" ]; then
7578 path=$(do_facet mgs $llog_reader $obj_file |
7579 grep "path=" | awk '{ print $NF }' |
7580 sed -e "s/^path=//g")
7581 if [ $obj_file != $mntpt/$path ]; then
7582 echo "FAILED test_60a wrong obj path" \
7583 "$montpt/$path, should be $obj_file"
7590 #restart mgs before "error", otherwise it will block the next test
7591 stop mgs || error "stop mgs failed"
7592 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
7593 $pass || error "test failed, see FAILED test_60a messages for specifics"
7595 run_test 60a "llog_test run from kernel module and test llog_reader"
7597 test_60b() { # bug 6411
7598 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7601 LLOG_COUNT=$(do_facet mgs dmesg |
7602 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
7603 /llog_[a-z]*.c:[0-9]/ {
7615 [[ $LLOG_COUNT -gt 120 ]] &&
7616 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
7618 run_test 60b "limit repeated messages from CERROR/CWARN"
7621 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7623 echo "create 5000 files"
7624 createmany -o $DIR/f60c- 5000
7625 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
7626 lctl set_param fail_loc=0x80000137
7627 unlinkmany $DIR/f60c- 5000
7628 lctl set_param fail_loc=0
7630 run_test 60c "unlink file when mds full"
7633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7635 SAVEPRINTK=$(lctl get_param -n printk)
7636 # verify "lctl mark" is even working"
7637 MESSAGE="test message ID $RANDOM $$"
7638 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7639 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
7641 lctl set_param printk=0 || error "set lnet.printk failed"
7642 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
7643 MESSAGE="new test message ID $RANDOM $$"
7644 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
7645 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7646 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
7648 lctl set_param -n printk="$SAVEPRINTK"
7650 run_test 60d "test printk console message masking"
7653 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7654 remote_mds_nodsh && skip "remote MDS with nodsh"
7657 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
7658 do_facet mds1 lctl set_param fail_loc=0x15b
7661 run_test 60e "no space while new llog is being created"
7667 test_mkdir -c $MDSCOUNT $DIR/$tdir
7672 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
7673 -c $MDSCOUNT $DIR/$tdir/subdir$index \
7675 mkdir $DIR/$tdir/subdir$index 2>/dev/null
7676 rmdir $DIR/$tdir/subdir$index 2>/dev/null
7677 index=$((index + 1))
7683 for i in {0..100}; do
7684 # define OBD_FAIL_OSD_TXN_START 0x19a
7685 local index=$((i % MDSCOUNT + 1))
7687 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
7694 for i in $(seq $MDSCOUNT); do
7695 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
7698 mkdir $DIR/$tdir/new || error "mkdir failed"
7699 rmdir $DIR/$tdir/new || error "rmdir failed"
7701 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
7703 for i in $(seq $MDSCOUNT); do
7704 wait_update_facet mds$i "$LCTL get_param -n \
7705 mdd.$(facet_svc mds$i).lfsck_namespace |
7706 awk '/^status/ { print \\\$2 }'" "completed"
7709 ls -R $DIR/$tdir || error "ls failed"
7710 rm -rf $DIR/$tdir || error "rmdir failed"
7712 run_test 60g "transaction abort won't cause MDT hung"
7715 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
7716 skip "Need MDS version at least 2.12.52"
7717 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
7721 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
7722 #define OBD_FAIL_MDS_STRIPE_FID 0x189
7723 for fail_loc in 0x80000188 0x80000189; do
7724 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
7725 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
7726 error "mkdir $dir-$fail_loc failed"
7727 for i in {0..10}; do
7728 # create may fail on missing stripe
7729 echo $i > $DIR/$tdir-$fail_loc/$i
7731 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7732 error "getdirstripe $tdir-$fail_loc failed"
7733 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
7734 error "migrate $tdir-$fail_loc failed"
7735 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7736 error "getdirstripe $tdir-$fail_loc failed"
7737 pushd $DIR/$tdir-$fail_loc
7739 echo $f | cmp $f - || error "$f data mismatch"
7742 rm -rf $DIR/$tdir-$fail_loc
7745 run_test 60h "striped directory with missing stripes can be accessed"
7748 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7751 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
7752 cancel_lru_locks osc
7753 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
7756 run_test 61a "mmap() writes don't make sync hang ================"
7759 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
7761 run_test 61b "mmap() of unstriped file is successful"
7763 # bug 2330 - insufficient obd_match error checking causes LBUG
7765 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7769 cancel_lru_locks osc
7770 lctl set_param fail_loc=0x405
7771 cat $f && error "cat succeeded, expect -EIO"
7772 lctl set_param fail_loc=0
7774 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
7775 # match every page all of the time.
7776 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
7778 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
7779 # Though this test is irrelevant anymore, it helped to reveal some
7780 # other grant bugs (LU-4482), let's keep it.
7781 test_63a() { # was test_63
7782 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7784 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
7786 for i in `seq 10` ; do
7787 dd if=/dev/zero of=$DIR/f63 bs=8k &
7793 rm -f $DIR/f63 || true
7795 run_test 63a "Verify oig_wait interruption does not crash ======="
7797 # bug 2248 - async write errors didn't return to application on sync
7798 # bug 3677 - async write errors left page locked
7800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7803 lctl set_param debug=-1
7805 # ensure we have a grant to do async writes
7806 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
7809 sync # sync lest earlier test intercept the fail_loc
7811 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7812 lctl set_param fail_loc=0x80000406
7813 $MULTIOP $DIR/$tfile Owy && \
7814 error "sync didn't return ENOMEM"
7815 sync; sleep 2; sync # do a real sync this time to flush page
7816 lctl get_param -n llite.*.dump_page_cache | grep locked && \
7817 error "locked page left in cache after async error" || true
7820 run_test 63b "async write errors should be returned to fsync ==="
7823 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7826 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
7828 run_test 64a "verify filter grant calculations (in kernel) ====="
7831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7833 sh oos.sh $MOUNT || error "oos.sh failed: $?"
7835 run_test 64b "check out-of-space detection on client"
7838 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
7840 run_test 64c "verify grant shrink"
7842 # this does exactly what osc_request.c:osc_announce_cached() does in
7843 # order to calculate max amount of grants to ask from server
7847 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
7848 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
7850 ((rpc_in_flight ++));
7851 nrpages=$((nrpages * rpc_in_flight))
7853 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
7855 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
7857 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
7858 local undirty=$((nrpages * PAGE_SIZE))
7860 local max_extent_pages
7861 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
7862 grep grant_max_extent_size | awk '{print $2}')
7863 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
7864 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
7865 local grant_extent_tax
7866 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7867 grep grant_extent_tax | awk '{print $2}')
7869 undirty=$((undirty + nrextents * grant_extent_tax))
7874 # this is size of unit for grant allocation. It should be equal to
7875 # what tgt_grant.c:tgt_grant_chunk() calculates
7879 local grant_extent_tax
7881 max_brw_size=$($LCTL get_param osc.${tgt}.import |
7882 grep max_brw_size | awk '{print $2}')
7884 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7885 grep grant_extent_tax | awk '{print $2}')
7887 echo $(((max_brw_size + grant_extent_tax) * 2))
7891 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
7892 skip "OST < 2.10.55 doesn't limit grants enough"
7894 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
7895 local file=$DIR/$tfile
7897 [[ $($LCTL get_param osc.${tgt}.import |
7898 grep "connect_flags:.*grant_param") ]] ||
7899 skip "no grant_param connect flag"
7901 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
7903 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
7905 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
7906 stack_trap "rm -f $file" EXIT
7908 $LFS setstripe $file -i 0 -c 1
7909 dd if=/dev/zero of=$file bs=1M count=1000 &
7914 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
7915 if [[ $cur_grant -gt $max_cur_granted ]]
7918 error "cur_grant $cur_grant > $max_cur_granted"
7921 [[ $? -ne 0 ]] && break;
7926 wait_delete_completed
7927 $LCTL set_param debug="$olddebug" 2> /dev/null || true
7929 run_test 64d "check grant limit exceed"
7931 # bug 1414 - set/get directories' stripe info
7933 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7935 test_mkdir $DIR/$tdir
7937 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7939 run_test 65a "directory with no stripe info"
7942 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7944 test_mkdir $DIR/$tdir
7945 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7947 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7950 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
7952 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
7955 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7956 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
7958 test_mkdir $DIR/$tdir
7959 local stripesize=$($LFS getstripe -S $DIR/$tdir)
7961 $LFS setstripe -S $((stripesize * 4)) -i 1 \
7962 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
7964 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
7966 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
7969 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7971 test_mkdir $DIR/$tdir
7972 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
7973 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7975 if [[ $STRIPECOUNT -le 0 ]]; then
7977 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
7978 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
7979 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
7981 sc=$(($STRIPECOUNT - 1))
7983 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
7984 touch $DIR/$tdir/f4 $DIR/$tdir/f5
7985 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
7986 error "lverify failed"
7988 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
7991 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7993 test_mkdir $DIR/$tdir
7995 $LFS setstripe $DIR/$tdir || error "setstripe"
7996 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7997 error "no stripe info failed"
7999 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
8001 run_test 65e "directory setstripe defaults"
8004 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8006 test_mkdir $DIR/${tdir}f
8007 $RUNAS $LFS setstripe $DIR/${tdir}f &&
8008 error "setstripe succeeded" || true
8010 run_test 65f "dir setstripe permission (should return error) ==="
8013 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8015 test_mkdir $DIR/$tdir
8016 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8018 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8019 error "setstripe -S failed"
8020 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
8021 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
8022 error "delete default stripe failed"
8024 run_test 65g "directory setstripe -d"
8027 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8029 test_mkdir $DIR/$tdir
8030 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8032 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8033 error "setstripe -S failed"
8034 test_mkdir $DIR/$tdir/dd1
8035 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
8036 error "stripe info inherit failed"
8038 run_test 65h "directory stripe info inherit ===================="
8041 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8043 save_layout_restore_at_exit $MOUNT
8045 # bug6367: set non-default striping on root directory
8046 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
8048 # bug12836: getstripe on -1 default directory striping
8049 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
8051 # bug12836: getstripe -v on -1 default directory striping
8052 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
8054 # bug12836: new find on -1 default directory striping
8055 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
8057 run_test 65i "various tests to set root directory striping"
8059 test_65j() { # bug6367
8060 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8064 # if we aren't already remounting for each test, do so for this test
8065 if [ "$I_MOUNTED" = "yes" ]; then
8066 cleanup || error "failed to unmount"
8070 save_layout_restore_at_exit $MOUNT
8072 $LFS setstripe -d $MOUNT || error "setstripe failed"
8074 run_test 65j "set default striping on root directory (bug 6367)="
8078 wait_delete_completed
8079 do_facet $SINGLEMDS "lctl set_param -n \
8080 osp.$ost*MDT0000.max_create_count=$max_count"
8081 do_facet $SINGLEMDS "lctl set_param -n \
8082 osp.$ost*MDT0000.create_count=$count"
8083 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
8084 echo $INACTIVE_OSC "is Activate"
8086 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
8089 test_65k() { # bug11679
8090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8091 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8092 remote_mds_nodsh && skip "remote MDS with nodsh"
8094 local disable_precreate=true
8095 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
8096 disable_precreate=false
8098 echo "Check OST status: "
8099 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
8100 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
8102 for OSC in $MDS_OSCS; do
8103 echo $OSC "is active"
8104 do_facet $SINGLEMDS lctl --device %$OSC activate
8107 for INACTIVE_OSC in $MDS_OSCS; do
8108 local ost=$(osc_to_ost $INACTIVE_OSC)
8109 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
8110 lov.*md*.target_obd |
8111 awk -F: /$ost/'{ print $1 }' | head -n 1)
8114 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
8115 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
8117 echo "Deactivate: " $INACTIVE_OSC
8118 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
8120 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
8121 osp.$ost*MDT0000.create_count")
8122 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
8123 osp.$ost*MDT0000.max_create_count")
8124 $disable_precreate &&
8125 do_facet $SINGLEMDS "lctl set_param -n \
8126 osp.$ost*MDT0000.max_create_count=0"
8128 for idx in $(seq 0 $((OSTCOUNT - 1))); do
8129 [ -f $DIR/$tdir/$idx ] && continue
8130 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
8131 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
8133 error "setstripe $idx should succeed"; }
8134 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
8136 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
8139 do_facet $SINGLEMDS "lctl set_param -n \
8140 osp.$ost*MDT0000.max_create_count=$max_count"
8141 do_facet $SINGLEMDS "lctl set_param -n \
8142 osp.$ost*MDT0000.create_count=$count"
8143 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
8144 echo $INACTIVE_OSC "is Activate"
8146 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
8149 run_test 65k "validate manual striping works properly with deactivated OSCs"
8151 test_65l() { # bug 12836
8152 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8154 test_mkdir -p $DIR/$tdir/test_dir
8155 $LFS setstripe -c -1 $DIR/$tdir/test_dir
8156 $LFS find -mtime -1 $DIR/$tdir >/dev/null
8158 run_test 65l "lfs find on -1 stripe dir ========================"
8161 local layout=$(save_layout $MOUNT)
8162 $RUNAS $LFS setstripe -c 2 $MOUNT && {
8163 restore_layout $MOUNT $layout
8164 error "setstripe should fail by non-root users"
8168 run_test 65m "normal user can't set filesystem default stripe"
8171 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
8172 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
8173 skip "Need MDS version at least 2.12.50"
8174 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
8176 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
8177 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
8178 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
8180 local root_layout=$(save_layout $MOUNT)
8181 stack_trap "restore_layout $MOUNT $root_layout" EXIT
8183 # new subdirectory under root directory should not inherit
8184 # the default layout from root
8185 local dir1=$MOUNT/$tdir-1
8186 mkdir $dir1 || error "mkdir $dir1 failed"
8187 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
8188 error "$dir1 shouldn't have LOV EA"
8190 # delete the default layout on root directory
8191 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
8193 local dir2=$MOUNT/$tdir-2
8194 mkdir $dir2 || error "mkdir $dir2 failed"
8195 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
8196 error "$dir2 shouldn't have LOV EA"
8198 # set a new striping pattern on root directory
8199 local def_stripe_size=$($LFS getstripe -S $MOUNT)
8200 local new_def_stripe_size=$((def_stripe_size * 2))
8201 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
8202 error "set stripe size on $MOUNT failed"
8204 # new file created in $dir2 should inherit the new stripe size from
8205 # the filesystem default
8206 local file2=$dir2/$tfile-2
8207 touch $file2 || error "touch $file2 failed"
8209 local file2_stripe_size=$($LFS getstripe -S $file2)
8210 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
8211 error "$file2 didn't inherit stripe size $new_def_stripe_size"
8213 local dir3=$MOUNT/$tdir-3
8214 mkdir $dir3 || error "mkdir $dir3 failed"
8215 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
8216 # the root layout, which is the actual default layout that will be used
8217 # when new files are created in $dir3.
8218 local dir3_layout=$(get_layout_param $dir3)
8219 local root_dir_layout=$(get_layout_param $MOUNT)
8220 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
8221 error "$dir3 should show the default layout from $MOUNT"
8223 # set OST pool on root directory
8224 local pool=$TESTNAME
8225 pool_add $pool || error "add $pool failed"
8226 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8227 error "add targets to $pool failed"
8229 $LFS setstripe -p $pool $MOUNT ||
8230 error "set OST pool on $MOUNT failed"
8232 # new file created in $dir3 should inherit the pool from
8233 # the filesystem default
8234 local file3=$dir3/$tfile-3
8235 touch $file3 || error "touch $file3 failed"
8237 local file3_pool=$($LFS getstripe -p $file3)
8238 [[ "$file3_pool" = "$pool" ]] ||
8239 error "$file3 didn't inherit OST pool $pool"
8241 local dir4=$MOUNT/$tdir-4
8242 mkdir $dir4 || error "mkdir $dir4 failed"
8243 local dir4_layout=$(get_layout_param $dir4)
8244 root_dir_layout=$(get_layout_param $MOUNT)
8245 echo "$LFS getstripe -d $dir4"
8246 $LFS getstripe -d $dir4
8247 echo "$LFS getstripe -d $MOUNT"
8248 $LFS getstripe -d $MOUNT
8249 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
8250 error "$dir4 should show the default layout from $MOUNT"
8252 # new file created in $dir4 should inherit the pool from
8253 # the filesystem default
8254 local file4=$dir4/$tfile-4
8255 touch $file4 || error "touch $file4 failed"
8257 local file4_pool=$($LFS getstripe -p $file4)
8258 [[ "$file4_pool" = "$pool" ]] ||
8259 error "$file4 didn't inherit OST pool $pool"
8261 # new subdirectory under non-root directory should inherit
8262 # the default layout from its parent directory
8263 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
8264 error "set directory layout on $dir4 failed"
8266 local dir5=$dir4/$tdir-5
8267 mkdir $dir5 || error "mkdir $dir5 failed"
8269 dir4_layout=$(get_layout_param $dir4)
8270 local dir5_layout=$(get_layout_param $dir5)
8271 [[ "$dir4_layout" = "$dir5_layout" ]] ||
8272 error "$dir5 should inherit the default layout from $dir4"
8274 # though subdir under ROOT doesn't inherit default layout, but
8275 # its sub dir/file should be created with default layout.
8276 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
8277 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
8278 skip "Need MDS version at least 2.12.59"
8280 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
8281 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
8282 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
8284 if [ $default_lmv_hash == "none" ]; then
8285 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
8287 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
8288 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
8291 $LFS setdirstripe -D -c 2 $MOUNT ||
8292 error "setdirstripe -D -c 2 failed"
8293 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
8294 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
8295 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
8297 run_test 65n "don't inherit default layout from root for new subdirectories"
8299 # bug 2543 - update blocks count on client
8301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8304 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
8305 sync; sync_all_data; sync; sync_all_data
8306 cancel_lru_locks osc
8307 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
8308 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
8310 run_test 66 "update inode blocks count on client ==============="
8313 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
8317 swapon -s | awk '($1 == "'$1'") { print $4 }'
8320 # bug5265, obdfilter oa2dentry return -ENOENT
8321 # #define OBD_FAIL_SRV_ENOENT 0x217
8323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8324 remote_ost_nodsh && skip "remote OST with nodsh"
8327 $LFS setstripe -c 1 -i 0 $f
8329 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
8331 do_facet ost1 lctl set_param fail_loc=0x217
8332 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
8333 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
8335 do_facet ost1 lctl set_param fail_loc=0
8336 $DIRECTIO write $f 0 2 || error "write error"
8338 cancel_lru_locks osc
8339 $DIRECTIO read $f 0 1 || error "read error"
8341 do_facet ost1 lctl set_param fail_loc=0x217
8342 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
8344 do_facet ost1 lctl set_param fail_loc=0
8347 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
8350 test_mkdir $DIR/$tdir
8351 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
8352 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
8354 run_test 71 "Running dbench on lustre (don't segment fault) ===="
8356 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
8357 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8358 [ "$RUNAS_ID" = "$UID" ] &&
8359 skip_env "RUNAS_ID = UID = $UID -- skipping"
8360 # Check that testing environment is properly set up. Skip if not
8361 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
8362 skip_env "User $RUNAS_ID does not exist - skipping"
8365 chmod 777 $DIR/$tfile
8366 chmod ug+s $DIR/$tfile
8367 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
8368 error "$RUNAS dd $DIR/$tfile failed"
8369 # See if we are still setuid/sgid
8370 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
8371 error "S/gid is not dropped on write"
8372 # Now test that MDS is updated too
8373 cancel_lru_locks mdc
8374 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
8375 error "S/gid is not dropped on MDS"
8378 run_test 72a "Test that remove suid works properly (bug5695) ===="
8380 test_72b() { # bug 24226 -- keep mode setting when size is not changing
8383 [ "$RUNAS_ID" = "$UID" ] &&
8384 skip_env "RUNAS_ID = UID = $UID -- skipping"
8385 [ "$RUNAS_ID" -eq 0 ] &&
8386 skip_env "RUNAS_ID = 0 -- skipping"
8387 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8388 # Check that testing environment is properly set up. Skip if not
8389 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
8390 skip_env "User $RUNAS_ID does not exist - skipping"
8392 touch $DIR/${tfile}-f{g,u}
8393 test_mkdir $DIR/${tfile}-dg
8394 test_mkdir $DIR/${tfile}-du
8395 chmod 770 $DIR/${tfile}-{f,d}{g,u}
8396 chmod g+s $DIR/${tfile}-{f,d}g
8397 chmod u+s $DIR/${tfile}-{f,d}u
8398 for perm in 777 2777 4777; do
8399 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
8400 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
8401 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
8402 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
8406 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
8408 # bug 3462 - multiple simultaneous MDC requests
8410 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8412 test_mkdir $DIR/d73-1
8413 test_mkdir $DIR/d73-2
8414 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
8417 lctl set_param fail_loc=0x80000129
8418 $MULTIOP $DIR/d73-1/f73-2 Oc &
8420 lctl set_param fail_loc=0
8422 $MULTIOP $DIR/d73-2/f73-3 Oc &
8426 wait $pid1 || return 1
8430 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
8431 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
8432 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
8436 run_test 73 "multiple MDC requests (should not deadlock)"
8438 test_74a() { # bug 6149, 6184
8439 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8442 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8444 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8445 # will spin in a tight reconnection loop
8446 $LCTL set_param fail_loc=0x8000030e
8447 # get any lock that won't be difficult - lookup works.
8449 $LCTL set_param fail_loc=0
8453 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
8455 test_74b() { # bug 13310
8456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8458 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8460 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8461 # will spin in a tight reconnection loop
8462 $LCTL set_param fail_loc=0x8000030e
8463 # get a "difficult" lock
8465 $LCTL set_param fail_loc=0
8469 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
8472 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8474 #define OBD_FAIL_LDLM_NEW_LOCK
8475 $LCTL set_param fail_loc=0x319
8476 touch $DIR/$tfile && error "touch successful"
8477 $LCTL set_param fail_loc=0
8480 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
8483 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
8486 test_76() { # Now for bug 20433, added originally in bug 1443
8487 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8489 cancel_lru_locks osc
8490 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
8491 local before=$(num_inodes)
8492 local count=$((512 * cpus))
8493 [ "$SLOW" = "no" ] && count=$((64 * cpus))
8495 echo "before inodes: $before"
8496 for i in $(seq $count); do
8500 cancel_lru_locks osc
8501 local after=$(num_inodes)
8502 echo "after inodes: $after"
8503 while (( after > before + 8 * ${cpus:-1} )); do
8507 (( wait % 5 == 0 )) && echo "wait $wait seconds inodes: $after"
8508 if (( wait > 30 )); then
8509 error "inode slab grew from $before to $after"
8513 run_test 76 "confirm clients recycle inodes properly ===="
8519 # Note: in sptlrpc modes which enable its own bulk checksum, the
8520 # original crc32_le bulk checksum will be automatically disabled,
8521 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
8522 # will be checked by sptlrpc code against sptlrpc bulk checksum.
8523 # In this case set_checksums() will not be no-op, because sptlrpc
8524 # bulk checksum will be enabled all through the test.
8526 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
8527 lctl set_param -n osc.*.checksums $1
8531 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8532 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
8533 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8534 tr -d [] | head -n1)}
8537 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
8539 log "set checksum type to $1, rc = $rc"
8543 get_osc_checksum_type()
8545 # arugment 1: OST name, like OST0000
8547 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
8548 sed 's/.*\[\(.*\)\].*/\1/g')
8550 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
8554 F77_TMP=$TMP/f77-temp
8557 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
8558 error "error writing to $F77_TMP"
8561 test_77a() { # bug 10889
8562 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8563 $GSS && skip_env "could not run with gss"
8565 [ ! -f $F77_TMP ] && setup_f77
8567 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
8571 run_test 77a "normal checksum read/write operation"
8573 test_77b() { # bug 10889
8574 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8575 $GSS && skip_env "could not run with gss"
8577 [ ! -f $F77_TMP ] && setup_f77
8578 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8579 $LCTL set_param fail_loc=0x80000409
8582 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8583 error "dd error: $?"
8584 $LCTL set_param fail_loc=0
8586 for algo in $CKSUM_TYPES; do
8587 cancel_lru_locks osc
8588 set_checksum_type $algo
8589 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8590 $LCTL set_param fail_loc=0x80000408
8591 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
8592 $LCTL set_param fail_loc=0
8595 set_checksum_type $ORIG_CSUM_TYPE
8598 run_test 77b "checksum error on client write, read"
8603 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
8605 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
8606 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
8607 $check_ost && [ -n "$ost_file_prefix" ] &&
8608 do_facet ost1 rm -f ${ost_file_prefix}\*
8612 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8613 $GSS && skip_env "could not run with gss"
8614 remote_ost_nodsh && skip "remote OST with nodsh"
8617 local osc_file_prefix
8619 local check_ost=false
8620 local ost_file_prefix
8626 # ensure corruption will occur on first OSS/OST
8627 $LFS setstripe -i 0 $DIR/$tfile
8629 [ ! -f $F77_TMP ] && setup_f77
8630 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8631 error "dd write error: $?"
8632 fid=$($LFS path2fid $DIR/$tfile)
8634 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
8637 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
8638 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
8640 echo "OSS do not support bulk pages dump upon error"
8643 osc_file_prefix=$($LCTL get_param -n debug_path)
8644 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
8646 trap cleanup_77c EXIT
8649 # enable bulk pages dump upon error on Client
8650 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
8651 # enable bulk pages dump upon error on OSS
8653 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
8655 # flush Client cache to allow next read to reach OSS
8656 cancel_lru_locks osc
8658 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8659 $LCTL set_param fail_loc=0x80000408
8660 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
8661 $LCTL set_param fail_loc=0
8665 # check cksum dump on Client
8666 osc_file=$(ls ${osc_file_prefix}*)
8667 [ -n "$osc_file" ] || error "no checksum dump file on Client"
8668 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
8669 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
8670 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
8671 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
8673 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
8674 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8675 error "dump content does not match on Client"
8677 $check_ost || skip "No need to check cksum dump on OSS"
8679 # check cksum dump on OSS
8680 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
8681 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
8682 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
8683 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
8684 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8685 error "dump content does not match on OSS"
8689 run_test 77c "checksum error on client read with debug"
8691 test_77d() { # bug 10889
8692 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8693 $GSS && skip_env "could not run with gss"
8695 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8696 $LCTL set_param fail_loc=0x80000409
8698 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8699 error "direct write: rc=$?"
8700 $LCTL set_param fail_loc=0
8703 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8704 $LCTL set_param fail_loc=0x80000408
8706 cancel_lru_locks osc
8707 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8708 error "direct read: rc=$?"
8709 $LCTL set_param fail_loc=0
8712 run_test 77d "checksum error on OST direct write, read"
8714 test_77f() { # bug 10889
8715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8716 $GSS && skip_env "could not run with gss"
8719 for algo in $CKSUM_TYPES; do
8720 cancel_lru_locks osc
8721 set_checksum_type $algo
8722 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8723 $LCTL set_param fail_loc=0x409
8724 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
8725 error "direct write succeeded"
8726 $LCTL set_param fail_loc=0
8728 set_checksum_type $ORIG_CSUM_TYPE
8731 run_test 77f "repeat checksum error on write (expect error)"
8733 test_77g() { # bug 10889
8734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8735 $GSS && skip_env "could not run with gss"
8736 remote_ost_nodsh && skip "remote OST with nodsh"
8738 [ ! -f $F77_TMP ] && setup_f77
8740 local file=$DIR/$tfile
8741 stack_trap "rm -f $file" EXIT
8743 $LFS setstripe -c 1 -i 0 $file
8744 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
8745 do_facet ost1 lctl set_param fail_loc=0x8000021a
8747 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
8748 error "write error: rc=$?"
8749 do_facet ost1 lctl set_param fail_loc=0
8752 cancel_lru_locks osc
8753 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
8754 do_facet ost1 lctl set_param fail_loc=0x8000021b
8756 cmp $F77_TMP $file || error "file compare failed"
8757 do_facet ost1 lctl set_param fail_loc=0
8760 run_test 77g "checksum error on OST write, read"
8762 test_77k() { # LU-10906
8763 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8764 $GSS && skip_env "could not run with gss"
8766 local cksum_param="osc.$FSNAME*.checksums"
8767 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
8771 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
8772 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
8773 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
8777 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
8778 error "failed to set checksum=$i on MGS"
8779 wait_update $HOSTNAME "$get_checksum" $i
8781 echo "remount client, checksum should be $i"
8782 remount_client $MOUNT || error "failed to remount client"
8783 checksum=$(eval $get_checksum)
8784 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8786 # remove persistent param to avoid races with checksum mountopt below
8787 do_facet mgs $LCTL set_param -P -d $cksum_param ||
8788 error "failed to delete checksum on MGS"
8790 for opt in "checksum" "nochecksum"; do
8791 #remount with mount option
8792 echo "remount client with option $opt, checksum should be $i"
8793 umount_client $MOUNT || error "failed to umount client"
8794 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
8795 error "failed to mount client with option '$opt'"
8796 checksum=$(eval $get_checksum)
8797 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8801 remount_client $MOUNT || error "failed to remount client"
8803 run_test 77k "enable/disable checksum correctly"
8806 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8807 $GSS && skip_env "could not run with gss"
8810 stack_trap "set_checksums $ORIG_CSUM" EXIT
8811 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
8813 set_checksum_type invalid && error "unexpected success of invalid checksum type"
8815 $LFS setstripe -c 1 -i 0 $DIR/$tfile
8816 for algo in $CKSUM_TYPES; do
8817 set_checksum_type $algo || error "fail to set checksum type $algo"
8818 osc_algo=$(get_osc_checksum_type OST0000)
8819 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
8821 # no locks, no reqs to let the connection idle
8822 cancel_lru_locks osc
8823 lru_resize_disable osc
8824 wait_osc_import_state client ost1 IDLE
8826 # ensure ost1 is connected
8827 stat $DIR/$tfile >/dev/null || error "can't stat"
8828 wait_osc_import_state client ost1 FULL
8830 osc_algo=$(get_osc_checksum_type OST0000)
8831 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
8835 run_test 77l "preferred checksum type is remembered after reconnected"
8837 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
8846 test_78() { # bug 10901
8847 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8848 remote_ost || skip_env "local OST"
8851 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
8852 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
8853 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
8854 echo "MemTotal: $MEMTOTAL"
8856 # reserve 256MB of memory for the kernel and other running processes,
8857 # and then take 1/2 of the remaining memory for the read/write buffers.
8858 if [ $MEMTOTAL -gt 512 ] ;then
8859 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
8861 # for those poor memory-starved high-end clusters...
8862 MEMTOTAL=$((MEMTOTAL / 2))
8864 echo "Mem to use for directio: $MEMTOTAL"
8866 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
8867 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
8868 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
8869 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
8871 echo "Smallest OST: $SMALLESTOST"
8872 [[ $SMALLESTOST -lt 10240 ]] &&
8873 skip "too small OSTSIZE, useless to run large O_DIRECT test"
8875 trap cleanup_test_78 EXIT
8877 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
8878 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
8880 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
8881 echo "File size: $F78SIZE"
8882 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
8883 for i in $(seq 1 $NSEQ); do
8884 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
8885 echo directIO rdwr round $i of $NSEQ
8886 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
8891 run_test 78 "handle large O_DIRECT writes correctly ============"
8893 test_79() { # bug 12743
8894 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8896 wait_delete_completed
8898 BKTOTAL=$(calc_osc_kbytes kbytestotal)
8899 BKFREE=$(calc_osc_kbytes kbytesfree)
8900 BKAVAIL=$(calc_osc_kbytes kbytesavail)
8902 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
8903 DFTOTAL=`echo $STRING | cut -d, -f1`
8904 DFUSED=`echo $STRING | cut -d, -f2`
8905 DFAVAIL=`echo $STRING | cut -d, -f3`
8906 DFFREE=$(($DFTOTAL - $DFUSED))
8908 ALLOWANCE=$((64 * $OSTCOUNT))
8910 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
8911 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
8912 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
8914 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
8915 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
8916 error "df free($DFFREE) mismatch OST free($BKFREE)"
8918 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
8919 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
8920 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
8923 run_test 79 "df report consistency check ======================="
8925 test_80() { # bug 10718
8926 remote_ost_nodsh && skip "remote OST with nodsh"
8927 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8929 # relax strong synchronous semantics for slow backends like ZFS
8930 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
8931 local soc="obdfilter.*.sync_lock_cancel"
8932 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8934 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
8935 if [ -z "$save" ]; then
8936 soc="obdfilter.*.sync_on_lock_cancel"
8937 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8940 if [ "$save" != "never" ]; then
8941 local hosts=$(comma_list $(osts_nodes))
8943 do_nodes $hosts $LCTL set_param $soc=never
8944 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
8948 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
8950 local before=$(date +%s)
8951 cancel_lru_locks osc
8952 local after=$(date +%s)
8953 local diff=$((after - before))
8954 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
8958 run_test 80 "Page eviction is equally fast at high offsets too"
8960 test_81a() { # LU-456
8961 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8962 remote_ost_nodsh && skip "remote OST with nodsh"
8964 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8965 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
8966 do_facet ost1 lctl set_param fail_loc=0x80000228
8968 # write should trigger a retry and success
8969 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8970 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8972 if [ $RC -ne 0 ] ; then
8973 error "write should success, but failed for $RC"
8976 run_test 81a "OST should retry write when get -ENOSPC ==============="
8978 test_81b() { # LU-456
8979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8980 remote_ost_nodsh && skip "remote OST with nodsh"
8982 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8983 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
8984 do_facet ost1 lctl set_param fail_loc=0x228
8986 # write should retry several times and return -ENOSPC finally
8987 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8988 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8991 if [ $RC -ne $ENOSPC ] ; then
8992 error "dd should fail for -ENOSPC, but succeed."
8995 run_test 81b "OST should return -ENOSPC when retry still fails ======="
8997 test_82() { # LU-1031
8998 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
9002 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
9004 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
9006 kill -USR1 $MULTIPID2
9008 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
9009 error "First grouplock does not block second one"
9011 echo "Second grouplock blocks first one"
9013 kill -USR1 $MULTIPID1
9017 run_test 82 "Basic grouplock test"
9020 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
9022 test_mkdir $DIR/$tdir.cvsroot
9023 chown $RUNAS_ID $DIR/$tdir.cvsroot
9026 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
9029 # some versions of cvs import exit(1) when asked to import links or
9030 # files they can't read. ignore those files.
9031 local toignore=$(find . -type l -printf '-I %f\n' -o \
9032 ! -perm /4 -printf '-I %f\n')
9033 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
9034 $tdir.reposname vtag rtag
9037 test_mkdir $DIR/$tdir.reposname
9038 chown $RUNAS_ID $DIR/$tdir.reposname
9039 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
9041 cd $DIR/$tdir.reposname
9043 $RUNAS cvs add -m 'addmsg' foo99
9045 $RUNAS cvs commit -m 'nomsg' foo99
9046 rm -fr $DIR/$tdir.cvsroot
9048 run_test 99 "cvs strange file/directory operations"
9051 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9052 [[ "$NETTYPE" =~ tcp ]] ||
9053 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
9054 remote_ost_nodsh && skip "remote OST with nodsh"
9055 remote_mds_nodsh && skip "remote MDS with nodsh"
9057 skip "useless for local single node setup"
9059 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
9060 [ "$PROT" != "tcp" ] && continue
9061 RPORT=$(echo $REMOTE | cut -d: -f2)
9062 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
9065 LPORT=`echo $LOCAL | cut -d: -f2`
9066 if [ $LPORT -ge 1024 ]; then
9067 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
9069 error_exit "local: $LPORT > 1024, remote: $RPORT"
9072 [ "$rc" = 0 ] || error_exit "privileged port not found" )
9074 run_test 100 "check local port using privileged port ==========="
9076 function get_named_value()
9085 echo $line | sed "s/^$tag[ ]*//"
9092 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
9093 awk '/^max_cached_mb/ { print $2 }')
9096 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
9101 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9106 local cache_limit=32
9108 $LCTL set_param -n osc.*-osc*.rpc_stats 0
9109 trap cleanup_101a EXIT
9110 $LCTL set_param -n llite.*.read_ahead_stats 0
9111 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
9114 # randomly read 10000 of 64K chunks from file 3x 32MB in size
9116 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
9117 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
9120 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
9121 get_named_value 'read but discarded' | cut -d" " -f1); do
9122 discard=$(($discard + $s))
9126 $LCTL get_param osc.*-osc*.rpc_stats
9127 $LCTL get_param llite.*.read_ahead_stats
9129 # Discard is generally zero, but sometimes a few random reads line up
9130 # and trigger larger readahead, which is wasted & leads to discards.
9131 if [[ $(($discard)) -gt $nreads ]]; then
9132 error "too many ($discard) discarded pages"
9134 rm -f $DIR/$tfile || true
9136 run_test 101a "check read-ahead for random reads"
9139 test_mkdir $DIR/$tdir
9141 local FILE_LENGTH=$2
9144 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
9146 local list=$(comma_list $(osts_nodes))
9147 set_osd_param $list '' read_cache_enable 0
9148 set_osd_param $list '' writethrough_cache_enable 0
9150 trap cleanup_test101bc EXIT
9151 # prepare the read-ahead file
9152 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
9154 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
9155 count=$FILE_SIZE_MB 2> /dev/null
9159 cleanup_test101bc() {
9164 local list=$(comma_list $(osts_nodes))
9165 set_osd_param $list '' read_cache_enable 1
9166 set_osd_param $list '' writethrough_cache_enable 1
9170 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
9175 local STRIPE_SIZE=$2
9176 local FILE_LENGTH=$3
9177 local RA_INC=1048576
9178 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
9179 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
9180 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
9181 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
9182 get_named_value 'read but discarded' |
9183 cut -d" " -f1 | calc_total)
9184 if [[ $DISCARD -gt $discard_limit ]]; then
9185 $LCTL get_param llite.*.read_ahead_stats
9186 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
9188 echo "Read-ahead success for size ${READ_SIZE}"
9193 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9194 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9196 local STRIPE_SIZE=1048576
9197 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
9199 if [ $SLOW == "yes" ]; then
9200 local FILE_LENGTH=$((STRIDE_SIZE * 64))
9202 local FILE_LENGTH=$((STRIDE_SIZE * 8))
9205 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
9207 # prepare the read-ahead file
9208 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
9209 cancel_lru_locks osc
9210 for BIDX in 2 4 8 16 32 64 128 256
9212 local BSIZE=$((BIDX*4096))
9213 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
9214 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
9215 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
9216 $LCTL set_param -n llite.*.read_ahead_stats 0
9217 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
9218 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
9219 cancel_lru_locks osc
9220 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
9225 run_test 101b "check stride-io mode read-ahead ================="
9228 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9230 local STRIPE_SIZE=1048576
9231 local FILE_LENGTH=$((STRIPE_SIZE*100))
9236 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
9238 cancel_lru_locks osc
9239 $LCTL set_param osc.*.rpc_stats 0
9240 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
9241 $LCTL get_param osc.*.rpc_stats
9242 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
9243 local stats=$($LCTL get_param -n $osc_rpc_stats)
9244 local lines=$(echo "$stats" | awk 'END {print NR;}')
9247 if [ $lines -le 20 ]; then
9248 echo "continue debug"
9251 for size in 1 2 4 8; do
9252 local rpc=$(echo "$stats" |
9253 awk '($1 == "'$size':") {print $2; exit; }')
9254 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
9255 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
9257 echo "$osc_rpc_stats check passed!"
9262 run_test 101c "check stripe_size aligned read-ahead ================="
9265 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9267 local file=$DIR/$tfile
9268 local sz_MB=${FILESIZE_101d:-80}
9269 local ra_MB=${READAHEAD_MB:-40}
9271 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
9272 [ $free_MB -lt $sz_MB ] &&
9273 skip "Need free space ${sz_MB}M, have ${free_MB}M"
9275 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
9276 $LFS setstripe -c -1 $file || error "setstripe failed"
9278 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
9279 echo Cancel LRU locks on lustre client to flush the client cache
9280 cancel_lru_locks osc
9282 echo Disable read-ahead
9283 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
9284 $LCTL set_param -n llite.*.max_read_ahead_mb=0
9285 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_RA" EXIT
9286 $LCTL get_param -n llite.*.max_read_ahead_mb
9288 echo "Reading the test file $file with read-ahead disabled"
9289 local sz_KB=$((sz_MB * 1024 / 4))
9290 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
9291 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
9292 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
9293 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
9295 echo "Cancel LRU locks on lustre client to flush the client cache"
9296 cancel_lru_locks osc
9297 echo Enable read-ahead with ${ra_MB}MB
9298 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
9300 echo "Reading the test file $file with read-ahead enabled"
9301 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
9302 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
9304 echo "read-ahead disabled time read $raOFF"
9305 echo "read-ahead enabled time read $raON"
9308 wait_delete_completed
9310 # use awk for this check instead of bash because it handles decimals
9311 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
9312 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
9314 run_test 101d "file read with and without read-ahead enabled"
9317 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9319 local file=$DIR/$tfile
9320 local size_KB=500 #KB
9324 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
9325 local need_KB=$((count * size_KB))
9326 [[ $free_KB -le $need_KB ]] &&
9327 skip_env "Need free space $need_KB, have $free_KB"
9329 echo "Creating $count ${size_KB}K test files"
9330 for ((i = 0; i < $count; i++)); do
9331 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
9334 echo "Cancel LRU locks on lustre client to flush the client cache"
9335 cancel_lru_locks $OSC
9337 echo "Reset readahead stats"
9338 $LCTL set_param -n llite.*.read_ahead_stats 0
9340 for ((i = 0; i < $count; i++)); do
9341 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
9344 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9345 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9347 for ((i = 0; i < $count; i++)); do
9348 rm -rf $file.$i 2>/dev/null
9351 #10000 means 20% reads are missing in readahead
9352 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
9354 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
9357 which iozone || skip_env "no iozone installed"
9359 local old_debug=$($LCTL get_param debug)
9360 old_debug=${old_debug#*=}
9361 $LCTL set_param debug="reada mmap"
9363 # create a test file
9364 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
9366 echo Cancel LRU locks on lustre client to flush the client cache
9367 cancel_lru_locks osc
9369 echo Reset readahead stats
9370 $LCTL set_param -n llite.*.read_ahead_stats 0
9372 echo mmap read the file with small block size
9373 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
9376 echo checking missing pages
9377 $LCTL get_param llite.*.read_ahead_stats
9378 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9379 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9381 $LCTL set_param debug="$old_debug"
9382 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
9385 run_test 101f "check mmap read performance"
9387 test_101g_brw_size_test() {
9389 local pages=$((mb * 1048576 / PAGE_SIZE))
9390 local file=$DIR/$tfile
9392 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
9393 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
9394 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
9395 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
9399 stack_trap "rm -f $file" EXIT
9400 $LCTL set_param -n osc.*.rpc_stats=0
9402 # 10 RPCs should be enough for the test
9404 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
9405 { error "dd write ${mb} MB blocks failed"; return 3; }
9406 cancel_lru_locks osc
9407 dd of=/dev/null if=$file bs=${mb}M count=$count ||
9408 { error "dd write ${mb} MB blocks failed"; return 4; }
9410 # calculate number of full-sized read and write RPCs
9411 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
9412 sed -n '/pages per rpc/,/^$/p' |
9413 awk '/'$pages':/ { reads += $2; writes += $6 }; \
9414 END { print reads,writes }'))
9415 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
9417 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
9424 remote_ost_nodsh && skip "remote OST with nodsh"
9427 local osts=$(get_facets OST)
9428 local list=$(comma_list $(osts_nodes))
9429 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9430 local brw_size="obdfilter.*.brw_size"
9432 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9434 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
9436 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
9437 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
9438 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
9439 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
9440 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
9441 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
9443 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
9446 if [[ $orig_mb -lt 16 ]]; then
9447 save_lustre_params $osts "$brw_size" > $p
9448 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
9449 error "set 16MB RPC size failed"
9451 echo "remount client to enable new RPC size"
9452 remount_client $MOUNT || error "remount_client failed"
9455 test_101g_brw_size_test 16 || error "16MB RPC test failed"
9456 # should be able to set brw_size=12, but no rpc_stats for that
9457 test_101g_brw_size_test 8 || error "8MB RPC test failed"
9460 test_101g_brw_size_test 4 || error "4MB RPC test failed"
9462 if [[ $orig_mb -lt 16 ]]; then
9463 restore_lustre_params < $p
9464 remount_client $MOUNT || error "remount_client restore failed"
9467 rm -f $p $DIR/$tfile
9469 run_test 101g "Big bulk(4/16 MiB) readahead"
9472 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9474 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
9475 error "dd 70M file failed"
9476 echo Cancel LRU locks on lustre client to flush the client cache
9477 cancel_lru_locks osc
9479 echo "Reset readahead stats"
9480 $LCTL set_param -n llite.*.read_ahead_stats 0
9482 echo "Read 10M of data but cross 64M bundary"
9483 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
9484 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9485 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9486 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
9487 rm -f $p $DIR/$tfile
9489 run_test 101h "Readahead should cover current read window"
9492 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
9493 error "dd 10M file failed"
9495 local max_per_file_mb=$($LCTL get_param -n \
9496 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
9497 cancel_lru_locks osc
9498 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
9499 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
9500 error "set max_read_ahead_per_file_mb to 1 failed"
9502 echo "Reset readahead stats"
9503 $LCTL set_param llite.*.read_ahead_stats=0
9505 dd if=$DIR/$tfile of=/dev/null bs=2M
9507 $LCTL get_param llite.*.read_ahead_stats
9508 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9509 awk '/misses/ { print $2 }')
9510 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
9513 run_test 101i "allow current readahead to exceed reservation"
9516 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
9517 error "setstripe $DIR/$tfile failed"
9518 local file_size=$((1048576 * 16))
9519 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
9520 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
9522 echo Disable read-ahead
9523 $LCTL set_param -n llite.*.max_read_ahead_mb=0
9525 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
9526 for blk in $PAGE_SIZE 1048576 $file_size; do
9527 cancel_lru_locks osc
9528 echo "Reset readahead stats"
9529 $LCTL set_param -n llite.*.read_ahead_stats=0
9530 local count=$(($file_size / $blk))
9531 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
9532 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9533 get_named_value 'failed to fast read' |
9534 cut -d" " -f1 | calc_total)
9535 $LCTL get_param -n llite.*.read_ahead_stats
9536 [ $miss -eq $count ] || error "expected $count got $miss"
9539 rm -f $p $DIR/$tfile
9541 run_test 101j "A complete read block should be submitted when no RA"
9544 test_mkdir $DIR/$tdir
9545 chown $RUNAS_ID $DIR/$tdir
9548 STRIPE_COUNT=$OSTCOUNT
9549 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
9551 trap cleanup_test102 EXIT
9553 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
9555 for num in 1 2 3 4; do
9556 for count in $(seq 1 $STRIPE_COUNT); do
9557 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
9558 local size=`expr $STRIPE_SIZE \* $num`
9559 local file=file"$num-$idx-$count"
9560 $1 $LFS setstripe -S $size -i $idx -c $count $file
9566 $1 tar cf $TMP/f102.tar $tdir --xattrs
9572 rm -rf $DIR/d0.sanity/d102
9576 [ "$UID" != 0 ] && skip "must run as root"
9577 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
9578 skip_env "must have user_xattr"
9580 [ -z "$(which setfattr 2>/dev/null)" ] &&
9581 skip_env "could not find setfattr"
9583 local testfile=$DIR/$tfile
9586 echo "set/get xattr..."
9587 setfattr -n trusted.name1 -v value1 $testfile ||
9588 error "setfattr -n trusted.name1=value1 $testfile failed"
9589 getfattr -n trusted.name1 $testfile 2> /dev/null |
9590 grep "trusted.name1=.value1" ||
9591 error "$testfile missing trusted.name1=value1"
9593 setfattr -n user.author1 -v author1 $testfile ||
9594 error "setfattr -n user.author1=author1 $testfile failed"
9595 getfattr -n user.author1 $testfile 2> /dev/null |
9596 grep "user.author1=.author1" ||
9597 error "$testfile missing trusted.author1=author1"
9600 setfattr -n trusted.name2 -v value2 $testfile ||
9601 error "$testfile unable to set trusted.name2"
9602 setfattr -n trusted.name3 -v value3 $testfile ||
9603 error "$testfile unable to set trusted.name3"
9604 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
9605 grep "trusted.name" | wc -l) -eq 3 ] ||
9606 error "$testfile missing 3 trusted.name xattrs"
9608 setfattr -n user.author2 -v author2 $testfile ||
9609 error "$testfile unable to set user.author2"
9610 setfattr -n user.author3 -v author3 $testfile ||
9611 error "$testfile unable to set user.author3"
9612 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
9613 grep "user.author" | wc -l) -eq 3 ] ||
9614 error "$testfile missing 3 user.author xattrs"
9616 echo "remove xattr..."
9617 setfattr -x trusted.name1 $testfile ||
9618 error "$testfile error deleting trusted.name1"
9619 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
9620 error "$testfile did not delete trusted.name1 xattr"
9622 setfattr -x user.author1 $testfile ||
9623 error "$testfile error deleting user.author1"
9624 echo "set lustre special xattr ..."
9625 $LFS setstripe -c1 $testfile
9626 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
9627 awk -F "=" '/trusted.lov/ { print $2 }' )
9628 setfattr -n "trusted.lov" -v $lovea $testfile ||
9629 error "$testfile doesn't ignore setting trusted.lov again"
9630 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
9631 error "$testfile allow setting invalid trusted.lov"
9634 run_test 102a "user xattr test =================================="
9636 check_102b_layout() {
9638 local testfile=$DIR/$tfile
9640 echo "test layout '$layout'"
9641 $LFS setstripe $layout $testfile || error "setstripe failed"
9642 $LFS getstripe -y $testfile
9644 echo "get/set/list trusted.lov xattr ..." # b=10930
9645 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
9646 [[ "$value" =~ "trusted.lov" ]] ||
9647 error "can't get trusted.lov from $testfile"
9648 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
9649 error "getstripe failed"
9651 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
9653 value=$(cut -d= -f2 <<<$value)
9654 # LU-13168: truncated xattr should fail if short lov_user_md header
9655 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
9656 lens="${#value}" || lens="$(seq 4 2 ${#value})"
9657 for len in $lens; do
9658 echo "setfattr $len $testfile.2"
9659 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
9660 [ $len -lt 66 ] && error "short xattr len=$len worked"
9662 local stripe_size=$($LFS getstripe -S $testfile.2)
9663 local stripe_count=$($LFS getstripe -c $testfile.2)
9664 [[ $stripe_size -eq 65536 ]] ||
9665 error "stripe size $stripe_size != 65536"
9666 [[ $stripe_count -eq $stripe_count_orig ]] ||
9667 error "stripe count $stripe_count != $stripe_count_orig"
9668 rm $testfile $testfile.2
9672 [ -z "$(which setfattr 2>/dev/null)" ] &&
9673 skip_env "could not find setfattr"
9674 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9676 # check plain layout
9677 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
9679 # and also check composite layout
9680 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
9683 run_test 102b "getfattr/setfattr for trusted.lov EAs"
9686 [ -z "$(which setfattr 2>/dev/null)" ] &&
9687 skip_env "could not find setfattr"
9688 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9690 # b10930: get/set/list lustre.lov xattr
9691 echo "get/set/list lustre.lov xattr ..."
9692 test_mkdir $DIR/$tdir
9693 chown $RUNAS_ID $DIR/$tdir
9694 local testfile=$DIR/$tdir/$tfile
9695 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
9696 error "setstripe failed"
9697 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
9698 error "getstripe failed"
9699 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
9700 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
9702 local testfile2=${testfile}2
9703 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
9704 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
9706 $RUNAS $MCREATE $testfile2
9707 $RUNAS setfattr -n lustre.lov -v $value $testfile2
9708 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
9709 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
9710 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
9711 [ $stripe_count -eq $STRIPECOUNT ] ||
9712 error "stripe count $stripe_count != $STRIPECOUNT"
9714 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
9716 compare_stripe_info1() {
9717 local stripe_index_all_zero=true
9719 for num in 1 2 3 4; do
9720 for count in $(seq 1 $STRIPE_COUNT); do
9721 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
9722 local size=$((STRIPE_SIZE * num))
9723 local file=file"$num-$offset-$count"
9724 stripe_size=$($LFS getstripe -S $PWD/$file)
9725 [[ $stripe_size -ne $size ]] &&
9726 error "$file: size $stripe_size != $size"
9727 stripe_count=$($LFS getstripe -c $PWD/$file)
9728 # allow fewer stripes to be created, ORI-601
9729 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
9730 error "$file: count $stripe_count != $count"
9731 stripe_index=$($LFS getstripe -i $PWD/$file)
9732 [[ $stripe_index -ne 0 ]] &&
9733 stripe_index_all_zero=false
9737 $stripe_index_all_zero &&
9738 error "all files are being extracted starting from OST index 0"
9742 have_xattrs_include() {
9743 tar --help | grep -q xattrs-include &&
9744 echo --xattrs-include="lustre.*"
9748 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9749 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9751 XINC=$(have_xattrs_include)
9753 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9755 compare_stripe_info1
9757 run_test 102d "tar restore stripe info from tarfile,not keep osts"
9760 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9761 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9763 XINC=$(have_xattrs_include)
9765 test_mkdir $DIR/$tdir.restore
9767 tar cf - --xattrs $tdir | tar xf - \
9768 -C $DIR/$tdir.restore --xattrs $XINC
9769 cd $DIR/$tdir.restore/$tdir
9770 compare_stripe_info1
9772 run_test 102f "tar copy files, not keep osts"
9775 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
9776 skip "must have user_xattr"
9777 [ -z "$(which setfattr 2>/dev/null)" ] &&
9778 skip_env "could not find setfattr"
9779 [ -z "$(which getfattr 2>/dev/null)" ] &&
9780 skip_env "could not find getfattr"
9782 local xsize=${1:-1024} # in bytes
9783 local file=$DIR/$tfile
9784 local value="$(generate_string $xsize)"
9785 local xbig=trusted.big
9789 log "save $xbig on $file"
9792 setfattr -n $xbig -v $value $file ||
9793 error "saving $xbig on $file failed"
9795 setfattr -n $xbig -v $value $file &&
9796 error "saving $xbig on $file succeeded"
9800 local orig=$(get_xattr_value $xbig $file)
9801 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
9803 local xsml=trusted.sml
9804 log "save $xsml on $file"
9805 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
9807 local new=$(get_xattr_value $xbig $file)
9808 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
9810 log "grow $xsml on $file"
9811 setfattr -n $xsml -v "$value" $file ||
9812 error "growing $xsml on $file failed"
9814 new=$(get_xattr_value $xbig $file)
9815 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
9816 log "$xbig still valid after growing $xsml"
9821 test_102h() { # bug 15777
9824 run_test 102h "grow xattr from inside inode to external block"
9827 large_xattr_enabled || skip_env "ea_inode feature disabled"
9829 echo "setting xattr of max xattr size: $(max_xattr_size)"
9830 grow_xattr $(max_xattr_size)
9832 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
9833 echo "This should fail:"
9834 grow_xattr $(($(max_xattr_size) + 10)) 1
9836 run_test 102ha "grow xattr from inside inode to external inode"
9838 test_102i() { # bug 17038
9839 [ -z "$(which getfattr 2>/dev/null)" ] &&
9840 skip "could not find getfattr"
9843 ln -s $DIR/$tfile $DIR/${tfile}link
9844 getfattr -n trusted.lov $DIR/$tfile ||
9845 error "lgetxattr on $DIR/$tfile failed"
9846 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
9847 grep -i "no such attr" ||
9848 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
9849 rm -f $DIR/$tfile $DIR/${tfile}link
9851 run_test 102i "lgetxattr test on symbolic link ============"
9854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9855 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9857 XINC=$(have_xattrs_include)
9858 setup_test102 "$RUNAS"
9859 chown $RUNAS_ID $DIR/$tdir
9860 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9862 compare_stripe_info1 "$RUNAS"
9864 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
9867 [ -z "$(which setfattr 2>/dev/null)" ] &&
9868 skip "could not find setfattr"
9871 # b22187 just check that does not crash for regular file.
9872 setfattr -n trusted.lov $DIR/$tfile
9873 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
9874 local test_kdir=$DIR/$tdir
9875 test_mkdir $test_kdir
9876 local default_size=$($LFS getstripe -S $test_kdir)
9877 local default_count=$($LFS getstripe -c $test_kdir)
9878 local default_offset=$($LFS getstripe -i $test_kdir)
9879 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
9880 error 'dir setstripe failed'
9881 setfattr -n trusted.lov $test_kdir
9882 local stripe_size=$($LFS getstripe -S $test_kdir)
9883 local stripe_count=$($LFS getstripe -c $test_kdir)
9884 local stripe_offset=$($LFS getstripe -i $test_kdir)
9885 [ $stripe_size -eq $default_size ] ||
9886 error "stripe size $stripe_size != $default_size"
9887 [ $stripe_count -eq $default_count ] ||
9888 error "stripe count $stripe_count != $default_count"
9889 [ $stripe_offset -eq $default_offset ] ||
9890 error "stripe offset $stripe_offset != $default_offset"
9891 rm -rf $DIR/$tfile $test_kdir
9893 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
9896 [ -z "$(which getfattr 2>/dev/null)" ] &&
9897 skip "could not find getfattr"
9899 # LU-532 trusted. xattr is invisible to non-root
9900 local testfile=$DIR/$tfile
9904 echo "listxattr as user..."
9905 chown $RUNAS_ID $testfile
9906 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
9907 grep -q "trusted" &&
9908 error "$testfile trusted xattrs are user visible"
9912 run_test 102l "listxattr size test =================================="
9914 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
9915 local path=$DIR/$tfile
9918 listxattr_size_check $path || error "listattr_size_check $path failed"
9920 run_test 102m "Ensure listxattr fails on small bufffer ========"
9924 getxattr() { # getxattr path name
9925 # Return the base64 encoding of the value of xattr name on path.
9929 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
9931 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9933 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9935 getfattr --absolute-names --encoding=base64 --name=$name $path |
9936 awk -F= -v name=$name '$1 == name {
9937 print substr($0, index($0, "=") + 1);
9941 test_102n() { # LU-4101 mdt: protect internal xattrs
9942 [ -z "$(which setfattr 2>/dev/null)" ] &&
9943 skip "could not find setfattr"
9944 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
9946 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
9949 local file0=$DIR/$tfile.0
9950 local file1=$DIR/$tfile.1
9951 local xattr0=$TMP/$tfile.0
9952 local xattr1=$TMP/$tfile.1
9953 local namelist="lov lma lmv link fid version som hsm"
9957 rm -rf $file0 $file1 $xattr0 $xattr1
9960 # Get 'before' xattrs of $file1.
9961 getfattr --absolute-names --dump --match=- $file1 > $xattr0
9963 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
9964 namelist+=" lfsck_namespace"
9965 for name in $namelist; do
9966 # Try to copy xattr from $file0 to $file1.
9967 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9969 setfattr --name=trusted.$name --value="$value" $file1 ||
9970 error "setxattr 'trusted.$name' failed"
9972 # Try to set a garbage xattr.
9973 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9975 if [[ x$name == "xlov" ]]; then
9976 setfattr --name=trusted.lov --value="$value" $file1 &&
9977 error "setxattr invalid 'trusted.lov' success"
9979 setfattr --name=trusted.$name --value="$value" $file1 ||
9980 error "setxattr invalid 'trusted.$name' failed"
9983 # Try to remove the xattr from $file1. We don't care if this
9984 # appears to succeed or fail, we just don't want there to be
9985 # any changes or crashes.
9986 setfattr --remove=$trusted.$name $file1 2> /dev/null
9989 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
9992 # Try to copy xattr from $file0 to $file1.
9993 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9995 setfattr --name=trusted.$name --value="$value" $file1 ||
9996 error "setxattr 'trusted.$name' failed"
9998 # Try to set a garbage xattr.
9999 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
10001 setfattr --name=trusted.$name --value="$value" $file1 ||
10002 error "setxattr 'trusted.$name' failed"
10004 # Try to remove the xattr from $file1. We don't care if this
10005 # appears to succeed or fail, we just don't want there to be
10006 # any changes or crashes.
10007 setfattr --remove=$trusted.$name $file1 2> /dev/null
10010 # Get 'after' xattrs of file1.
10011 getfattr --absolute-names --dump --match=- $file1 > $xattr1
10013 if ! diff $xattr0 $xattr1; then
10014 error "before and after xattrs of '$file1' differ"
10017 rm -rf $file0 $file1 $xattr0 $xattr1
10021 run_test 102n "silently ignore setxattr on internal trusted xattrs"
10023 test_102p() { # LU-4703 setxattr did not check ownership
10024 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
10025 skip "MDS needs to be at least 2.5.56"
10027 local testfile=$DIR/$tfile
10031 echo "setfacl as user..."
10032 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
10033 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
10035 echo "setfattr as user..."
10036 setfacl -m "u:$RUNAS_ID:---" $testfile
10037 $RUNAS setfattr -x system.posix_acl_access $testfile
10038 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
10040 run_test 102p "check setxattr(2) correctly fails without permission"
10043 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
10044 skip "MDS needs to be at least 2.6.92"
10046 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
10048 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
10051 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
10052 skip "MDS needs to be at least 2.6.93"
10054 touch $DIR/$tfile || error "touch"
10055 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
10056 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
10057 rm $DIR/$tfile || error "rm"
10060 mkdir -p $DIR/$tdir || error "mkdir"
10061 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
10062 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
10063 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
10064 error "$testfile error deleting user.author1"
10065 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
10066 grep "user.$(basename $tdir)" &&
10067 error "$tdir did not delete user.$(basename $tdir)"
10068 rmdir $DIR/$tdir || error "rmdir"
10071 test_mkdir $DIR/$tdir
10072 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
10073 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
10074 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
10075 error "$testfile error deleting user.author1"
10076 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
10077 grep "user.$(basename $tdir)" &&
10078 error "$tdir did not delete user.$(basename $tdir)"
10079 rmdir $DIR/$tdir || error "rm striped dir"
10081 run_test 102r "set EAs with empty values"
10084 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
10085 skip "MDS needs to be at least 2.11.52"
10087 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10089 save_lustre_params client "llite.*.xattr_cache" > $save
10091 for cache in 0 1; do
10092 lctl set_param llite.*.xattr_cache=$cache
10095 touch $DIR/$tfile || error "touch"
10096 for prefix in lustre security system trusted user; do
10097 # Note getxattr() may fail with 'Operation not
10098 # supported' or 'No such attribute' depending
10099 # on prefix and cache.
10100 getfattr -n $prefix.n102s $DIR/$tfile &&
10101 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
10105 restore_lustre_params < $save
10107 run_test 102s "getting nonexistent xattrs should fail"
10110 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
10111 skip "MDS needs to be at least 2.11.52"
10113 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10115 save_lustre_params client "llite.*.xattr_cache" > $save
10117 for cache in 0 1; do
10118 lctl set_param llite.*.xattr_cache=$cache
10120 for buf_size in 0 256; do
10122 touch $DIR/$tfile || error "touch"
10123 setfattr -n user.multiop $DIR/$tfile
10124 $MULTIOP $DIR/$tfile oa$buf_size ||
10125 error "cannot get zero length xattr value (buf_size = $buf_size)"
10129 restore_lustre_params < $save
10131 run_test 102t "zero length xattr values handled correctly"
10135 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
10140 [ "$UID" != 0 ] && skip "must run as root"
10141 $GSS && skip_env "could not run under gss"
10142 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
10143 skip_env "must have acl enabled"
10144 [ -z "$(which setfacl 2>/dev/null)" ] &&
10145 skip_env "could not find setfacl"
10146 remote_mds_nodsh && skip "remote MDS with nodsh"
10148 gpasswd -a daemon bin # LU-5641
10149 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
10151 declare -a identity_old
10153 for num in $(seq $MDSCOUNT); do
10154 switch_identity $num true || identity_old[$num]=$?
10157 SAVE_UMASK=$(umask)
10159 mkdir -p $DIR/$tdir
10162 echo "performing cp ..."
10163 run_acl_subtest cp || error "run_acl_subtest cp failed"
10164 echo "performing getfacl-noacl..."
10165 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
10166 echo "performing misc..."
10167 run_acl_subtest misc || error "misc test failed"
10168 echo "performing permissions..."
10169 run_acl_subtest permissions || error "permissions failed"
10170 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
10171 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
10172 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
10173 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
10175 echo "performing permissions xattr..."
10176 run_acl_subtest permissions_xattr ||
10177 error "permissions_xattr failed"
10179 echo "performing setfacl..."
10180 run_acl_subtest setfacl || error "setfacl test failed"
10182 # inheritance test got from HP
10183 echo "performing inheritance..."
10184 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
10185 chmod +x make-tree || error "chmod +x failed"
10186 run_acl_subtest inheritance || error "inheritance test failed"
10189 echo "LU-974 ignore umask when acl is enabled..."
10190 run_acl_subtest 974 || error "LU-974 umask test failed"
10191 if [ $MDSCOUNT -ge 2 ]; then
10192 run_acl_subtest 974_remote ||
10193 error "LU-974 umask test failed under remote dir"
10196 echo "LU-2561 newly created file is same size as directory..."
10197 if [ "$mds1_FSTYPE" != "zfs" ]; then
10198 run_acl_subtest 2561 || error "LU-2561 test failed"
10200 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
10203 run_acl_subtest 4924 || error "LU-4924 test failed"
10208 for num in $(seq $MDSCOUNT); do
10209 if [ "${identity_old[$num]}" = 1 ]; then
10210 switch_identity $num false || identity_old[$num]=$?
10214 run_test 103a "acl test"
10220 for U in {0..511}; do
10222 local O=$(printf "%04o" $U)
10224 umask $(printf "%04o" $((511 ^ $O)))
10225 $LFS setstripe -c 1 $DIR/$tfile.s$O
10226 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
10228 (( $S == ($O & 0666) )) ||
10229 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
10231 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
10232 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
10233 (( $S == ($O & 0666) )) ||
10234 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
10236 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
10237 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
10238 (( $S == ($O & 0666) )) ||
10239 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
10240 rm -f $DIR/$tfile.[smp]$0
10244 # limit the concurrently running threads to 64. LU-11878
10245 local idx=$((U % 64))
10246 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
10251 run_test 103b "umask lfs setstripe"
10254 mkdir -p $DIR/$tdir
10255 cp -rp $DIR/$tdir $DIR/$tdir.bak
10257 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
10258 error "$DIR/$tdir shouldn't contain default ACL"
10259 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
10260 error "$DIR/$tdir.bak shouldn't contain default ACL"
10263 run_test 103c "'cp -rp' won't set empty acl"
10266 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10269 lfs df || error "lfs df failed"
10270 lfs df -ih || error "lfs df -ih failed"
10271 lfs df -h $DIR || error "lfs df -h $DIR failed"
10272 lfs df -i $DIR || error "lfs df -i $DIR failed"
10273 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
10274 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
10276 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
10277 lctl --device %$OSC deactivate
10278 lfs df || error "lfs df with deactivated OSC failed"
10279 lctl --device %$OSC activate
10280 # wait the osc back to normal
10281 wait_osc_import_ready client ost
10283 lfs df || error "lfs df with reactivated OSC failed"
10286 run_test 104a "lfs df [-ih] [path] test ========================="
10289 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10290 [ $RUNAS_ID -eq $UID ] &&
10291 skip_env "RUNAS_ID = UID = $UID -- skipping"
10293 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
10294 grep "Permission denied" | wc -l)))
10295 if [ $denied_cnt -ne 0 ]; then
10296 error "lfs check servers test failed"
10299 run_test 104b "$RUNAS lfs check servers test ===================="
10302 # doesn't work on 2.4 kernels
10304 if $(flock_is_enabled); then
10305 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
10307 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
10311 run_test 105a "flock when mounted without -o flock test ========"
10315 if $(flock_is_enabled); then
10316 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
10318 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
10322 run_test 105b "fcntl when mounted without -o flock test ========"
10326 if $(flock_is_enabled); then
10327 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
10329 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
10333 run_test 105c "lockf when mounted without -o flock test"
10335 test_105d() { # bug 15924
10336 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10338 test_mkdir $DIR/$tdir
10339 flock_is_enabled || skip_env "mount w/o flock enabled"
10340 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
10341 $LCTL set_param fail_loc=0x80000315
10342 flocks_test 2 $DIR/$tdir
10344 run_test 105d "flock race (should not freeze) ========"
10346 test_105e() { # bug 22660 && 22040
10347 flock_is_enabled || skip_env "mount w/o flock enabled"
10350 flocks_test 3 $DIR/$tfile
10352 run_test 105e "Two conflicting flocks from same process"
10354 test_106() { #bug 10921
10355 test_mkdir $DIR/$tdir
10356 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
10357 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
10359 run_test 106 "attempt exec of dir followed by chown of that dir"
10362 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10370 local save_pattern=$(sysctl -n kernel.core_pattern)
10371 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
10372 sysctl -w kernel.core_pattern=$file
10373 sysctl -w kernel.core_uses_pid=0
10375 ulimit -c unlimited
10381 kill -s 11 $SLEEPPID
10383 if [ -e $file ]; then
10384 size=`stat -c%s $file`
10385 [ $size -eq 0 ] && error "Fail to create core file $file"
10387 error "Fail to create core file $file"
10390 sysctl -w kernel.core_pattern=$save_pattern
10391 sysctl -w kernel.core_uses_pid=$save_uses_pid
10394 run_test 107 "Coredump on SIG"
10397 test_mkdir $DIR/$tdir
10398 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
10399 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
10400 error "mkdir with 256 char should fail, but did not"
10401 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
10402 error "create with 255 char failed"
10403 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
10404 error "create with 256 char should fail, but did not"
10409 run_test 110 "filename length checking"
10412 # Purpose: To verify dynamic thread (OSS) creation.
10415 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10416 remote_ost_nodsh && skip "remote OST with nodsh"
10418 # Lustre does not stop service threads once they are started.
10419 # Reset number of running threads to default.
10424 local save_params="$TMP/sanity-$TESTNAME.parameters"
10426 # Get ll_ost_io count before I/O
10427 OSTIO_pre=$(do_facet ost1 \
10428 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
10429 # Exit if lustre is not running (ll_ost_io not running).
10430 [ -z "$OSTIO_pre" ] && error "no OSS threads"
10432 echo "Starting with $OSTIO_pre threads"
10433 local thread_max=$((OSTIO_pre * 2))
10434 local rpc_in_flight=$((thread_max * 2))
10435 # Number of I/O Process proposed to be started.
10437 local facets=$(get_facets OST)
10439 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
10440 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
10442 # Set in_flight to $rpc_in_flight
10443 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
10444 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
10445 nfiles=${rpc_in_flight}
10446 # Set ost thread_max to $thread_max
10447 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
10449 # 5 Minutes should be sufficient for max number of OSS
10450 # threads(thread_max) to be created.
10454 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
10455 test_mkdir $DIR/$tdir
10456 for i in $(seq $nfiles); do
10457 local file=$DIR/$tdir/${tfile}-$i
10458 $LFS setstripe -c -1 -i 0 $file
10459 ($WTL $file $timeout)&
10462 # I/O Started - Wait for thread_started to reach thread_max or report
10463 # error if thread_started is more than thread_max.
10464 echo "Waiting for thread_started to reach thread_max"
10465 local thread_started=0
10466 local end_time=$((SECONDS + timeout))
10468 while [ $SECONDS -le $end_time ] ; do
10470 # Get ost i/o thread_started count.
10471 thread_started=$(do_facet ost1 \
10473 ost.OSS.ost_io.threads_started | cut -d= -f2")
10474 # Break out if thread_started is equal/greater than thread_max
10475 if [[ $thread_started -ge $thread_max ]]; then
10476 echo ll_ost_io thread_started $thread_started, \
10477 equal/greater than thread_max $thread_max
10483 # Cleanup - We have the numbers, Kill i/o jobs if running.
10484 jobcount=($(jobs -p))
10485 for i in $(seq 0 $((${#jobcount[@]}-1)))
10487 kill -9 ${jobcount[$i]}
10488 if [ $? -ne 0 ] ; then
10490 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
10494 # Cleanup files left by WTL binary.
10495 for i in $(seq $nfiles); do
10496 local file=$DIR/$tdir/${tfile}-$i
10498 if [ $? -ne 0 ] ; then
10499 echo "Warning: Failed to delete file $file"
10503 restore_lustre_params <$save_params
10504 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
10506 # Error out if no new thread has started or Thread started is greater
10508 if [[ $thread_started -le $OSTIO_pre ||
10509 $thread_started -gt $thread_max ]]; then
10510 error "ll_ost_io: thread_started $thread_started" \
10511 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
10512 "No new thread started or thread started greater " \
10516 run_test 115 "verify dynamic thread creation===================="
10519 wait_delete_completed
10520 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
10521 echo "OST kbytes available: ${AVAIL[@]}"
10526 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
10527 #echo OST $i: ${AVAIL[i]}kb
10528 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
10532 if [[ ${AVAIL[i]} -lt $MINV ]]; then
10537 echo "Min free space: OST $MINI: $MINV"
10538 echo "Max free space: OST $MAXI: $MAXV"
10541 test_116a() { # was previously test_116()
10542 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10543 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10544 remote_mds_nodsh && skip "remote MDS with nodsh"
10546 echo -n "Free space priority "
10547 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
10552 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
10553 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
10554 trap simple_cleanup_common EXIT
10556 # Check if we need to generate uneven OSTs
10557 test_mkdir -p $DIR/$tdir/OST${MINI}
10558 local FILL=$((MINV / 4))
10559 local DIFF=$((MAXV - MINV))
10560 local DIFF2=$((DIFF * 100 / MINV))
10562 local threshold=$(do_facet $SINGLEMDS \
10563 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
10564 threshold=${threshold%%%}
10565 echo -n "Check for uneven OSTs: "
10566 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
10568 if [[ $DIFF2 -gt $threshold ]]; then
10570 echo "Don't need to fill OST$MINI"
10572 # generate uneven OSTs. Write 2% over the QOS threshold value
10574 DIFF=$((threshold - DIFF2 + 2))
10575 DIFF2=$((MINV * DIFF / 100))
10576 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
10577 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
10578 error "setstripe failed"
10579 DIFF=$((DIFF2 / 2048))
10581 while [ $i -lt $DIFF ]; do
10583 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
10584 bs=2M count=1 2>/dev/null
10593 DIFF=$((MAXV - MINV))
10594 DIFF2=$((DIFF * 100 / MINV))
10595 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
10596 if [ $DIFF2 -gt $threshold ]; then
10599 echo "failed - QOS mode won't be used"
10600 simple_cleanup_common
10601 skip "QOS imbalance criteria not met"
10609 # now fill using QOS
10610 $LFS setstripe -c 1 $DIR/$tdir
10611 FILL=$((FILL / 200))
10612 if [ $FILL -gt 600 ]; then
10615 echo "writing $FILL files to QOS-assigned OSTs"
10617 while [ $i -lt $FILL ]; do
10619 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
10620 count=1 2>/dev/null
10623 echo "wrote $i 200k files"
10627 echo "Note: free space may not be updated, so measurements might be off"
10629 DIFF2=$((MAXV - MINV))
10630 echo "free space delta: orig $DIFF final $DIFF2"
10631 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
10632 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
10633 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
10634 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
10635 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
10636 if [[ $DIFF -gt 0 ]]; then
10637 FILL=$((DIFF2 * 100 / DIFF - 100))
10638 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
10641 # Figure out which files were written where
10642 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10643 awk '/'$MINI1': / {print $2; exit}')
10645 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10646 echo "$MINC files created on smaller OST $MINI1"
10647 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10648 awk '/'$MAXI1': / {print $2; exit}')
10650 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10651 echo "$MAXC files created on larger OST $MAXI1"
10652 if [[ $MINC -gt 0 ]]; then
10653 FILL=$((MAXC * 100 / MINC - 100))
10654 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
10656 [[ $MAXC -gt $MINC ]] ||
10657 error_ignore LU-9 "stripe QOS didn't balance free space"
10658 simple_cleanup_common
10660 run_test 116a "stripe QOS: free space balance ==================="
10662 test_116b() { # LU-2093
10663 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10664 remote_mds_nodsh && skip "remote MDS with nodsh"
10666 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
10667 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
10668 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
10669 [ -z "$old_rr" ] && skip "no QOS"
10670 do_facet $SINGLEMDS lctl set_param \
10671 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
10672 mkdir -p $DIR/$tdir
10673 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
10674 createmany -o $DIR/$tdir/f- 20 || error "can't create"
10675 do_facet $SINGLEMDS lctl set_param fail_loc=0
10677 do_facet $SINGLEMDS lctl set_param \
10678 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
10680 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
10682 test_117() # bug 10891
10684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10686 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
10687 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
10688 lctl set_param fail_loc=0x21e
10689 > $DIR/$tfile || error "truncate failed"
10690 lctl set_param fail_loc=0
10691 echo "Truncate succeeded."
10694 run_test 117 "verify osd extend =========="
10696 NO_SLOW_RESENDCOUNT=4
10697 export OLD_RESENDCOUNT=""
10698 set_resend_count () {
10699 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
10700 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
10701 lctl set_param -n $PROC_RESENDCOUNT $1
10702 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
10705 # for reduce test_118* time (b=14842)
10706 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10708 # Reset async IO behavior after error case
10710 FILE=$DIR/reset_async
10712 # Ensure all OSCs are cleared
10713 $LFS setstripe -c -1 $FILE
10714 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
10719 test_118a() #bug 11710
10721 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10725 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10726 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10727 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10729 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10730 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10735 run_test 118a "verify O_SYNC works =========="
10739 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10740 remote_ost_nodsh && skip "remote OST with nodsh"
10744 #define OBD_FAIL_SRV_ENOENT 0x217
10745 set_nodes_failloc "$(osts_nodes)" 0x217
10746 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10748 set_nodes_failloc "$(osts_nodes)" 0
10749 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10750 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10753 if [[ $RC -eq 0 ]]; then
10754 error "Must return error due to dropped pages, rc=$RC"
10758 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10759 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10763 echo "Dirty pages not leaked on ENOENT"
10765 # Due to the above error the OSC will issue all RPCs syncronously
10766 # until a subsequent RPC completes successfully without error.
10767 $MULTIOP $DIR/$tfile Ow4096yc
10772 run_test 118b "Reclaim dirty pages on fatal error =========="
10776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10778 # for 118c, restore the original resend count, LU-1940
10779 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
10780 set_resend_count $OLD_RESENDCOUNT
10781 remote_ost_nodsh && skip "remote OST with nodsh"
10785 #define OBD_FAIL_OST_EROFS 0x216
10786 set_nodes_failloc "$(osts_nodes)" 0x216
10788 # multiop should block due to fsync until pages are written
10789 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10793 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10794 error "Multiop failed to block on fsync, pid=$MULTIPID"
10797 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10799 if [[ $WRITEBACK -eq 0 ]]; then
10800 error "No page in writeback, writeback=$WRITEBACK"
10803 set_nodes_failloc "$(osts_nodes)" 0
10806 if [[ $RC -ne 0 ]]; then
10807 error "Multiop fsync failed, rc=$RC"
10810 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10811 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10813 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10814 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10818 echo "Dirty pages flushed via fsync on EROFS"
10821 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
10823 # continue to use small resend count to reduce test_118* time (b=14842)
10824 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10828 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10829 remote_ost_nodsh && skip "remote OST with nodsh"
10833 #define OBD_FAIL_OST_BRW_PAUSE_BULK
10834 set_nodes_failloc "$(osts_nodes)" 0x214
10835 # multiop should block due to fsync until pages are written
10836 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10840 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10841 error "Multiop failed to block on fsync, pid=$MULTIPID"
10844 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10846 if [[ $WRITEBACK -eq 0 ]]; then
10847 error "No page in writeback, writeback=$WRITEBACK"
10850 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
10851 set_nodes_failloc "$(osts_nodes)" 0
10853 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10854 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10856 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10857 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10861 echo "Dirty pages gaurenteed flushed via fsync"
10864 run_test 118d "Fsync validation inject a delay of the bulk =========="
10867 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10871 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
10872 lctl set_param fail_loc=0x8000040a
10874 # Should simulate EINVAL error which is fatal
10875 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10877 if [[ $RC -eq 0 ]]; then
10878 error "Must return error due to dropped pages, rc=$RC"
10881 lctl set_param fail_loc=0x0
10883 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10884 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10885 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10887 if [[ $LOCKED -ne 0 ]]; then
10888 error "Locked pages remain in cache, locked=$LOCKED"
10891 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10892 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10896 echo "No pages locked after fsync"
10901 run_test 118f "Simulate unrecoverable OSC side error =========="
10904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10908 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
10909 lctl set_param fail_loc=0x406
10911 # simulate local -ENOMEM
10912 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10915 lctl set_param fail_loc=0
10916 if [[ $RC -eq 0 ]]; then
10917 error "Must return error due to dropped pages, rc=$RC"
10920 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10921 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10922 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10924 if [[ $LOCKED -ne 0 ]]; then
10925 error "Locked pages remain in cache, locked=$LOCKED"
10928 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10929 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10933 echo "No pages locked after fsync"
10938 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
10941 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10942 remote_ost_nodsh && skip "remote OST with nodsh"
10946 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10947 set_nodes_failloc "$(osts_nodes)" 0x20e
10948 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10949 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10952 set_nodes_failloc "$(osts_nodes)" 0
10953 if [[ $RC -eq 0 ]]; then
10954 error "Must return error due to dropped pages, rc=$RC"
10957 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10958 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10959 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10961 if [[ $LOCKED -ne 0 ]]; then
10962 error "Locked pages remain in cache, locked=$LOCKED"
10965 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10966 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10970 echo "No pages locked after fsync"
10974 run_test 118h "Verify timeout in handling recoverables errors =========="
10976 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10980 remote_ost_nodsh && skip "remote OST with nodsh"
10984 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10985 set_nodes_failloc "$(osts_nodes)" 0x20e
10987 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10988 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10991 set_nodes_failloc "$(osts_nodes)" 0
10995 if [[ $RC -ne 0 ]]; then
10996 error "got error, but should be not, rc=$RC"
10999 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11000 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11001 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
11002 if [[ $LOCKED -ne 0 ]]; then
11003 error "Locked pages remain in cache, locked=$LOCKED"
11006 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11007 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11011 echo "No pages locked after fsync"
11015 run_test 118i "Fix error before timeout in recoverable error =========="
11017 [ "$SLOW" = "no" ] && set_resend_count 4
11020 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11021 remote_ost_nodsh && skip "remote OST with nodsh"
11025 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
11026 set_nodes_failloc "$(osts_nodes)" 0x220
11028 # return -EIO from OST
11029 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11031 set_nodes_failloc "$(osts_nodes)" 0x0
11032 if [[ $RC -eq 0 ]]; then
11033 error "Must return error due to dropped pages, rc=$RC"
11036 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11037 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11038 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
11039 if [[ $LOCKED -ne 0 ]]; then
11040 error "Locked pages remain in cache, locked=$LOCKED"
11043 # in recoverable error on OST we want resend and stay until it finished
11044 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11045 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11049 echo "No pages locked after fsync"
11053 run_test 118j "Simulate unrecoverable OST side error =========="
11057 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11058 remote_ost_nodsh && skip "remote OSTs with nodsh"
11060 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
11061 set_nodes_failloc "$(osts_nodes)" 0x20e
11062 test_mkdir $DIR/$tdir
11064 for ((i=0;i<10;i++)); do
11065 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
11066 error "dd to $DIR/$tdir/$tfile-$i failed" )&
11073 set_nodes_failloc "$(osts_nodes)" 0
11076 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
11078 test_118l() # LU-646
11080 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11082 test_mkdir $DIR/$tdir
11083 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
11086 run_test 118l "fsync dir"
11088 test_118m() # LU-3066
11090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11092 test_mkdir $DIR/$tdir
11093 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
11096 run_test 118m "fdatasync dir ========="
11098 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
11105 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11106 remote_ost_nodsh && skip "remote OSTs with nodsh"
11108 # Sleep to avoid a cached response.
11109 #define OBD_STATFS_CACHE_SECONDS 1
11112 # Inject a 10 second delay in the OST_STATFS handler.
11113 #define OBD_FAIL_OST_STATFS_DELAY 0x242
11114 set_nodes_failloc "$(osts_nodes)" 0x242
11117 stat --file-system $MOUNT > /dev/null
11120 set_nodes_failloc "$(osts_nodes)" 0
11122 if ((end - begin > 20)); then
11123 error "statfs took $((end - begin)) seconds, expected 10"
11126 run_test 118n "statfs() sends OST_STATFS requests in parallel"
11128 test_119a() # bug 11737
11130 BSIZE=$((512 * 1024))
11131 directio write $DIR/$tfile 0 1 $BSIZE
11132 # We ask to read two blocks, which is more than a file size.
11133 # directio will indicate an error when requested and actual
11134 # sizes aren't equeal (a normal situation in this case) and
11135 # print actual read amount.
11136 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
11137 if [ "$NOB" != "$BSIZE" ]; then
11138 error "read $NOB bytes instead of $BSIZE"
11142 run_test 119a "Short directIO read must return actual read amount"
11144 test_119b() # bug 11737
11146 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11148 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
11149 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
11151 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
11152 error "direct read failed"
11155 run_test 119b "Sparse directIO read must return actual read amount"
11157 test_119c() # bug 13099
11160 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
11161 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
11164 run_test 119c "Testing for direct read hitting hole"
11166 test_119d() # bug 15950
11168 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11170 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
11171 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
11173 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
11174 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
11175 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
11176 lctl set_param fail_loc=0x40d
11177 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
11180 cat $DIR/$tfile > /dev/null &
11181 lctl set_param fail_loc=0
11184 log "the DIO writes have completed, now wait for the reads (should not block very long)"
11186 [ -n "`ps h -p $pid_reads -o comm`" ] && \
11187 error "the read rpcs have not completed in 2s"
11189 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
11191 run_test 119d "The DIO path should try to send a new rpc once one is completed"
11194 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11195 remote_mds_nodsh && skip "remote MDS with nodsh"
11196 test_mkdir -i0 -c1 $DIR/$tdir
11197 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11198 skip_env "no early lock cancel on server"
11200 lru_resize_disable mdc
11201 lru_resize_disable osc
11202 cancel_lru_locks mdc
11203 # asynchronous object destroy at MDT could cause bl ast to client
11204 cancel_lru_locks osc
11206 stat $DIR/$tdir > /dev/null
11207 can1=$(do_facet mds1 \
11208 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11209 awk '/ldlm_cancel/ {print $2}')
11210 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11211 awk '/ldlm_bl_callback/ {print $2}')
11212 test_mkdir -i0 -c1 $DIR/$tdir/d1
11213 can2=$(do_facet mds1 \
11214 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11215 awk '/ldlm_cancel/ {print $2}')
11216 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11217 awk '/ldlm_bl_callback/ {print $2}')
11218 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11219 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11220 lru_resize_enable mdc
11221 lru_resize_enable osc
11223 run_test 120a "Early Lock Cancel: mkdir test"
11226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11227 remote_mds_nodsh && skip "remote MDS with nodsh"
11228 test_mkdir $DIR/$tdir
11229 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11230 skip_env "no early lock cancel on server"
11232 lru_resize_disable mdc
11233 lru_resize_disable osc
11234 cancel_lru_locks mdc
11235 stat $DIR/$tdir > /dev/null
11236 can1=$(do_facet $SINGLEMDS \
11237 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11238 awk '/ldlm_cancel/ {print $2}')
11239 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11240 awk '/ldlm_bl_callback/ {print $2}')
11241 touch $DIR/$tdir/f1
11242 can2=$(do_facet $SINGLEMDS \
11243 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11244 awk '/ldlm_cancel/ {print $2}')
11245 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11246 awk '/ldlm_bl_callback/ {print $2}')
11247 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11248 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11249 lru_resize_enable mdc
11250 lru_resize_enable osc
11252 run_test 120b "Early Lock Cancel: create test"
11255 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11256 remote_mds_nodsh && skip "remote MDS with nodsh"
11257 test_mkdir -i0 -c1 $DIR/$tdir
11258 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11259 skip "no early lock cancel on server"
11261 lru_resize_disable mdc
11262 lru_resize_disable osc
11263 test_mkdir -i0 -c1 $DIR/$tdir/d1
11264 test_mkdir -i0 -c1 $DIR/$tdir/d2
11265 touch $DIR/$tdir/d1/f1
11266 cancel_lru_locks mdc
11267 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
11268 can1=$(do_facet mds1 \
11269 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11270 awk '/ldlm_cancel/ {print $2}')
11271 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11272 awk '/ldlm_bl_callback/ {print $2}')
11273 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
11274 can2=$(do_facet mds1 \
11275 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11276 awk '/ldlm_cancel/ {print $2}')
11277 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11278 awk '/ldlm_bl_callback/ {print $2}')
11279 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11280 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11281 lru_resize_enable mdc
11282 lru_resize_enable osc
11284 run_test 120c "Early Lock Cancel: link test"
11287 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11288 remote_mds_nodsh && skip "remote MDS with nodsh"
11289 test_mkdir -i0 -c1 $DIR/$tdir
11290 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11291 skip_env "no early lock cancel on server"
11293 lru_resize_disable mdc
11294 lru_resize_disable osc
11296 cancel_lru_locks mdc
11297 stat $DIR/$tdir > /dev/null
11298 can1=$(do_facet mds1 \
11299 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11300 awk '/ldlm_cancel/ {print $2}')
11301 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11302 awk '/ldlm_bl_callback/ {print $2}')
11303 chmod a+x $DIR/$tdir
11304 can2=$(do_facet mds1 \
11305 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11306 awk '/ldlm_cancel/ {print $2}')
11307 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11308 awk '/ldlm_bl_callback/ {print $2}')
11309 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11310 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11311 lru_resize_enable mdc
11312 lru_resize_enable osc
11314 run_test 120d "Early Lock Cancel: setattr test"
11317 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11318 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11319 skip_env "no early lock cancel on server"
11320 remote_mds_nodsh && skip "remote MDS with nodsh"
11322 local dlmtrace_set=false
11324 test_mkdir -i0 -c1 $DIR/$tdir
11325 lru_resize_disable mdc
11326 lru_resize_disable osc
11327 ! $LCTL get_param debug | grep -q dlmtrace &&
11328 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
11329 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
11330 cancel_lru_locks mdc
11331 cancel_lru_locks osc
11332 dd if=$DIR/$tdir/f1 of=/dev/null
11333 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
11334 # XXX client can not do early lock cancel of OST lock
11335 # during unlink (LU-4206), so cancel osc lock now.
11337 cancel_lru_locks osc
11338 can1=$(do_facet mds1 \
11339 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11340 awk '/ldlm_cancel/ {print $2}')
11341 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11342 awk '/ldlm_bl_callback/ {print $2}')
11343 unlink $DIR/$tdir/f1
11345 can2=$(do_facet mds1 \
11346 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11347 awk '/ldlm_cancel/ {print $2}')
11348 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11349 awk '/ldlm_bl_callback/ {print $2}')
11350 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
11351 $LCTL dk $TMP/cancel.debug.txt
11352 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
11353 $LCTL dk $TMP/blocking.debug.txt
11354 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
11355 lru_resize_enable mdc
11356 lru_resize_enable osc
11358 run_test 120e "Early Lock Cancel: unlink test"
11361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11362 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11363 skip_env "no early lock cancel on server"
11364 remote_mds_nodsh && skip "remote MDS with nodsh"
11366 test_mkdir -i0 -c1 $DIR/$tdir
11367 lru_resize_disable mdc
11368 lru_resize_disable osc
11369 test_mkdir -i0 -c1 $DIR/$tdir/d1
11370 test_mkdir -i0 -c1 $DIR/$tdir/d2
11371 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
11372 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
11373 cancel_lru_locks mdc
11374 cancel_lru_locks osc
11375 dd if=$DIR/$tdir/d1/f1 of=/dev/null
11376 dd if=$DIR/$tdir/d2/f2 of=/dev/null
11377 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
11378 # XXX client can not do early lock cancel of OST lock
11379 # during rename (LU-4206), so cancel osc lock now.
11381 cancel_lru_locks osc
11382 can1=$(do_facet mds1 \
11383 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11384 awk '/ldlm_cancel/ {print $2}')
11385 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11386 awk '/ldlm_bl_callback/ {print $2}')
11387 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
11389 can2=$(do_facet mds1 \
11390 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11391 awk '/ldlm_cancel/ {print $2}')
11392 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11393 awk '/ldlm_bl_callback/ {print $2}')
11394 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11395 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11396 lru_resize_enable mdc
11397 lru_resize_enable osc
11399 run_test 120f "Early Lock Cancel: rename test"
11402 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11403 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11404 skip_env "no early lock cancel on server"
11405 remote_mds_nodsh && skip "remote MDS with nodsh"
11407 lru_resize_disable mdc
11408 lru_resize_disable osc
11410 echo create $count files
11411 test_mkdir $DIR/$tdir
11412 cancel_lru_locks mdc
11413 cancel_lru_locks osc
11416 can0=$(do_facet $SINGLEMDS \
11417 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11418 awk '/ldlm_cancel/ {print $2}')
11419 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11420 awk '/ldlm_bl_callback/ {print $2}')
11421 createmany -o $DIR/$tdir/f $count
11423 can1=$(do_facet $SINGLEMDS \
11424 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11425 awk '/ldlm_cancel/ {print $2}')
11426 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11427 awk '/ldlm_bl_callback/ {print $2}')
11429 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
11430 echo rm $count files
11433 can2=$(do_facet $SINGLEMDS \
11434 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11435 awk '/ldlm_cancel/ {print $2}')
11436 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11437 awk '/ldlm_bl_callback/ {print $2}')
11439 echo total: $count removes in $((t2-t1))
11440 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
11442 # wait for commitment of removal
11443 lru_resize_enable mdc
11444 lru_resize_enable osc
11446 run_test 120g "Early Lock Cancel: performance test"
11448 test_121() { #bug #10589
11449 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11452 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
11453 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
11454 lctl set_param fail_loc=0x310
11455 cancel_lru_locks osc > /dev/null
11456 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
11457 lctl set_param fail_loc=0
11458 [[ $reads -eq $writes ]] ||
11459 error "read $reads blocks, must be $writes blocks"
11461 run_test 121 "read cancel race ========="
11463 test_123a_base() { # was test 123, statahead(bug 11401)
11467 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
11468 log "testing UP system. Performance may be lower than expected."
11473 test_mkdir $DIR/$tdir
11474 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
11475 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
11477 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
11478 createmany -o $DIR/$tdir/$tfile $j $((i - j))
11480 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
11481 lctl set_param -n llite.*.statahead_max 0
11482 lctl get_param llite.*.statahead_max
11483 cancel_lru_locks mdc
11484 cancel_lru_locks osc
11486 time $lsx $DIR/$tdir | wc -l
11488 delta=$((etime - stime))
11489 log "$lsx $i files without statahead: $delta sec"
11490 lctl set_param llite.*.statahead_max=$max
11492 swrong=$(lctl get_param -n llite.*.statahead_stats |
11493 grep "statahead wrong:" | awk '{print $3}')
11494 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
11495 cancel_lru_locks mdc
11496 cancel_lru_locks osc
11498 time $lsx $DIR/$tdir | wc -l
11500 delta_sa=$((etime - stime))
11501 log "$lsx $i files with statahead: $delta_sa sec"
11502 lctl get_param -n llite.*.statahead_stats
11503 ewrong=$(lctl get_param -n llite.*.statahead_stats |
11504 grep "statahead wrong:" | awk '{print $3}')
11506 [[ $swrong -lt $ewrong ]] &&
11507 log "statahead was stopped, maybe too many locks held!"
11508 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
11510 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
11511 max=$(lctl get_param -n llite.*.statahead_max |
11513 lctl set_param -n llite.*.statahead_max 0
11514 lctl get_param llite.*.statahead_max
11515 cancel_lru_locks mdc
11516 cancel_lru_locks osc
11518 time $lsx $DIR/$tdir | wc -l
11520 delta=$((etime - stime))
11521 log "$lsx $i files again without statahead: $delta sec"
11522 lctl set_param llite.*.statahead_max=$max
11523 if [ $((delta_sa * 100 > delta * 105 && delta_sa > delta + 2)) ]; then
11524 if [ $SLOWOK -eq 0 ]; then
11525 error "$lsx $i files is slower with statahead!"
11527 log "$lsx $i files is slower with statahead!"
11533 [ $delta -gt 20 ] && break
11534 [ $delta -gt 8 ] && MULT=$((50 / delta))
11535 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
11543 delta=$((etime - stime))
11544 log "rm -r $DIR/$tdir/: $delta seconds"
11546 lctl get_param -n llite.*.statahead_stats
11550 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11552 test_123a_base "ls -l"
11554 run_test 123aa "verify statahead work"
11557 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11559 statx_supported || skip_env "Test must be statx() syscall supported"
11561 test_123a_base "$STATX -l"
11563 run_test 123ab "verify statahead work by using statx"
11566 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11568 statx_supported || skip_env "Test must be statx() syscall supported"
11575 cancel_lru_locks $OSC
11576 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
11577 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
11578 awk '/agl.total:/ {print $3}')
11579 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
11580 test_123a_base "$STATX --cached=always -D"
11581 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
11582 awk '/agl.total:/ {print $3}')
11583 [ $agl_before -eq $agl_after ] ||
11584 error "Should not trigger AGL thread - $agl_before:$agl_after"
11585 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
11586 [ $rpcs_after -eq $rpcs_before ] ||
11587 error "$STATX should not send glimpse RPCs to $OSC"
11589 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
11591 test_123b () { # statahead(bug 15027)
11592 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11594 test_mkdir $DIR/$tdir
11595 createmany -o $DIR/$tdir/$tfile-%d 1000
11597 cancel_lru_locks mdc
11598 cancel_lru_locks osc
11600 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
11601 lctl set_param fail_loc=0x80000803
11602 ls -lR $DIR/$tdir > /dev/null
11604 lctl set_param fail_loc=0x0
11605 lctl get_param -n llite.*.statahead_stats
11610 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
11613 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
11615 test_mkdir -i 0 -c 1 $DIR/$tdir.0
11616 test_mkdir -i 1 -c 1 $DIR/$tdir.1
11617 touch $DIR/$tdir.1/{1..3}
11618 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
11620 remount_client $MOUNT
11622 $MULTIOP $DIR/$tdir.0 Q
11624 # let statahead to complete
11625 ls -l $DIR/$tdir.0 > /dev/null
11627 testid=$(echo $TESTNAME | tr '_' ' ')
11628 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
11629 error "statahead warning" || true
11631 run_test 123c "Can not initialize inode warning on DNE statahead"
11634 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11635 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11636 skip_env "no lru resize on server"
11640 test_mkdir $DIR/$tdir
11642 log "create $NR files at $DIR/$tdir"
11643 createmany -o $DIR/$tdir/f $NR ||
11644 error "failed to create $NR files in $DIR/$tdir"
11646 cancel_lru_locks mdc
11647 ls -l $DIR/$tdir > /dev/null
11651 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
11652 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
11653 LRU_SIZE=$($LCTL get_param -n $PARAM)
11654 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
11655 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
11657 log "NS=$(basename $NSDIR)"
11662 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
11663 skip "Not enough cached locks created!"
11665 log "LRU=$LRU_SIZE"
11669 # We know that lru resize allows one client to hold $LIMIT locks
11670 # for 10h. After that locks begin to be killed by client.
11672 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
11674 if [ $LIMIT -lt $LRU_SIZE ]; then
11675 skip "Limit is too small $LIMIT"
11678 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
11679 # killing locks. Some time was spent for creating locks. This means
11680 # that up to the moment of sleep finish we must have killed some of
11681 # them (10-100 locks). This depends on how fast ther were created.
11682 # Many of them were touched in almost the same moment and thus will
11683 # be killed in groups.
11684 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
11686 # Use $LRU_SIZE_B here to take into account real number of locks
11687 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
11688 local LRU_SIZE_B=$LRU_SIZE
11690 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
11691 log "OLD_LVF=$OLD_LVF"
11692 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
11694 # Let's make sure that we really have some margin. Client checks
11695 # cached locks every 10 sec.
11696 SLEEP=$((SLEEP+20))
11697 log "Sleep ${SLEEP} sec"
11699 while ((SEC<$SLEEP)); do
11703 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
11704 echo -n "$LRU_SIZE"
11707 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
11708 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
11710 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
11711 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
11712 unlinkmany $DIR/$tdir/f $NR
11716 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
11717 log "unlink $NR files at $DIR/$tdir"
11718 unlinkmany $DIR/$tdir/f $NR
11720 run_test 124a "lru resize ======================================="
11722 get_max_pool_limit()
11724 local limit=$($LCTL get_param \
11725 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
11727 for l in $limit; do
11728 if [[ $l -gt $max ]]; then
11736 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11737 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11738 skip_env "no lru resize on server"
11740 LIMIT=$(get_max_pool_limit)
11742 NR=$(($(default_lru_size)*20))
11743 if [[ $NR -gt $LIMIT ]]; then
11744 log "Limit lock number by $LIMIT locks"
11748 IFree=$(mdsrate_inodes_available)
11749 if [ $IFree -lt $NR ]; then
11750 log "Limit lock number by $IFree inodes"
11754 lru_resize_disable mdc
11755 test_mkdir -p $DIR/$tdir/disable_lru_resize
11757 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
11758 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
11759 cancel_lru_locks mdc
11762 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11765 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11768 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11772 nolruresize_delta=$((etime-stime))
11773 log "ls -la time: $nolruresize_delta seconds"
11774 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11775 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
11777 lru_resize_enable mdc
11778 test_mkdir -p $DIR/$tdir/enable_lru_resize
11780 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
11781 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
11782 cancel_lru_locks mdc
11785 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11788 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11791 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11795 lruresize_delta=$((etime-stime))
11796 log "ls -la time: $lruresize_delta seconds"
11797 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11799 if [ $lruresize_delta -gt $nolruresize_delta ]; then
11800 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
11801 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
11802 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
11804 log "lru resize performs the same with no lru resize"
11806 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
11808 run_test 124b "lru resize (performance test) ======================="
11811 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11812 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11813 skip_env "no lru resize on server"
11815 # cache ununsed locks on client
11817 cancel_lru_locks mdc
11818 test_mkdir $DIR/$tdir
11819 createmany -o $DIR/$tdir/f $nr ||
11820 error "failed to create $nr files in $DIR/$tdir"
11821 ls -l $DIR/$tdir > /dev/null
11823 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11824 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11825 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11826 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11827 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11829 # set lru_max_age to 1 sec
11830 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11831 echo "sleep $((recalc_p * 2)) seconds..."
11832 sleep $((recalc_p * 2))
11834 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11835 # restore lru_max_age
11836 $LCTL set_param -n $nsdir.lru_max_age $max_age
11837 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11838 unlinkmany $DIR/$tdir/f $nr
11840 run_test 124c "LRUR cancel very aged locks"
11843 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11844 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11845 skip_env "no lru resize on server"
11847 # cache ununsed locks on client
11850 lru_resize_disable mdc
11851 stack_trap "lru_resize_enable mdc" EXIT
11853 cancel_lru_locks mdc
11855 # asynchronous object destroy at MDT could cause bl ast to client
11856 test_mkdir $DIR/$tdir
11857 createmany -o $DIR/$tdir/f $nr ||
11858 error "failed to create $nr files in $DIR/$tdir"
11859 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
11861 ls -l $DIR/$tdir > /dev/null
11863 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11864 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11865 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11866 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11868 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11870 # set lru_max_age to 1 sec
11871 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11872 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
11874 echo "sleep $((recalc_p * 2)) seconds..."
11875 sleep $((recalc_p * 2))
11877 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11879 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11881 run_test 124d "cancel very aged locks if lru-resize diasbaled"
11883 test_125() { # 13358
11884 $LCTL get_param -n llite.*.client_type | grep -q local ||
11885 skip "must run as local client"
11886 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
11887 skip_env "must have acl enabled"
11888 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11890 test_mkdir $DIR/$tdir
11891 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
11892 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
11893 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
11895 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
11897 test_126() { # bug 12829/13455
11898 $GSS && skip_env "must run as gss disabled"
11899 $LCTL get_param -n llite.*.client_type | grep -q local ||
11900 skip "must run as local client"
11901 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
11903 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
11904 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
11906 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
11908 run_test 126 "check that the fsgid provided by the client is taken into account"
11910 test_127a() { # bug 15521
11911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11912 local name count samp unit min max sum sumsq
11914 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
11915 echo "stats before reset"
11916 $LCTL get_param osc.*.stats
11917 $LCTL set_param osc.*.stats=0
11918 local fsize=$((2048 * 1024))
11920 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
11921 cancel_lru_locks osc
11922 dd if=$DIR/$tfile of=/dev/null bs=$fsize
11924 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
11925 stack_trap "rm -f $TMP/$tfile.tmp"
11926 while read name count samp unit min max sum sumsq; do
11927 echo "got name=$name count=$count unit=$unit min=$min max=$max"
11928 [ ! $min ] && error "Missing min value for $name proc entry"
11929 eval $name=$count || error "Wrong proc format"
11932 read_bytes|write_bytes)
11933 [[ "$unit" =~ "bytes" ]] ||
11934 error "unit is not 'bytes': $unit"
11935 (( $min >= 4096 )) || error "min is too small: $min"
11936 (( $min <= $fsize )) || error "min is too big: $min"
11937 (( $max >= 4096 )) || error "max is too small: $max"
11938 (( $max <= $fsize )) || error "max is too big: $max"
11939 (( $sum == $fsize )) || error "sum is wrong: $sum"
11940 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
11941 error "sumsquare is too small: $sumsq"
11942 (( $sumsq <= $fsize * $fsize )) ||
11943 error "sumsquare is too big: $sumsq"
11945 ost_read|ost_write)
11946 [[ "$unit" =~ "usec" ]] ||
11947 error "unit is not 'usec': $unit"
11951 done < $DIR/$tfile.tmp
11953 #check that we actually got some stats
11954 [ "$read_bytes" ] || error "Missing read_bytes stats"
11955 [ "$write_bytes" ] || error "Missing write_bytes stats"
11956 [ "$read_bytes" != 0 ] || error "no read done"
11957 [ "$write_bytes" != 0 ] || error "no write done"
11959 run_test 127a "verify the client stats are sane"
11961 test_127b() { # bug LU-333
11962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11963 local name count samp unit min max sum sumsq
11965 echo "stats before reset"
11966 $LCTL get_param llite.*.stats
11967 $LCTL set_param llite.*.stats=0
11969 # perform 2 reads and writes so MAX is different from SUM.
11970 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11971 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11972 cancel_lru_locks osc
11973 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11974 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11976 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
11977 stack_trap "rm -f $TMP/$tfile.tmp"
11978 while read name count samp unit min max sum sumsq; do
11979 echo "got name=$name count=$count unit=$unit min=$min max=$max"
11980 eval $name=$count || error "Wrong proc format"
11983 read_bytes|write_bytes)
11984 [[ "$unit" =~ "bytes" ]] ||
11985 error "unit is not 'bytes': $unit"
11986 (( $count == 2 )) || error "count is not 2: $count"
11987 (( $min == $PAGE_SIZE )) ||
11988 error "min is not $PAGE_SIZE: $min"
11989 (( $max == $PAGE_SIZE )) ||
11990 error "max is not $PAGE_SIZE: $max"
11991 (( $sum == $PAGE_SIZE * 2 )) ||
11992 error "sum is not $((PAGE_SIZE * 2)): $sum"
11995 [[ "$unit" =~ "usec" ]] ||
11996 error "unit is not 'usec': $unit"
12000 done < $TMP/$tfile.tmp
12002 #check that we actually got some stats
12003 [ "$read_bytes" ] || error "Missing read_bytes stats"
12004 [ "$write_bytes" ] || error "Missing write_bytes stats"
12005 [ "$read_bytes" != 0 ] || error "no read done"
12006 [ "$write_bytes" != 0 ] || error "no write done"
12008 run_test 127b "verify the llite client stats are sane"
12010 test_127c() { # LU-12394
12011 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
12018 $LCTL set_param llite.*.extents_stats=1
12019 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
12021 # Use two stripes so there is enough space in default config
12022 $LFS setstripe -c 2 $DIR/$tfile
12024 # Extent stats start at 0-4K and go in power of two buckets
12025 # LL_HIST_START = 12 --> 2^12 = 4K
12026 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
12027 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
12029 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
12031 # Write and read, 2x each, second time at a non-zero offset
12032 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
12033 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
12034 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
12035 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
12039 $LCTL get_param llite.*.extents_stats
12042 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
12044 local bucket=$($LCTL get_param -n llite.*.extents_stats |
12046 reads=$(echo $bucket | awk '{print $5}')
12047 writes=$(echo $bucket | awk '{print $9}')
12048 [ "$reads" -eq $count ] ||
12049 error "$reads reads in < $bsize bucket, expect $count"
12050 [ "$writes" -eq $count ] ||
12051 error "$writes writes in < $bsize bucket, expect $count"
12054 # Test mmap write and read
12055 $LCTL set_param llite.*.extents_stats=c
12057 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
12058 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
12059 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
12061 $LCTL get_param llite.*.extents_stats
12063 count=$(((size*1024) / PAGE_SIZE))
12065 bsize=$((2 * PAGE_SIZE / 1024))K
12067 bucket=$($LCTL get_param -n llite.*.extents_stats |
12069 reads=$(echo $bucket | awk '{print $5}')
12070 writes=$(echo $bucket | awk '{print $9}')
12071 # mmap writes fault in the page first, creating an additonal read
12072 [ "$reads" -eq $((2 * count)) ] ||
12073 error "$reads reads in < $bsize bucket, expect $count"
12074 [ "$writes" -eq $count ] ||
12075 error "$writes writes in < $bsize bucket, expect $count"
12077 run_test 127c "test llite extent stats with regular & mmap i/o"
12079 test_128() { # bug 15212
12081 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
12086 result=$(grep error $TMP/$tfile.log)
12087 rm -f $DIR/$tfile $TMP/$tfile.log
12088 [ -z "$result" ] ||
12089 error "consecutive find's under interactive lfs failed"
12091 run_test 128 "interactive lfs for 2 consecutive find's"
12093 set_dir_limits () {
12098 local ldproc=/proc/fs/ldiskfs
12099 local facets=$(get_facets MDS)
12101 for facet in ${facets//,/ }; do
12102 canondev=$(ldiskfs_canon \
12103 *.$(convert_facet2label $facet).mntdev $facet)
12104 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
12105 ldproc=/sys/fs/ldiskfs
12106 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
12107 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
12111 check_mds_dmesg() {
12112 local facets=$(get_facets MDS)
12113 for facet in ${facets//,/ }; do
12114 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
12120 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12121 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
12122 skip "Need MDS version with at least 2.5.56"
12123 if [ "$mds1_FSTYPE" != ldiskfs ]; then
12124 skip_env "ldiskfs only test"
12126 remote_mds_nodsh && skip "remote MDS with nodsh"
12129 local has_warning=false
12132 mkdir -p $DIR/$tdir
12134 # block size of mds1
12135 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
12136 set_dir_limits $maxsize $((maxsize * 6 / 8))
12137 stack_trap "set_dir_limits 0 0"
12138 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
12139 local dirsize=$(stat -c%s "$DIR/$tdir")
12141 while (( $dirsize <= $maxsize )); do
12142 $MCREATE $DIR/$tdir/file_base_$nfiles
12144 # check two errors:
12145 # ENOSPC for ext4 max_dir_size, which has been used since
12146 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
12147 if (( rc == ENOSPC )); then
12149 echo "rc=$rc returned as expected after $nfiles files"
12151 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
12152 error "create failed w/o dir size limit"
12154 # messages may be rate limited if test is run repeatedly
12155 check_mds_dmesg '"is approaching max"' ||
12156 echo "warning message should be output"
12157 check_mds_dmesg '"has reached max"' ||
12158 echo "reached message should be output"
12160 dirsize=$(stat -c%s "$DIR/$tdir")
12162 [[ $dirsize -ge $maxsize ]] && return 0
12163 error "dirsize $dirsize < $maxsize after $nfiles files"
12164 elif (( rc != 0 )); then
12167 nfiles=$((nfiles + 1))
12168 dirsize=$(stat -c%s "$DIR/$tdir")
12171 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
12173 run_test 129 "test directory size limit ========================"
12182 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12183 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12185 trap cleanup_130 EXIT RETURN
12187 local fm_file=$DIR/$tfile
12188 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
12189 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
12190 error "dd failed for $fm_file"
12192 # LU-1795: test filefrag/FIEMAP once, even if unsupported
12193 filefrag -ves $fm_file
12195 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12196 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12197 [ $RC != 0 ] && error "filefrag $fm_file failed"
12199 filefrag_op=$(filefrag -ve -k $fm_file |
12200 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12201 lun=$($LFS getstripe -i $fm_file)
12203 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
12206 for line in $filefrag_op
12208 frag_lun=`echo $line | cut -d: -f5`
12209 ext_len=`echo $line | cut -d: -f4`
12210 if (( $frag_lun != $lun )); then
12212 error "FIEMAP on 1-stripe file($fm_file) failed"
12215 (( tot_len += ext_len ))
12218 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
12220 error "FIEMAP on 1-stripe file($fm_file) failed;"
12226 echo "FIEMAP on single striped file succeeded"
12228 run_test 130a "FIEMAP (1-stripe file)"
12231 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
12233 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12234 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12236 trap cleanup_130 EXIT RETURN
12238 local fm_file=$DIR/$tfile
12239 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
12240 error "setstripe on $fm_file"
12241 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12242 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12244 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
12245 error "dd failed on $fm_file"
12247 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12248 filefrag_op=$(filefrag -ve -k $fm_file |
12249 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12251 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12252 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12257 for line in $filefrag_op
12259 frag_lun=$(echo $line | cut -d: -f5 |
12260 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12261 ext_len=$(echo $line | cut -d: -f4)
12262 if (( $frag_lun != $last_lun )); then
12263 if (( tot_len != 1024 )); then
12265 error "FIEMAP on $fm_file failed; returned " \
12266 "len $tot_len for OST $last_lun instead of 1024"
12269 (( num_luns += 1 ))
12273 (( tot_len += ext_len ))
12276 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
12278 error "FIEMAP on $fm_file failed; returned wrong number of " \
12279 "luns or wrong len for OST $last_lun"
12285 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
12287 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
12290 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12292 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12293 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12295 trap cleanup_130 EXIT RETURN
12297 local fm_file=$DIR/$tfile
12298 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
12299 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12300 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12302 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
12303 error "dd failed on $fm_file"
12305 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12306 filefrag_op=$(filefrag -ve -k $fm_file |
12307 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12309 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12310 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12315 for line in $filefrag_op
12317 frag_lun=$(echo $line | cut -d: -f5 |
12318 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12319 ext_len=$(echo $line | cut -d: -f4)
12320 if (( $frag_lun != $last_lun )); then
12321 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
12322 if (( logical != 512 )); then
12324 error "FIEMAP on $fm_file failed; returned " \
12325 "logical start for lun $logical instead of 512"
12328 if (( tot_len != 512 )); then
12330 error "FIEMAP on $fm_file failed; returned " \
12331 "len $tot_len for OST $last_lun instead of 1024"
12334 (( num_luns += 1 ))
12338 (( tot_len += ext_len ))
12341 if (( num_luns != 2 || tot_len != 512 )); then
12343 error "FIEMAP on $fm_file failed; returned wrong number of " \
12344 "luns or wrong len for OST $last_lun"
12350 echo "FIEMAP on 2-stripe file with hole succeeded"
12352 run_test 130c "FIEMAP (2-stripe file with hole)"
12355 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
12357 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12358 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12360 trap cleanup_130 EXIT RETURN
12362 local fm_file=$DIR/$tfile
12363 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
12364 error "setstripe on $fm_file"
12365 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12366 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12368 local actual_stripe_count=$($LFS getstripe -c $fm_file)
12369 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
12370 error "dd failed on $fm_file"
12372 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12373 filefrag_op=$(filefrag -ve -k $fm_file |
12374 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12376 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12377 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12382 for line in $filefrag_op
12384 frag_lun=$(echo $line | cut -d: -f5 |
12385 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12386 ext_len=$(echo $line | cut -d: -f4)
12387 if (( $frag_lun != $last_lun )); then
12388 if (( tot_len != 1024 )); then
12390 error "FIEMAP on $fm_file failed; returned " \
12391 "len $tot_len for OST $last_lun instead of 1024"
12394 (( num_luns += 1 ))
12398 (( tot_len += ext_len ))
12401 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
12403 error "FIEMAP on $fm_file failed; returned wrong number of " \
12404 "luns or wrong len for OST $last_lun"
12410 echo "FIEMAP on N-stripe file succeeded"
12412 run_test 130d "FIEMAP (N-stripe file)"
12415 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12417 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12418 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12420 trap cleanup_130 EXIT RETURN
12422 local fm_file=$DIR/$tfile
12423 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
12424 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12425 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12428 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
12429 for ((i = 0; i < $NUM_BLKS; i++))
12431 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
12434 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12435 filefrag_op=$(filefrag -ve -k $fm_file |
12436 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12438 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12439 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12444 for line in $filefrag_op
12446 frag_lun=$(echo $line | cut -d: -f5 |
12447 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12448 ext_len=$(echo $line | cut -d: -f4)
12449 if (( $frag_lun != $last_lun )); then
12450 if (( tot_len != $EXPECTED_LEN )); then
12452 error "FIEMAP on $fm_file failed; returned " \
12453 "len $tot_len for OST $last_lun instead " \
12457 (( num_luns += 1 ))
12461 (( tot_len += ext_len ))
12464 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
12466 error "FIEMAP on $fm_file failed; returned wrong number " \
12467 "of luns or wrong len for OST $last_lun"
12473 echo "FIEMAP with continuation calls succeeded"
12475 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
12478 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12479 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12481 local fm_file=$DIR/$tfile
12482 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
12483 error "multiop create with lov_delay_create on $fm_file"
12485 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12486 filefrag_extents=$(filefrag -vek $fm_file |
12487 awk '/extents? found/ { print $2 }')
12488 if [[ "$filefrag_extents" != "0" ]]; then
12489 error "FIEMAP on $fm_file failed; " \
12490 "returned $filefrag_extents expected 0"
12495 run_test 130f "FIEMAP (unstriped file)"
12497 # Test for writev/readv
12499 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
12500 error "writev test failed"
12501 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
12502 error "readv failed"
12505 run_test 131a "test iov's crossing stripe boundary for writev/readv"
12508 local fsize=$((524288 + 1048576 + 1572864))
12509 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
12510 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
12511 error "append writev test failed"
12513 ((fsize += 1572864 + 1048576))
12514 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
12515 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
12516 error "append writev test failed"
12519 run_test 131b "test append writev"
12522 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
12525 run_test 131c "test read/write on file w/o objects"
12528 rwv -f $DIR/$tfile -w -n 1 1572864
12529 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
12530 if [ "$NOB" != 1572864 ]; then
12531 error "Short read filed: read $NOB bytes instead of 1572864"
12535 run_test 131d "test short read"
12538 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
12539 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
12540 error "read hitting hole failed"
12543 run_test 131e "test read hitting hole"
12552 mds*) res=$(do_facet $facet \
12553 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
12555 ost*) res=$(do_facet $facet \
12556 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
12558 *) error "Wrong facet '$facet'" ;;
12560 [ "$res" ] || error "The counter for $op on $facet was not incremented"
12561 # if the argument $3 is zero, it means any stat increment is ok.
12562 if [[ $want -gt 0 ]]; then
12563 local count=$(echo $res | awk '{ print $2 }')
12564 [[ $count -ne $want ]] &&
12565 error "The $op counter on $facet is $count, not $want"
12570 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12571 remote_ost_nodsh && skip "remote OST with nodsh"
12572 remote_mds_nodsh && skip "remote MDS with nodsh"
12573 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12574 skip_env "MDS doesn't support rename stats"
12576 local testdir=$DIR/${tdir}/stats_testdir
12578 mkdir -p $DIR/${tdir}
12581 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12582 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12584 # verify mdt stats first.
12585 mkdir ${testdir} || error "mkdir failed"
12586 check_stats $SINGLEMDS "mkdir" 1
12587 touch ${testdir}/${tfile} || error "touch failed"
12588 check_stats $SINGLEMDS "open" 1
12589 check_stats $SINGLEMDS "close" 1
12590 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
12591 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
12592 check_stats $SINGLEMDS "mknod" 2
12594 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
12595 check_stats $SINGLEMDS "unlink" 1
12596 rm -f ${testdir}/${tfile} || error "file remove failed"
12597 check_stats $SINGLEMDS "unlink" 2
12599 # remove working dir and check mdt stats again.
12600 rmdir ${testdir} || error "rmdir failed"
12601 check_stats $SINGLEMDS "rmdir" 1
12603 local testdir1=$DIR/${tdir}/stats_testdir1
12604 mkdir -p ${testdir}
12605 mkdir -p ${testdir1}
12606 touch ${testdir1}/test1
12607 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
12608 check_stats $SINGLEMDS "crossdir_rename" 1
12610 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
12611 check_stats $SINGLEMDS "samedir_rename" 1
12613 rm -rf $DIR/${tdir}
12615 run_test 133a "Verifying MDT stats ========================================"
12620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12621 remote_ost_nodsh && skip "remote OST with nodsh"
12622 remote_mds_nodsh && skip "remote MDS with nodsh"
12624 local testdir=$DIR/${tdir}/stats_testdir
12626 mkdir -p ${testdir} || error "mkdir failed"
12627 touch ${testdir}/${tfile} || error "touch failed"
12628 cancel_lru_locks mdc
12631 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12632 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12634 # extra mdt stats verification.
12635 chmod 444 ${testdir}/${tfile} || error "chmod failed"
12636 check_stats $SINGLEMDS "setattr" 1
12637 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12638 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
12640 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
12641 check_stats $SINGLEMDS "getattr" 1
12643 rm -rf $DIR/${tdir}
12645 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
12646 # so the check below is not reliable
12647 [ $MDSCOUNT -eq 1 ] || return 0
12649 # Sleep to avoid a cached response.
12650 #define OBD_STATFS_CACHE_SECONDS 1
12652 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12653 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12654 $LFS df || error "lfs failed"
12655 check_stats $SINGLEMDS "statfs" 1
12657 # check aggregated statfs (LU-10018)
12658 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
12660 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
12663 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12664 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12666 check_stats $SINGLEMDS "statfs" 1
12668 # We want to check that the client didn't send OST_STATFS to
12669 # ost1 but the MDT also uses OST_STATFS for precreate. So some
12670 # extra care is needed here.
12671 if remote_mds; then
12672 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
12673 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
12675 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
12676 [ "$res" ] && error "OST got STATFS"
12681 run_test 133b "Verifying extra MDT stats =================================="
12684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12685 remote_ost_nodsh && skip "remote OST with nodsh"
12686 remote_mds_nodsh && skip "remote MDS with nodsh"
12688 local testdir=$DIR/$tdir/stats_testdir
12690 test_mkdir -p $testdir
12692 # verify obdfilter stats.
12693 $LFS setstripe -c 1 -i 0 $testdir/$tfile
12695 cancel_lru_locks osc
12696 wait_delete_completed
12699 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12700 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12702 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
12705 cancel_lru_locks osc
12706 check_stats ost1 "write" 1
12708 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
12709 check_stats ost1 "read" 1
12711 > $testdir/$tfile || error "truncate failed"
12712 check_stats ost1 "punch" 1
12714 rm -f $testdir/$tfile || error "file remove failed"
12715 wait_delete_completed
12716 check_stats ost1 "destroy" 1
12720 run_test 133c "Verifying OST stats ========================================"
12727 while [ $value -ge 2 ]; do
12732 if [ $orig -gt $order ]; then
12740 local size=('K' 'M' 'G' 'T');
12742 local size_string=$value
12744 while [ $value -ge 1024 ]; do
12745 if [ $i -gt 3 ]; then
12746 #T is the biggest unit we get here, if that is bigger,
12748 size_string=${value}T
12751 value=$((value >> 10))
12752 if [ $value -lt 1024 ]; then
12753 size_string=${value}${size[$i]}
12762 get_rename_size() {
12764 local context=${2:-.}
12765 local sample=$(do_facet $SINGLEMDS $LCTL \
12766 get_param mdt.$FSNAME-MDT0000.rename_stats |
12767 grep -A1 $context |
12768 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
12773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12774 remote_ost_nodsh && skip "remote OST with nodsh"
12775 remote_mds_nodsh && skip "remote MDS with nodsh"
12776 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12777 skip_env "MDS doesn't support rename stats"
12779 local testdir1=$DIR/${tdir}/stats_testdir1
12780 local testdir2=$DIR/${tdir}/stats_testdir2
12781 mkdir -p $DIR/${tdir}
12783 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12785 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
12786 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
12788 createmany -o $testdir1/test 512 || error "createmany failed"
12790 # check samedir rename size
12791 mv ${testdir1}/test0 ${testdir1}/test_0
12793 local testdir1_size=$(ls -l $DIR/${tdir} |
12794 awk '/stats_testdir1/ {print $5}')
12795 local testdir2_size=$(ls -l $DIR/${tdir} |
12796 awk '/stats_testdir2/ {print $5}')
12798 testdir1_size=$(order_2 $testdir1_size)
12799 testdir2_size=$(order_2 $testdir2_size)
12801 testdir1_size=$(size_in_KMGT $testdir1_size)
12802 testdir2_size=$(size_in_KMGT $testdir2_size)
12804 echo "source rename dir size: ${testdir1_size}"
12805 echo "target rename dir size: ${testdir2_size}"
12807 local cmd="do_facet $SINGLEMDS $LCTL "
12808 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
12810 eval $cmd || error "$cmd failed"
12811 local samedir=$($cmd | grep 'same_dir')
12812 local same_sample=$(get_rename_size $testdir1_size)
12813 [ -z "$samedir" ] && error "samedir_rename_size count error"
12814 [[ $same_sample -eq 1 ]] ||
12815 error "samedir_rename_size error $same_sample"
12816 echo "Check same dir rename stats success"
12818 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12820 # check crossdir rename size
12821 mv ${testdir1}/test_0 ${testdir2}/test_0
12823 testdir1_size=$(ls -l $DIR/${tdir} |
12824 awk '/stats_testdir1/ {print $5}')
12825 testdir2_size=$(ls -l $DIR/${tdir} |
12826 awk '/stats_testdir2/ {print $5}')
12828 testdir1_size=$(order_2 $testdir1_size)
12829 testdir2_size=$(order_2 $testdir2_size)
12831 testdir1_size=$(size_in_KMGT $testdir1_size)
12832 testdir2_size=$(size_in_KMGT $testdir2_size)
12834 echo "source rename dir size: ${testdir1_size}"
12835 echo "target rename dir size: ${testdir2_size}"
12837 eval $cmd || error "$cmd failed"
12838 local crossdir=$($cmd | grep 'crossdir')
12839 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
12840 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
12841 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
12842 [[ $src_sample -eq 1 ]] ||
12843 error "crossdir_rename_size error $src_sample"
12844 [[ $tgt_sample -eq 1 ]] ||
12845 error "crossdir_rename_size error $tgt_sample"
12846 echo "Check cross dir rename stats success"
12847 rm -rf $DIR/${tdir}
12849 run_test 133d "Verifying rename_stats ========================================"
12852 remote_mds_nodsh && skip "remote MDS with nodsh"
12853 remote_ost_nodsh && skip "remote OST with nodsh"
12854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12856 local testdir=$DIR/${tdir}/stats_testdir
12857 local ctr f0 f1 bs=32768 count=42 sum
12859 mkdir -p ${testdir} || error "mkdir failed"
12861 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
12863 for ctr in {write,read}_bytes; do
12865 cancel_lru_locks osc
12867 do_facet ost1 $LCTL set_param -n \
12868 "obdfilter.*.exports.clear=clear"
12870 if [ $ctr = write_bytes ]; then
12872 f1=${testdir}/${tfile}
12874 f0=${testdir}/${tfile}
12878 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
12881 cancel_lru_locks osc
12883 sum=$(do_facet ost1 $LCTL get_param \
12884 "obdfilter.*.exports.*.stats" |
12885 awk -v ctr=$ctr 'BEGIN { sum = 0 }
12886 $1 == ctr { sum += $7 }
12887 END { printf("%0.0f", sum) }')
12889 if ((sum != bs * count)); then
12890 error "Bad $ctr sum, expected $((bs * count)), got $sum"
12894 rm -rf $DIR/${tdir}
12896 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
12899 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
12900 skip "too old lustre for get_param -R ($facet_ver)"
12902 # verifying readability.
12903 $LCTL get_param -R '*' &> /dev/null
12905 # Verifing writability with badarea_io.
12906 $LCTL list_param -FR '*' | grep '=' | tr -d = |
12907 egrep -v 'force_lbug|changelog_mask' | xargs badarea_io ||
12908 error "client badarea_io failed"
12910 # remount the FS in case writes/reads /proc break the FS
12911 cleanup || error "failed to unmount"
12912 setup || error "failed to setup"
12914 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
12917 remote_mds_nodsh && skip "remote MDS with nodsh"
12918 remote_ost_nodsh && skip "remote OST with nodsh"
12921 for facet in mds1 ost1; do
12922 local facet_ver=$(lustre_version_code $facet)
12923 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
12924 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
12926 log "$facet: too old lustre for get_param -R"
12928 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
12929 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
12930 tr -d = | egrep -v 'force_lbug|changelog_mask' |
12931 xargs badarea_io" ||
12932 error "$facet badarea_io failed"
12934 skip_noexit "$facet: too old lustre for get_param -R"
12938 # remount the FS in case writes/reads /proc break the FS
12939 cleanup || error "failed to unmount"
12940 setup || error "failed to setup"
12942 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
12945 remote_mds_nodsh && skip "remote MDS with nodsh"
12946 remote_ost_nodsh && skip "remote OST with nodsh"
12947 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
12948 skip "Need MDS version at least 2.9.54"
12951 for facet in client mds1 ost1; do
12952 # Get the list of files that are missing the terminating newline
12953 local plist=$(do_facet $facet
12954 $LCTL list_param -FR '*' | grep '=' | tr -d =)
12956 for ent in $plist; do
12957 local missing=$(do_facet $facet $LCTL get_param $ent \|\
12958 awk -v FS='\v' -v RS='\v\v' \
12959 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
12960 print FILENAME}'" 2>/dev/null)
12961 [ -z $missing ] || {
12962 do_facet $facet $LCTL get_param $ent | od -An -tx1
12963 error "file does not end with newline: $facet-$ent"
12968 run_test 133h "Proc files should end with newlines"
12971 remote_mds_nodsh && skip "remote MDS with nodsh"
12972 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12973 skip "Need MDS version at least 2.7.54"
12975 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12976 cancel_lru_locks mdc
12978 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12979 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12980 [ $unused -eq 0 ] || error "$unused locks are not cleared"
12983 createmany -o $DIR/$tdir/f $nr ||
12984 error "failed to create $nr files in $DIR/$tdir"
12985 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12987 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
12988 do_facet mds1 $LCTL set_param fail_loc=0x327
12989 do_facet mds1 $LCTL set_param fail_val=500
12992 echo "sleep 10 seconds ..."
12994 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
12996 do_facet mds1 $LCTL set_param fail_loc=0
12997 do_facet mds1 $LCTL set_param fail_val=0
12998 [ $lck_cnt -lt $unused ] ||
12999 error "No locks reclaimed, before:$unused, after:$lck_cnt"
13002 unlinkmany $DIR/$tdir/f $nr
13004 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
13007 remote_mds_nodsh && skip "remote MDS with nodsh"
13008 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
13009 skip "Need MDS version at least 2.7.54"
13011 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
13012 cancel_lru_locks mdc
13014 local low_wm=$(do_facet mds1 $LCTL get_param -n \
13015 ldlm.lock_reclaim_threshold_mb)
13016 # disable reclaim temporarily
13017 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
13019 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
13020 do_facet mds1 $LCTL set_param fail_loc=0x328
13021 do_facet mds1 $LCTL set_param fail_val=500
13023 $LCTL set_param debug=+trace
13026 createmany -o $DIR/$tdir/f $nr &
13027 local create_pid=$!
13029 echo "Sleep $TIMEOUT seconds ..."
13031 if ! ps -p $create_pid > /dev/null 2>&1; then
13032 do_facet mds1 $LCTL set_param fail_loc=0
13033 do_facet mds1 $LCTL set_param fail_val=0
13034 do_facet mds1 $LCTL set_param \
13035 ldlm.lock_reclaim_threshold_mb=${low_wm}m
13036 error "createmany finished incorrectly!"
13038 do_facet mds1 $LCTL set_param fail_loc=0
13039 do_facet mds1 $LCTL set_param fail_val=0
13040 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
13041 wait $create_pid || return 1
13043 unlinkmany $DIR/$tdir/f $nr
13045 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
13048 remote_mds_nodsh && skip "remote MDS with nodsh"
13049 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
13050 skip "Need MDS version at least 2.13.50"
13053 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
13055 #define OBD_FAIL_PLAIN_RECORDS 0x1319
13056 #set only one record at plain llog
13057 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
13059 #fill already existed plain llog each 64767
13060 #wrapping whole catalog
13061 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
13063 createmany -o $DIR/$tdir/$tfile_ 64700
13064 for (( i = 0; i < 64700; i = i + 2 ))
13066 rm $DIR/$tdir/$tfile_$i &
13067 rm $DIR/$tdir/$tfile_$((i + 1)) &
13072 #waiting osp synchronization
13073 wait_delete_completed
13075 run_test 135 "Race catalog processing"
13078 remote_mds_nodsh && skip "remote MDS with nodsh"
13079 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
13080 skip "Need MDS version at least 2.13.50"
13083 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
13084 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
13085 #set only one record at plain llog
13086 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
13087 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
13089 #fill already existed 2 plain llogs each 64767
13090 #wrapping whole catalog
13091 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
13092 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
13093 wait_delete_completed
13095 createmany -o $DIR/$tdir/$tfile_ 10
13098 do_facet $SINGLEMDS $LCTL set_param fail_val=3
13099 for (( i = 0; i < 10; i = i + 3 ))
13101 rm $DIR/$tdir/$tfile_$i &
13102 rm $DIR/$tdir/$tfile_$((i + 1)) &
13106 rm $DIR/$tdir/$tfile_$((i + 2)) &
13109 #waiting osp synchronization
13110 wait_delete_completed
13112 run_test 136 "Race catalog processing 2"
13114 test_140() { #bug-17379
13115 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13117 test_mkdir $DIR/$tdir
13118 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
13119 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
13121 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
13122 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
13124 while i=$((i + 1)); do
13126 cd $i || error "Changing to $i"
13127 ln -s ../stat stat || error "Creating stat symlink"
13128 # Read the symlink until ELOOP present,
13129 # not LBUGing the system is considered success,
13130 # we didn't overrun the stack.
13131 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
13132 if [ $ret -ne 0 ]; then
13133 if [ $ret -eq 40 ]; then
13136 error "Open stat symlink"
13142 echo "The symlink depth = $i"
13143 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
13144 error "Invalid symlink depth"
13146 # Test recursive symlink
13147 ln -s symlink_self symlink_self
13148 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
13149 echo "open symlink_self returns $ret"
13150 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
13152 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
13155 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13157 local TF="$TMP/$tfile"
13159 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
13161 cancel_lru_locks $OSC
13162 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
13163 remount_client $MOUNT
13165 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
13168 $TRUNCATE $DIR/$tfile 6000
13169 cancel_lru_locks $OSC
13170 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
13173 echo "12345" >>$DIR/$tfile
13174 cancel_lru_locks $OSC
13175 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
13178 echo "12345" >>$DIR/$tfile
13179 cancel_lru_locks $OSC
13180 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
13185 run_test 150a "truncate/append tests"
13188 [ "$ost1_FSTYPE" != ldiskfs ] && skip "non-ldiskfs backend"
13189 [ $OST1_VERSION -lt $(version_code 2.13.50) ] &&
13190 skip "Need OST version at least 2.13.53"
13192 check_fallocate $DIR/$tfile || error "fallocate failed"
13194 run_test 150b "Verify fallocate (prealloc) functionality"
13200 [ "$ost1_FSTYPE" != ldiskfs ] && skip "non-ldiskfs backend"
13201 [ $OST1_VERSION -lt $(version_code 2.13.50) ] &&
13202 skip "Need OST version at least 2.13.53"
13204 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tdir || error "setstripe failed"
13205 fallocate -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
13206 sync; sync_all_data
13207 cancel_lru_locks $OSC
13209 bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
13210 want=$((OSTCOUNT * 1048576))
13212 # Must allocate all requested space, not more than 5% extra
13213 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
13214 error "bytes $bytes is not $want"
13216 run_test 150c "Verify fallocate Size and Blocks"
13222 [ "$ost1_FSTYPE" != ldiskfs ] && skip "non-ldiskfs backend"
13223 [ $OST1_VERSION -lt $(version_code 2.13.50) ] &&
13224 skip "Need OST version at least 2.13.53"
13226 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tdir || error "setstripe failed"
13227 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
13228 sync; sync_all_data
13229 cancel_lru_locks $OSC
13231 bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
13232 want=$((OSTCOUNT * 1048576))
13234 # Must allocate all requested space, not more than 5% extra
13235 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
13236 error "bytes $bytes is not $want"
13238 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
13240 #LU-2902 roc_hit was not able to read all values from lproc
13241 function roc_hit_init() {
13242 local list=$(comma_list $(osts_nodes))
13243 local dir=$DIR/$tdir-check
13244 local file=$dir/$tfile
13250 #use setstripe to do a write to every ost
13251 for i in $(seq 0 $((OSTCOUNT-1))); do
13252 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
13253 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
13254 idx=$(printf %04x $i)
13255 BEFORE=$(get_osd_param $list *OST*$idx stats |
13256 awk '$1 == "cache_access" {sum += $7}
13257 END { printf("%0.0f", sum) }')
13259 cancel_lru_locks osc
13260 cat $file >/dev/null
13262 AFTER=$(get_osd_param $list *OST*$idx stats |
13263 awk '$1 == "cache_access" {sum += $7}
13264 END { printf("%0.0f", sum) }')
13266 echo BEFORE:$BEFORE AFTER:$AFTER
13267 if ! let "AFTER - BEFORE == 4"; then
13269 error "roc_hit is not safe to use"
13277 function roc_hit() {
13278 local list=$(comma_list $(osts_nodes))
13279 echo $(get_osd_param $list '' stats |
13280 awk '$1 == "cache_hit" {sum += $7}
13281 END { printf("%0.0f", sum) }')
13284 function set_cache() {
13287 if [ "$2" == "off" ]; then
13290 local list=$(comma_list $(osts_nodes))
13291 set_osd_param $list '' $1_cache_enable $on
13293 cancel_lru_locks osc
13297 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13298 remote_ost_nodsh && skip "remote OST with nodsh"
13301 local list=$(comma_list $(osts_nodes))
13303 # check whether obdfilter is cache capable at all
13304 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
13305 skip "not cache-capable obdfilter"
13308 # check cache is enabled on all obdfilters
13309 if get_osd_param $list '' read_cache_enable | grep 0; then
13310 skip "oss cache is disabled"
13313 set_osd_param $list '' writethrough_cache_enable 1
13315 # check write cache is enabled on all obdfilters
13316 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
13317 skip "oss write cache is NOT enabled"
13322 #define OBD_FAIL_OBD_NO_LRU 0x609
13323 do_nodes $list $LCTL set_param fail_loc=0x609
13325 # pages should be in the case right after write
13326 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
13329 local BEFORE=$(roc_hit)
13330 cancel_lru_locks osc
13331 cat $DIR/$tfile >/dev/null
13332 local AFTER=$(roc_hit)
13334 do_nodes $list $LCTL set_param fail_loc=0
13336 if ! let "AFTER - BEFORE == CPAGES"; then
13337 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13340 cancel_lru_locks osc
13341 # invalidates OST cache
13342 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
13343 set_osd_param $list '' read_cache_enable 0
13344 cat $DIR/$tfile >/dev/null
13346 # now data shouldn't be found in the cache
13348 cancel_lru_locks osc
13349 cat $DIR/$tfile >/dev/null
13351 if let "AFTER - BEFORE != 0"; then
13352 error "IN CACHE: before: $BEFORE, after: $AFTER"
13355 set_osd_param $list '' read_cache_enable 1
13358 run_test 151 "test cache on oss and controls ==============================="
13361 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13363 local TF="$TMP/$tfile"
13365 # simulate ENOMEM during write
13366 #define OBD_FAIL_OST_NOMEM 0x226
13367 lctl set_param fail_loc=0x80000226
13368 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
13370 sync || error "sync failed"
13371 lctl set_param fail_loc=0
13373 # discard client's cache
13374 cancel_lru_locks osc
13376 # simulate ENOMEM during read
13377 lctl set_param fail_loc=0x80000226
13378 cmp $TF $DIR/$tfile || error "cmp failed"
13379 lctl set_param fail_loc=0
13383 run_test 152 "test read/write with enomem ============================"
13386 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
13388 run_test 153 "test if fdatasync does not crash ======================="
13390 dot_lustre_fid_permission_check() {
13392 local ffid=$MOUNT/.lustre/fid/$fid
13395 echo "stat fid $fid"
13396 stat $ffid > /dev/null || error "stat $ffid failed."
13397 echo "touch fid $fid"
13398 touch $ffid || error "touch $ffid failed."
13399 echo "write to fid $fid"
13400 cat /etc/hosts > $ffid || error "write $ffid failed."
13401 echo "read fid $fid"
13402 diff /etc/hosts $ffid || error "read $ffid failed."
13403 echo "append write to fid $fid"
13404 cat /etc/hosts >> $ffid || error "append write $ffid failed."
13405 echo "rename fid $fid"
13406 mv $ffid $test_dir/$tfile.1 &&
13407 error "rename $ffid to $tfile.1 should fail."
13408 touch $test_dir/$tfile.1
13409 mv $test_dir/$tfile.1 $ffid &&
13410 error "rename $tfile.1 to $ffid should fail."
13411 rm -f $test_dir/$tfile.1
13412 echo "truncate fid $fid"
13413 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
13414 echo "link fid $fid"
13415 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
13416 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
13417 echo "setfacl fid $fid"
13418 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
13419 echo "getfacl fid $fid"
13420 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
13422 echo "unlink fid $fid"
13423 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
13424 echo "mknod fid $fid"
13425 mknod $ffid c 1 3 && error "mknod $ffid should fail."
13427 fid=[0xf00000400:0x1:0x0]
13428 ffid=$MOUNT/.lustre/fid/$fid
13430 echo "stat non-exist fid $fid"
13431 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
13432 echo "write to non-exist fid $fid"
13433 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
13434 echo "link new fid $fid"
13435 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
13437 mkdir -p $test_dir/$tdir
13438 touch $test_dir/$tdir/$tfile
13439 fid=$($LFS path2fid $test_dir/$tdir)
13442 error "error: could not get fid for $test_dir/$dir/$tfile."
13444 ffid=$MOUNT/.lustre/fid/$fid
13447 ls $ffid > /dev/null || error "ls $ffid failed."
13448 echo "touch $fid/$tfile.1"
13449 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
13451 echo "touch $MOUNT/.lustre/fid/$tfile"
13452 touch $MOUNT/.lustre/fid/$tfile && \
13453 error "touch $MOUNT/.lustre/fid/$tfile should fail."
13455 echo "setxattr to $MOUNT/.lustre/fid"
13456 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
13458 echo "listxattr for $MOUNT/.lustre/fid"
13459 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
13461 echo "delxattr from $MOUNT/.lustre/fid"
13462 setfattr -x trusted.name1 $MOUNT/.lustre/fid
13464 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
13465 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
13466 error "touch invalid fid should fail."
13468 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
13469 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
13470 error "touch non-normal fid should fail."
13472 echo "rename $tdir to $MOUNT/.lustre/fid"
13473 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
13474 error "rename to $MOUNT/.lustre/fid should fail."
13476 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
13478 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
13479 local new_obf_mode=777
13481 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
13482 chmod $new_obf_mode $DIR/.lustre/fid ||
13483 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
13485 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
13486 [ $obf_mode -eq $new_obf_mode ] ||
13487 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
13489 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
13490 chmod $old_obf_mode $DIR/.lustre/fid ||
13491 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
13494 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
13495 fid=$($LFS path2fid $test_dir/$tfile-2)
13497 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
13499 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
13500 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
13501 error "create lov data thru .lustre failed"
13503 echo "cp /etc/passwd $test_dir/$tfile-2"
13504 cp /etc/passwd $test_dir/$tfile-2 ||
13505 error "copy to $test_dir/$tfile-2 failed."
13506 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
13507 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
13508 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
13510 rm -rf $test_dir/tfile.lnk
13511 rm -rf $test_dir/$tfile-2
13515 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13516 skip "Need MDS version at least 2.4.1"
13518 local tf=$DIR/$tfile
13521 local fid=$($LFS path2fid $tf)
13522 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
13524 # check that we get the same pathname back
13525 local found=$($LFS fid2path $MOUNT "$fid")
13526 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
13527 [ "$found" == "$tf" ] ||
13528 error "fid2path($fid=path2fid($tf)) = $found != $tf"
13530 run_test 154A "lfs path2fid and fid2path basic checks"
13533 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13534 skip "Need MDS version at least 2.4.1"
13536 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
13537 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
13538 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
13539 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
13541 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
13542 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
13544 # check that we get the same pathname
13545 echo "PFID: $PFID, name: $name"
13546 local FOUND=$($LFS fid2path $MOUNT "$PFID")
13547 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
13548 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
13549 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
13551 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
13553 run_test 154B "verify the ll_decode_linkea tool"
13556 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13557 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13558 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
13559 skip "Need MDS version at least 2.2.51"
13560 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13562 cp /etc/hosts $DIR/$tfile
13564 fid=$($LFS path2fid $DIR/$tfile)
13566 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
13568 dot_lustre_fid_permission_check "$fid" $DIR ||
13569 error "dot lustre permission check $fid failed"
13571 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
13573 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
13575 touch $MOUNT/.lustre/file &&
13576 error "creation is not allowed under .lustre"
13578 mkdir $MOUNT/.lustre/dir &&
13579 error "mkdir is not allowed under .lustre"
13583 run_test 154a "Open-by-FID"
13586 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13587 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13588 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13589 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
13590 skip "Need MDS version at least 2.2.51"
13592 local remote_dir=$DIR/$tdir/remote_dir
13596 mkdir -p $DIR/$tdir
13597 $LFS mkdir -i $MDTIDX $remote_dir ||
13598 error "create remote directory failed"
13600 cp /etc/hosts $remote_dir/$tfile
13602 fid=$($LFS path2fid $remote_dir/$tfile)
13604 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
13606 dot_lustre_fid_permission_check "$fid" $remote_dir ||
13607 error "dot lustre permission check $fid failed"
13610 run_test 154b "Open-by-FID for remote directory"
13613 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13614 skip "Need MDS version at least 2.4.1"
13616 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
13617 local FID1=$($LFS path2fid $DIR/$tfile.1)
13618 local FID2=$($LFS path2fid $DIR/$tfile.2)
13619 local FID3=$($LFS path2fid $DIR/$tfile.3)
13622 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
13623 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
13624 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
13626 [ "$FID" = "${!want}" ] ||
13627 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
13631 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
13633 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
13634 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
13638 run_test 154c "lfs path2fid and fid2path multiple arguments"
13641 remote_mds_nodsh && skip "remote MDS with nodsh"
13642 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
13643 skip "Need MDS version at least 2.5.53"
13645 if remote_mds; then
13646 nid=$($LCTL list_nids | sed "s/\./\\\./g")
13650 local proc_ofile="mdt.*.exports.'$nid'.open_files"
13657 local fid=$($LFS path2fid $DIR/$tfile)
13660 cmd="exec $fd<$DIR/$tfile"
13662 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
13663 echo "$fid_list" | grep "$fid"
13666 cmd="exec $fd>/dev/null"
13668 if [ $rc -ne 0 ]; then
13669 error "FID $fid not found in open files list $fid_list"
13672 run_test 154d "Verify open file fid"
13676 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
13677 skip "Need MDS version at least 2.6.50"
13679 if ls -a $MOUNT | grep -q '^\.lustre$'; then
13680 error ".lustre returned by readdir"
13683 run_test 154e ".lustre is not returned by readdir"
13686 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13688 # create parent directory on a single MDT to avoid cross-MDT hardlinks
13689 test_mkdir -p -c1 $DIR/$tdir/d
13690 # test dirs inherit from its stripe
13691 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
13692 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
13693 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
13694 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
13697 # get fid of parents
13698 local FID0=$($LFS path2fid $DIR/$tdir/d)
13699 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
13700 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
13701 local FID3=$($LFS path2fid $DIR)
13703 # check that path2fid --parents returns expected <parent_fid>/name
13704 # 1) test for a directory (single parent)
13705 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
13706 [ "$parent" == "$FID0/foo1" ] ||
13707 error "expected parent: $FID0/foo1, got: $parent"
13709 # 2) test for a file with nlink > 1 (multiple parents)
13710 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
13711 echo "$parent" | grep -F "$FID1/$tfile" ||
13712 error "$FID1/$tfile not returned in parent list"
13713 echo "$parent" | grep -F "$FID2/link" ||
13714 error "$FID2/link not returned in parent list"
13716 # 3) get parent by fid
13717 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
13718 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13719 echo "$parent" | grep -F "$FID1/$tfile" ||
13720 error "$FID1/$tfile not returned in parent list (by fid)"
13721 echo "$parent" | grep -F "$FID2/link" ||
13722 error "$FID2/link not returned in parent list (by fid)"
13724 # 4) test for entry in root directory
13725 parent=$($LFS path2fid --parents $DIR/f)
13726 echo "$parent" | grep -F "$FID3/f" ||
13727 error "$FID3/f not returned in parent list"
13729 # 5) test it on root directory
13730 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
13731 error "$MOUNT should not have parents"
13733 # enable xattr caching and check that linkea is correctly updated
13734 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
13735 save_lustre_params client "llite.*.xattr_cache" > $save
13736 lctl set_param llite.*.xattr_cache 1
13738 # 6.1) linkea update on rename
13739 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
13741 # get parents by fid
13742 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13743 # foo1 should no longer be returned in parent list
13744 echo "$parent" | grep -F "$FID1" &&
13745 error "$FID1 should no longer be in parent list"
13746 # the new path should appear
13747 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
13748 error "$FID2/$tfile.moved is not in parent list"
13750 # 6.2) linkea update on unlink
13751 rm -f $DIR/$tdir/d/foo2/link
13752 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13753 # foo2/link should no longer be returned in parent list
13754 echo "$parent" | grep -F "$FID2/link" &&
13755 error "$FID2/link should no longer be in parent list"
13759 restore_lustre_params < $save
13762 run_test 154f "get parent fids by reading link ea"
13766 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13767 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
13768 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
13769 skip "Need MDS version at least 2.6.92"
13771 mkdir -p $DIR/$tdir
13772 llapi_fid_test -d $DIR/$tdir
13774 run_test 154g "various llapi FID tests"
13776 test_155_small_load() {
13777 local temp=$TMP/$tfile
13778 local file=$DIR/$tfile
13780 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
13781 error "dd of=$temp bs=6096 count=1 failed"
13783 cancel_lru_locks $OSC
13784 cmp $temp $file || error "$temp $file differ"
13786 $TRUNCATE $temp 6000
13787 $TRUNCATE $file 6000
13788 cmp $temp $file || error "$temp $file differ (truncate1)"
13790 echo "12345" >>$temp
13791 echo "12345" >>$file
13792 cmp $temp $file || error "$temp $file differ (append1)"
13794 echo "12345" >>$temp
13795 echo "12345" >>$file
13796 cmp $temp $file || error "$temp $file differ (append2)"
13802 test_155_big_load() {
13803 remote_ost_nodsh && skip "remote OST with nodsh"
13805 local temp=$TMP/$tfile
13806 local file=$DIR/$tfile
13809 local cache_size=$(do_facet ost$((MAXI+1)) \
13810 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
13811 local large_file_size=$((cache_size * 2))
13813 echo "OSS cache size: $cache_size KB"
13814 echo "Large file size: $large_file_size KB"
13816 [ $MAXV -le $large_file_size ] &&
13817 skip_env "max available OST size needs > $large_file_size KB"
13819 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
13821 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
13822 error "dd of=$temp bs=$large_file_size count=1k failed"
13825 cancel_lru_locks osc
13826 cmp $temp $file || error "$temp $file differ"
13832 save_writethrough() {
13833 local facets=$(get_facets OST)
13835 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
13839 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13841 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13843 save_writethrough $p
13846 set_cache writethrough on
13847 test_155_small_load
13848 restore_lustre_params < $p
13851 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
13854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13856 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13858 save_writethrough $p
13861 set_cache writethrough off
13862 test_155_small_load
13863 restore_lustre_params < $p
13866 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
13869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13871 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13873 save_writethrough $p
13876 set_cache writethrough on
13877 test_155_small_load
13878 restore_lustre_params < $p
13881 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
13884 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13886 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13888 save_writethrough $p
13891 set_cache writethrough off
13892 test_155_small_load
13893 restore_lustre_params < $p
13896 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
13899 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13901 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13903 save_writethrough $p
13906 set_cache writethrough on
13908 restore_lustre_params < $p
13911 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
13914 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13916 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13918 save_writethrough $p
13921 set_cache writethrough off
13923 restore_lustre_params < $p
13926 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
13929 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13931 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13933 save_writethrough $p
13936 set_cache writethrough on
13938 restore_lustre_params < $p
13941 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
13944 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13946 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13948 save_writethrough $p
13951 set_cache writethrough off
13953 restore_lustre_params < $p
13956 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
13959 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13960 remote_ost_nodsh && skip "remote OST with nodsh"
13961 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
13962 skip "stats not implemented on old servers"
13963 [ "$ost1_FSTYPE" = "zfs" ] &&
13964 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
13969 local file="$DIR/$tfile"
13970 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13972 save_writethrough $p
13975 log "Turn on read and write cache"
13977 set_cache writethrough on
13979 log "Write data and read it back."
13980 log "Read should be satisfied from the cache."
13981 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13983 cancel_lru_locks osc
13984 cat $file >/dev/null
13986 if ! let "AFTER - BEFORE == CPAGES"; then
13987 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
13989 log "cache hits: before: $BEFORE, after: $AFTER"
13992 log "Read again; it should be satisfied from the cache."
13994 cancel_lru_locks osc
13995 cat $file >/dev/null
13997 if ! let "AFTER - BEFORE == CPAGES"; then
13998 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
14000 log "cache hits:: before: $BEFORE, after: $AFTER"
14003 log "Turn off the read cache and turn on the write cache"
14005 set_cache writethrough on
14007 log "Read again; it should be satisfied from the cache."
14009 cancel_lru_locks osc
14010 cat $file >/dev/null
14012 if ! let "AFTER - BEFORE == CPAGES"; then
14013 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
14015 log "cache hits:: before: $BEFORE, after: $AFTER"
14018 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
14019 # > 2.12.56 uses pagecache if cached
14020 log "Read again; it should not be satisfied from the cache."
14022 cancel_lru_locks osc
14023 cat $file >/dev/null
14025 if ! let "AFTER - BEFORE == 0"; then
14026 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
14028 log "cache hits:: before: $BEFORE, after: $AFTER"
14032 log "Write data and read it back."
14033 log "Read should be satisfied from the cache."
14034 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
14036 cancel_lru_locks osc
14037 cat $file >/dev/null
14039 if ! let "AFTER - BEFORE == CPAGES"; then
14040 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
14042 log "cache hits:: before: $BEFORE, after: $AFTER"
14045 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
14046 # > 2.12.56 uses pagecache if cached
14047 log "Read again; it should not be satisfied from the cache."
14049 cancel_lru_locks osc
14050 cat $file >/dev/null
14052 if ! let "AFTER - BEFORE == 0"; then
14053 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
14055 log "cache hits:: before: $BEFORE, after: $AFTER"
14059 log "Turn off read and write cache"
14061 set_cache writethrough off
14063 log "Write data and read it back"
14064 log "It should not be satisfied from the cache."
14066 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
14067 cancel_lru_locks osc
14069 cat $file >/dev/null
14071 if ! let "AFTER - BEFORE == 0"; then
14072 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
14074 log "cache hits:: before: $BEFORE, after: $AFTER"
14077 log "Turn on the read cache and turn off the write cache"
14079 set_cache writethrough off
14081 log "Write data and read it back"
14082 log "It should not be satisfied from the cache."
14084 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
14086 cancel_lru_locks osc
14087 cat $file >/dev/null
14089 if ! let "AFTER - BEFORE == 0"; then
14090 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
14092 log "cache hits:: before: $BEFORE, after: $AFTER"
14095 log "Read again; it should be satisfied from the cache."
14097 cancel_lru_locks osc
14098 cat $file >/dev/null
14100 if ! let "AFTER - BEFORE == CPAGES"; then
14101 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
14103 log "cache hits:: before: $BEFORE, after: $AFTER"
14106 restore_lustre_params < $p
14109 run_test 156 "Verification of tunables"
14112 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14113 remote_mds_nodsh && skip "remote MDS with nodsh"
14114 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
14115 skip "Need MDS version at least 2.2.0"
14117 changelog_register || error "changelog_register failed"
14118 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14119 changelog_users $SINGLEMDS | grep -q $cl_user ||
14120 error "User $cl_user not found in changelog_users"
14123 test_mkdir -p $DIR/$tdir/pics/2008/zachy
14124 changelog_clear 0 || error "changelog_clear failed"
14125 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
14126 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
14127 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14128 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14129 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14130 rm $DIR/$tdir/pics/desktop.jpg
14132 changelog_dump | tail -10
14134 echo "verifying changelog mask"
14135 changelog_chmask "-MKDIR"
14136 changelog_chmask "-CLOSE"
14138 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
14139 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
14141 changelog_chmask "+MKDIR"
14142 changelog_chmask "+CLOSE"
14144 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
14145 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
14147 changelog_dump | tail -10
14148 MKDIRS=$(changelog_dump | grep -c "MKDIR")
14149 CLOSES=$(changelog_dump | grep -c "CLOSE")
14150 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
14151 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
14154 echo "verifying target fid"
14155 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
14156 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
14157 [ "$fidc" == "$fidf" ] ||
14158 error "changelog '$tfile' fid $fidc != file fid $fidf"
14159 echo "verifying parent fid"
14160 # The FID returned from the Changelog may be the directory shard on
14161 # a different MDT, and not the FID returned by path2fid on the parent.
14162 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
14163 # since this is what will matter when recreating this file in the tree.
14164 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
14165 local pathp=$($LFS fid2path $MOUNT "$fidp")
14166 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
14167 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
14169 echo "getting records for $cl_user"
14170 changelog_users $SINGLEMDS
14171 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
14173 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
14174 error "changelog_clear failed"
14175 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
14176 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
14177 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
14178 error "user index expect $user_rec1 + $nclr != $user_rec2"
14180 local min0_rec=$(changelog_users $SINGLEMDS |
14181 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
14182 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
14183 awk '{ print $1; exit; }')
14185 changelog_dump | tail -n 5
14186 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
14187 [ $first_rec == $((min0_rec + 1)) ] ||
14188 error "first index should be $min0_rec + 1 not $first_rec"
14190 # LU-3446 changelog index reset on MDT restart
14191 local cur_rec1=$(changelog_users $SINGLEMDS |
14192 awk '/^current.index:/ { print $NF }')
14193 changelog_clear 0 ||
14194 error "clear all changelog records for $cl_user failed"
14195 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
14196 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
14197 error "Fail to start $SINGLEMDS"
14198 local cur_rec2=$(changelog_users $SINGLEMDS |
14199 awk '/^current.index:/ { print $NF }')
14200 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
14201 [ $cur_rec1 == $cur_rec2 ] ||
14202 error "current index should be $cur_rec1 not $cur_rec2"
14204 echo "verifying users from this test are deregistered"
14205 changelog_deregister || error "changelog_deregister failed"
14206 changelog_users $SINGLEMDS | grep -q $cl_user &&
14207 error "User '$cl_user' still in changelog_users"
14209 # lctl get_param -n mdd.*.changelog_users
14210 # current index: 144
14211 # ID index (idle seconds)
14213 if ! changelog_users $SINGLEMDS | grep "^cl"; then
14214 # this is the normal case where all users were deregistered
14215 # make sure no new records are added when no users are present
14216 local last_rec1=$(changelog_users $SINGLEMDS |
14217 awk '/^current.index:/ { print $NF }')
14218 touch $DIR/$tdir/chloe
14219 local last_rec2=$(changelog_users $SINGLEMDS |
14220 awk '/^current.index:/ { print $NF }')
14221 echo "verify changelogs are off: $last_rec1 == $last_rec2"
14222 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
14224 # any changelog users must be leftovers from a previous test
14225 changelog_users $SINGLEMDS
14226 echo "other changelog users; can't verify off"
14229 run_test 160a "changelog sanity"
14231 test_160b() { # LU-3587
14232 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14233 remote_mds_nodsh && skip "remote MDS with nodsh"
14234 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
14235 skip "Need MDS version at least 2.2.0"
14237 changelog_register || error "changelog_register failed"
14238 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14239 changelog_users $SINGLEMDS | grep -q $cl_user ||
14240 error "User '$cl_user' not found in changelog_users"
14242 local longname1=$(str_repeat a 255)
14243 local longname2=$(str_repeat b 255)
14246 echo "creating very long named file"
14247 touch $longname1 || error "create of '$longname1' failed"
14248 echo "renaming very long named file"
14249 mv $longname1 $longname2
14251 changelog_dump | grep RENME | tail -n 5
14254 run_test 160b "Verify that very long rename doesn't crash in changelog"
14257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14258 remote_mds_nodsh && skip "remote MDS with nodsh"
14260 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
14261 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
14262 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
14263 skip "Need MDS version at least 2.5.58 or 2.5.2+"
14267 # Registration step
14268 changelog_register || error "changelog_register failed"
14271 mkdir -p $DIR/$tdir
14272 $MCREATE $DIR/$tdir/foo_160c
14273 changelog_chmask "-TRUNC"
14274 $TRUNCATE $DIR/$tdir/foo_160c 200
14275 changelog_chmask "+TRUNC"
14276 $TRUNCATE $DIR/$tdir/foo_160c 199
14277 changelog_dump | tail -n 5
14278 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
14279 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
14281 run_test 160c "verify that changelog log catch the truncate event"
14284 remote_mds_nodsh && skip "remote MDS with nodsh"
14285 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14286 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14287 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
14288 skip "Need MDS version at least 2.7.60"
14290 # Registration step
14291 changelog_register || error "changelog_register failed"
14293 mkdir -p $DIR/$tdir/migrate_dir
14294 changelog_clear 0 || error "changelog_clear failed"
14296 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
14297 changelog_dump | tail -n 5
14298 local migrates=$(changelog_dump | grep -c "MIGRT")
14299 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
14301 run_test 160d "verify that changelog log catch the migrate event"
14304 remote_mds_nodsh && skip "remote MDS with nodsh"
14307 changelog_register || error "changelog_register failed"
14309 # Delete a future user (expect fail)
14310 local MDT0=$(facet_svc $SINGLEMDS)
14311 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
14314 if [ $rc -eq 0 ]; then
14315 error "Deleted non-existant user cl77"
14316 elif [ $rc -ne 2 ]; then
14317 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
14320 # Clear to a bad index (1 billion should be safe)
14321 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
14324 if [ $rc -eq 0 ]; then
14325 error "Successfully cleared to invalid CL index"
14326 elif [ $rc -ne 22 ]; then
14327 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
14330 run_test 160e "changelog negative testing (should return errors)"
14333 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14334 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14335 skip "Need MDS version at least 2.10.56"
14337 local mdts=$(comma_list $(mdts_nodes))
14340 changelog_register || error "first changelog_register failed"
14341 changelog_register || error "second changelog_register failed"
14343 declare -A cl_user1
14344 declare -A cl_user2
14349 # generate some changelog records to accumulate on each MDT
14350 # use fnv1a because created files should be evenly distributed
14351 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14352 error "test_mkdir $tdir failed"
14353 log "$(date +%s): creating first files"
14354 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14355 error "create $DIR/$tdir/$tfile failed"
14357 # check changelogs have been generated
14358 local start=$SECONDS
14359 local idle_time=$((MDSCOUNT * 5 + 5))
14360 local nbcl=$(changelog_dump | wc -l)
14361 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14363 for param in "changelog_max_idle_time=$idle_time" \
14365 "changelog_min_gc_interval=2" \
14366 "changelog_min_free_cat_entries=3"; do
14367 local MDT0=$(facet_svc $SINGLEMDS)
14368 local var="${param%=*}"
14369 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14371 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14372 do_nodes $mdts $LCTL set_param mdd.*.$param
14375 # force cl_user2 to be idle (1st part), but also cancel the
14376 # cl_user1 records so that it is not evicted later in the test.
14377 local sleep1=$((idle_time / 2))
14378 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
14381 # simulate changelog catalog almost full
14382 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
14383 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
14385 for i in $(seq $MDSCOUNT); do
14386 cl_users=(${CL_USERS[mds$i]})
14387 cl_user1[mds$i]="${cl_users[0]}"
14388 cl_user2[mds$i]="${cl_users[1]}"
14390 [ -n "${cl_user1[mds$i]}" ] ||
14391 error "mds$i: no user registered"
14392 [ -n "${cl_user2[mds$i]}" ] ||
14393 error "mds$i: only ${cl_user2[mds$i]} is registered"
14395 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14396 [ -n "$user_rec1" ] ||
14397 error "mds$i: User ${cl_user1[mds$i]} not registered"
14398 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14399 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14400 [ -n "$user_rec2" ] ||
14401 error "mds$i: User ${cl_user1[mds$i]} not registered"
14402 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14403 "$user_rec1 + 2 == $user_rec2"
14404 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14405 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14406 "$user_rec1 + 2, but is $user_rec2"
14407 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14408 [ -n "$user_rec2" ] ||
14409 error "mds$i: User ${cl_user2[mds$i]} not registered"
14410 [ $user_rec1 == $user_rec2 ] ||
14411 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14412 "$user_rec1, but is $user_rec2"
14415 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
14416 local sleep2=$((idle_time - (SECONDS - start) + 1))
14417 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
14420 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
14421 # cl_user1 should be OK because it recently processed records.
14422 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
14423 createmany -m $DIR/$tdir/${tfile}b $((MDSCOUNT * 2)) ||
14424 error "create $DIR/$tdir/${tfile}b failed"
14426 # ensure gc thread is done
14427 for i in $(mdts_nodes); do
14429 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
14430 error "$i: GC-thread not done"
14434 for i in $(seq $MDSCOUNT); do
14435 # check cl_user1 still registered
14436 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14437 error "mds$i: User ${cl_user1[mds$i]} not registered"
14438 # check cl_user2 unregistered
14439 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14440 error "mds$i: User ${cl_user2[mds$i]} still registered"
14442 # check changelogs are present and starting at $user_rec1 + 1
14443 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14444 [ -n "$user_rec1" ] ||
14445 error "mds$i: User ${cl_user1[mds$i]} not registered"
14446 first_rec=$($LFS changelog $(facet_svc mds$i) |
14447 awk '{ print $1; exit; }')
14449 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14450 [ $((user_rec1 + 1)) == $first_rec ] ||
14451 error "mds$i: first index should be $user_rec1 + 1, " \
14452 "but is $first_rec"
14455 run_test 160f "changelog garbage collect (timestamped users)"
14458 remote_mds_nodsh && skip "remote MDS with nodsh"
14459 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14460 skip "Need MDS version at least 2.10.56"
14462 local mdts=$(comma_list $(mdts_nodes))
14464 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
14465 do_nodes $mdts $LCTL set_param fail_loc=0x1314
14468 changelog_register || error "first changelog_register failed"
14469 changelog_register || error "second changelog_register failed"
14471 declare -A cl_user1
14472 declare -A cl_user2
14477 # generate some changelog records to accumulate on each MDT
14478 # use fnv1a because created files should be evenly distributed
14479 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14480 error "mkdir $tdir failed"
14481 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14482 error "create $DIR/$tdir/$tfile failed"
14484 # check changelogs have been generated
14485 local nbcl=$(changelog_dump | wc -l)
14486 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14488 # reduce the max_idle_indexes value to make sure we exceed it
14489 max_ndx=$((nbcl / 2 - 1))
14491 for param in "changelog_max_idle_indexes=$max_ndx" \
14493 "changelog_min_gc_interval=2" \
14494 "changelog_min_free_cat_entries=3"; do
14495 local MDT0=$(facet_svc $SINGLEMDS)
14496 local var="${param%=*}"
14497 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14499 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14500 do_nodes $mdts $LCTL set_param mdd.*.$param ||
14501 error "unable to set mdd.*.$param"
14504 # simulate changelog catalog almost full
14505 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
14506 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
14508 for i in $(seq $MDSCOUNT); do
14509 cl_users=(${CL_USERS[mds$i]})
14510 cl_user1[mds$i]="${cl_users[0]}"
14511 cl_user2[mds$i]="${cl_users[1]}"
14513 [ -n "${cl_user1[mds$i]}" ] ||
14514 error "mds$i: no user registered"
14515 [ -n "${cl_user2[mds$i]}" ] ||
14516 error "mds$i: only ${cl_user1[mds$i]} is registered"
14518 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14519 [ -n "$user_rec1" ] ||
14520 error "mds$i: User ${cl_user1[mds$i]} not registered"
14521 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14522 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14523 [ -n "$user_rec2" ] ||
14524 error "mds$i: User ${cl_user1[mds$i]} not registered"
14525 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14526 "$user_rec1 + 2 == $user_rec2"
14527 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14528 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14529 "$user_rec1 + 2, but is $user_rec2"
14530 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14531 [ -n "$user_rec2" ] ||
14532 error "mds$i: User ${cl_user2[mds$i]} not registered"
14533 [ $user_rec1 == $user_rec2 ] ||
14534 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14535 "$user_rec1, but is $user_rec2"
14538 # ensure we are past the previous changelog_min_gc_interval set above
14541 # generate one more changelog to trigger fail_loc
14542 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14543 error "create $DIR/$tdir/${tfile}bis failed"
14545 # ensure gc thread is done
14546 for i in $(mdts_nodes); do
14548 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
14549 error "$i: GC-thread not done"
14553 for i in $(seq $MDSCOUNT); do
14554 # check cl_user1 still registered
14555 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14556 error "mds$i: User ${cl_user1[mds$i]} not registered"
14557 # check cl_user2 unregistered
14558 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14559 error "mds$i: User ${cl_user2[mds$i]} still registered"
14561 # check changelogs are present and starting at $user_rec1 + 1
14562 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14563 [ -n "$user_rec1" ] ||
14564 error "mds$i: User ${cl_user1[mds$i]} not registered"
14565 first_rec=$($LFS changelog $(facet_svc mds$i) |
14566 awk '{ print $1; exit; }')
14568 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14569 [ $((user_rec1 + 1)) == $first_rec ] ||
14570 error "mds$i: first index should be $user_rec1 + 1, " \
14571 "but is $first_rec"
14574 run_test 160g "changelog garbage collect (old users)"
14577 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14578 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14579 skip "Need MDS version at least 2.10.56"
14581 local mdts=$(comma_list $(mdts_nodes))
14584 changelog_register || error "first changelog_register failed"
14585 changelog_register || error "second changelog_register failed"
14587 declare -A cl_user1
14588 declare -A cl_user2
14593 # generate some changelog records to accumulate on each MDT
14594 # use fnv1a because created files should be evenly distributed
14595 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14596 error "test_mkdir $tdir failed"
14597 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14598 error "create $DIR/$tdir/$tfile failed"
14600 # check changelogs have been generated
14601 local nbcl=$(changelog_dump | wc -l)
14602 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14604 for param in "changelog_max_idle_time=10" \
14606 "changelog_min_gc_interval=2"; do
14607 local MDT0=$(facet_svc $SINGLEMDS)
14608 local var="${param%=*}"
14609 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14611 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14612 do_nodes $mdts $LCTL set_param mdd.*.$param
14615 # force cl_user2 to be idle (1st part)
14618 for i in $(seq $MDSCOUNT); do
14619 cl_users=(${CL_USERS[mds$i]})
14620 cl_user1[mds$i]="${cl_users[0]}"
14621 cl_user2[mds$i]="${cl_users[1]}"
14623 [ -n "${cl_user1[mds$i]}" ] ||
14624 error "mds$i: no user registered"
14625 [ -n "${cl_user2[mds$i]}" ] ||
14626 error "mds$i: only ${cl_user2[mds$i]} is registered"
14628 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14629 [ -n "$user_rec1" ] ||
14630 error "mds$i: User ${cl_user1[mds$i]} not registered"
14631 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14632 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14633 [ -n "$user_rec2" ] ||
14634 error "mds$i: User ${cl_user1[mds$i]} not registered"
14635 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14636 "$user_rec1 + 2 == $user_rec2"
14637 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14638 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14639 "$user_rec1 + 2, but is $user_rec2"
14640 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14641 [ -n "$user_rec2" ] ||
14642 error "mds$i: User ${cl_user2[mds$i]} not registered"
14643 [ $user_rec1 == $user_rec2 ] ||
14644 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14645 "$user_rec1, but is $user_rec2"
14648 # force cl_user2 to be idle (2nd part) and to reach
14649 # changelog_max_idle_time
14652 # force each GC-thread start and block then
14653 # one per MDT/MDD, set fail_val accordingly
14654 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
14655 do_nodes $mdts $LCTL set_param fail_loc=0x1316
14657 # generate more changelogs to trigger fail_loc
14658 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14659 error "create $DIR/$tdir/${tfile}bis failed"
14661 # stop MDT to stop GC-thread, should be done in back-ground as it will
14662 # block waiting for the thread to be released and exit
14663 declare -A stop_pids
14664 for i in $(seq $MDSCOUNT); do
14666 stop_pids[mds$i]=$!
14669 for i in $(mdts_nodes); do
14672 local facets=$(facets_up_on_host $i)
14674 for facet in ${facets//,/ }; do
14675 if [[ $facet == mds* ]]; then
14679 # ensure each MDS's gc threads are still present and all in "R"
14680 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
14681 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
14682 error "$i: expected $nb GC-thread"
14684 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
14686 error "$i: GC-thread not found in R-state"
14687 # check umounts of each MDT on MDS have reached kthread_stop()
14688 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
14689 error "$i: expected $nb umount"
14691 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
14692 error "$i: umount not found in D-state"
14695 # release all GC-threads
14696 do_nodes $mdts $LCTL set_param fail_loc=0
14698 # wait for MDT stop to complete
14699 for i in $(seq $MDSCOUNT); do
14700 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
14704 # may try to check if any orphan changelog records are present
14705 # via ldiskfs/zfs and llog_reader...
14707 # re-start/mount MDTs
14708 for i in $(seq $MDSCOUNT); do
14709 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
14710 error "Fail to start mds$i"
14714 for i in $(seq $MDSCOUNT); do
14715 # check cl_user1 still registered
14716 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14717 error "mds$i: User ${cl_user1[mds$i]} not registered"
14718 # check cl_user2 unregistered
14719 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14720 error "mds$i: User ${cl_user2[mds$i]} still registered"
14722 # check changelogs are present and starting at $user_rec1 + 1
14723 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14724 [ -n "$user_rec1" ] ||
14725 error "mds$i: User ${cl_user1[mds$i]} not registered"
14726 first_rec=$($LFS changelog $(facet_svc mds$i) |
14727 awk '{ print $1; exit; }')
14729 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14730 [ $((user_rec1 + 1)) == $first_rec ] ||
14731 error "mds$i: first index should be $user_rec1 + 1, " \
14732 "but is $first_rec"
14735 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
14740 local mdts=$(comma_list $(mdts_nodes))
14742 changelog_register || error "first changelog_register failed"
14744 # generate some changelog records to accumulate on each MDT
14745 # use fnv1a because created files should be evenly distributed
14746 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14747 error "mkdir $tdir failed"
14748 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14749 error "create $DIR/$tdir/$tfile failed"
14751 # check changelogs have been generated
14752 local nbcl=$(changelog_dump | wc -l)
14753 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14755 # simulate race between register and unregister
14756 # XXX as fail_loc is set per-MDS, with DNE configs the race
14757 # simulation will only occur for one MDT per MDS and for the
14758 # others the normal race scenario will take place
14759 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
14760 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
14761 do_nodes $mdts $LCTL set_param fail_val=1
14763 # unregister 1st user
14764 changelog_deregister &
14766 # wait some time for deregister work to reach race rdv
14768 # register 2nd user
14769 changelog_register || error "2nd user register failed"
14771 wait $pid1 || error "1st user deregister failed"
14775 declare -A LAST_REC
14776 for i in $(seq $MDSCOUNT); do
14777 if changelog_users mds$i | grep "^cl"; then
14778 # make sure new records are added with one user present
14779 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
14780 awk '/^current.index:/ { print $NF }')
14782 error "mds$i has no user registered"
14786 # generate more changelog records to accumulate on each MDT
14787 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14788 error "create $DIR/$tdir/${tfile}bis failed"
14790 for i in $(seq $MDSCOUNT); do
14791 last_rec=$(changelog_users $SINGLEMDS |
14792 awk '/^current.index:/ { print $NF }')
14793 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
14794 [ $last_rec != ${LAST_REC[mds$i]} ] ||
14795 error "changelogs are off on mds$i"
14798 run_test 160i "changelog user register/unregister race"
14801 remote_mds_nodsh && skip "remote MDS with nodsh"
14802 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
14803 skip "Need MDS version at least 2.12.56"
14805 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
14806 stack_trap "umount $MOUNT2" EXIT
14808 changelog_register || error "first changelog_register failed"
14809 stack_trap "changelog_deregister" EXIT
14811 # generate some changelog
14812 # use fnv1a because created files should be evenly distributed
14813 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14814 error "mkdir $tdir failed"
14815 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14816 error "create $DIR/$tdir/${tfile}bis failed"
14818 # open the changelog device
14819 exec 3>/dev/changelog-$FSNAME-MDT0000
14820 stack_trap "exec 3>&-" EXIT
14821 exec 4</dev/changelog-$FSNAME-MDT0000
14822 stack_trap "exec 4<&-" EXIT
14824 # umount the first lustre mount
14826 stack_trap "mount_client $MOUNT" EXIT
14829 cat <&4 >/dev/null || error "read changelog failed"
14832 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14833 changelog_users $SINGLEMDS | grep -q $cl_user ||
14834 error "User $cl_user not found in changelog_users"
14836 printf 'clear:'$cl_user':0' >&3
14838 run_test 160j "client can be umounted while its chanangelog is being used"
14841 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14842 remote_mds_nodsh && skip "remote MDS with nodsh"
14844 mkdir -p $DIR/$tdir/1/1
14846 changelog_register || error "changelog_register failed"
14847 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14849 changelog_users $SINGLEMDS | grep -q $cl_user ||
14850 error "User '$cl_user' not found in changelog_users"
14851 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
14852 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
14853 rmdir $DIR/$tdir/1/1 & sleep 1
14855 touch $DIR/$tdir/2/2
14856 rm -rf $DIR/$tdir/2
14861 changelog_dump | grep rmdir || error "rmdir not recorded"
14864 changelog_deregister
14866 run_test 160k "Verify that changelog records are not lost"
14869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14871 test_mkdir -c1 $DIR/$tdir
14872 cp /etc/hosts $DIR/$tdir/$tfile
14873 test_mkdir -c1 $DIR/$tdir/foo1
14874 test_mkdir -c1 $DIR/$tdir/foo2
14875 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
14876 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
14877 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
14878 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
14879 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
14880 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14881 $LFS fid2path $DIR $FID
14882 error "bad link ea"
14885 rm $DIR/$tdir/foo2/zachary
14887 rm $DIR/$tdir/foo2/thor
14889 rm $DIR/$tdir/$tfile
14891 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
14892 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
14893 { $LFS fid2path $DIR $FID; error "bad link rename"; }
14894 rm $DIR/$tdir/foo2/maggie
14897 local longname=$tfile.avg_len_is_thirty_two_
14898 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
14899 error_noexit 'failed to unlink many hardlinks'" EXIT
14900 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
14901 error "failed to hardlink many files"
14902 links=$($LFS fid2path $DIR $FID | wc -l)
14903 echo -n "${links}/1000 links in link EA"
14904 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
14906 run_test 161a "link ea sanity"
14909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14910 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
14913 local remote_dir=$DIR/$tdir/remote_dir
14915 mkdir -p $DIR/$tdir
14916 $LFS mkdir -i $MDTIDX $remote_dir ||
14917 error "create remote directory failed"
14919 cp /etc/hosts $remote_dir/$tfile
14920 mkdir -p $remote_dir/foo1
14921 mkdir -p $remote_dir/foo2
14922 ln $remote_dir/$tfile $remote_dir/foo1/sofia
14923 ln $remote_dir/$tfile $remote_dir/foo2/zachary
14924 ln $remote_dir/$tfile $remote_dir/foo1/luna
14925 ln $remote_dir/$tfile $remote_dir/foo2/thor
14927 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
14929 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14930 $LFS fid2path $DIR $FID
14931 error "bad link ea"
14934 rm $remote_dir/foo2/zachary
14936 rm $remote_dir/foo2/thor
14938 rm $remote_dir/$tfile
14940 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
14941 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
14942 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
14943 $LFS fid2path $DIR $FID
14944 error "bad link rename"
14946 rm $remote_dir/foo2/maggie
14949 local longname=filename_avg_len_is_thirty_two_
14950 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
14951 error "failed to hardlink many files"
14952 links=$($LFS fid2path $DIR $FID | wc -l)
14953 echo -n "${links}/1000 links in link EA"
14954 [[ ${links} -gt 60 ]] ||
14955 error "expected at least 60 links in link EA"
14956 unlinkmany $remote_dir/foo2/$longname 1000 ||
14957 error "failed to unlink many hardlinks"
14959 run_test 161b "link ea sanity under remote directory"
14962 remote_mds_nodsh && skip "remote MDS with nodsh"
14963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14964 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
14965 skip "Need MDS version at least 2.1.5"
14967 # define CLF_RENAME_LAST 0x0001
14968 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
14969 changelog_register || error "changelog_register failed"
14972 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
14973 touch $DIR/$tdir/foo_161c
14974 touch $DIR/$tdir/bar_161c
14975 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14976 changelog_dump | grep RENME | tail -n 5
14977 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14978 changelog_clear 0 || error "changelog_clear failed"
14979 if [ x$flags != "x0x1" ]; then
14980 error "flag $flags is not 0x1"
14983 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
14984 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
14985 touch $DIR/$tdir/foo_161c
14986 touch $DIR/$tdir/bar_161c
14987 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14988 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14989 changelog_dump | grep RENME | tail -n 5
14990 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14991 changelog_clear 0 || error "changelog_clear failed"
14992 if [ x$flags != "x0x0" ]; then
14993 error "flag $flags is not 0x0"
14995 echo "rename overwrite a target having nlink > 1," \
14996 "changelog record has flags of $flags"
14998 # rename doesn't overwrite a target (changelog flag 0x0)
14999 touch $DIR/$tdir/foo_161c
15000 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
15001 changelog_dump | grep RENME | tail -n 5
15002 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
15003 changelog_clear 0 || error "changelog_clear failed"
15004 if [ x$flags != "x0x0" ]; then
15005 error "flag $flags is not 0x0"
15007 echo "rename doesn't overwrite a target," \
15008 "changelog record has flags of $flags"
15010 # define CLF_UNLINK_LAST 0x0001
15011 # unlink a file having nlink = 1 (changelog flag 0x1)
15012 rm -f $DIR/$tdir/foo2_161c
15013 changelog_dump | grep UNLNK | tail -n 5
15014 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
15015 changelog_clear 0 || error "changelog_clear failed"
15016 if [ x$flags != "x0x1" ]; then
15017 error "flag $flags is not 0x1"
15019 echo "unlink a file having nlink = 1," \
15020 "changelog record has flags of $flags"
15022 # unlink a file having nlink > 1 (changelog flag 0x0)
15023 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
15024 rm -f $DIR/$tdir/foobar_161c
15025 changelog_dump | grep UNLNK | tail -n 5
15026 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
15027 changelog_clear 0 || error "changelog_clear failed"
15028 if [ x$flags != "x0x0" ]; then
15029 error "flag $flags is not 0x0"
15031 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
15033 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
15036 remote_mds_nodsh && skip "remote MDS with nodsh"
15037 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
15042 changelog_register || error "changelog_register failed"
15044 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
15045 # interfer with $MOUNT/.lustre/fid/ access
15047 [[ $? -eq 0 ]] || error "mkdir failed"
15049 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
15050 $LCTL set_param fail_loc=0x8000140c
15052 $LCTL set_param fail_val=5
15055 echo foofoo > $DIR/$tdir/$tfile &
15058 # wait for create to be delayed
15062 [[ $? -eq 0 ]] || error "create should be blocked"
15064 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
15065 stack_trap "rm -f $tempfile"
15066 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
15067 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
15068 # some delay may occur during ChangeLog publishing and file read just
15069 # above, that could allow file write to happen finally
15070 [[ -s $tempfile ]] && echo "file should be empty"
15072 $LCTL set_param fail_loc=0
15075 [[ $? -eq 0 ]] || error "create failed"
15077 run_test 161d "create with concurrent .lustre/fid access"
15080 local expected="$1"
15085 path=$($LFS fid2path "$@")
15088 if [ $rc -ne 0 ]; then
15089 error "path looked up of '$expected' failed: rc=$rc"
15090 elif [ "$path" != "$expected" ]; then
15091 error "path looked up '$path' instead of '$expected'"
15093 echo "FID '$fid' resolves to path '$path' as expected"
15097 test_162a() { # was test_162
15098 test_mkdir -p -c1 $DIR/$tdir/d2
15099 touch $DIR/$tdir/d2/$tfile
15100 touch $DIR/$tdir/d2/x1
15101 touch $DIR/$tdir/d2/x2
15102 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
15103 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
15105 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
15106 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
15109 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
15110 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
15111 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
15113 # softlink to wrong file
15114 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
15115 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
15116 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
15119 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
15120 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
15121 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
15122 # fid2path dir/fsname should both work
15123 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
15124 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
15126 # hardlink count: check that there are 2 links
15127 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
15128 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
15130 # hardlink indexing: remove the first link
15131 rm $DIR/$tdir/d2/p/q/r/hlink
15132 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
15134 run_test 162a "path lookup sanity"
15137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15138 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15141 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
15142 error "create striped dir failed"
15144 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
15145 tail -n 1 | awk '{print $2}')
15146 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
15148 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
15149 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
15152 for ((i=0;i<5;i++)); do
15153 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
15154 error "get fid for f$i failed"
15155 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
15157 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
15158 error "get fid for d$i failed"
15159 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
15164 run_test 162b "striped directory path lookup sanity"
15166 # LU-4239: Verify fid2path works with paths 100 or more directories deep
15168 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
15169 skip "Need MDS version at least 2.7.51"
15171 local lpath=$tdir.local
15172 local rpath=$tdir.remote
15174 test_mkdir $DIR/$lpath
15175 test_mkdir $DIR/$rpath
15177 for ((i = 0; i <= 101; i++)); do
15180 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
15181 error "get fid for local directory $DIR/$lpath failed"
15182 check_path "$DIR/$lpath" $MOUNT $FID --link 0
15185 test_mkdir $DIR/$rpath
15186 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
15187 error "get fid for remote directory $DIR/$rpath failed"
15188 check_path "$DIR/$rpath" $MOUNT $FID --link 0
15193 run_test 162c "fid2path works with paths 100 or more directories deep"
15195 oalr_event_count() {
15199 awk -v name="${FSNAME}-OST0000" \
15200 -v event="${event}" \
15201 '$1 == "TRACE" && $2 == event && $3 == name' \
15206 oalr_expect_event_count() {
15209 local expect="${3}"
15212 count=$(oalr_event_count "${event}" "${trace}")
15213 if ((count == expect)); then
15217 error_noexit "${event} event count was '${count}', expected ${expect}"
15223 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
15225 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
15229 sync # Flush previous IOs so we can count log entries.
15230 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
15231 stack_trap cleanup_165 EXIT
15235 local trace="/tmp/${tfile}.trace"
15239 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
15243 do_facet ost1 ofd_access_log_reader --list
15246 do_facet ost1 killall -TERM ofd_access_log_reader
15250 if ((rc != 0)); then
15251 error "ofd_access_log_reader exited with rc = '${rc}'"
15254 # Parse trace file for discovery events:
15255 oalr_expect_event_count alr_log_add "${trace}" 1
15256 oalr_expect_event_count alr_log_eof "${trace}" 1
15257 oalr_expect_event_count alr_log_free "${trace}" 1
15259 run_test 165a "ofd access log discovery"
15262 local trace="/tmp/${tfile}.trace"
15263 local file="${DIR}/${tfile}"
15274 lfs setstripe -c 1 -i 0 "${file}"
15275 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15276 do_facet ost1 ofd_access_log_reader --list
15278 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
15280 do_facet ost1 killall -TERM ofd_access_log_reader
15284 if ((rc != 0)); then
15285 error "ofd_access_log_reader exited with rc = '${rc}'"
15288 oalr_expect_event_count alr_log_entry "${trace}" 1
15290 pfid1=$($LFS path2fid "${file}")
15292 # 1 2 3 4 5 6 7 8 9 10
15293 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
15294 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
15296 echo "entry = '${entry[*]}'" >&2
15299 if [[ "${pfid1}" != "${pfid2}" ]]; then
15300 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
15304 if ((size != 1048576)); then
15305 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
15309 if [[ "${flags}" != "w" ]]; then
15310 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
15313 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
15314 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c || error "cannot read '${file}'"
15316 do_facet ost1 killall -TERM ofd_access_log_reader
15320 if ((rc != 0)); then
15321 error "ofd_access_log_reader exited with rc = '${rc}'"
15324 oalr_expect_event_count alr_log_entry "${trace}" 1
15326 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
15327 echo "entry = '${entry[*]}'" >&2
15330 if [[ "${pfid1}" != "${pfid2}" ]]; then
15331 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
15335 if ((size != 524288)); then
15336 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
15340 if [[ "${flags}" != "r" ]]; then
15341 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
15344 run_test 165b "ofd access log entries are produced and consumed"
15347 local file="${DIR}/${tdir}/${tfile}"
15348 test_mkdir "${DIR}/${tdir}"
15352 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
15354 # 4096 / 64 = 64. Create twice as many entries.
15355 for ((i = 0; i < 128; i++)); do
15356 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c || error "cannot create file"
15360 do_facet ost1 ofd_access_log_reader --list
15361 unlinkmany "${file}-%d" 128
15363 run_test 165c "full ofd access logs do not block IOs"
15365 oal_peek_entry_count() {
15366 do_facet ost1 ofd_access_log_reader --list | awk '$1 == "_entry_count:" { print $2; }'
15369 oal_expect_entry_count() {
15370 local entry_count=$(oal_peek_entry_count)
15373 if ((entry_count == expect)); then
15377 error_noexit "bad entry count, got ${entry_count}, expected ${expect}"
15378 do_facet ost1 ofd_access_log_reader --list >&2
15383 local trace="/tmp/${tfile}.trace"
15384 local file="${DIR}/${tdir}/${tfile}"
15385 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
15387 test_mkdir "${DIR}/${tdir}"
15390 lfs setstripe -c 1 -i 0 "${file}"
15392 do_facet ost1 lctl set_param "${param}=rw"
15393 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15394 oal_expect_entry_count 1
15396 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15397 oal_expect_entry_count 2
15399 do_facet ost1 lctl set_param "${param}=r"
15400 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15401 oal_expect_entry_count 2
15403 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15404 oal_expect_entry_count 3
15406 do_facet ost1 lctl set_param "${param}=w"
15407 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15408 oal_expect_entry_count 4
15410 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15411 oal_expect_entry_count 4
15413 do_facet ost1 lctl set_param "${param}=0"
15414 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15415 oal_expect_entry_count 4
15417 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15418 oal_expect_entry_count 4
15420 run_test 165d "ofd_access_log mask works"
15423 # do directio so as not to populate the page cache
15424 log "creating a 10 Mb file"
15425 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
15426 log "starting reads"
15427 dd if=$DIR/$tfile of=/dev/null bs=4096 &
15428 log "truncating the file"
15429 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
15431 kill %+ || true # reads might have finished
15432 echo "wait until dd is finished"
15434 log "removing the temporary file"
15435 rm -rf $DIR/$tfile || error "tmp file removal failed"
15437 run_test 169 "parallel read and truncate should not deadlock"
15440 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15442 $LCTL clear # bug 18514
15443 $LCTL debug_daemon start $TMP/${tfile}_log_good
15445 $LCTL debug_daemon stop
15446 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
15447 error "sed failed to read log_good"
15449 $LCTL debug_daemon start $TMP/${tfile}_log_good
15451 $LCTL debug_daemon stop
15453 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
15454 error "lctl df log_bad failed"
15456 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
15457 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
15459 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
15460 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
15462 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
15463 error "bad_line good_line1 good_line2 are empty"
15465 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
15466 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
15467 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
15469 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
15470 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
15471 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
15473 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
15474 error "bad_line_new good_line_new are empty"
15476 local expected_good=$((good_line1 + good_line2*2))
15478 rm -f $TMP/${tfile}*
15479 # LU-231, short malformed line may not be counted into bad lines
15480 if [ $bad_line -ne $bad_line_new ] &&
15481 [ $bad_line -ne $((bad_line_new - 1)) ]; then
15482 error "expected $bad_line bad lines, but got $bad_line_new"
15486 if [ $expected_good -ne $good_line_new ]; then
15487 error "expected $expected_good good lines, but got $good_line_new"
15492 run_test 170 "test lctl df to handle corrupted log ====================="
15494 test_171() { # bug20592
15495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15497 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
15498 $LCTL set_param fail_loc=0x50e
15499 $LCTL set_param fail_val=3000
15500 multiop_bg_pause $DIR/$tfile O_s || true
15502 kill -USR1 $MULTIPID
15506 if dmesg | grep "recursive fault"; then
15507 error "caught a recursive fault"
15509 $LCTL set_param fail_loc=0
15512 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
15514 # it would be good to share it with obdfilter-survey/iokit-libecho code
15515 setup_obdecho_osc () {
15518 local obdfilter_name=$2
15519 echo "Creating new osc for $obdfilter_name on $ost_nid"
15520 # make sure we can find loopback nid
15521 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
15523 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
15524 ${obdfilter_name}_osc_UUID || rc=2; }
15525 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
15526 ${obdfilter_name}_UUID $ost_nid || rc=3; }
15530 cleanup_obdecho_osc () {
15531 local obdfilter_name=$1
15532 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
15533 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
15540 local pages=${3:-64}
15545 local obd_size=$(get_obd_size $node $OBD)
15546 local page_size=$(get_page_size $node)
15547 if [[ -n "$obd_size" ]]; then
15548 local new_count=$((obd_size / (pages * page_size / 1024)))
15549 [[ $new_count -ge $count ]] || count=$new_count
15552 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
15553 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
15555 if [ $rc -eq 0 ]; then
15556 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
15557 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
15559 echo "New object id is $id"
15560 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
15562 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
15563 "test_brw $count w v $pages $id" || rc=4; }
15564 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
15566 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
15567 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
15568 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
15569 { do_facet $node "$LCTL --device ec detach" || rc=6; }
15570 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
15575 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15577 if ! module_loaded obdecho; then
15578 load_module obdecho/obdecho &&
15579 stack_trap "rmmod obdecho" EXIT ||
15580 error "unable to load obdecho on client"
15583 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
15584 local host=$($LCTL get_param -n osc.$osc.import |
15585 awk '/current_connection:/ { print $2 }' )
15586 local target=$($LCTL get_param -n osc.$osc.import |
15587 awk '/target:/ { print $2 }' )
15588 target=${target%_UUID}
15590 if [ -n "$target" ]; then
15591 setup_obdecho_osc $host $target &&
15592 stack_trap "cleanup_obdecho_osc $target" EXIT ||
15593 { error "obdecho setup failed with $?"; return; }
15595 obdecho_test ${target}_osc client ||
15596 error "obdecho_test failed on ${target}_osc"
15598 $LCTL get_param osc.$osc.import
15599 error "there is no osc.$osc.import target"
15602 run_test 180a "test obdecho on osc"
15605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15606 remote_ost_nodsh && skip "remote OST with nodsh"
15608 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
15609 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
15610 error "failed to load module obdecho"
15612 local target=$(do_facet ost1 $LCTL dl |
15613 awk '/obdfilter/ { print $4; exit; }')
15615 if [ -n "$target" ]; then
15616 obdecho_test $target ost1 || error "obdecho_test failed with $?"
15618 do_facet ost1 $LCTL dl
15619 error "there is no obdfilter target on ost1"
15622 run_test 180b "test obdecho directly on obdfilter"
15624 test_180c() { # LU-2598
15625 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15626 remote_ost_nodsh && skip "remote OST with nodsh"
15627 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
15628 skip "Need MDS version at least 2.4.0"
15630 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
15631 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
15632 error "failed to load module obdecho"
15634 local target=$(do_facet ost1 $LCTL dl |
15635 awk '/obdfilter/ { print $4; exit; }')
15637 if [ -n "$target" ]; then
15638 local pages=16384 # 64MB bulk I/O RPC size
15640 obdecho_test "$target" ost1 "$pages" ||
15641 error "obdecho_test with pages=$pages failed with $?"
15643 do_facet ost1 $LCTL dl
15644 error "there is no obdfilter target on ost1"
15647 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
15649 test_181() { # bug 22177
15650 test_mkdir $DIR/$tdir
15651 # create enough files to index the directory
15652 createmany -o $DIR/$tdir/foobar 4000
15653 # print attributes for debug purpose
15656 multiop_bg_pause $DIR/$tdir D_Sc || return 1
15658 # remove the files & current working dir
15659 unlinkmany $DIR/$tdir/foobar 4000
15661 kill -USR1 $MULTIPID
15663 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
15666 run_test 181 "Test open-unlinked dir ========================"
15672 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15674 $LCTL set_param mdc.*.rpc_stats=clear
15676 for (( i = 0; i < $tcount; i++ )) ; do
15677 mkdir $DIR/$tdir/$i
15680 for (( i = 0; i < $tcount; i++ )) ; do
15681 createmany -o $DIR/$tdir/$i/f- $fcount &
15685 for (( i = 0; i < $tcount; i++ )) ; do
15686 unlinkmany $DIR/$tdir/$i/f- $fcount &
15690 $LCTL get_param mdc.*.rpc_stats
15694 run_test 182 "Test parallel modify metadata operations ================"
15696 test_183() { # LU-2275
15697 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15698 remote_mds_nodsh && skip "remote MDS with nodsh"
15699 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
15700 skip "Need MDS version at least 2.3.56"
15702 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15703 echo aaa > $DIR/$tdir/$tfile
15705 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
15706 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
15708 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
15709 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
15711 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
15713 # Flush negative dentry cache
15714 touch $DIR/$tdir/$tfile
15716 # We are not checking for any leaked references here, they'll
15717 # become evident next time we do cleanup with module unload.
15720 run_test 183 "No crash or request leak in case of strange dispositions ========"
15722 # test suite 184 is for LU-2016, LU-2017
15724 check_swap_layouts_support
15726 dir0=$DIR/$tdir/$testnum
15727 test_mkdir -p -c1 $dir0
15732 $LFS setstripe -c1 $file1
15734 $LFS setstripe -c2 $file2
15736 gen1=$($LFS getstripe -g $file1)
15737 gen2=$($LFS getstripe -g $file2)
15739 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
15740 gen=$($LFS getstripe -g $file1)
15741 [[ $gen1 != $gen ]] ||
15742 "Layout generation on $file1 does not change"
15743 gen=$($LFS getstripe -g $file2)
15744 [[ $gen2 != $gen ]] ||
15745 "Layout generation on $file2 does not change"
15747 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
15748 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
15750 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
15752 run_test 184a "Basic layout swap"
15755 check_swap_layouts_support
15757 dir0=$DIR/$tdir/$testnum
15758 mkdir -p $dir0 || error "creating dir $dir0"
15765 $LFS setstripe -c1 $file1
15766 $LFS setstripe -c2 $file2
15767 $LFS setstripe -c1 $file3
15768 chown $RUNAS_ID $file3
15769 gen1=$($LFS getstripe -g $file1)
15770 gen2=$($LFS getstripe -g $file2)
15772 $LFS swap_layouts $dir1 $dir2 &&
15773 error "swap of directories layouts should fail"
15774 $LFS swap_layouts $dir1 $file1 &&
15775 error "swap of directory and file layouts should fail"
15776 $RUNAS $LFS swap_layouts $file1 $file2 &&
15777 error "swap of file we cannot write should fail"
15778 $LFS swap_layouts $file1 $file3 &&
15779 error "swap of file with different owner should fail"
15780 /bin/true # to clear error code
15782 run_test 184b "Forbidden layout swap (will generate errors)"
15785 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
15786 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
15787 check_swap_layouts_support
15789 local dir0=$DIR/$tdir/$testnum
15790 mkdir -p $dir0 || error "creating dir $dir0"
15792 local ref1=$dir0/ref1
15793 local ref2=$dir0/ref2
15794 local file1=$dir0/file1
15795 local file2=$dir0/file2
15796 # create a file large enough for the concurrent test
15797 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
15798 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
15799 echo "ref file size: ref1($(stat -c %s $ref1))," \
15800 "ref2($(stat -c %s $ref2))"
15803 dd if=$ref1 of=$file1 bs=16k &
15806 # Make sure dd starts to copy file
15807 while [ ! -f $file1 ]; do sleep 0.1; done
15809 $LFS swap_layouts $file1 $file2
15812 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
15813 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
15815 # how many bytes copied before swapping layout
15816 local copied=$(stat -c %s $file2)
15817 local remaining=$(stat -c %s $ref1)
15818 remaining=$((remaining - copied))
15819 echo "Copied $copied bytes before swapping layout..."
15821 cmp -n $copied $file1 $ref2 | grep differ &&
15822 error "Content mismatch [0, $copied) of ref2 and file1"
15823 cmp -n $copied $file2 $ref1 ||
15824 error "Content mismatch [0, $copied) of ref1 and file2"
15825 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
15826 error "Content mismatch [$copied, EOF) of ref1 and file1"
15829 rm -f $ref1 $ref2 $file1 $file2
15831 run_test 184c "Concurrent write and layout swap"
15834 check_swap_layouts_support
15835 [ -z "$(which getfattr 2>/dev/null)" ] &&
15836 skip_env "no getfattr command"
15838 local file1=$DIR/$tdir/$tfile-1
15839 local file2=$DIR/$tdir/$tfile-2
15840 local file3=$DIR/$tdir/$tfile-3
15844 mkdir -p $DIR/$tdir
15845 touch $file1 || error "create $file1 failed"
15846 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
15847 error "create $file2 failed"
15848 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
15849 error "create $file3 failed"
15850 lovea1=$(get_layout_param $file1)
15852 $LFS swap_layouts $file2 $file3 ||
15853 error "swap $file2 $file3 layouts failed"
15854 $LFS swap_layouts $file1 $file2 ||
15855 error "swap $file1 $file2 layouts failed"
15857 lovea2=$(get_layout_param $file2)
15860 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
15862 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
15863 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
15865 run_test 184d "allow stripeless layouts swap"
15868 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
15869 skip "Need MDS version at least 2.6.94"
15870 check_swap_layouts_support
15871 [ -z "$(which getfattr 2>/dev/null)" ] &&
15872 skip_env "no getfattr command"
15874 local file1=$DIR/$tdir/$tfile-1
15875 local file2=$DIR/$tdir/$tfile-2
15876 local file3=$DIR/$tdir/$tfile-3
15879 mkdir -p $DIR/$tdir
15880 touch $file1 || error "create $file1 failed"
15881 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
15882 error "create $file2 failed"
15883 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
15884 error "create $file3 failed"
15886 $LFS swap_layouts $file1 $file2 ||
15887 error "swap $file1 $file2 layouts failed"
15889 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
15890 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
15892 echo 123 > $file1 || error "Should be able to write into $file1"
15894 $LFS swap_layouts $file1 $file3 ||
15895 error "swap $file1 $file3 layouts failed"
15897 echo 123 > $file1 || error "Should be able to write into $file1"
15899 rm -rf $file1 $file2 $file3
15901 run_test 184e "Recreate layout after stripeless layout swaps"
15904 # Create a file with name longer than sizeof(struct stat) ==
15905 # 144 to see if we can get chars from the file name to appear
15906 # in the returned striping. Note that 'f' == 0x66.
15907 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
15909 mkdir -p $DIR/$tdir
15910 mcreate $DIR/$tdir/$file
15911 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
15912 error "IOC_MDC_GETFILEINFO returned garbage striping"
15915 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
15917 test_185() { # LU-2441
15918 # LU-3553 - no volatile file support in old servers
15919 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
15920 skip "Need MDS version at least 2.3.60"
15922 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15923 touch $DIR/$tdir/spoo
15924 local mtime1=$(stat -c "%Y" $DIR/$tdir)
15925 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
15926 error "cannot create/write a volatile file"
15927 [ "$FILESET" == "" ] &&
15928 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
15929 error "FID is still valid after close"
15931 multiop_bg_pause $DIR/$tdir vVw4096_c
15938 # assume that the next FID for this client is sequential, since stdout
15939 # is unfortunately eaten by multiop_bg_pause
15940 local n=$((${fidv[1]} + 1))
15941 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
15942 if [ "$FILESET" == "" ]; then
15943 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
15944 error "FID is missing before close"
15946 kill -USR1 $multi_pid
15947 # 1 second delay, so if mtime change we will see it
15949 local mtime2=$(stat -c "%Y" $DIR/$tdir)
15950 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
15952 run_test 185 "Volatile file support"
15954 function create_check_volatile() {
15958 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
15961 local FID=$(cat /tmp/${tfile}.fid)
15962 [ "$FID" == "" ] && error "can't get FID for volatile"
15963 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
15964 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
15965 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
15969 cancel_lru_locks mdc # flush opencache
15970 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
15975 # LU-12516 - volatile creation via .lustre
15976 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
15977 skip "Need MDS version at least 2.3.55"
15979 create_check_volatile 0
15980 [ $MDSCOUNT -lt 2 ] && return 0
15983 create_check_volatile 1
15987 run_test 185a "Volatile file creation in .lustre/fid/"
15990 remote_mds_nodsh && skip "remote MDS with nodsh"
15991 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15992 skip "Need MDS version at least 2.3.0"
15994 local dir0=$DIR/$tdir/$testnum
15995 mkdir -p $dir0 || error "creating dir $dir0"
15997 local file=$dir0/file1
15998 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
15999 local dv1=$($LFS data_version $file)
16000 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
16001 local dv2=$($LFS data_version $file)
16002 [[ $dv1 != $dv2 ]] ||
16003 error "data version did not change on write $dv1 == $dv2"
16008 run_test 187a "Test data version change"
16011 remote_mds_nodsh && skip "remote MDS with nodsh"
16012 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
16013 skip "Need MDS version at least 2.3.0"
16015 local dir0=$DIR/$tdir/$testnum
16016 mkdir -p $dir0 || error "creating dir $dir0"
16018 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
16019 [[ ${DV[0]} != ${DV[1]} ]] ||
16020 error "data version did not change on write"\
16021 " ${DV[0]} == ${DV[1]}"
16026 run_test 187b "Test data version change on volatile file"
16029 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16030 remote_mgs_nodsh && skip "remote MGS with nodsh"
16031 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16033 local POOL=${POOL:-cea1}
16034 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
16035 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
16038 local last_ost=$(($OSTCOUNT - 1))
16040 local ost_list=$(seq $first_ost $ost_step $last_ost)
16041 local ost_range="$first_ost $last_ost $ost_step"
16042 local test_path=$POOL_ROOT/$POOL_DIR_NAME
16043 local file_dir=$POOL_ROOT/file_tst
16044 local subdir=$test_path/subdir
16048 # former test_200a test_200b
16049 pool_add $POOL || { rc=$? ; break; }
16050 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
16051 # former test_200c test_200d
16052 mkdir -p $test_path
16053 pool_set_dir $POOL $test_path || { rc=$? ; break; }
16054 pool_check_dir $POOL $test_path || { rc=$? ; break; }
16056 pool_check_dir $POOL $subdir || { rc=$? ; break; }
16057 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
16058 || { rc=$? ; break; }
16059 # former test_200e test_200f
16060 local files=$((OSTCOUNT*3))
16061 pool_alloc_files $POOL $test_path $files "$ost_list" \
16062 || { rc=$? ; break; }
16063 pool_create_files $POOL $file_dir $files "$ost_list" \
16064 || { rc=$? ; break; }
16065 # former test_200g test_200h
16066 pool_lfs_df $POOL || { rc=$? ; break; }
16067 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
16069 # former test_201a test_201b test_201c
16070 pool_remove_first_target $POOL || { rc=$? ; break; }
16072 local f=$test_path/$tfile
16073 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
16074 pool_remove $POOL $f || { rc=$? ; break; }
16082 run_test 200 "OST pools"
16084 # usage: default_attr <count | size | offset>
16086 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
16089 # usage: check_default_stripe_attr
16090 check_default_stripe_attr() {
16091 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
16094 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
16096 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
16100 error "unknown getstripe attr '$1'"
16103 [ $ACTUAL == $EXPECTED ] ||
16104 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
16108 test_mkdir $DIR/$tdir
16109 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
16111 check_default_stripe_attr --stripe-count
16112 check_default_stripe_attr --stripe-size
16113 check_default_stripe_attr --stripe-index
16115 run_test 204a "Print default stripe attributes"
16118 test_mkdir $DIR/$tdir
16119 $LFS setstripe --stripe-count 1 $DIR/$tdir
16121 check_default_stripe_attr --stripe-size
16122 check_default_stripe_attr --stripe-index
16124 run_test 204b "Print default stripe size and offset"
16127 test_mkdir $DIR/$tdir
16128 $LFS setstripe --stripe-size 65536 $DIR/$tdir
16130 check_default_stripe_attr --stripe-count
16131 check_default_stripe_attr --stripe-index
16133 run_test 204c "Print default stripe count and offset"
16136 test_mkdir $DIR/$tdir
16137 $LFS setstripe --stripe-index 0 $DIR/$tdir
16139 check_default_stripe_attr --stripe-count
16140 check_default_stripe_attr --stripe-size
16142 run_test 204d "Print default stripe count and size"
16145 test_mkdir $DIR/$tdir
16146 $LFS setstripe -d $DIR/$tdir
16148 check_default_stripe_attr --stripe-count --raw
16149 check_default_stripe_attr --stripe-size --raw
16150 check_default_stripe_attr --stripe-index --raw
16152 run_test 204e "Print raw stripe attributes"
16155 test_mkdir $DIR/$tdir
16156 $LFS setstripe --stripe-count 1 $DIR/$tdir
16158 check_default_stripe_attr --stripe-size --raw
16159 check_default_stripe_attr --stripe-index --raw
16161 run_test 204f "Print raw stripe size and offset"
16164 test_mkdir $DIR/$tdir
16165 $LFS setstripe --stripe-size 65536 $DIR/$tdir
16167 check_default_stripe_attr --stripe-count --raw
16168 check_default_stripe_attr --stripe-index --raw
16170 run_test 204g "Print raw stripe count and offset"
16173 test_mkdir $DIR/$tdir
16174 $LFS setstripe --stripe-index 0 $DIR/$tdir
16176 check_default_stripe_attr --stripe-count --raw
16177 check_default_stripe_attr --stripe-size --raw
16179 run_test 204h "Print raw stripe count and size"
16181 # Figure out which job scheduler is being used, if any,
16182 # or use a fake one
16183 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
16184 JOBENV=SLURM_JOB_ID
16185 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
16187 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
16189 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
16190 JOBENV=LOADL_STEP_ID
16191 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
16194 $LCTL list_param jobid_name > /dev/null 2>&1
16195 if [ $? -eq 0 ]; then
16201 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
16203 verify_jobstats() {
16208 # we don't really need to clear the stats for this test to work, since each
16209 # command has a unique jobid, but it makes debugging easier if needed.
16210 # for facet in $facets; do
16211 # local dev=$(convert_facet2label $facet)
16212 # # clear old jobstats
16213 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
16216 # use a new JobID for each test, or we might see an old one
16217 [ "$JOBENV" = "FAKE_JOBID" ] &&
16218 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
16220 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
16222 [ "$JOBENV" = "nodelocal" ] && {
16223 FAKE_JOBID=id.$testnum.%e.$RANDOM
16224 $LCTL set_param jobid_name=$FAKE_JOBID
16225 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
16228 log "Test: ${cmd[*]}"
16229 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
16231 if [ $JOBENV = "FAKE_JOBID" ]; then
16232 FAKE_JOBID=$JOBVAL ${cmd[*]}
16237 # all files are created on OST0000
16238 for facet in $facets; do
16239 local stats="*.$(convert_facet2label $facet).job_stats"
16241 # strip out libtool wrappers for in-tree executables
16242 if [ $(do_facet $facet lctl get_param $stats |
16243 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
16244 do_facet $facet lctl get_param $stats
16245 error "No jobstats for $JOBVAL found on $facet::$stats"
16251 local new_jobenv=$1
16253 set_persistent_param_and_check client "jobid_var" \
16254 "$FSNAME.sys.jobid_var" $new_jobenv
16257 test_205a() { # Job stats
16258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16259 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
16260 skip "Need MDS version with at least 2.7.1"
16261 remote_mgs_nodsh && skip "remote MGS with nodsh"
16262 remote_mds_nodsh && skip "remote MDS with nodsh"
16263 remote_ost_nodsh && skip "remote OST with nodsh"
16264 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
16265 skip "Server doesn't support jobstats"
16266 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
16268 local old_jobenv=$($LCTL get_param -n jobid_var)
16269 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
16271 if [[ $PERM_CMD == *"set_param -P"* ]]; then
16272 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
16274 stack_trap "do_facet mgs $PERM_CMD \
16275 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
16279 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
16280 mdt.*.job_cleanup_interval | head -n 1)
16281 local new_interval=5
16282 do_facet $SINGLEMDS \
16283 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
16284 stack_trap "do_facet $SINGLEMDS \
16285 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
16286 local start=$SECONDS
16290 cmd="mkdir $DIR/$tdir"
16291 verify_jobstats "$cmd" "$SINGLEMDS"
16293 cmd="rmdir $DIR/$tdir"
16294 verify_jobstats "$cmd" "$SINGLEMDS"
16295 # mkdir on secondary MDT
16296 if [ $MDSCOUNT -gt 1 ]; then
16297 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
16298 verify_jobstats "$cmd" "mds2"
16301 cmd="mknod $DIR/$tfile c 1 3"
16302 verify_jobstats "$cmd" "$SINGLEMDS"
16304 cmd="rm -f $DIR/$tfile"
16305 verify_jobstats "$cmd" "$SINGLEMDS"
16306 # create all files on OST0000 so verify_jobstats can find OST stats
16308 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
16309 verify_jobstats "$cmd" "$SINGLEMDS"
16311 cmd="touch $DIR/$tfile"
16312 verify_jobstats "$cmd" "$SINGLEMDS ost1"
16314 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
16315 verify_jobstats "$cmd" "ost1"
16317 cancel_lru_locks osc
16318 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
16319 verify_jobstats "$cmd" "ost1"
16321 cmd="$TRUNCATE $DIR/$tfile 0"
16322 verify_jobstats "$cmd" "$SINGLEMDS ost1"
16324 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
16325 verify_jobstats "$cmd" "$SINGLEMDS"
16326 # jobstats expiry - sleep until old stats should be expired
16327 local left=$((new_interval + 5 - (SECONDS - start)))
16328 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
16329 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
16331 cmd="mkdir $DIR/$tdir.expire"
16332 verify_jobstats "$cmd" "$SINGLEMDS"
16333 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
16334 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
16336 # Ensure that jobid are present in changelog (if supported by MDS)
16337 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
16338 changelog_dump | tail -10
16339 jobids=$(changelog_dump | tail -9 | grep -c "j=")
16340 [ $jobids -eq 9 ] ||
16341 error "Wrong changelog jobid count $jobids != 9"
16345 jobstats_set $JOBENV
16347 changelog_dump | grep $tfile
16348 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
16349 [ $jobids -eq 0 ] ||
16350 error "Unexpected jobids when jobid_var=$JOBENV"
16353 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
16354 JOBENV="JOBCOMPLEX"
16355 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
16357 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
16359 run_test 205a "Verify job stats"
16361 # LU-13117, LU-13597
16363 job_stats="mdt.*.job_stats"
16364 $LCTL set_param $job_stats=clear
16365 $LCTL set_param jobid_var=USER jobid_name="%e.%u"
16366 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
16367 do_facet $SINGLEMDS $LCTL get_param $job_stats |
16368 grep "job_id:.*foolish" &&
16369 error "Unexpected jobid found"
16370 do_facet $SINGLEMDS $LCTL get_param $job_stats |
16371 grep "open:.*min.*max.*sum" ||
16372 error "wrong job_stats format found"
16374 run_test 205b "Verify job stats jobid and output format"
16376 # LU-1480, LU-1773 and LU-1657
16378 mkdir -p $DIR/$tdir
16379 $LFS setstripe -c -1 $DIR/$tdir
16380 #define OBD_FAIL_LOV_INIT 0x1403
16381 $LCTL set_param fail_loc=0xa0001403
16382 $LCTL set_param fail_val=1
16383 touch $DIR/$tdir/$tfile || true
16385 run_test 206 "fail lov_init_raid0() doesn't lbug"
16388 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
16389 local fsz=`stat -c %s $DIR/$tfile`
16390 cancel_lru_locks mdc
16392 # do not return layout in getattr intent
16393 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
16394 $LCTL set_param fail_loc=0x170
16395 local sz=`stat -c %s $DIR/$tfile`
16397 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
16401 run_test 207a "can refresh layout at glimpse"
16404 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
16405 local cksum=`md5sum $DIR/$tfile`
16406 local fsz=`stat -c %s $DIR/$tfile`
16407 cancel_lru_locks mdc
16408 cancel_lru_locks osc
16410 # do not return layout in getattr intent
16411 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
16412 $LCTL set_param fail_loc=0x171
16414 # it will refresh layout after the file is opened but before read issues
16415 echo checksum is "$cksum"
16416 echo "$cksum" |md5sum -c --quiet || error "file differs"
16420 run_test 207b "can refresh layout at open"
16423 # FIXME: in this test suite, only RD lease is used. This is okay
16424 # for now as only exclusive open is supported. After generic lease
16425 # is done, this test suite should be revised. - Jinshan
16427 remote_mds_nodsh && skip "remote MDS with nodsh"
16428 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
16429 skip "Need MDS version at least 2.4.52"
16431 echo "==== test 1: verify get lease work"
16432 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
16434 echo "==== test 2: verify lease can be broken by upcoming open"
16435 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
16439 $MULTIOP $DIR/$tfile oO_RDONLY:c
16440 kill -USR1 $PID && wait $PID || error "break lease error"
16442 echo "==== test 3: verify lease can't be granted if an open already exists"
16443 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
16447 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
16448 kill -USR1 $PID && wait $PID || error "open file error"
16450 echo "==== test 4: lease can sustain over recovery"
16451 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
16457 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
16459 echo "==== test 5: lease broken can't be regained by replay"
16460 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
16464 # open file to break lease and then recovery
16465 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
16468 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
16472 run_test 208 "Exclusive open"
16475 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
16476 skip_env "must have disp_stripe"
16479 sync; sleep 5; sync;
16481 echo 3 > /proc/sys/vm/drop_caches
16482 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
16484 # open/close 500 times
16485 for i in $(seq 500); do
16489 echo 3 > /proc/sys/vm/drop_caches
16490 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
16492 echo "before: $req_before, after: $req_after"
16493 [ $((req_after - req_before)) -ge 300 ] &&
16494 error "open/close requests are not freed"
16497 run_test 209 "read-only open/close requests should be freed promptly"
16502 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
16506 $LFS getstripe $DIR/$tfile
16508 wait $pid || error "multiop failed"
16510 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
16514 $LFS getstripe $DIR/$tfile
16516 wait $pid || error "multiop failed"
16518 run_test 210 "lfs getstripe does not break leases"
16522 size=$((size % 8192 + 1))
16523 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
16524 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
16525 rm -f $DIR/f212 $DIR/f212.xyz
16527 run_test 212 "Sendfile test ============================================"
16530 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
16531 cancel_lru_locks osc
16532 lctl set_param fail_loc=0x8000040f
16533 # generate a read lock
16534 cat $DIR/$tfile > /dev/null
16535 # write to the file, it will try to cancel the above read lock.
16536 cat /etc/hosts >> $DIR/$tfile
16538 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
16540 test_214() { # for bug 20133
16541 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
16542 for (( i=0; i < 340; i++ )) ; do
16543 touch $DIR/$tdir/d214c/a$i
16546 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
16547 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
16548 ls $DIR/d214c || error "ls $DIR/d214c failed"
16549 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
16550 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
16552 run_test 214 "hash-indexed directory test - bug 20133"
16554 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
16555 create_lnet_proc_files() {
16556 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
16559 # counterpart of create_lnet_proc_files
16560 remove_lnet_proc_files() {
16561 rm -f $TMP/lnet_$1.sys
16564 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
16565 # 3rd arg as regexp for body
16566 check_lnet_proc_stats() {
16567 local l=$(cat "$TMP/lnet_$1" |wc -l)
16568 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
16570 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
16573 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
16574 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
16575 # optional and can be regexp for 2nd line (lnet.routes case)
16576 check_lnet_proc_entry() {
16577 local blp=2 # blp stands for 'position of 1st line of body'
16578 [ -z "$5" ] || blp=3 # lnet.routes case
16580 local l=$(cat "$TMP/lnet_$1" |wc -l)
16581 # subtracting one from $blp because the body can be empty
16582 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
16584 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
16585 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
16587 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
16588 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
16590 # bail out if any unexpected line happened
16591 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
16592 [ "$?" != 0 ] || error "$2 misformatted"
16595 test_215() { # for bugs 18102, 21079, 21517
16596 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16598 local N='(0|[1-9][0-9]*)' # non-negative numeric
16599 local P='[1-9][0-9]*' # positive numeric
16600 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
16601 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
16602 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
16603 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
16605 local L1 # regexp for 1st line
16606 local L2 # regexp for 2nd line (optional)
16607 local BR # regexp for the rest (body)
16609 # lnet.stats should look as 11 space-separated non-negative numerics
16610 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
16611 create_lnet_proc_files "stats"
16612 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
16613 remove_lnet_proc_files "stats"
16615 # lnet.routes should look like this:
16616 # Routing disabled/enabled
16617 # net hops priority state router
16618 # where net is a string like tcp0, hops > 0, priority >= 0,
16619 # state is up/down,
16620 # router is a string like 192.168.1.1@tcp2
16621 L1="^Routing (disabled|enabled)$"
16622 L2="^net +hops +priority +state +router$"
16623 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
16624 create_lnet_proc_files "routes"
16625 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
16626 remove_lnet_proc_files "routes"
16628 # lnet.routers should look like this:
16629 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
16630 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
16631 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
16632 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
16633 L1="^ref +rtr_ref +alive +router$"
16634 BR="^$P +$P +(up|down) +$NID$"
16635 create_lnet_proc_files "routers"
16636 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
16637 remove_lnet_proc_files "routers"
16639 # lnet.peers should look like this:
16640 # nid refs state last max rtr min tx min queue
16641 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
16642 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
16643 # numeric (0 or >0 or <0), queue >= 0.
16644 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
16645 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
16646 create_lnet_proc_files "peers"
16647 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
16648 remove_lnet_proc_files "peers"
16650 # lnet.buffers should look like this:
16651 # pages count credits min
16652 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
16653 L1="^pages +count +credits +min$"
16654 BR="^ +$N +$N +$I +$I$"
16655 create_lnet_proc_files "buffers"
16656 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
16657 remove_lnet_proc_files "buffers"
16659 # lnet.nis should look like this:
16660 # nid status alive refs peer rtr max tx min
16661 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
16662 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
16663 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
16664 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
16665 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
16666 create_lnet_proc_files "nis"
16667 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
16668 remove_lnet_proc_files "nis"
16670 # can we successfully write to lnet.stats?
16671 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
16673 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
16675 test_216() { # bug 20317
16676 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16677 remote_ost_nodsh && skip "remote OST with nodsh"
16680 local facets=$(get_facets OST)
16681 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16683 save_lustre_params client "osc.*.contention_seconds" > $p
16684 save_lustre_params $facets \
16685 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
16686 save_lustre_params $facets \
16687 "ldlm.namespaces.filter-*.contended_locks" >> $p
16688 save_lustre_params $facets \
16689 "ldlm.namespaces.filter-*.contention_seconds" >> $p
16690 clear_stats osc.*.osc_stats
16692 # agressive lockless i/o settings
16693 do_nodes $(comma_list $(osts_nodes)) \
16694 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
16695 ldlm.namespaces.filter-*.contended_locks=0 \
16696 ldlm.namespaces.filter-*.contention_seconds=60"
16697 lctl set_param -n osc.*.contention_seconds=60
16699 $DIRECTIO write $DIR/$tfile 0 10 4096
16700 $CHECKSTAT -s 40960 $DIR/$tfile
16702 # disable lockless i/o
16703 do_nodes $(comma_list $(osts_nodes)) \
16704 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
16705 ldlm.namespaces.filter-*.contended_locks=32 \
16706 ldlm.namespaces.filter-*.contention_seconds=0"
16707 lctl set_param -n osc.*.contention_seconds=0
16708 clear_stats osc.*.osc_stats
16710 dd if=/dev/zero of=$DIR/$tfile count=0
16711 $CHECKSTAT -s 0 $DIR/$tfile
16713 restore_lustre_params <$p
16717 run_test 216 "check lockless direct write updates file size and kms correctly"
16719 test_217() { # bug 22430
16720 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16725 for node in $(nodes_list); do
16726 nid=$(host_nids_address $node $NETTYPE)
16727 if [[ $nid = *-* ]] ; then
16728 echo "lctl ping $(h2nettype $nid)"
16729 lctl ping $(h2nettype $nid)
16731 echo "skipping $node (no hyphen detected)"
16735 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
16738 # do directio so as not to populate the page cache
16739 log "creating a 10 Mb file"
16740 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
16741 log "starting reads"
16742 dd if=$DIR/$tfile of=/dev/null bs=4096 &
16743 log "truncating the file"
16744 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
16746 kill %+ || true # reads might have finished
16747 echo "wait until dd is finished"
16749 log "removing the temporary file"
16750 rm -rf $DIR/$tfile || error "tmp file removal failed"
16752 run_test 218 "parallel read and truncate should not deadlock"
16755 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16757 # write one partial page
16758 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
16759 # set no grant so vvp_io_commit_write will do sync write
16760 $LCTL set_param fail_loc=0x411
16761 # write a full page at the end of file
16762 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
16764 $LCTL set_param fail_loc=0
16765 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
16766 $LCTL set_param fail_loc=0x411
16767 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
16770 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
16771 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
16773 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
16775 test_220() { #LU-325
16776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16777 remote_ost_nodsh && skip "remote OST with nodsh"
16778 remote_mds_nodsh && skip "remote MDS with nodsh"
16779 remote_mgs_nodsh && skip "remote MGS with nodsh"
16783 # create on MDT0000 so the last_id and next_id are correct
16785 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
16789 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
16790 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
16791 osp.$mdtosc_proc1.prealloc_last_id)
16792 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
16793 osp.$mdtosc_proc1.prealloc_next_id)
16797 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
16798 #define OBD_FAIL_OST_ENOINO 0x229
16799 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
16800 create_pool $FSNAME.$TESTNAME || return 1
16801 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
16803 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
16805 MDSOBJS=$((last_id - next_id))
16806 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
16808 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
16809 echo "OST still has $count kbytes free"
16811 echo "create $MDSOBJS files @next_id..."
16812 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
16814 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
16815 osp.$mdtosc_proc1.prealloc_last_id)
16816 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
16817 osp.$mdtosc_proc1.prealloc_next_id)
16819 echo "after creation, last_id=$last_id2, next_id=$next_id2"
16824 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
16825 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
16827 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
16828 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
16829 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
16830 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
16831 echo "unlink $MDSOBJS files @$next_id..."
16832 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
16834 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
16837 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16839 dd if=`which date` of=$MOUNT/date oflag=sync
16840 chmod +x $MOUNT/date
16842 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
16843 $LCTL set_param fail_loc=0x80001401
16845 $MOUNT/date > /dev/null
16848 run_test 221 "make sure fault and truncate race to not cause OOM"
16851 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16854 test_mkdir $DIR/$tdir
16855 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16856 createmany -o $DIR/$tdir/$tfile 10
16857 cancel_lru_locks mdc
16858 cancel_lru_locks osc
16859 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
16860 $LCTL set_param fail_loc=0x31a
16861 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
16862 $LCTL set_param fail_loc=0
16865 run_test 222a "AGL for ls should not trigger CLIO lock failure"
16868 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16871 test_mkdir $DIR/$tdir
16872 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16873 createmany -o $DIR/$tdir/$tfile 10
16874 cancel_lru_locks mdc
16875 cancel_lru_locks osc
16876 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
16877 $LCTL set_param fail_loc=0x31a
16878 rm -r $DIR/$tdir || error "AGL for rmdir failed"
16879 $LCTL set_param fail_loc=0
16881 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
16884 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16887 test_mkdir $DIR/$tdir
16888 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16889 createmany -o $DIR/$tdir/$tfile 10
16890 cancel_lru_locks mdc
16891 cancel_lru_locks osc
16892 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
16893 $LCTL set_param fail_loc=0x31b
16894 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
16895 $LCTL set_param fail_loc=0
16898 run_test 223 "osc reenqueue if without AGL lock granted ======================="
16900 test_224a() { # LU-1039, MRP-303
16901 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16903 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
16904 $LCTL set_param fail_loc=0x508
16905 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
16906 $LCTL set_param fail_loc=0
16909 run_test 224a "Don't panic on bulk IO failure"
16911 test_224b() { # LU-1039, MRP-303
16912 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16914 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
16915 cancel_lru_locks osc
16916 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
16917 $LCTL set_param fail_loc=0x515
16918 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
16919 $LCTL set_param fail_loc=0
16922 run_test 224b "Don't panic on bulk IO failure"
16924 test_224c() { # LU-6441
16925 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16926 remote_mds_nodsh && skip "remote MDS with nodsh"
16928 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16929 save_writethrough $p
16930 set_cache writethrough on
16932 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
16933 local at_max=$($LCTL get_param -n at_max)
16934 local timeout=$($LCTL get_param -n timeout)
16935 local test_at="at_max"
16936 local param_at="$FSNAME.sys.at_max"
16937 local test_timeout="timeout"
16938 local param_timeout="$FSNAME.sys.timeout"
16940 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
16942 set_persistent_param_and_check client "$test_at" "$param_at" 0
16943 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
16945 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
16946 do_facet ost1 "$LCTL set_param fail_loc=0x520"
16947 $LFS setstripe -c 1 -i 0 $DIR/$tfile
16948 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
16950 do_facet ost1 "$LCTL set_param fail_loc=0"
16952 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
16953 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
16956 $LCTL set_param -n $pages_per_rpc
16957 restore_lustre_params < $p
16960 run_test 224c "Don't hang if one of md lost during large bulk RPC"
16962 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
16964 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16965 if [ -z ${MDSSURVEY} ]; then
16966 skip_env "mds-survey not found"
16968 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16969 skip "Need MDS version at least 2.2.51"
16971 local mds=$(facet_host $SINGLEMDS)
16972 local target=$(do_nodes $mds 'lctl dl' |
16973 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
16975 local cmd1="file_count=1000 thrhi=4"
16976 local cmd2="dir_count=2 layer=mdd stripe_count=0"
16977 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16978 local cmd="$cmd1 $cmd2 $cmd3"
16980 rm -f ${TMP}/mds_survey*
16982 eval $cmd || error "mds-survey with zero-stripe failed"
16983 cat ${TMP}/mds_survey*
16984 rm -f ${TMP}/mds_survey*
16986 run_test 225a "Metadata survey sanity with zero-stripe"
16989 if [ -z ${MDSSURVEY} ]; then
16990 skip_env "mds-survey not found"
16992 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16993 skip "Need MDS version at least 2.2.51"
16994 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16995 remote_mds_nodsh && skip "remote MDS with nodsh"
16996 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
16997 skip_env "Need to mount OST to test"
17000 local mds=$(facet_host $SINGLEMDS)
17001 local target=$(do_nodes $mds 'lctl dl' |
17002 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
17004 local cmd1="file_count=1000 thrhi=4"
17005 local cmd2="dir_count=2 layer=mdd stripe_count=1"
17006 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
17007 local cmd="$cmd1 $cmd2 $cmd3"
17009 rm -f ${TMP}/mds_survey*
17011 eval $cmd || error "mds-survey with stripe_count failed"
17012 cat ${TMP}/mds_survey*
17013 rm -f ${TMP}/mds_survey*
17015 run_test 225b "Metadata survey sanity with stripe_count = 1"
17017 mcreate_path2fid () {
17023 local path=$DIR/$tdir/$name
17028 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
17029 error "cannot create $desc"
17031 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
17033 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
17035 fid_path=$($LFS fid2path $MOUNT $fid)
17037 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
17039 [ "$path" == "$fid_path" ] ||
17040 error "fid2path returned $fid_path, expected $path"
17042 echo "pass with $path and $fid"
17047 mkdir -p $DIR/$tdir
17049 mcreate_path2fid 0010666 0 0 fifo "FIFO"
17050 mcreate_path2fid 0020666 1 3 null "character special file (null)"
17051 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
17052 mcreate_path2fid 0040666 0 0 dir "directory"
17053 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
17054 mcreate_path2fid 0100666 0 0 file "regular file"
17055 mcreate_path2fid 0120666 0 0 link "symbolic link"
17056 mcreate_path2fid 0140666 0 0 sock "socket"
17058 run_test 226a "call path2fid and fid2path on files of all type"
17061 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17066 mkdir -p $DIR/$tdir
17067 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
17068 error "create remote directory failed"
17069 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
17070 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
17071 "character special file (null)"
17072 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
17073 "character special file (no device)"
17074 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
17075 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
17076 "block special file (loop)"
17077 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
17078 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
17079 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
17081 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
17083 # LU-1299 Executing or running ldd on a truncated executable does not
17084 # cause an out-of-memory condition.
17086 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17087 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
17089 dd if=$(which date) of=$MOUNT/date bs=1k count=1
17090 chmod +x $MOUNT/date
17092 $MOUNT/date > /dev/null
17093 ldd $MOUNT/date > /dev/null
17096 run_test 227 "running truncated executable does not cause OOM"
17098 # LU-1512 try to reuse idle OI blocks
17100 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17101 remote_mds_nodsh && skip "remote MDS with nodsh"
17102 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
17104 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
17105 local myDIR=$DIR/$tdir
17108 #define OBD_FAIL_SEQ_EXHAUST 0x1002
17109 $LCTL set_param fail_loc=0x80001002
17110 createmany -o $myDIR/t- 10000
17111 $LCTL set_param fail_loc=0
17112 # The guard is current the largest FID holder
17114 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
17116 local IDX=$(($SEQ % 64))
17118 do_facet $SINGLEMDS sync
17119 # Make sure journal flushed.
17121 local blk1=$(do_facet $SINGLEMDS \
17122 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17123 grep Blockcount | awk '{print $4}')
17125 # Remove old files, some OI blocks will become idle.
17126 unlinkmany $myDIR/t- 10000
17127 # Create new files, idle OI blocks should be reused.
17128 createmany -o $myDIR/t- 2000
17129 do_facet $SINGLEMDS sync
17130 # Make sure journal flushed.
17132 local blk2=$(do_facet $SINGLEMDS \
17133 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17134 grep Blockcount | awk '{print $4}')
17136 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
17138 run_test 228a "try to reuse idle OI blocks"
17141 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17142 remote_mds_nodsh && skip "remote MDS with nodsh"
17143 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
17145 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
17146 local myDIR=$DIR/$tdir
17149 #define OBD_FAIL_SEQ_EXHAUST 0x1002
17150 $LCTL set_param fail_loc=0x80001002
17151 createmany -o $myDIR/t- 10000
17152 $LCTL set_param fail_loc=0
17153 # The guard is current the largest FID holder
17155 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
17157 local IDX=$(($SEQ % 64))
17159 do_facet $SINGLEMDS sync
17160 # Make sure journal flushed.
17162 local blk1=$(do_facet $SINGLEMDS \
17163 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17164 grep Blockcount | awk '{print $4}')
17166 # Remove old files, some OI blocks will become idle.
17167 unlinkmany $myDIR/t- 10000
17170 stop $SINGLEMDS || error "Fail to stop MDT."
17172 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
17174 df $MOUNT || error "Fail to df."
17175 # Create new files, idle OI blocks should be reused.
17176 createmany -o $myDIR/t- 2000
17177 do_facet $SINGLEMDS sync
17178 # Make sure journal flushed.
17180 local blk2=$(do_facet $SINGLEMDS \
17181 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17182 grep Blockcount | awk '{print $4}')
17184 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
17186 run_test 228b "idle OI blocks can be reused after MDT restart"
17190 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17191 remote_mds_nodsh && skip "remote MDS with nodsh"
17192 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
17194 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
17195 local myDIR=$DIR/$tdir
17198 #define OBD_FAIL_SEQ_EXHAUST 0x1002
17199 $LCTL set_param fail_loc=0x80001002
17200 # 20000 files can guarantee there are index nodes in the OI file
17201 createmany -o $myDIR/t- 20000
17202 $LCTL set_param fail_loc=0
17203 # The guard is current the largest FID holder
17205 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
17207 local IDX=$(($SEQ % 64))
17209 do_facet $SINGLEMDS sync
17210 # Make sure journal flushed.
17212 local blk1=$(do_facet $SINGLEMDS \
17213 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17214 grep Blockcount | awk '{print $4}')
17216 # Remove old files, some OI blocks will become idle.
17217 unlinkmany $myDIR/t- 20000
17219 # The OI file should become empty now
17221 # Create new files, idle OI blocks should be reused.
17222 createmany -o $myDIR/t- 2000
17223 do_facet $SINGLEMDS sync
17224 # Make sure journal flushed.
17226 local blk2=$(do_facet $SINGLEMDS \
17227 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17228 grep Blockcount | awk '{print $4}')
17230 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
17232 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
17234 test_229() { # LU-2482, LU-3448
17235 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17236 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
17237 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
17238 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
17242 # Create a file with a released layout and stripe count 2.
17243 $MULTIOP $DIR/$tfile H2c ||
17244 error "failed to create file with released layout"
17246 $LFS getstripe -v $DIR/$tfile
17248 local pattern=$($LFS getstripe -L $DIR/$tfile)
17249 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
17251 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
17253 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
17254 stat $DIR/$tfile || error "failed to stat released file"
17256 chown $RUNAS_ID $DIR/$tfile ||
17257 error "chown $RUNAS_ID $DIR/$tfile failed"
17259 chgrp $RUNAS_ID $DIR/$tfile ||
17260 error "chgrp $RUNAS_ID $DIR/$tfile failed"
17262 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
17263 rm $DIR/$tfile || error "failed to remove released file"
17265 run_test 229 "getstripe/stat/rm/attr changes work on released files"
17268 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17269 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17270 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17271 skip "Need MDS version at least 2.11.52"
17275 test_mkdir $DIR/$tdir
17276 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
17277 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
17278 [ $mdt_idx -ne 0 ] &&
17279 error "create local directory on wrong MDT $mdt_idx"
17281 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
17282 error "create remote directory failed"
17283 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
17284 [ $mdt_idx -ne $MDTIDX ] &&
17285 error "create remote directory on wrong MDT $mdt_idx"
17287 createmany -o $DIR/$tdir/test_230/t- 10 ||
17288 error "create files on remote directory failed"
17289 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
17290 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
17291 rm -r $DIR/$tdir || error "unlink remote directory failed"
17293 run_test 230a "Create remote directory and files under the remote directory"
17296 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17297 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17298 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17299 skip "Need MDS version at least 2.11.52"
17307 local migrate_dir=$DIR/$tdir/migrate_dir
17308 local other_dir=$DIR/$tdir/other_dir
17310 test_mkdir $DIR/$tdir
17311 test_mkdir -i0 -c1 $migrate_dir
17312 test_mkdir -i0 -c1 $other_dir
17313 for ((i=0; i<10; i++)); do
17314 mkdir -p $migrate_dir/dir_${i}
17315 createmany -o $migrate_dir/dir_${i}/f 10 ||
17316 error "create files under remote dir failed $i"
17319 cp /etc/passwd $migrate_dir/$tfile
17320 cp /etc/passwd $other_dir/$tfile
17321 chattr +SAD $migrate_dir
17322 chattr +SAD $migrate_dir/$tfile
17324 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
17325 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
17326 local old_dir_mode=$(stat -c%f $migrate_dir)
17327 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
17329 mkdir -p $migrate_dir/dir_default_stripe2
17330 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
17331 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
17333 mkdir -p $other_dir
17334 ln $migrate_dir/$tfile $other_dir/luna
17335 ln $migrate_dir/$tfile $migrate_dir/sofia
17336 ln $other_dir/$tfile $migrate_dir/david
17337 ln -s $migrate_dir/$tfile $other_dir/zachary
17338 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
17339 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
17345 for len in 58 59 60; do
17346 lnktgt=$(str_repeat 'l' $len)
17347 touch $migrate_dir/$lnktgt
17348 ln -s $lnktgt $migrate_dir/${len}char_ln
17352 for len in 4094 4095; do
17353 lnktgt=$(str_repeat 'l' $len)
17354 ln -s $lnktgt $migrate_dir/${len}char_ln
17358 for len in 254 255; do
17359 touch $migrate_dir/$(str_repeat 'l' $len)
17362 $LFS migrate -m $MDTIDX $migrate_dir ||
17363 error "fails on migrating remote dir to MDT1"
17365 echo "migratate to MDT1, then checking.."
17366 for ((i = 0; i < 10; i++)); do
17367 for file in $(find $migrate_dir/dir_${i}); do
17368 mdt_index=$($LFS getstripe -m $file)
17369 # broken symlink getstripe will fail
17370 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
17371 error "$file is not on MDT${MDTIDX}"
17375 # the multiple link file should still in MDT0
17376 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
17377 [ $mdt_index == 0 ] ||
17378 error "$file is not on MDT${MDTIDX}"
17380 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
17381 [ "$old_dir_flag" = "$new_dir_flag" ] ||
17382 error " expect $old_dir_flag get $new_dir_flag"
17384 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
17385 [ "$old_file_flag" = "$new_file_flag" ] ||
17386 error " expect $old_file_flag get $new_file_flag"
17388 local new_dir_mode=$(stat -c%f $migrate_dir)
17389 [ "$old_dir_mode" = "$new_dir_mode" ] ||
17390 error "expect mode $old_dir_mode get $new_dir_mode"
17392 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
17393 [ "$old_file_mode" = "$new_file_mode" ] ||
17394 error "expect mode $old_file_mode get $new_file_mode"
17396 diff /etc/passwd $migrate_dir/$tfile ||
17397 error "$tfile different after migration"
17399 diff /etc/passwd $other_dir/luna ||
17400 error "luna different after migration"
17402 diff /etc/passwd $migrate_dir/sofia ||
17403 error "sofia different after migration"
17405 diff /etc/passwd $migrate_dir/david ||
17406 error "david different after migration"
17408 diff /etc/passwd $other_dir/zachary ||
17409 error "zachary different after migration"
17411 diff /etc/passwd $migrate_dir/${tfile}_ln ||
17412 error "${tfile}_ln different after migration"
17414 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
17415 error "${tfile}_ln_other different after migration"
17417 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
17418 [ $stripe_count = 2 ] ||
17419 error "dir strpe_count $d != 2 after migration."
17421 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
17422 [ $stripe_count = 2 ] ||
17423 error "file strpe_count $d != 2 after migration."
17425 #migrate back to MDT0
17428 $LFS migrate -m $MDTIDX $migrate_dir ||
17429 error "fails on migrating remote dir to MDT0"
17431 echo "migrate back to MDT0, checking.."
17432 for file in $(find $migrate_dir); do
17433 mdt_index=$($LFS getstripe -m $file)
17434 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
17435 error "$file is not on MDT${MDTIDX}"
17438 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
17439 [ "$old_dir_flag" = "$new_dir_flag" ] ||
17440 error " expect $old_dir_flag get $new_dir_flag"
17442 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
17443 [ "$old_file_flag" = "$new_file_flag" ] ||
17444 error " expect $old_file_flag get $new_file_flag"
17446 local new_dir_mode=$(stat -c%f $migrate_dir)
17447 [ "$old_dir_mode" = "$new_dir_mode" ] ||
17448 error "expect mode $old_dir_mode get $new_dir_mode"
17450 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
17451 [ "$old_file_mode" = "$new_file_mode" ] ||
17452 error "expect mode $old_file_mode get $new_file_mode"
17454 diff /etc/passwd ${migrate_dir}/$tfile ||
17455 error "$tfile different after migration"
17457 diff /etc/passwd ${other_dir}/luna ||
17458 error "luna different after migration"
17460 diff /etc/passwd ${migrate_dir}/sofia ||
17461 error "sofia different after migration"
17463 diff /etc/passwd ${other_dir}/zachary ||
17464 error "zachary different after migration"
17466 diff /etc/passwd $migrate_dir/${tfile}_ln ||
17467 error "${tfile}_ln different after migration"
17469 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
17470 error "${tfile}_ln_other different after migration"
17472 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
17473 [ $stripe_count = 2 ] ||
17474 error "dir strpe_count $d != 2 after migration."
17476 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
17477 [ $stripe_count = 2 ] ||
17478 error "file strpe_count $d != 2 after migration."
17480 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17482 run_test 230b "migrate directory"
17485 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17486 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17487 remote_mds_nodsh && skip "remote MDS with nodsh"
17488 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17489 skip "Need MDS version at least 2.11.52"
17495 local migrate_dir=$DIR/$tdir/migrate_dir
17497 #If migrating directory fails in the middle, all entries of
17498 #the directory is still accessiable.
17499 test_mkdir $DIR/$tdir
17500 test_mkdir -i0 -c1 $migrate_dir
17501 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
17503 createmany -o $migrate_dir/f $total ||
17504 error "create files under ${migrate_dir} failed"
17506 # fail after migrating top dir, and this will fail only once, so the
17507 # first sub file migration will fail (currently f3), others succeed.
17508 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
17509 do_facet mds1 lctl set_param fail_loc=0x1801
17510 local t=$(ls $migrate_dir | wc -l)
17511 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
17512 error "migrate should fail"
17513 local u=$(ls $migrate_dir | wc -l)
17514 [ "$u" == "$t" ] || error "$u != $t during migration"
17516 # add new dir/file should succeed
17517 mkdir $migrate_dir/dir ||
17518 error "mkdir failed under migrating directory"
17519 touch $migrate_dir/file ||
17520 error "create file failed under migrating directory"
17522 # add file with existing name should fail
17523 for file in $migrate_dir/f*; do
17524 stat $file > /dev/null || error "stat $file failed"
17525 $OPENFILE -f O_CREAT:O_EXCL $file &&
17526 error "open(O_CREAT|O_EXCL) $file should fail"
17527 $MULTIOP $file m && error "create $file should fail"
17528 touch $DIR/$tdir/remote_dir/$tfile ||
17529 error "touch $tfile failed"
17530 ln $DIR/$tdir/remote_dir/$tfile $file &&
17531 error "link $file should fail"
17532 mdt_index=$($LFS getstripe -m $file)
17533 if [ $mdt_index == 0 ]; then
17534 # file failed to migrate is not allowed to rename to
17535 mv $DIR/$tdir/remote_dir/$tfile $file &&
17536 error "rename to $file should fail"
17538 mv $DIR/$tdir/remote_dir/$tfile $file ||
17539 error "rename to $file failed"
17541 echo hello >> $file || error "write $file failed"
17544 # resume migration with different options should fail
17545 $LFS migrate -m 0 $migrate_dir &&
17546 error "migrate -m 0 $migrate_dir should fail"
17548 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
17549 error "migrate -c 2 $migrate_dir should fail"
17551 # resume migration should succeed
17552 $LFS migrate -m $MDTIDX $migrate_dir ||
17553 error "migrate $migrate_dir failed"
17555 echo "Finish migration, then checking.."
17556 for file in $(find $migrate_dir); do
17557 mdt_index=$($LFS getstripe -m $file)
17558 [ $mdt_index == $MDTIDX ] ||
17559 error "$file is not on MDT${MDTIDX}"
17562 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17564 run_test 230c "check directory accessiblity if migration failed"
17567 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17568 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17569 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17570 skip "Need MDS version at least 2.11.52"
17572 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
17574 local migrate_dir=$DIR/$tdir/migrate_dir
17584 old_index=$((RANDOM % MDSCOUNT))
17585 old_count=$((MDSCOUNT - old_index))
17586 new_index=$((RANDOM % MDSCOUNT))
17587 new_count=$((MDSCOUNT - new_index))
17588 new_hash=1 # for all_char
17590 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
17591 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
17593 test_mkdir $DIR/$tdir
17594 test_mkdir -i $old_index -c $old_count $migrate_dir
17596 for ((i=0; i<100; i++)); do
17597 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
17598 createmany -o $migrate_dir/dir_${i}/f 100 ||
17599 error "create files under remote dir failed $i"
17602 echo -n "Migrate from MDT$old_index "
17603 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
17604 echo -n "to MDT$new_index"
17605 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
17608 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
17609 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
17610 error "migrate remote dir error"
17612 echo "Finish migration, then checking.."
17613 for file in $(find $migrate_dir); do
17614 mdt_index=$($LFS getstripe -m $file)
17615 if [ $mdt_index -lt $new_index ] ||
17616 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
17617 error "$file is on MDT$mdt_index"
17621 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17623 run_test 230d "check migrate big directory"
17626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17627 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17628 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17629 skip "Need MDS version at least 2.11.52"
17636 mkdir -p $DIR/$tdir
17637 mkdir $DIR/$tdir/migrate_dir
17638 mkdir $DIR/$tdir/other_dir
17639 touch $DIR/$tdir/migrate_dir/a
17640 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
17641 ls $DIR/$tdir/other_dir
17643 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17644 error "migrate dir fails"
17646 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
17647 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
17649 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17650 [ $mdt_index == 0 ] || error "a is not on MDT0"
17652 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
17653 error "migrate dir fails"
17655 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
17656 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
17658 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17659 [ $mdt_index == 1 ] || error "a is not on MDT1"
17661 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
17662 [ $mdt_index == 1 ] || error "b is not on MDT1"
17664 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
17665 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
17667 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
17669 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17671 run_test 230e "migrate mulitple local link files"
17674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17675 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17676 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17677 skip "Need MDS version at least 2.11.52"
17682 mkdir -p $DIR/$tdir
17683 mkdir $DIR/$tdir/migrate_dir
17684 $LFS mkdir -i1 $DIR/$tdir/other_dir
17685 touch $DIR/$tdir/migrate_dir/a
17686 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
17687 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
17688 ls $DIR/$tdir/other_dir
17690 # a should be migrated to MDT1, since no other links on MDT0
17691 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17692 error "#1 migrate dir fails"
17693 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
17694 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
17695 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17696 [ $mdt_index == 1 ] || error "a is not on MDT1"
17698 # a should stay on MDT1, because it is a mulitple link file
17699 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
17700 error "#2 migrate dir fails"
17701 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17702 [ $mdt_index == 1 ] || error "a is not on MDT1"
17704 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17705 error "#3 migrate dir fails"
17707 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
17708 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
17709 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
17711 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
17712 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
17714 # a should be migrated to MDT0, since no other links on MDT1
17715 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
17716 error "#4 migrate dir fails"
17717 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17718 [ $mdt_index == 0 ] || error "a is not on MDT0"
17720 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17722 run_test 230f "migrate mulitple remote link files"
17725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17726 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17727 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17728 skip "Need MDS version at least 2.11.52"
17730 mkdir -p $DIR/$tdir/migrate_dir
17732 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
17733 error "migrating dir to non-exist MDT succeeds"
17736 run_test 230g "migrate dir to non-exist MDT"
17739 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17740 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17741 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17742 skip "Need MDS version at least 2.11.52"
17746 mkdir -p $DIR/$tdir/migrate_dir
17748 $LFS migrate -m1 $DIR &&
17749 error "migrating mountpoint1 should fail"
17751 $LFS migrate -m1 $DIR/$tdir/.. &&
17752 error "migrating mountpoint2 should fail"
17755 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
17756 error "migrating $tdir/migrate_dir/.. should fail"
17760 run_test 230h "migrate .. and root"
17763 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17764 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17765 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17766 skip "Need MDS version at least 2.11.52"
17768 mkdir -p $DIR/$tdir/migrate_dir
17770 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
17771 error "migration fails with a tailing slash"
17773 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
17774 error "migration fails with two tailing slashes"
17776 run_test 230i "lfs migrate -m tolerates trailing slashes"
17779 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17780 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
17781 skip "Need MDS version at least 2.11.52"
17783 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
17784 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
17785 error "create $tfile failed"
17786 cat /etc/passwd > $DIR/$tdir/$tfile
17788 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
17790 cmp /etc/passwd $DIR/$tdir/$tfile ||
17791 error "DoM file mismatch after migration"
17793 run_test 230j "DoM file data not changed after dir migration"
17796 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
17797 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17798 skip "Need MDS version at least 2.11.56"
17801 local files_on_starting_mdt=0
17803 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
17804 $LFS getdirstripe $DIR/$tdir
17805 for i in $(seq $total); do
17806 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
17807 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
17808 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17811 echo "$files_on_starting_mdt files on MDT0"
17813 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
17814 $LFS getdirstripe $DIR/$tdir
17816 files_on_starting_mdt=0
17817 for i in $(seq $total); do
17818 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
17819 error "file $tfile.$i mismatch after migration"
17820 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
17821 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17824 echo "$files_on_starting_mdt files on MDT1 after migration"
17825 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
17827 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
17828 $LFS getdirstripe $DIR/$tdir
17830 files_on_starting_mdt=0
17831 for i in $(seq $total); do
17832 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
17833 error "file $tfile.$i mismatch after 2nd migration"
17834 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
17835 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17838 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
17839 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
17843 run_test 230k "file data not changed after dir migration"
17846 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17847 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17848 skip "Need MDS version at least 2.11.56"
17850 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
17851 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
17852 error "create files under remote dir failed $i"
17853 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
17855 run_test 230l "readdir between MDTs won't crash"
17858 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17859 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17860 skip "Need MDS version at least 2.11.56"
17863 local mig_dir=$DIR/$tdir/migrate_dir
17864 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
17868 echo "Creating files and dirs with xattrs"
17869 test_mkdir $DIR/$tdir
17870 test_mkdir -i0 -c1 $mig_dir
17872 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
17873 error "cannot set xattr attr1 on dir"
17874 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
17875 error "cannot set xattr attr2 on dir"
17876 touch $mig_dir/dir/f0
17877 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
17878 error "cannot set xattr attr1 on file"
17879 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
17880 error "cannot set xattr attr2 on file"
17881 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
17882 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
17883 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
17884 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
17885 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
17886 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
17887 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
17888 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
17889 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
17891 echo "Migrating to MDT1"
17892 $LFS migrate -m $MDTIDX $mig_dir ||
17893 error "fails on migrating dir to MDT1"
17895 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
17896 echo "Checking xattrs"
17897 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
17898 [ "$val" = $longstr ] ||
17899 error "expecting xattr1 $longstr on dir, found $val"
17900 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
17901 [ "$val" = $shortstr ] ||
17902 error "expecting xattr2 $shortstr on dir, found $val"
17903 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
17904 [ "$val" = $longstr ] ||
17905 error "expecting xattr1 $longstr on file, found $val"
17906 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
17907 [ "$val" = $shortstr ] ||
17908 error "expecting xattr2 $shortstr on file, found $val"
17910 run_test 230m "xattrs not changed after dir migration"
17913 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17914 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
17915 skip "Need MDS version at least 2.13.53"
17917 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
17918 cat /etc/hosts > $DIR/$tdir/$tfile
17919 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
17920 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
17922 cmp /etc/hosts $DIR/$tdir/$tfile ||
17923 error "File data mismatch after migration"
17925 run_test 230n "Dir migration with mirrored file"
17928 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
17929 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
17930 skip "Need MDS version at least 2.13.52"
17932 local mdts=$(comma_list $(mdts_nodes))
17934 local restripe_status
17939 # in case "crush" hash type is not set
17940 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
17942 restripe_status=$(do_facet mds1 $LCTL get_param -n \
17943 mdt.*MDT0000.enable_dir_restripe)
17944 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
17945 stack_trap "do_nodes $mdts $LCTL set_param \
17946 mdt.*.enable_dir_restripe=$restripe_status"
17949 createmany -m $DIR/$tdir/f 100 ||
17950 error "create files under remote dir failed $i"
17951 createmany -d $DIR/$tdir/d 100 ||
17952 error "create dirs under remote dir failed $i"
17954 for i in $(seq 2 $MDSCOUNT); do
17955 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
17956 $LFS setdirstripe -c $i $DIR/$tdir ||
17957 error "split -c $i $tdir failed"
17958 wait_update $HOSTNAME \
17959 "$LFS getdirstripe -H $DIR/$tdir" "crush" 100 ||
17960 error "dir split not finished"
17961 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
17962 awk '/migrate/ {sum += $2} END { print sum }')
17963 echo "$delta files migrated when dir split from $((i - 1)) to $i stripes"
17964 # delta is around total_files/stripe_count
17965 [ $delta -lt $((200 /(i - 1))) ] ||
17966 error "$delta files migrated"
17969 run_test 230o "dir split"
17972 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
17973 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
17974 skip "Need MDS version at least 2.13.52"
17976 local mdts=$(comma_list $(mdts_nodes))
17978 local restripe_status
17983 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
17985 restripe_status=$(do_facet mds1 $LCTL get_param -n \
17986 mdt.*MDT0000.enable_dir_restripe)
17987 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
17988 stack_trap "do_nodes $mdts $LCTL set_param \
17989 mdt.*.enable_dir_restripe=$restripe_status"
17991 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
17992 createmany -m $DIR/$tdir/f 100 ||
17993 error "create files under remote dir failed $i"
17994 createmany -d $DIR/$tdir/d 100 ||
17995 error "create dirs under remote dir failed $i"
17997 for i in $(seq $((MDSCOUNT - 1)) -1 1); do
17998 local mdt_hash="crush"
18000 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
18001 $LFS setdirstripe -c $i $DIR/$tdir ||
18002 error "split -c $i $tdir failed"
18003 [ $i -eq 1 ] && mdt_hash="none"
18004 wait_update $HOSTNAME \
18005 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash 100 ||
18006 error "dir merge not finished"
18007 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
18008 awk '/migrate/ {sum += $2} END { print sum }')
18009 echo "$delta files migrated when dir merge from $((i + 1)) to $i stripes"
18010 # delta is around total_files/stripe_count
18011 [ $delta -lt $((200 / i)) ] ||
18012 error "$delta files migrated"
18015 run_test 230p "dir merge"
18018 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
18019 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
18020 skip "Need MDS version at least 2.13.52"
18022 local mdts=$(comma_list $(mdts_nodes))
18023 local saved_threshold=$(do_facet mds1 \
18024 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
18025 local saved_delta=$(do_facet mds1 \
18026 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
18027 local threshold=100
18030 local stripe_count=0
18034 stack_trap "do_nodes $mdts $LCTL set_param \
18035 mdt.*.dir_split_count=$saved_threshold"
18036 stack_trap "do_nodes $mdts $LCTL set_param \
18037 mdt.*.dir_split_delta=$saved_delta"
18038 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
18039 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
18040 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
18041 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
18042 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
18043 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
18045 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
18046 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
18048 while [ $stripe_count -lt $MDSCOUNT ]; do
18049 createmany -m $DIR/$tdir/f $total $((threshold * 3 / 2)) ||
18050 error "create sub files failed"
18051 stat $DIR/$tdir > /dev/null
18052 total=$((total + threshold * 3 / 2))
18053 stripe_count=$((stripe_count + delta))
18054 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
18056 wait_update $HOSTNAME \
18057 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
18058 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
18060 wait_update $HOSTNAME \
18061 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
18062 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
18064 nr_files=$($LFS getstripe -m $DIR/$tdir/* |
18065 grep -w $stripe_index | wc -l)
18066 echo "$nr_files files on MDT$stripe_index after split"
18067 [ $nr_files -lt $((total / (stripe_count - 1))) ] ||
18068 error "$nr_files files on MDT$stripe_index after split"
18070 nr_files=$(ls $DIR/$tdir | wc -w)
18071 [ $nr_files -eq $total ] ||
18072 error "total sub files $nr_files != $total"
18075 run_test 230q "dir auto split"
18079 # For simplicity this test assumes that max_pages_per_rpc
18080 # is the same across all OSCs
18081 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
18082 local bulk_size=$((max_pages * PAGE_SIZE))
18083 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
18086 mkdir -p $DIR/$tdir
18087 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
18088 error "failed to set stripe with -S ${brw_size}M option"
18090 # clear the OSC stats
18091 $LCTL set_param osc.*.stats=0 &>/dev/null
18094 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
18095 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
18096 oflag=direct &>/dev/null || error "dd failed"
18098 sync; sleep 1; sync # just to be safe
18099 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
18100 if [ x$nrpcs != "x1" ]; then
18101 $LCTL get_param osc.*.stats
18102 error "found $nrpcs ost_write RPCs, not 1 as expected"
18106 # Drop the OSC cache, otherwise we will read from it
18107 cancel_lru_locks osc
18109 # clear the OSC stats
18110 $LCTL set_param osc.*.stats=0 &>/dev/null
18112 # Client reads $bulk_size.
18113 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
18114 iflag=direct &>/dev/null || error "dd failed"
18116 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
18117 if [ x$nrpcs != "x1" ]; then
18118 $LCTL get_param osc.*.stats
18119 error "found $nrpcs ost_read RPCs, not 1 as expected"
18122 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
18125 mkdir -p $DIR/$tdir
18127 for i in {0..1023}; do
18128 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
18129 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
18130 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
18134 run_test 231b "must not assert on fully utilized OST request buffer"
18137 mkdir -p $DIR/$tdir
18138 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
18140 #define OBD_FAIL_LDLM_OST_LVB 0x31c
18141 do_facet ost1 $LCTL set_param fail_loc=0x31c
18143 # ignore dd failure
18144 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
18146 do_facet ost1 $LCTL set_param fail_loc=0
18147 umount_client $MOUNT || error "umount failed"
18148 mount_client $MOUNT || error "mount failed"
18149 stop ost1 || error "cannot stop ost1"
18150 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18152 run_test 232a "failed lock should not block umount"
18155 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
18156 skip "Need MDS version at least 2.10.58"
18158 mkdir -p $DIR/$tdir
18159 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
18160 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
18162 cancel_lru_locks osc
18164 #define OBD_FAIL_LDLM_OST_LVB 0x31c
18165 do_facet ost1 $LCTL set_param fail_loc=0x31c
18168 $LFS data_version $DIR/$tdir/$tfile || true
18170 do_facet ost1 $LCTL set_param fail_loc=0
18171 umount_client $MOUNT || error "umount failed"
18172 mount_client $MOUNT || error "mount failed"
18173 stop ost1 || error "cannot stop ost1"
18174 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18176 run_test 232b "failed data version lock should not block umount"
18179 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
18180 skip "Need MDS version at least 2.3.64"
18181 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
18183 local fid=$($LFS path2fid $MOUNT)
18185 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
18186 error "cannot access $MOUNT using its FID '$fid'"
18188 run_test 233a "checking that OBF of the FS root succeeds"
18191 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
18192 skip "Need MDS version at least 2.5.90"
18193 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
18195 local fid=$($LFS path2fid $MOUNT/.lustre)
18197 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
18198 error "cannot access $MOUNT/.lustre using its FID '$fid'"
18200 fid=$($LFS path2fid $MOUNT/.lustre/fid)
18201 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
18202 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
18204 run_test 233b "checking that OBF of the FS .lustre succeeds"
18207 local p="$TMP/sanityN-$TESTNAME.parameters"
18208 save_lustre_params client "llite.*.xattr_cache" > $p
18209 lctl set_param llite.*.xattr_cache 1 ||
18210 skip_env "xattr cache is not supported"
18212 mkdir -p $DIR/$tdir || error "mkdir failed"
18213 touch $DIR/$tdir/$tfile || error "touch failed"
18214 # OBD_FAIL_LLITE_XATTR_ENOMEM
18215 $LCTL set_param fail_loc=0x1405
18216 getfattr -n user.attr $DIR/$tdir/$tfile &&
18217 error "getfattr should have failed with ENOMEM"
18218 $LCTL set_param fail_loc=0x0
18221 restore_lustre_params < $p
18224 run_test 234 "xattr cache should not crash on ENOMEM"
18227 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
18228 skip "Need MDS version at least 2.4.52"
18230 flock_deadlock $DIR/$tfile
18235 124) error "process hangs on a deadlock"
18237 *) error "error executing flock_deadlock $DIR/$tfile"
18241 run_test 235 "LU-1715: flock deadlock detection does not work properly"
18245 check_swap_layouts_support
18247 local ref1=/etc/passwd
18248 local ref2=/etc/group
18249 local file1=$DIR/$tdir/f1
18250 local file2=$DIR/$tdir/f2
18252 test_mkdir -c1 $DIR/$tdir
18253 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
18254 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
18255 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
18256 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
18257 local fd=$(free_fd)
18258 local cmd="exec $fd<>$file2"
18261 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
18262 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
18265 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
18270 run_test 236 "Layout swap on open unlinked file"
18272 # LU-4659 linkea consistency
18274 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
18275 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
18276 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
18277 skip "Need MDS version at least 2.5.58 or 2.5.2+"
18280 ln $DIR/$tfile $DIR/$tfile.lnk
18281 touch $DIR/$tfile.new
18282 mv $DIR/$tfile.new $DIR/$tfile
18283 local fid1=$($LFS path2fid $DIR/$tfile)
18284 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
18285 local path1=$($LFS fid2path $FSNAME "$fid1")
18286 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
18287 local path2=$($LFS fid2path $FSNAME "$fid2")
18288 [ $tfile.lnk == $path2 ] ||
18289 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
18292 run_test 238 "Verify linkea consistency"
18294 test_239A() { # was test_239
18295 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
18296 skip "Need MDS version at least 2.5.60"
18298 local list=$(comma_list $(mdts_nodes))
18300 mkdir -p $DIR/$tdir
18301 createmany -o $DIR/$tdir/f- 5000
18302 unlinkmany $DIR/$tdir/f- 5000
18303 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
18304 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
18305 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
18306 osp.*MDT*.sync_in_flight" | calc_sum)
18307 [ "$changes" -eq 0 ] || error "$changes not synced"
18309 run_test 239A "osp_sync test"
18311 test_239a() { #LU-5297
18312 remote_mds_nodsh && skip "remote MDS with nodsh"
18315 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
18316 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
18317 chgrp $RUNAS_GID $DIR/$tfile
18318 wait_delete_completed
18320 run_test 239a "process invalid osp sync record correctly"
18322 test_239b() { #LU-5297
18323 remote_mds_nodsh && skip "remote MDS with nodsh"
18326 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
18327 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
18328 chgrp $RUNAS_GID $DIR/$tfile1
18329 wait_delete_completed
18330 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18332 chgrp $RUNAS_GID $DIR/$tfile2
18333 wait_delete_completed
18335 run_test 239b "process osp sync record with ENOMEM error correctly"
18338 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18339 remote_mds_nodsh && skip "remote MDS with nodsh"
18341 mkdir -p $DIR/$tdir
18343 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
18344 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
18345 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
18346 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
18348 umount_client $MOUNT || error "umount failed"
18349 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
18350 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
18351 mount_client $MOUNT || error "failed to mount client"
18353 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
18354 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
18356 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
18362 for LOOP in $(seq $count); do
18363 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
18364 cancel_lru_locks $OSC || true
18372 for LOOP in $(seq $1); do
18373 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
18378 test_241a() { # was test_241
18379 local bsize=$PAGE_SIZE
18381 (( bsize < 40960 )) && bsize=40960
18382 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
18384 cancel_lru_locks $OSC
18385 test_241_bio 1000 $bsize &
18387 test_241_dio 1000 $bsize
18390 run_test 241a "bio vs dio"
18393 local bsize=$PAGE_SIZE
18395 (( bsize < 40960 )) && bsize=40960
18396 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
18398 test_241_dio 1000 $bsize &
18400 test_241_dio 1000 $bsize
18403 run_test 241b "dio vs dio"
18406 remote_mds_nodsh && skip "remote MDS with nodsh"
18408 mkdir -p $DIR/$tdir
18409 touch $DIR/$tdir/$tfile
18411 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
18412 do_facet mds1 lctl set_param fail_loc=0x105
18413 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
18415 do_facet mds1 lctl set_param fail_loc=0
18416 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
18418 run_test 242 "mdt_readpage failure should not cause directory unreadable"
18422 test_mkdir $DIR/$tdir
18423 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
18425 run_test 243 "various group lock tests"
18429 test_mkdir $DIR/$tdir
18430 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
18431 sendfile_grouplock $DIR/$tdir/$tfile || \
18432 error "sendfile+grouplock failed"
18435 run_test 244a "sendfile with group lock tests"
18439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18442 local size=$((1024*1024))
18444 test_mkdir $DIR/$tdir
18445 for i in $(seq 1 $threads); do
18446 local file=$DIR/$tdir/file_$((i / 10))
18447 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
18450 for i in $(seq 1 $threads); do
18454 run_test 244b "multi-threaded write with group lock"
18457 local flagname="multi_mod_rpcs"
18458 local connect_data_name="max_mod_rpcs"
18461 # check if multiple modify RPCs flag is set
18462 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
18463 grep "connect_flags:")
18466 echo "$out" | grep -qw $flagname
18467 if [ $? -ne 0 ]; then
18468 echo "connect flag $flagname is not set"
18472 # check if multiple modify RPCs data is set
18473 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
18476 echo "$out" | grep -qw $connect_data_name ||
18477 error "import should have connect data $connect_data_name"
18479 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
18485 umount_client $submount
18490 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
18492 skip_env "Fileset feature is not supported"
18494 local submount=${MOUNT}_$tdir
18497 mkdir -p $submount || error "mkdir $submount failed"
18498 FILESET="$FILESET/$tdir" mount_client $submount ||
18499 error "mount $submount failed"
18500 trap "cleanup_247 $submount" EXIT
18501 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
18502 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
18503 error "read $MOUNT/$tdir/$tfile failed"
18504 cleanup_247 $submount
18506 run_test 247a "mount subdir as fileset"
18509 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
18510 skip_env "Fileset feature is not supported"
18512 local submount=${MOUNT}_$tdir
18514 rm -rf $MOUNT/$tdir
18515 mkdir -p $submount || error "mkdir $submount failed"
18517 FILESET="$FILESET/$tdir" mount_client $submount &&
18518 error "mount $submount should fail"
18521 run_test 247b "mount subdir that dose not exist"
18524 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
18525 skip_env "Fileset feature is not supported"
18527 local submount=${MOUNT}_$tdir
18529 mkdir -p $MOUNT/$tdir/dir1
18530 mkdir -p $submount || error "mkdir $submount failed"
18531 trap "cleanup_247 $submount" EXIT
18532 FILESET="$FILESET/$tdir" mount_client $submount ||
18533 error "mount $submount failed"
18534 local fid=$($LFS path2fid $MOUNT/)
18535 $LFS fid2path $submount $fid && error "fid2path should fail"
18536 cleanup_247 $submount
18538 run_test 247c "running fid2path outside root"
18541 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
18542 skip "Fileset feature is not supported"
18544 local submount=${MOUNT}_$tdir
18546 mkdir -p $MOUNT/$tdir/dir1
18547 mkdir -p $submount || error "mkdir $submount failed"
18548 FILESET="$FILESET/$tdir" mount_client $submount ||
18549 error "mount $submount failed"
18550 trap "cleanup_247 $submount" EXIT
18551 local fid=$($LFS path2fid $submount/dir1)
18552 $LFS fid2path $submount $fid || error "fid2path should succeed"
18553 cleanup_247 $submount
18555 run_test 247d "running fid2path inside root"
18559 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
18561 skip "Fileset feature is not supported"
18563 local submount=${MOUNT}_$tdir
18566 mkdir -p $submount || error "mkdir $submount failed"
18567 FILESET="$FILESET/.." mount_client $submount &&
18568 error "mount $submount should fail"
18571 run_test 247e "mount .. as fileset"
18574 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18575 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
18576 skip "Need at least version 2.13.52"
18577 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
18579 skip "Fileset feature is not supported"
18581 mkdir $DIR/$tdir || error "mkdir $tdir failed"
18582 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
18583 error "mkdir remote failed"
18584 mkdir $DIR/$tdir/remote/subdir || error "mkdir remote/subdir failed"
18585 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/striped ||
18586 error "mkdir striped failed"
18587 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
18589 local submount=${MOUNT}_$tdir
18591 mkdir -p $submount || error "mkdir $submount failed"
18594 local fileset=$FILESET
18596 for dir in $tdir/remote $tdir/remote/subdir \
18597 $tdir/striped $tdir/striped/subdir $tdir/striped/. ; do
18598 FILESET="$fileset/$dir" mount_client $submount ||
18599 error "mount $dir failed"
18600 umount_client $submount
18603 run_test 247f "mount striped or remote directory as fileset"
18606 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
18607 [ -z "$fast_read_sav" ] && skip "no fast read support"
18609 # create a large file for fast read verification
18610 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
18612 # make sure the file is created correctly
18613 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
18614 { rm -f $DIR/$tfile; skip "file creation error"; }
18616 echo "Test 1: verify that fast read is 4 times faster on cache read"
18618 # small read with fast read enabled
18619 $LCTL set_param -n llite.*.fast_read=1
18620 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
18621 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18622 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18623 # small read with fast read disabled
18624 $LCTL set_param -n llite.*.fast_read=0
18625 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
18626 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18627 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18629 # verify that fast read is 4 times faster for cache read
18630 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
18631 error_not_in_vm "fast read was not 4 times faster: " \
18632 "$t_fast vs $t_slow"
18634 echo "Test 2: verify the performance between big and small read"
18635 $LCTL set_param -n llite.*.fast_read=1
18637 # 1k non-cache read
18638 cancel_lru_locks osc
18639 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
18640 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18641 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18643 # 1M non-cache read
18644 cancel_lru_locks osc
18645 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
18646 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18647 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18649 # verify that big IO is not 4 times faster than small IO
18650 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
18651 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
18653 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
18656 run_test 248a "fast read verification"
18659 # Default short_io_bytes=16384, try both smaller and larger sizes.
18660 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
18661 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
18662 echo "bs=53248 count=113 normal buffered write"
18663 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
18664 error "dd of initial data file failed"
18665 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
18667 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
18668 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
18669 error "dd with sync normal writes failed"
18670 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
18672 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
18673 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
18674 error "dd with sync small writes failed"
18675 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
18677 cancel_lru_locks osc
18679 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
18680 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
18681 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
18682 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
18683 iflag=direct || error "dd with O_DIRECT small read failed"
18684 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
18685 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
18686 error "compare $TMP/$tfile.1 failed"
18688 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
18689 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
18691 # just to see what the maximum tunable value is, and test parsing
18692 echo "test invalid parameter 2MB"
18693 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
18694 error "too-large short_io_bytes allowed"
18695 echo "test maximum parameter 512KB"
18696 # if we can set a larger short_io_bytes, run test regardless of version
18697 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
18698 # older clients may not allow setting it this large, that's OK
18699 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
18700 skip "Need at least client version 2.13.50"
18701 error "medium short_io_bytes failed"
18703 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
18704 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
18706 echo "test large parameter 64KB"
18707 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
18708 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
18710 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
18711 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
18712 error "dd with sync large writes failed"
18713 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
18715 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
18716 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
18717 num=$((113 * 4096 / PAGE_SIZE))
18718 echo "bs=$size count=$num oflag=direct large write $tfile.3"
18719 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
18720 error "dd with O_DIRECT large writes failed"
18721 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
18722 error "compare $DIR/$tfile.3 failed"
18724 cancel_lru_locks osc
18726 echo "bs=$size count=$num iflag=direct large read $tfile.2"
18727 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
18728 error "dd with O_DIRECT large read failed"
18729 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
18730 error "compare $TMP/$tfile.2 failed"
18732 echo "bs=$size count=$num iflag=direct large read $tfile.3"
18733 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
18734 error "dd with O_DIRECT large read failed"
18735 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
18736 error "compare $TMP/$tfile.3 failed"
18738 run_test 248b "test short_io read and write for both small and large sizes"
18740 test_249() { # LU-7890
18741 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
18742 skip "Need at least version 2.8.54"
18745 $LFS setstripe -c 1 $DIR/$tfile
18746 # Offset 2T == 4k * 512M
18747 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
18748 error "dd to 2T offset failed"
18750 run_test 249 "Write above 2T file size"
18753 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
18754 && skip "no 16TB file size limit on ZFS"
18756 $LFS setstripe -c 1 $DIR/$tfile
18757 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
18758 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
18759 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
18760 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
18761 conv=notrunc,fsync && error "append succeeded"
18764 run_test 250 "Write above 16T limit"
18767 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
18769 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
18770 #Skip once - writing the first stripe will succeed
18771 $LCTL set_param fail_loc=0xa0001407 fail_val=1
18772 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
18773 error "short write happened"
18775 $LCTL set_param fail_loc=0xa0001407 fail_val=1
18776 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
18777 error "short read happened"
18781 run_test 251 "Handling short read and write correctly"
18784 remote_mds_nodsh && skip "remote MDS with nodsh"
18785 remote_ost_nodsh && skip "remote OST with nodsh"
18786 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
18787 skip_env "ldiskfs only test"
18797 # check lr_reader on OST0000
18799 dev=$(facet_device $tgt)
18800 out=$(do_facet $tgt $LR_READER $dev)
18801 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18803 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
18804 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
18805 error "Invalid uuid returned by $LR_READER on target $tgt"
18806 echo -e "uuid returned by $LR_READER is '$uuid'\n"
18808 # check lr_reader -c on MDT0000
18810 dev=$(facet_device $tgt)
18811 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
18812 skip "$LR_READER does not support additional options"
18814 out=$(do_facet $tgt $LR_READER -c $dev)
18815 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18817 num=$(echo "$out" | grep -c "mdtlov")
18818 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
18819 error "Invalid number of mdtlov clients returned by $LR_READER"
18820 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
18822 # check lr_reader -cr on MDT0000
18823 out=$(do_facet $tgt $LR_READER -cr $dev)
18824 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18826 echo "$out" | grep -q "^reply_data:$" ||
18827 error "$LR_READER should have returned 'reply_data' section"
18828 num=$(echo "$out" | grep -c "client_generation")
18829 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
18831 run_test 252 "check lr_reader tool"
18834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18835 remote_mds_nodsh && skip "remote MDS with nodsh"
18836 remote_mgs_nodsh && skip "remote MGS with nodsh"
18840 local ost_name=$(ostname_from_index $ostidx)
18843 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
18844 do_facet $SINGLEMDS $LCTL get_param -n \
18845 osp.$mdtosc_proc1.reserved_mb_high ||
18846 skip "remote MDS does not support reserved_mb_high"
18850 wait_delete_completed
18853 pool_add $TESTNAME || error "Pool creation failed"
18854 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
18856 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
18857 error "Setstripe failed"
18859 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
18861 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
18863 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
18865 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
18866 osp.$mdtosc_proc1.prealloc_status)
18867 echo "prealloc_status $oa_status"
18869 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
18870 error "File creation should fail"
18872 #object allocation was stopped, but we still able to append files
18873 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
18874 oflag=append || error "Append failed"
18876 rm -f $DIR/$tdir/$tfile.0
18878 # For this test, we want to delete the files we created to go out of
18879 # space but leave the watermark, so we remain nearly out of space
18880 ost_watermarks_enospc_delete_files $tfile $ostidx
18882 wait_delete_completed
18886 for i in $(seq 10 12); do
18887 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
18888 2>/dev/null || error "File creation failed after rm"
18891 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
18892 osp.$mdtosc_proc1.prealloc_status)
18893 echo "prealloc_status $oa_status"
18895 if (( oa_status != 0 )); then
18896 error "Object allocation still disable after rm"
18899 run_test 253 "Check object allocation limit"
18902 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18903 remote_mds_nodsh && skip "remote MDS with nodsh"
18904 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
18905 skip "MDS does not support changelog_size"
18908 local MDT0=$(facet_svc $SINGLEMDS)
18910 changelog_register || error "changelog_register failed"
18912 changelog_clear 0 || error "changelog_clear failed"
18914 local size1=$(do_facet $SINGLEMDS \
18915 $LCTL get_param -n mdd.$MDT0.changelog_size)
18916 echo "Changelog size $size1"
18919 $LFS mkdir -i 0 $DIR/$tdir
18921 mkdir -p $DIR/$tdir/pics/2008/zachy
18922 touch $DIR/$tdir/pics/2008/zachy/timestamp
18923 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
18924 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
18925 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
18926 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
18927 rm $DIR/$tdir/pics/desktop.jpg
18929 local size2=$(do_facet $SINGLEMDS \
18930 $LCTL get_param -n mdd.$MDT0.changelog_size)
18931 echo "Changelog size after work $size2"
18933 (( $size2 > $size1 )) ||
18934 error "new Changelog size=$size2 less than old size=$size1"
18936 run_test 254 "Check changelog size"
18943 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
18944 awk -F: '{print $2}' | grep $type > /dev/null
18945 if [ $? -ne 0 ]; then
18955 lfs ladvise -a willread $file > /dev/null 2>&1
18956 if [ $? -eq 0 ]; then
18960 lfs ladvise -a willread $file 2>&1 |
18961 grep "Inappropriate ioctl for device" > /dev/null
18962 if [ $? -eq 0 ]; then
18969 bc <<<"scale=2; ($1 - $2) * 100 / $2"
18972 # run a random read IO workload
18973 # usage: random_read_iops <filename> <filesize> <iosize>
18974 random_read_iops() {
18977 local iosize=${3:-4096}
18979 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
18980 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
18983 drop_file_oss_cache() {
18987 $LFS ladvise -a dontneed $file 2>/dev/null ||
18988 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
18991 ladvise_willread_performance()
18994 local average_origin=0
18995 local average_cache=0
18996 local average_ladvise=0
18998 for ((i = 1; i <= $repeat; i++)); do
18999 echo "Iter $i/$repeat: reading without willread hint"
19000 cancel_lru_locks osc
19001 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
19002 local speed_origin=$(random_read_iops $DIR/$tfile $size)
19003 echo "Iter $i/$repeat: uncached speed: $speed_origin"
19004 average_origin=$(bc <<<"$average_origin + $speed_origin")
19006 cancel_lru_locks osc
19007 local speed_cache=$(random_read_iops $DIR/$tfile $size)
19008 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
19009 average_cache=$(bc <<<"$average_cache + $speed_cache")
19011 cancel_lru_locks osc
19012 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
19013 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
19014 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
19015 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
19016 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
19018 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
19019 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
19020 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
19022 speedup_cache=$(percent $average_cache $average_origin)
19023 speedup_ladvise=$(percent $average_ladvise $average_origin)
19025 echo "Average uncached read: $average_origin"
19026 echo "Average speedup with OSS cached read: " \
19027 "$average_cache = +$speedup_cache%"
19028 echo "Average speedup with ladvise willread: " \
19029 "$average_ladvise = +$speedup_ladvise%"
19031 local lowest_speedup=20
19032 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
19033 echo "Speedup with OSS cached read less than $lowest_speedup%," \
19034 "got $average_cache%. Skipping ladvise willread check."
19038 # the test won't work on ZFS until it supports 'ladvise dontneed', but
19039 # it is still good to run until then to exercise 'ladvise willread'
19040 ! $LFS ladvise -a dontneed $DIR/$tfile &&
19041 [ "$ost1_FSTYPE" = "zfs" ] &&
19042 echo "osd-zfs does not support dontneed or drop_caches" &&
19045 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
19046 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
19047 error_not_in_vm "Speedup with willread is less than " \
19048 "$lowest_speedup%, got $average_ladvise%"
19052 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
19053 skip "lustre < 2.8.54 does not support ladvise "
19054 remote_ost_nodsh && skip "remote OST with nodsh"
19056 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
19058 ladvise_no_type willread $DIR/$tfile &&
19059 skip "willread ladvise is not supported"
19061 ladvise_no_ioctl $DIR/$tfile &&
19062 skip "ladvise ioctl is not supported"
19065 local size=$((size_mb * 1048576))
19066 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
19067 error "dd to $DIR/$tfile failed"
19069 lfs ladvise -a willread $DIR/$tfile ||
19070 error "Ladvise failed with no range argument"
19072 lfs ladvise -a willread -s 0 $DIR/$tfile ||
19073 error "Ladvise failed with no -l or -e argument"
19075 lfs ladvise -a willread -e 1 $DIR/$tfile ||
19076 error "Ladvise failed with only -e argument"
19078 lfs ladvise -a willread -l 1 $DIR/$tfile ||
19079 error "Ladvise failed with only -l argument"
19081 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
19082 error "End offset should not be smaller than start offset"
19084 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
19085 error "End offset should not be equal to start offset"
19087 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
19088 error "Ladvise failed with overflowing -s argument"
19090 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
19091 error "Ladvise failed with overflowing -e argument"
19093 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
19094 error "Ladvise failed with overflowing -l argument"
19096 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
19097 error "Ladvise succeeded with conflicting -l and -e arguments"
19099 echo "Synchronous ladvise should wait"
19101 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
19102 do_nodes $(comma_list $(osts_nodes)) \
19103 $LCTL set_param fail_val=$delay fail_loc=0x237
19105 local start_ts=$SECONDS
19106 lfs ladvise -a willread $DIR/$tfile ||
19107 error "Ladvise failed with no range argument"
19108 local end_ts=$SECONDS
19109 local inteval_ts=$((end_ts - start_ts))
19111 if [ $inteval_ts -lt $(($delay - 1)) ]; then
19112 error "Synchronous advice didn't wait reply"
19115 echo "Asynchronous ladvise shouldn't wait"
19116 local start_ts=$SECONDS
19117 lfs ladvise -a willread -b $DIR/$tfile ||
19118 error "Ladvise failed with no range argument"
19119 local end_ts=$SECONDS
19120 local inteval_ts=$((end_ts - start_ts))
19122 if [ $inteval_ts -gt $(($delay / 2)) ]; then
19123 error "Asynchronous advice blocked"
19126 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
19127 ladvise_willread_performance
19129 run_test 255a "check 'lfs ladvise -a willread'"
19135 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
19139 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
19140 skip "lustre < 2.8.54 does not support ladvise "
19141 remote_ost_nodsh && skip "remote OST with nodsh"
19143 lfs setstripe -c 1 -i 0 $DIR/$tfile
19145 ladvise_no_type dontneed $DIR/$tfile &&
19146 skip "dontneed ladvise is not supported"
19148 ladvise_no_ioctl $DIR/$tfile &&
19149 skip "ladvise ioctl is not supported"
19151 ! $LFS ladvise -a dontneed $DIR/$tfile &&
19152 [ "$ost1_FSTYPE" = "zfs" ] &&
19153 skip "zfs-osd does not support 'ladvise dontneed'"
19156 local size=$((size_mb * 1048576))
19157 # In order to prevent disturbance of other processes, only check 3/4
19158 # of the memory usage
19159 local kibibytes=$((size_mb * 1024 * 3 / 4))
19161 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
19162 error "dd to $DIR/$tfile failed"
19164 #force write to complete before dropping OST cache & checking memory
19167 local total=$(facet_meminfo ost1 MemTotal)
19168 echo "Total memory: $total KiB"
19170 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
19171 local before_read=$(facet_meminfo ost1 Cached)
19172 echo "Cache used before read: $before_read KiB"
19174 lfs ladvise -a willread $DIR/$tfile ||
19175 error "Ladvise willread failed"
19176 local after_read=$(facet_meminfo ost1 Cached)
19177 echo "Cache used after read: $after_read KiB"
19179 lfs ladvise -a dontneed $DIR/$tfile ||
19180 error "Ladvise dontneed again failed"
19181 local no_read=$(facet_meminfo ost1 Cached)
19182 echo "Cache used after dontneed ladvise: $no_read KiB"
19184 if [ $total -lt $((before_read + kibibytes)) ]; then
19185 echo "Memory is too small, abort checking"
19189 if [ $((before_read + kibibytes)) -gt $after_read ]; then
19190 error "Ladvise willread should use more memory" \
19191 "than $kibibytes KiB"
19194 if [ $((no_read + kibibytes)) -gt $after_read ]; then
19195 error "Ladvise dontneed should release more memory" \
19196 "than $kibibytes KiB"
19199 run_test 255b "check 'lfs ladvise -a dontneed'"
19202 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
19203 skip "lustre < 2.10.50 does not support lockahead"
19211 test_mkdir -p $DIR/$tdir
19212 $LFS setstripe -i 0 -c 1 $DIR/$tdir
19214 #test 10 returns only success/failure
19216 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19218 if [ $rc -eq 255 ]; then
19219 error "Ladvise test${i} failed, ${rc}"
19222 #test 11 counts lock enqueue requests, all others count new locks
19224 count=$(do_facet ost1 \
19225 $LCTL get_param -n ost.OSS.ost.stats)
19226 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
19228 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19230 if [ $rc -eq 255 ]; then
19231 error "Ladvise test${i} failed, ${rc}"
19234 new_count=$(do_facet ost1 \
19235 $LCTL get_param -n ost.OSS.ost.stats)
19236 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
19237 awk '{ print $2 }')
19239 difference="$((new_count - count))"
19240 if [ $difference -ne $rc ]; then
19241 error "Ladvise test${i}, bad enqueue count, returned " \
19242 "${rc}, actual ${difference}"
19245 for i in $(seq 12 21); do
19246 # If we do not do this, we run the risk of having too many
19247 # locks and starting lock cancellation while we are checking
19249 cancel_lru_locks osc
19251 count=$($LCTL get_param -n \
19252 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
19254 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19256 if [ $rc -eq 255 ]; then
19257 error "Ladvise test ${i} failed, ${rc}"
19260 new_count=$($LCTL get_param -n \
19261 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
19262 difference="$((new_count - count))"
19264 # Test 15 output is divided by 100 to map down to valid return
19265 if [ $i -eq 15 ]; then
19269 if [ $difference -ne $rc ]; then
19270 error "Ladvise test ${i}, bad lock count, returned " \
19271 "${rc}, actual ${difference}"
19275 #test 22 returns only success/failure
19277 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19279 if [ $rc -eq 255 ]; then
19280 error "Ladvise test${i} failed, ${rc}"
19283 run_test 255c "suite of ladvise lockahead tests"
19286 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19287 remote_mds_nodsh && skip "remote MDS with nodsh"
19288 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
19289 changelog_users $SINGLEMDS | grep "^cl" &&
19290 skip "active changelog user"
19296 mdt_dev=$(mdsdevname 1)
19299 changelog_register || error "changelog_register failed"
19302 mkdir -p $DIR/$tdir
19304 changelog_clear 0 || error "changelog_clear failed"
19307 touch $DIR/$tdir/{1..10}
19310 stop $SINGLEMDS || error "Fail to stop MDT"
19314 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
19316 #after mount new plainllog is used
19317 touch $DIR/$tdir/{11..19}
19318 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
19319 stack_trap "rm -f $tmpfile"
19320 cat_sl=$(do_facet $SINGLEMDS "sync; \
19321 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
19322 llog_reader $tmpfile | grep -c type=1064553b")
19323 do_facet $SINGLEMDS llog_reader $tmpfile
19325 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
19327 changelog_clear 0 || error "changelog_clear failed"
19329 cat_sl=$(do_facet $SINGLEMDS "sync; \
19330 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
19331 llog_reader $tmpfile | grep -c type=1064553b")
19333 if (( cat_sl == 2 )); then
19334 error "Empty plain llog was not deleted from changelog catalog"
19335 elif (( cat_sl != 1 )); then
19336 error "Active plain llog shouldn't be deleted from catalog"
19339 run_test 256 "Check llog delete for empty and not full state"
19342 remote_mds_nodsh && skip "remote MDS with nodsh"
19343 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
19344 skip "Need MDS version at least 2.8.55"
19346 test_mkdir $DIR/$tdir
19348 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
19349 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
19352 #define OBD_FAIL_MDS_XATTR_REP 0x161
19353 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
19354 local facet=mds$((mdtidx + 1))
19355 set_nodes_failloc $(facet_active_host $facet) 0x80000161
19356 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
19358 stop $facet || error "stop MDS failed"
19359 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
19360 error "start MDS fail"
19361 wait_recovery_complete $facet
19363 run_test 257 "xattr locks are not lost"
19365 # Verify we take the i_mutex when security requires it
19367 #define OBD_FAIL_IMUTEX_SEC 0x141c
19368 $LCTL set_param fail_loc=0x141c
19370 chmod u+s $DIR/$tfile
19371 chmod a+rwx $DIR/$tfile
19372 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
19374 if [ $RC -ne 0 ]; then
19375 error "error, failed to take i_mutex, rc=$?"
19379 run_test 258a "verify i_mutex security behavior when suid attributes is set"
19381 # Verify we do NOT take the i_mutex in the normal case
19383 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
19384 $LCTL set_param fail_loc=0x141d
19387 chmod a+rw $DIR/$tfile
19388 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
19390 if [ $RC -ne 0 ]; then
19391 error "error, took i_mutex unnecessarily, rc=$?"
19396 run_test 258b "verify i_mutex security behavior"
19399 local file=$DIR/$tfile
19403 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
19405 stack_trap "rm -f $file" EXIT
19407 wait_delete_completed
19408 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19409 echo "before: $before"
19411 $LFS setstripe -i 0 -c 1 $file
19412 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
19414 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19415 echo "after write: $after"
19417 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
19418 do_facet ost1 $LCTL set_param fail_loc=0x2301
19420 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19421 echo "after truncate: $after"
19424 do_facet ost1 $LCTL set_param fail_loc=0
19425 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
19427 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19428 echo "after restart: $after"
19429 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
19430 error "missing truncate?"
19434 run_test 259 "crash at delayed truncate"
19437 #define OBD_FAIL_MDC_CLOSE 0x806
19438 $LCTL set_param fail_loc=0x80000806
19442 run_test 260 "Check mdc_close fail"
19444 ### Data-on-MDT sanity tests ###
19446 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19447 skip "Need MDS version at least 2.10.55 for DoM"
19450 local dom=$DIR/$tdir/dom_file
19451 local tmp=$DIR/$tdir/tmp_file
19453 mkdir -p $DIR/$tdir
19455 # basic checks for DoM component creation
19456 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
19457 error "Can set MDT layout to non-first entry"
19459 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
19460 error "Can define multiple entries as MDT layout"
19462 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
19464 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
19465 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
19466 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
19468 local mdtidx=$($LFS getstripe -m $dom)
19469 local mdtname=MDT$(printf %04x $mdtidx)
19470 local facet=mds$((mdtidx + 1))
19471 local space_check=1
19473 # Skip free space checks with ZFS
19474 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
19478 local size_tmp=$((65536 * 3))
19479 local mdtfree1=$(do_facet $facet \
19480 lctl get_param -n osd*.*$mdtname.kbytesfree)
19482 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
19483 # check also direct IO along write
19484 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
19485 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
19487 cmp $tmp $dom || error "file data is different"
19488 [ $(stat -c%s $dom) == $size_tmp ] ||
19489 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
19490 if [ $space_check == 1 ]; then
19491 local mdtfree2=$(do_facet $facet \
19492 lctl get_param -n osd*.*$mdtname.kbytesfree)
19494 # increase in usage from by $size_tmp
19495 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
19496 error "MDT free space wrong after write: " \
19497 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
19501 local size_dom=10000
19503 $TRUNCATE $dom $size_dom
19504 [ $(stat -c%s $dom) == $size_dom ] ||
19505 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
19506 if [ $space_check == 1 ]; then
19507 mdtfree1=$(do_facet $facet \
19508 lctl get_param -n osd*.*$mdtname.kbytesfree)
19509 # decrease in usage from $size_tmp to new $size_dom
19510 [ $(($mdtfree1 - $mdtfree2)) -ge \
19511 $(((size_tmp - size_dom) / 1024)) ] ||
19512 error "MDT free space is wrong after truncate: " \
19513 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
19519 size_dom=$((size_dom + size_tmp))
19520 [ $(stat -c%s $dom) == $size_dom ] ||
19521 error "bad size after append: $(stat -c%s $dom) != $size_dom"
19522 if [ $space_check == 1 ]; then
19523 mdtfree2=$(do_facet $facet \
19524 lctl get_param -n osd*.*$mdtname.kbytesfree)
19525 # increase in usage by $size_tmp from previous
19526 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
19527 error "MDT free space is wrong after append: " \
19528 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
19533 if [ $space_check == 1 ]; then
19534 mdtfree1=$(do_facet $facet \
19535 lctl get_param -n osd*.*$mdtname.kbytesfree)
19536 # decrease in usage by $size_dom from previous
19537 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
19538 error "MDT free space is wrong after removal: " \
19539 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
19542 # combined striping
19543 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
19544 error "Can't create DoM + OST striping"
19546 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
19547 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
19548 # check also direct IO along write
19549 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
19551 cmp $tmp $dom || error "file data is different"
19552 [ $(stat -c%s $dom) == $size_tmp ] ||
19553 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
19558 run_test 270a "DoM: basic functionality tests"
19561 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19562 skip "Need MDS version at least 2.10.55"
19564 local dom=$DIR/$tdir/dom_file
19565 local max_size=1048576
19567 mkdir -p $DIR/$tdir
19568 $LFS setstripe -E $max_size -L mdt $dom
19570 # truncate over the limit
19571 $TRUNCATE $dom $(($max_size + 1)) &&
19572 error "successful truncate over the maximum size"
19573 # write over the limit
19574 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
19575 error "successful write over the maximum size"
19576 # append over the limit
19577 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
19578 echo "12345" >> $dom && error "successful append over the maximum size"
19583 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
19586 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19587 skip "Need MDS version at least 2.10.55"
19589 mkdir -p $DIR/$tdir
19590 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19592 # check files inherit DoM EA
19593 touch $DIR/$tdir/first
19594 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
19595 error "bad pattern"
19596 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
19597 error "bad stripe count"
19598 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
19599 error "bad stripe size"
19601 # check directory inherits DoM EA and uses it as default
19602 mkdir $DIR/$tdir/subdir
19603 touch $DIR/$tdir/subdir/second
19604 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
19605 error "bad pattern in sub-directory"
19606 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
19607 error "bad stripe count in sub-directory"
19608 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
19609 error "bad stripe size in sub-directory"
19612 run_test 270c "DoM: DoM EA inheritance tests"
19615 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19616 skip "Need MDS version at least 2.10.55"
19618 mkdir -p $DIR/$tdir
19619 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19621 # inherit default DoM striping
19622 mkdir $DIR/$tdir/subdir
19623 touch $DIR/$tdir/subdir/f1
19625 # change default directory striping
19626 $LFS setstripe -c 1 $DIR/$tdir/subdir
19627 touch $DIR/$tdir/subdir/f2
19628 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
19629 error "wrong default striping in file 2"
19630 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
19631 error "bad pattern in file 2"
19634 run_test 270d "DoM: change striping from DoM to RAID0"
19637 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19638 skip "Need MDS version at least 2.10.55"
19640 mkdir -p $DIR/$tdir/dom
19641 mkdir -p $DIR/$tdir/norm
19644 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
19645 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
19647 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
19648 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
19650 # find DoM files by layout
19651 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
19652 [ $NUM -eq $DOMFILES ] ||
19653 error "lfs find -L: found $NUM, expected $DOMFILES"
19654 echo "Test 1: lfs find 20 DOM files by layout: OK"
19656 # there should be 1 dir with default DOM striping
19657 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
19659 error "lfs find -L: found $NUM, expected 1 dir"
19660 echo "Test 2: lfs find 1 DOM dir by layout: OK"
19662 # find DoM files by stripe size
19663 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
19664 [ $NUM -eq $DOMFILES ] ||
19665 error "lfs find -S: found $NUM, expected $DOMFILES"
19666 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
19668 # find files by stripe offset except DoM files
19669 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
19670 [ $NUM -eq $NORMFILES ] ||
19671 error "lfs find -i: found $NUM, expected $NORMFILES"
19672 echo "Test 5: lfs find no DOM files by stripe index: OK"
19675 run_test 270e "DoM: lfs find with DoM files test"
19678 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19679 skip "Need MDS version at least 2.10.55"
19681 local mdtname=${FSNAME}-MDT0000-mdtlov
19682 local dom=$DIR/$tdir/dom_file
19683 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
19684 lod.$mdtname.dom_stripesize)
19685 local dom_limit=131072
19687 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
19688 local dom_current=$(do_facet mds1 $LCTL get_param -n \
19689 lod.$mdtname.dom_stripesize)
19690 [ ${dom_limit} -eq ${dom_current} ] ||
19691 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
19693 $LFS mkdir -i 0 -c 1 $DIR/$tdir
19694 $LFS setstripe -d $DIR/$tdir
19695 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
19696 error "Can't set directory default striping"
19698 # exceed maximum stripe size
19699 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
19700 error "Can't create file with $((dom_limit * 2)) DoM stripe"
19701 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
19702 error "Able to create DoM component size more than LOD limit"
19704 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
19705 dom_current=$(do_facet mds1 $LCTL get_param -n \
19706 lod.$mdtname.dom_stripesize)
19707 [ 0 -eq ${dom_current} ] ||
19708 error "Can't set zero DoM stripe limit"
19711 # attempt to create DoM file on server with disabled DoM should
19712 # remove DoM entry from layout and be succeed
19713 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
19714 error "Can't create DoM file (DoM is disabled)"
19715 [ $($LFS getstripe -L $dom) == "mdt" ] &&
19716 error "File has DoM component while DoM is disabled"
19719 # attempt to create DoM file with only DoM stripe should return error
19720 $LFS setstripe -E $dom_limit -L mdt $dom &&
19721 error "Able to create DoM-only file while DoM is disabled"
19723 # too low values to be aligned with smallest stripe size 64K
19724 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
19725 dom_current=$(do_facet mds1 $LCTL get_param -n \
19726 lod.$mdtname.dom_stripesize)
19727 [ 30000 -eq ${dom_current} ] &&
19728 error "Can set too small DoM stripe limit"
19730 # 64K is a minimal stripe size in Lustre, expect limit of that size
19731 [ 65536 -eq ${dom_current} ] ||
19732 error "Limit is not set to 64K but ${dom_current}"
19734 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
19735 dom_current=$(do_facet mds1 $LCTL get_param -n \
19736 lod.$mdtname.dom_stripesize)
19738 [ 2147483648 -eq ${dom_current} ] &&
19739 error "Can set too large DoM stripe limit"
19741 do_facet mds1 $LCTL set_param -n \
19742 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
19743 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
19744 error "Can't create DoM component size after limit change"
19745 do_facet mds1 $LCTL set_param -n \
19746 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
19747 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
19748 error "Can't create DoM file after limit decrease"
19749 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
19750 error "Can create big DoM component after limit decrease"
19751 touch ${dom}_def ||
19752 error "Can't create file with old default layout"
19754 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
19757 run_test 270f "DoM: maximum DoM stripe size checks"
19760 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
19761 skip "Need MDS version at least 2.13.52"
19762 local dom=$DIR/$tdir/$tfile
19764 $LFS mkdir -i 0 -c 1 $DIR/$tdir
19765 local lodname=${FSNAME}-MDT0000-mdtlov
19767 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
19768 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
19769 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
19770 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
19772 local dom_limit=1024
19773 local dom_threshold="50%"
19775 $LFS setstripe -d $DIR/$tdir
19776 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
19777 error "Can't set directory default striping"
19779 do_facet mds1 $LCTL set_param -n \
19780 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
19781 # set 0 threshold and create DOM file to change tunable stripesize
19782 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
19783 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
19784 error "Failed to create $dom file"
19785 # now tunable dom_cur_stripesize should reach maximum
19786 local dom_current=$(do_facet mds1 $LCTL get_param -n \
19787 lod.${lodname}.dom_stripesize_cur_kb)
19788 [[ $dom_current == $dom_limit ]] ||
19789 error "Current DOM stripesize is not maximum"
19792 # set threshold for further tests
19793 do_facet mds1 $LCTL set_param -n \
19794 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
19795 echo "DOM threshold is $dom_threshold free space"
19798 # Spoof bfree to exceed threshold
19799 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
19800 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
19801 for spfree in 40 20 0 15 30 55; do
19802 do_facet mds1 $LCTL set_param -n fail_val=$spfree
19803 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
19804 error "Failed to create $dom file"
19805 dom_def=$(do_facet mds1 $LCTL get_param -n \
19806 lod.${lodname}.dom_stripesize_cur_kb)
19807 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
19808 [[ $dom_def != $dom_current ]] ||
19809 error "Default stripe size was not changed"
19810 if [[ $spfree > 0 ]] ; then
19811 dom_set=$($LFS getstripe -S $dom)
19812 [[ $dom_set == $((dom_def * 1024)) ]] ||
19813 error "DOM component size is still old"
19815 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
19816 error "DoM component is set with no free space"
19819 dom_current=$dom_def
19822 run_test 270g "DoM: default DoM stripe size depends on free space"
19825 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
19826 skip "Need MDS version at least 2.13.53"
19828 local mdtname=${FSNAME}-MDT0000-mdtlov
19829 local dom=$DIR/$tdir/$tfile
19830 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
19832 save_lustre_params mds1 "lod.*.dom_stripesize" > $save
19833 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
19835 $LFS mkdir -i 0 -c 1 $DIR/$tdir
19836 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 ||
19837 error "can't create OST file"
19838 # mirrored file with DOM entry in the second mirror
19839 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 ||
19840 error "can't create mirror with DoM component"
19842 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
19844 # DOM component in the middle and has other enries in the same mirror,
19845 # should succeed but lost DoM component
19846 $LFS setstripe --copy=${dom}_1 $dom ||
19847 error "Can't create file from OST|DOM mirror layout"
19848 # check new file has no DoM layout after all
19849 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
19850 error "File has DoM component while DoM is disabled"
19852 run_test 270h "DoM: DoM stripe removal when disabled on server"
19855 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19856 skip "Need MDS version at least 2.10.55"
19858 local dom=$DIR/$tdir/dom
19860 mkdir -p $DIR/$tdir
19862 $LFS setstripe -E 1024K -L mdt $dom
19864 lctl set_param -n mdc.*.stats=clear
19865 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
19866 cat $dom > /dev/null
19867 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
19868 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
19872 run_test 271a "DoM: data is cached for read after write"
19875 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19876 skip "Need MDS version at least 2.10.55"
19878 local dom=$DIR/$tdir/dom
19880 mkdir -p $DIR/$tdir
19882 $LFS setstripe -E 1024K -L mdt -E EOF $dom
19884 lctl set_param -n mdc.*.stats=clear
19885 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
19886 cancel_lru_locks mdc
19887 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
19888 # second stat to check size is cached on client
19889 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
19890 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
19891 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
19894 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
19897 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19898 skip "Need MDS version at least 2.10.55"
19900 local dom=$DIR/$tdir/dom
19902 mkdir -p $DIR/$tdir
19904 $LFS setstripe -E 1024K -L mdt -E EOF $dom
19906 lctl set_param -n mdc.*.stats=clear
19907 lctl set_param -n osc.*.stats=clear
19908 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
19909 cancel_lru_locks mdc
19910 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
19911 # second stat to check size is cached on client
19912 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
19913 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
19914 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
19915 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
19916 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
19919 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
19925 local mdt=MDT$(printf %04x $mdtidx)
19927 if [ -z $param ]; then
19928 lctl get_param -n mdc.*$mdt*.stats
19930 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
19935 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19936 skip "Need MDS version at least 2.10.55"
19938 local dom=$DIR/$tdir/dom
19940 mkdir -p $DIR/$tdir
19942 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19944 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
19945 local facet=mds$((mdtidx + 1))
19947 cancel_lru_locks mdc
19948 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
19949 createmany -o $dom 1000
19950 lctl set_param -n mdc.*.stats=clear
19951 smalliomany -w $dom 1000 200
19952 get_mdc_stats $mdtidx
19953 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
19954 # Each file has 1 open, 1 IO enqueues, total 2000
19955 # but now we have also +1 getxattr for security.capability, total 3000
19956 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
19957 unlinkmany $dom 1000
19959 cancel_lru_locks mdc
19960 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
19961 createmany -o $dom 1000
19962 lctl set_param -n mdc.*.stats=clear
19963 smalliomany -w $dom 1000 200
19964 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
19965 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
19966 # for OPEN and IO lock.
19967 [ $((enq - enq_2)) -ge 1000 ] ||
19968 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
19969 unlinkmany $dom 1000
19972 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
19974 cleanup_271def_tests() {
19980 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
19981 skip "Need MDS version at least 2.10.57"
19983 local dom=$DIR/$tdir/dom
19984 local tmp=$TMP/$tfile
19985 trap "cleanup_271def_tests $tmp" EXIT
19987 mkdir -p $DIR/$tdir
19989 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19991 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
19993 cancel_lru_locks mdc
19994 dd if=/dev/urandom of=$tmp bs=1000 count=1
19995 dd if=$tmp of=$dom bs=1000 count=1
19996 cancel_lru_locks mdc
19998 cat /etc/hosts >> $tmp
19999 lctl set_param -n mdc.*.stats=clear
20001 # append data to the same file it should update local page
20002 echo "Append to the same page"
20003 cat /etc/hosts >> $dom
20004 local num=$(get_mdc_stats $mdtidx ost_read)
20005 local ra=$(get_mdc_stats $mdtidx req_active)
20006 local rw=$(get_mdc_stats $mdtidx req_waittime)
20008 [ -z $num ] || error "$num READ RPC occured"
20009 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
20013 cmp $tmp $dom || error "file miscompare"
20015 cancel_lru_locks mdc
20016 lctl set_param -n mdc.*.stats=clear
20018 echo "Open and read file"
20019 cat $dom > /dev/null
20020 local num=$(get_mdc_stats $mdtidx ost_read)
20021 local ra=$(get_mdc_stats $mdtidx req_active)
20022 local rw=$(get_mdc_stats $mdtidx req_waittime)
20024 [ -z $num ] || error "$num READ RPC occured"
20025 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
20029 cmp $tmp $dom || error "file miscompare"
20033 run_test 271d "DoM: read on open (1K file in reply buffer)"
20036 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
20037 skip "Need MDS version at least 2.10.57"
20039 local dom=$DIR/$tdir/dom
20040 local tmp=$TMP/$tfile
20041 trap "cleanup_271def_tests $tmp" EXIT
20043 mkdir -p $DIR/$tdir
20045 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
20047 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
20049 cancel_lru_locks mdc
20050 dd if=/dev/urandom of=$tmp bs=265000 count=1
20051 dd if=$tmp of=$dom bs=265000 count=1
20052 cancel_lru_locks mdc
20053 cat /etc/hosts >> $tmp
20054 lctl set_param -n mdc.*.stats=clear
20056 echo "Append to the same page"
20057 cat /etc/hosts >> $dom
20058 local num=$(get_mdc_stats $mdtidx ost_read)
20059 local ra=$(get_mdc_stats $mdtidx req_active)
20060 local rw=$(get_mdc_stats $mdtidx req_waittime)
20062 [ -z $num ] || error "$num READ RPC occured"
20063 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
20067 cmp $tmp $dom || error "file miscompare"
20069 cancel_lru_locks mdc
20070 lctl set_param -n mdc.*.stats=clear
20072 echo "Open and read file"
20073 cat $dom > /dev/null
20074 local num=$(get_mdc_stats $mdtidx ost_read)
20075 local ra=$(get_mdc_stats $mdtidx req_active)
20076 local rw=$(get_mdc_stats $mdtidx req_waittime)
20078 [ -z $num ] && num=0
20079 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
20080 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
20084 cmp $tmp $dom || error "file miscompare"
20088 run_test 271f "DoM: read on open (200K file and read tail)"
20091 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
20092 skip "Skipping due to old client or server version"
20094 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
20096 $CHECKSTAT -t file $DIR1/$tfile
20098 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
20101 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
20102 $LCTL set_param fail_loc=0x80000314
20103 rm $DIR1/$tfile || error "Unlink fails"
20105 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
20106 [ $RC -eq 0 ] || error "Failed write to stale object"
20108 run_test 271g "Discard DoM data vs client flush race"
20111 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
20112 skip "Need MDS version at least 2.11.50"
20114 local dom=$DIR/$tdir/dom
20115 mkdir -p $DIR/$tdir
20117 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
20118 dd if=/dev/urandom of=$dom bs=512K count=1 ||
20119 error "failed to write data into $dom"
20120 local old_md5=$(md5sum $dom)
20122 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
20123 error "failed to migrate to the same DoM component"
20125 local new_md5=$(md5sum $dom)
20127 [ "$old_md5" == "$new_md5" ] ||
20128 error "md5sum differ: $old_md5, $new_md5"
20130 [ $($LFS getstripe -c $dom) -eq 2 ] ||
20131 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
20133 run_test 272a "DoM migration: new layout with the same DOM component"
20136 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
20137 skip "Need MDS version at least 2.11.50"
20139 local dom=$DIR/$tdir/dom
20140 mkdir -p $DIR/$tdir
20141 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
20143 local mdtidx=$($LFS getstripe -m $dom)
20144 local mdtname=MDT$(printf %04x $mdtidx)
20145 local facet=mds$((mdtidx + 1))
20147 local mdtfree1=$(do_facet $facet \
20148 lctl get_param -n osd*.*$mdtname.kbytesfree)
20149 dd if=/dev/urandom of=$dom bs=2M count=1 ||
20150 error "failed to write data into $dom"
20151 local old_md5=$(md5sum $dom)
20152 cancel_lru_locks mdc
20153 local mdtfree1=$(do_facet $facet \
20154 lctl get_param -n osd*.*$mdtname.kbytesfree)
20156 $LFS migrate -c2 $dom ||
20157 error "failed to migrate to the new composite layout"
20158 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
20159 error "MDT stripe was not removed"
20161 cancel_lru_locks mdc
20162 local new_md5=$(md5sum $dom)
20163 [ "$old_md5" == "$new_md5" ] ||
20164 error "$old_md5 != $new_md5"
20166 # Skip free space checks with ZFS
20167 if [ "$(facet_fstype $facet)" != "zfs" ]; then
20168 local mdtfree2=$(do_facet $facet \
20169 lctl get_param -n osd*.*$mdtname.kbytesfree)
20170 [ $mdtfree2 -gt $mdtfree1 ] ||
20171 error "MDT space is not freed after migration"
20175 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
20178 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
20179 skip "Need MDS version at least 2.11.50"
20181 local dom=$DIR/$tdir/$tfile
20182 mkdir -p $DIR/$tdir
20183 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
20185 local mdtidx=$($LFS getstripe -m $dom)
20186 local mdtname=MDT$(printf %04x $mdtidx)
20187 local facet=mds$((mdtidx + 1))
20189 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
20190 error "failed to write data into $dom"
20191 local old_md5=$(md5sum $dom)
20192 cancel_lru_locks mdc
20193 local mdtfree1=$(do_facet $facet \
20194 lctl get_param -n osd*.*$mdtname.kbytesfree)
20196 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
20197 error "failed to migrate to the new composite layout"
20198 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
20199 error "MDT stripe was not removed"
20201 cancel_lru_locks mdc
20202 local new_md5=$(md5sum $dom)
20203 [ "$old_md5" == "$new_md5" ] ||
20204 error "$old_md5 != $new_md5"
20206 # Skip free space checks with ZFS
20207 if [ "$(facet_fstype $facet)" != "zfs" ]; then
20208 local mdtfree2=$(do_facet $facet \
20209 lctl get_param -n osd*.*$mdtname.kbytesfree)
20210 [ $mdtfree2 -gt $mdtfree1 ] ||
20211 error "MDS space is not freed after migration"
20215 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
20218 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
20219 skip "Need MDS version at least 2.12.55"
20221 local dom=$DIR/$tdir/$tfile
20222 mkdir -p $DIR/$tdir
20223 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
20225 local mdtidx=$($LFS getstripe -m $dom)
20226 local mdtname=MDT$(printf %04x $mdtidx)
20227 local facet=mds$((mdtidx + 1))
20229 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
20230 error "failed to write data into $dom"
20231 local old_md5=$(md5sum $dom)
20232 cancel_lru_locks mdc
20233 local mdtfree1=$(do_facet $facet \
20234 lctl get_param -n osd*.*$mdtname.kbytesfree)
20236 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
20237 error "failed mirroring to the new composite layout"
20238 $LFS mirror resync $dom ||
20239 error "failed mirror resync"
20240 $LFS mirror split --mirror-id 1 -d $dom ||
20241 error "failed mirror split"
20243 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
20244 error "MDT stripe was not removed"
20246 cancel_lru_locks mdc
20247 local new_md5=$(md5sum $dom)
20248 [ "$old_md5" == "$new_md5" ] ||
20249 error "$old_md5 != $new_md5"
20251 # Skip free space checks with ZFS
20252 if [ "$(facet_fstype $facet)" != "zfs" ]; then
20253 local mdtfree2=$(do_facet $facet \
20254 lctl get_param -n osd*.*$mdtname.kbytesfree)
20255 [ $mdtfree2 -gt $mdtfree1 ] ||
20256 error "MDS space is not freed after DOM mirror deletion"
20260 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
20263 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
20264 skip "Need MDS version at least 2.12.55"
20266 local dom=$DIR/$tdir/$tfile
20267 mkdir -p $DIR/$tdir
20268 $LFS setstripe -c 2 $dom
20270 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
20271 error "failed to write data into $dom"
20272 local old_md5=$(md5sum $dom)
20273 cancel_lru_locks mdc
20275 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
20276 error "failed mirroring to the DOM layout"
20277 $LFS mirror resync $dom ||
20278 error "failed mirror resync"
20279 $LFS mirror split --mirror-id 1 -d $dom ||
20280 error "failed mirror split"
20282 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
20283 error "MDT stripe was not removed"
20285 cancel_lru_locks mdc
20286 local new_md5=$(md5sum $dom)
20287 [ "$old_md5" == "$new_md5" ] ||
20288 error "$old_md5 != $new_md5"
20292 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
20295 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
20296 skip "Need MDS version at least 2.12.55"
20298 local dom=$DIR/$tdir/$tfile
20299 mkdir -p $DIR/$tdir
20300 $LFS setstripe -c 2 $dom
20302 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
20303 error "failed to write data into $dom"
20304 local old_md5=$(md5sum $dom)
20305 cancel_lru_locks mdc
20307 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
20308 error "failed migrating to the DOM file"
20310 cancel_lru_locks mdc
20311 local new_md5=$(md5sum $dom)
20312 [ "$old_md5" != "$new_md5" ] &&
20313 error "$old_md5 != $new_md5"
20317 run_test 272f "DoM migration: OST-striped file to DOM file"
20320 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
20321 skip "Need MDS version at least 2.11.50"
20323 # Layout swap cannot be done if either file has DOM component,
20324 # this will never be supported, migration should be used instead
20326 local dom=$DIR/$tdir/$tfile
20327 mkdir -p $DIR/$tdir
20329 $LFS setstripe -c2 ${dom}_plain
20330 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
20331 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
20332 error "can swap layout with DoM component"
20333 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
20334 error "can swap layout with DoM component"
20336 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
20337 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
20338 error "can swap layout with DoM component"
20339 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
20340 error "can swap layout with DoM component"
20343 run_test 273a "DoM: layout swapping should fail with DOM"
20346 remote_ost_nodsh && skip "remote OST with nodsh"
20347 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
20348 skip "Need OST version >= 2.10.57"
20350 local file=$DIR/$tfile
20353 oss=$(comma_list $(osts_nodes))
20355 dd if=/dev/urandom of=$file bs=1M count=2 ||
20356 error "failed to create a file"
20357 cancel_lru_locks osc
20360 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
20361 error "failed to read a file"
20363 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
20364 $LCTL set_param fail_loc=0x8000031f
20366 cancel_lru_locks osc &
20369 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
20370 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
20371 #IO takes another lock, but matches the PENDING one
20372 #and places it to the IO RPC
20373 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
20374 error "failed to read a file with PENDING lock"
20376 run_test 275 "Read on a canceled duplicate lock"
20379 remote_ost_nodsh && skip "remote OST with nodsh"
20382 do_facet ost1 "(while true; do \
20383 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
20384 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
20387 for LOOP in $(seq 20); do
20389 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
20392 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
20393 rm $TMP/sanity_276_pid"
20395 run_test 276 "Race between mount and obd_statfs"
20398 $LCTL set_param ldlm.namespaces.*.lru_size=0
20399 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
20400 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
20401 grep ^used_mb | awk '{print $2}')
20402 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
20403 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
20404 oflag=direct conv=notrunc
20405 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
20406 grep ^used_mb | awk '{print $2}')
20407 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
20409 run_test 277 "Direct IO shall drop page cache"
20412 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
20413 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
20414 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
20415 skip "needs the same host for mdt1 mdt2" && return
20420 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
20421 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
20427 echo "Starting MDTs"
20428 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
20430 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
20432 do_facet mds2 $LCTL set_param fail_loc=0
20434 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
20435 wait_recovery_complete mds2
20437 run_test 278 "Race starting MDS between MDTs stop/start"
20440 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
20441 skip "Need MGS version at least 2.13.52"
20442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20443 combined_mgs_mds || skip "needs combined MGS/MDT"
20445 umount_client $MOUNT
20446 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
20447 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
20449 mount_client $MOUNT &
20451 stop mgs || error "stop mgs failed"
20452 #for a race mgs would crash
20453 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
20454 mount_client $MOUNT || error "mount client failed"
20456 run_test 280 "Race between MGS umount and client llog processing"
20458 cleanup_test_300() {
20462 test_striped_dir() {
20467 mkdir -p $DIR/$tdir
20469 SAVE_UMASK=$(umask)
20470 trap cleanup_test_300 RETURN EXIT
20472 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
20473 $DIR/$tdir/striped_dir ||
20474 error "set striped dir error"
20476 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
20477 [ "$mode" = "755" ] || error "expect 755 got $mode"
20479 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
20480 error "getdirstripe failed"
20481 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
20482 if [ "$stripe_count" != "2" ]; then
20483 error "1:stripe_count is $stripe_count, expect 2"
20485 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
20486 if [ "$stripe_count" != "2" ]; then
20487 error "2:stripe_count is $stripe_count, expect 2"
20490 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
20491 if [ "$stripe_index" != "$mdt_index" ]; then
20492 error "stripe_index is $stripe_index, expect $mdt_index"
20495 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
20496 error "nlink error after create striped dir"
20498 mkdir $DIR/$tdir/striped_dir/a
20499 mkdir $DIR/$tdir/striped_dir/b
20501 stat $DIR/$tdir/striped_dir/a ||
20502 error "create dir under striped dir failed"
20503 stat $DIR/$tdir/striped_dir/b ||
20504 error "create dir under striped dir failed"
20506 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
20507 error "nlink error after mkdir"
20509 rmdir $DIR/$tdir/striped_dir/a
20510 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
20511 error "nlink error after rmdir"
20513 rmdir $DIR/$tdir/striped_dir/b
20514 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
20515 error "nlink error after rmdir"
20517 chattr +i $DIR/$tdir/striped_dir
20518 createmany -o $DIR/$tdir/striped_dir/f 10 &&
20519 error "immutable flags not working under striped dir!"
20520 chattr -i $DIR/$tdir/striped_dir
20522 rmdir $DIR/$tdir/striped_dir ||
20523 error "rmdir striped dir error"
20531 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20532 skip "skipped for lustre < 2.7.0"
20533 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20534 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20536 test_striped_dir 0 || error "failed on striped dir on MDT0"
20537 test_striped_dir 1 || error "failed on striped dir on MDT0"
20539 run_test 300a "basic striped dir sanity test"
20542 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20543 skip "skipped for lustre < 2.7.0"
20544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20545 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20552 test_mkdir $DIR/$tdir || error "mkdir fail"
20553 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20554 error "set striped dir error"
20555 for i in {0..9}; do
20556 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
20558 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
20559 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
20560 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
20562 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
20563 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
20564 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
20568 run_test 300b "check ctime/mtime for striped dir"
20571 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20572 skip "skipped for lustre < 2.7.0"
20573 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20574 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20578 mkdir -p $DIR/$tdir
20579 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
20580 error "set striped dir error"
20582 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
20583 error "chown striped dir failed"
20585 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
20586 error "create 5k files failed"
20588 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
20590 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
20594 run_test 300c "chown && check ls under striped directory"
20597 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20598 skip "skipped for lustre < 2.7.0"
20599 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20600 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20605 mkdir -p $DIR/$tdir
20606 $LFS setstripe -c 2 $DIR/$tdir
20608 #local striped directory
20609 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20610 error "set striped dir error"
20611 #look at the directories for debug purposes
20613 $LFS getdirstripe $DIR/$tdir
20614 ls -l $DIR/$tdir/striped_dir
20615 $LFS getdirstripe $DIR/$tdir/striped_dir
20616 createmany -o $DIR/$tdir/striped_dir/f 10 ||
20617 error "create 10 files failed"
20619 #remote striped directory
20620 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
20621 error "set striped dir error"
20622 #look at the directories for debug purposes
20624 $LFS getdirstripe $DIR/$tdir
20625 ls -l $DIR/$tdir/remote_striped_dir
20626 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
20627 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
20628 error "create 10 files failed"
20630 for file in $(find $DIR/$tdir); do
20631 stripe_count=$($LFS getstripe -c $file)
20632 [ $stripe_count -eq 2 ] ||
20633 error "wrong stripe $stripe_count for $file"
20638 run_test 300d "check default stripe under striped directory"
20641 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20642 skip "Need MDS version at least 2.7.55"
20643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20644 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20649 mkdir -p $DIR/$tdir
20651 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20652 error "set striped dir error"
20654 touch $DIR/$tdir/striped_dir/a
20655 touch $DIR/$tdir/striped_dir/b
20656 touch $DIR/$tdir/striped_dir/c
20658 mkdir $DIR/$tdir/striped_dir/dir_a
20659 mkdir $DIR/$tdir/striped_dir/dir_b
20660 mkdir $DIR/$tdir/striped_dir/dir_c
20662 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
20663 error "set striped adir under striped dir error"
20665 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
20666 error "set striped bdir under striped dir error"
20668 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
20669 error "set striped cdir under striped dir error"
20671 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
20672 error "rename dir under striped dir fails"
20674 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
20675 error "rename dir under different stripes fails"
20677 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
20678 error "rename file under striped dir should succeed"
20680 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
20681 error "rename dir under striped dir should succeed"
20685 run_test 300e "check rename under striped directory"
20688 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20689 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20690 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20691 skip "Need MDS version at least 2.7.55"
20697 mkdir -p $DIR/$tdir
20699 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20700 error "set striped dir error"
20702 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
20703 error "set striped dir error"
20705 touch $DIR/$tdir/striped_dir/a
20706 mkdir $DIR/$tdir/striped_dir/dir_a
20707 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
20708 error "create striped dir under striped dir fails"
20710 touch $DIR/$tdir/striped_dir1/b
20711 mkdir $DIR/$tdir/striped_dir1/dir_b
20712 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
20713 error "create striped dir under striped dir fails"
20715 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
20716 error "rename dir under different striped dir should fail"
20718 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
20719 error "rename striped dir under diff striped dir should fail"
20721 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
20722 error "rename file under diff striped dirs fails"
20726 run_test 300f "check rename cross striped directory"
20728 test_300_check_default_striped_dir()
20731 local default_count=$2
20732 local default_index=$3
20735 local dir_stripe_index
20738 echo "checking $dirname $default_count $default_index"
20739 $LFS setdirstripe -D -c $default_count -i $default_index \
20740 -t all_char $DIR/$tdir/$dirname ||
20741 error "set default stripe on striped dir error"
20742 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
20743 [ $stripe_count -eq $default_count ] ||
20744 error "expect $default_count get $stripe_count for $dirname"
20746 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
20747 [ $stripe_index -eq $default_index ] ||
20748 error "expect $default_index get $stripe_index for $dirname"
20750 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
20751 error "create dirs failed"
20753 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
20754 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
20755 for dir in $(find $DIR/$tdir/$dirname/*); do
20756 stripe_count=$($LFS getdirstripe -c $dir)
20757 [ $stripe_count -eq $default_count ] ||
20758 [ $stripe_count -eq 0 ] || [ $default_count -eq 1 ] ||
20759 error "stripe count $default_count != $stripe_count for $dir"
20761 stripe_index=$($LFS getdirstripe -i $dir)
20762 [ $default_index -eq -1 ] ||
20763 [ $stripe_index -eq $default_index ] ||
20764 error "$stripe_index != $default_index for $dir"
20766 #check default stripe
20767 stripe_count=$($LFS getdirstripe -D -c $dir)
20768 [ $stripe_count -eq $default_count ] ||
20769 error "default count $default_count != $stripe_count for $dir"
20771 stripe_index=$($LFS getdirstripe -D -i $dir)
20772 [ $stripe_index -eq $default_index ] ||
20773 error "default index $default_index != $stripe_index for $dir"
20775 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
20779 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20780 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20781 skip "Need MDS version at least 2.7.55"
20788 mkdir $DIR/$tdir/normal_dir
20790 #Checking when client cache stripe index
20791 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
20792 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
20793 error "create striped_dir failed"
20795 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
20796 error "create dir0 fails"
20797 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
20798 [ $stripe_index -eq 0 ] ||
20799 error "dir0 expect index 0 got $stripe_index"
20801 mkdir $DIR/$tdir/striped_dir/dir1 ||
20802 error "create dir1 fails"
20803 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
20804 [ $stripe_index -eq 1 ] ||
20805 error "dir1 expect index 1 got $stripe_index"
20807 #check default stripe count/stripe index
20808 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
20809 test_300_check_default_striped_dir normal_dir 1 0
20810 test_300_check_default_striped_dir normal_dir 2 1
20811 test_300_check_default_striped_dir normal_dir 2 -1
20813 #delete default stripe information
20814 echo "delete default stripeEA"
20815 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
20816 error "set default stripe on striped dir error"
20818 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
20819 for dir in $(find $DIR/$tdir/normal_dir/*); do
20820 stripe_count=$($LFS getdirstripe -c $dir)
20821 [ $stripe_count -eq 0 ] ||
20822 error "expect 1 get $stripe_count for $dir"
20823 stripe_index=$($LFS getdirstripe -i $dir)
20824 [ $stripe_index -eq 0 ] ||
20825 error "expect 0 get $stripe_index for $dir"
20828 run_test 300g "check default striped directory for normal directory"
20831 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20832 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20833 skip "Need MDS version at least 2.7.55"
20839 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
20840 error "set striped dir error"
20842 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
20843 test_300_check_default_striped_dir striped_dir 1 0
20844 test_300_check_default_striped_dir striped_dir 2 1
20845 test_300_check_default_striped_dir striped_dir 2 -1
20847 #delete default stripe information
20848 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
20849 error "set default stripe on striped dir error"
20851 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
20852 for dir in $(find $DIR/$tdir/striped_dir/*); do
20853 stripe_count=$($LFS getdirstripe -c $dir)
20854 [ $stripe_count -eq 0 ] ||
20855 error "expect 1 get $stripe_count for $dir"
20858 run_test 300h "check default striped directory for striped directory"
20861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20862 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20863 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20864 skip "Need MDS version at least 2.7.55"
20871 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
20872 error "set striped dir error"
20874 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
20875 error "create files under striped dir failed"
20877 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
20878 error "set striped hashdir error"
20880 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
20881 error "create dir0 under hash dir failed"
20882 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
20883 error "create dir1 under hash dir failed"
20885 # unfortunately, we need to umount to clear dir layout cache for now
20886 # once we fully implement dir layout, we can drop this
20887 umount_client $MOUNT || error "umount failed"
20888 mount_client $MOUNT || error "mount failed"
20890 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
20891 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
20892 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
20894 #set the stripe to be unknown hash type
20895 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
20896 $LCTL set_param fail_loc=0x1901
20897 for ((i = 0; i < 10; i++)); do
20898 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
20899 error "stat f-$i failed"
20900 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
20903 touch $DIR/$tdir/striped_dir/f0 &&
20904 error "create under striped dir with unknown hash should fail"
20906 $LCTL set_param fail_loc=0
20908 umount_client $MOUNT || error "umount failed"
20909 mount_client $MOUNT || error "mount failed"
20913 run_test 300i "client handle unknown hash type striped directory"
20916 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20917 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20918 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20919 skip "Need MDS version at least 2.7.55"
20926 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
20927 $LCTL set_param fail_loc=0x1702
20928 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
20929 error "set striped dir error"
20931 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
20932 error "create files under striped dir failed"
20934 $LCTL set_param fail_loc=0
20936 rm -rf $DIR/$tdir || error "unlink striped dir fails"
20940 run_test 300j "test large update record"
20943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20944 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20945 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20946 skip "Need MDS version at least 2.7.55"
20948 # this test needs a huge transaction
20950 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
20951 osd*.$FSNAME-MDT0000.kbytestotal")
20952 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
20959 #define OBD_FAIL_LARGE_STRIPE 0x1703
20960 $LCTL set_param fail_loc=0x1703
20961 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
20962 error "set striped dir error"
20963 $LCTL set_param fail_loc=0
20965 $LFS getdirstripe $DIR/$tdir/striped_dir ||
20966 error "getstripeddir fails"
20967 rm -rf $DIR/$tdir/striped_dir ||
20968 error "unlink striped dir fails"
20972 run_test 300k "test large striped directory"
20975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20976 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20977 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20978 skip "Need MDS version at least 2.7.55"
20982 test_mkdir -p $DIR/$tdir/striped_dir
20983 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
20984 error "chown $RUNAS_ID failed"
20985 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
20986 error "set default striped dir failed"
20988 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
20989 $LCTL set_param fail_loc=0x80000158
20990 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
20992 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
20993 [ $stripe_index -eq 1 ] ||
20994 error "expect 1 get $stripe_index for $dir"
20996 run_test 300l "non-root user to create dir under striped dir with stale layout"
20999 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21000 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
21001 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
21002 skip "Need MDS version at least 2.7.55"
21004 mkdir -p $DIR/$tdir/striped_dir
21005 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
21006 error "set default stripes dir error"
21008 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
21010 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
21011 [ $stripe_count -eq 0 ] ||
21012 error "expect 0 get $stripe_count for a"
21014 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
21015 error "set default stripes dir error"
21017 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
21019 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
21020 [ $stripe_count -eq 0 ] ||
21021 error "expect 0 get $stripe_count for b"
21023 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
21024 error "set default stripes dir error"
21026 mkdir $DIR/$tdir/striped_dir/c &&
21027 error "default stripe_index is invalid, mkdir c should fails"
21029 rm -rf $DIR/$tdir || error "rmdir fails"
21031 run_test 300m "setstriped directory on single MDT FS"
21034 local list=$(comma_list $(mdts_nodes))
21037 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
21041 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21042 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21043 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
21044 skip "Need MDS version at least 2.7.55"
21045 remote_mds_nodsh && skip "remote MDS with nodsh"
21048 local list=$(comma_list $(mdts_nodes))
21050 trap cleanup_300n RETURN EXIT
21051 mkdir -p $DIR/$tdir
21052 chmod 777 $DIR/$tdir
21053 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
21054 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
21055 error "create striped dir succeeds with gid=0"
21057 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
21058 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
21059 error "create striped dir fails with gid=-1"
21061 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
21062 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
21063 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
21064 error "set default striped dir succeeds with gid=0"
21067 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
21068 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
21069 error "set default striped dir fails with gid=-1"
21072 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
21073 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
21074 error "create test_dir fails"
21075 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
21076 error "create test_dir1 fails"
21077 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
21078 error "create test_dir2 fails"
21081 run_test 300n "non-root user to create dir under striped dir with default EA"
21084 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21085 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21086 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
21087 skip "Need MDS version at least 2.7.55"
21092 mkdir -p $DIR/$tdir
21094 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
21095 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
21096 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
21097 skip "not enough free inodes $numfree1 $numfree2"
21100 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
21101 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
21102 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
21103 skip "not enough free space $numfree1 $numfree2"
21106 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
21107 error "setdirstripe fails"
21109 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
21110 error "create dirs fails"
21112 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
21113 ls $DIR/$tdir/striped_dir > /dev/null ||
21114 error "ls striped dir fails"
21115 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
21116 error "unlink big striped dir fails"
21118 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
21121 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21122 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21123 remote_mds_nodsh && skip "remote MDS with nodsh"
21125 mkdir -p $DIR/$tdir
21127 #define OBD_FAIL_OUT_ENOSPC 0x1704
21128 do_facet mds2 lctl set_param fail_loc=0x80001704
21129 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
21130 && error "create striped directory should fail"
21132 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
21134 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
21137 run_test 300p "create striped directory without space"
21140 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21141 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21143 local fd=$(free_fd)
21144 local cmd="exec $fd<$tdir"
21146 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
21149 trap "eval $cmd" EXIT
21150 cd $tdir || error "cd $tdir fails"
21151 rmdir ../$tdir || error "rmdir $tdir fails"
21152 mkdir local_dir && error "create dir succeeds"
21153 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
21157 run_test 300q "create remote directory under orphan directory"
21160 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
21161 skip "Need MDS version at least 2.7.55" && return
21162 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
21166 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
21167 error "set striped dir error"
21169 $LFS getdirstripe $DIR/$tdir/striped_dir ||
21170 error "getstripeddir fails"
21173 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
21174 awk '/lmv_stripe_count:/ { print $2 }')
21176 [ $MDSCOUNT -ne $stripe_count ] &&
21177 error "wrong stripe count $stripe_count expected $MDSCOUNT"
21179 rm -rf $DIR/$tdir/striped_dir ||
21180 error "unlink striped dir fails"
21182 run_test 300r "test -1 striped directory"
21184 prepare_remote_file() {
21185 mkdir $DIR/$tdir/src_dir ||
21186 error "create remote source failed"
21188 cp /etc/hosts $DIR/$tdir/src_dir/a ||
21189 error "cp to remote source failed"
21190 touch $DIR/$tdir/src_dir/a
21192 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
21193 error "create remote target dir failed"
21195 touch $DIR/$tdir/tgt_dir/b
21197 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
21198 error "rename dir cross MDT failed!"
21200 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
21201 error "src_child still exists after rename"
21203 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
21204 error "missing file(a) after rename"
21206 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
21207 error "diff after rename"
21211 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
21212 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21214 local remote_file=$DIR/$tdir/tgt_dir/b
21216 mkdir -p $DIR/$tdir
21218 prepare_remote_file || error "prepare remote file failed"
21221 $OPENUNLINK $remote_file $remote_file ||
21222 error "openunlink $remote_file failed"
21223 $CHECKSTAT -a $remote_file || error "$remote_file exists"
21225 run_test 310a "open unlink remote file"
21228 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
21229 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21231 local remote_file=$DIR/$tdir/tgt_dir/b
21233 mkdir -p $DIR/$tdir
21235 prepare_remote_file || error "prepare remote file failed"
21237 ln $remote_file $DIR/$tfile || error "link failed for remote file"
21238 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
21239 $CHECKSTAT -t file $remote_file || error "check file failed"
21241 run_test 310b "unlink remote file with multiple links while open"
21244 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21245 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
21247 local remote_file=$DIR/$tdir/tgt_dir/b
21249 mkdir -p $DIR/$tdir
21251 prepare_remote_file || error "prepare remote file failed"
21253 ln $remote_file $DIR/$tfile || error "link failed for remote file"
21254 multiop_bg_pause $remote_file O_uc ||
21255 error "mulitop failed for remote file"
21257 $MULTIOP $DIR/$tfile Ouc
21258 kill -USR1 $MULTIPID
21261 run_test 310c "open-unlink remote file with multiple links"
21265 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21266 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
21267 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
21268 skip "lustre < 2.8.54 does not contain LU-4825 fix"
21269 remote_mds_nodsh && skip "remote MDS with nodsh"
21271 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
21272 local mdts=$(comma_list $(mdts_nodes))
21274 mkdir -p $DIR/$tdir
21275 $LFS setstripe -i 0 -c 1 $DIR/$tdir
21276 createmany -o $DIR/$tdir/$tfile. 1000
21278 # statfs data is not real time, let's just calculate it
21279 old_iused=$((old_iused + 1000))
21281 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
21282 osp.*OST0000*MDT0000.create_count")
21283 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
21284 osp.*OST0000*MDT0000.max_create_count")
21285 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
21287 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
21288 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
21289 [ $index -ne 0 ] || error "$tfile stripe index is 0"
21291 unlinkmany $DIR/$tdir/$tfile. 1000
21293 do_nodes $mdts "$LCTL set_param -n \
21294 osp.*OST0000*.max_create_count=$max_count"
21295 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
21296 do_nodes $mdts "$LCTL set_param -n \
21297 osp.*OST0000*.create_count=$count"
21298 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
21299 grep "=0" && error "create_count is zero"
21302 for i in $(seq 120); do
21303 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
21304 # system may be too busy to destroy all objs in time, use
21305 # a somewhat small value to not fail autotest
21306 [ $((old_iused - new_iused)) -gt 400 ] && break
21310 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
21311 [ $((old_iused - new_iused)) -gt 400 ] ||
21312 error "objs not destroyed after unlink"
21314 run_test 311 "disable OSP precreate, and unlink should destroy objs"
21321 local vdevdir=$(dirname $(facet_vdevice $ost))
21322 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
21323 local zfs_zapid=$(do_facet $ost $cmd |
21324 grep -w "/O/0/d$((objid%32))" -C 5 |
21325 awk '/Object/{getline; print $1}')
21326 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
21327 awk "/$objid = /"'{printf $3}')
21332 zfs_object_blksz() {
21336 local vdevdir=$(dirname $(facet_vdevice $ost))
21337 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
21338 local blksz=$(do_facet $ost $cmd $objid |
21339 awk '/dblk/{getline; printf $4}')
21341 case "${blksz: -1}" in
21342 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
21343 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
21350 test_312() { # LU-4856
21351 remote_ost_nodsh && skip "remote OST with nodsh"
21352 [ "$ost1_FSTYPE" = "zfs" ] ||
21353 skip_env "the test only applies to zfs"
21355 local max_blksz=$(do_facet ost1 \
21356 $ZFS get -p recordsize $(facet_device ost1) |
21357 awk '!/VALUE/{print $3}')
21359 # to make life a little bit easier
21360 $LFS mkdir -c 1 -i 0 $DIR/$tdir
21361 $LFS setstripe -c 1 -i 0 $DIR/$tdir
21363 local tf=$DIR/$tdir/$tfile
21365 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
21367 # Get ZFS object id
21368 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
21369 # block size change by sequential overwrite
21372 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
21373 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
21375 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
21376 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
21380 # block size change by sequential append write
21381 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
21382 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
21383 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
21386 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
21387 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
21388 oflag=sync conv=notrunc
21390 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21391 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
21392 error "blksz error, actual $blksz, " \
21393 "expected: 2 * $count * $PAGE_SIZE"
21399 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
21400 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
21402 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
21403 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21404 [ $blksz -eq $PAGE_SIZE ] ||
21405 error "blksz error: $blksz, expected: $PAGE_SIZE"
21407 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
21408 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21409 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
21411 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
21412 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21413 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
21415 run_test 312 "make sure ZFS adjusts its block size by write pattern"
21418 remote_ost_nodsh && skip "remote OST with nodsh"
21420 local file=$DIR/$tfile
21423 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
21425 # define OBD_FAIL_TGT_RCVD_EIO 0x720
21426 do_facet ost1 "$LCTL set_param fail_loc=0x720"
21427 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
21428 error "write should failed"
21429 do_facet ost1 "$LCTL set_param fail_loc=0"
21432 run_test 313 "io should fail after last_rcvd update fail"
21435 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
21437 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
21438 do_facet ost1 "$LCTL set_param fail_loc=0x720"
21440 wait_delete_completed
21441 do_facet ost1 "$LCTL set_param fail_loc=0"
21443 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
21445 test_315() { # LU-618
21446 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
21448 local file=$DIR/$tfile
21451 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
21452 error "multiop file write failed"
21453 $MULTIOP $file oO_RDONLY:r4063232_c &
21458 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
21461 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
21464 run_test 315 "read should be accounted"
21467 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21468 large_xattr_enabled || skip_env "ea_inode feature disabled"
21470 rm -rf $DIR/$tdir/d
21471 mkdir -p $DIR/$tdir/d
21472 chown nobody $DIR/$tdir/d
21473 touch $DIR/$tdir/d/file
21475 $LFS mv -m1 $DIR/$tdir/d || error "lfs mv failed"
21477 run_test 316 "lfs mv"
21480 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
21481 skip "Need MDS version at least 2.11.53"
21482 if [ "$ost1_FSTYPE" == "zfs" ]; then
21483 skip "LU-10370: no implementation for ZFS"
21487 local grant_blk_size
21489 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
21490 awk '/grant_block_size:/ { print $2; exit; }')
21492 # Create File of size 5M. Truncate it to below size's and verify
21495 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
21496 error "Create file $DIR/$tfile failed"
21497 stack_trap "rm -f $DIR/$tfile" EXIT
21499 for trunc_sz in 2097152 4097 4000 509 0; do
21500 $TRUNCATE $DIR/$tfile $trunc_sz ||
21501 error "truncate $tfile to $trunc_sz failed"
21502 local sz=$(stat --format=%s $DIR/$tfile)
21503 local blk=$(stat --format=%b $DIR/$tfile)
21504 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
21505 grant_blk_size) * 8))
21507 if [[ $blk -ne $trunc_blk ]]; then
21508 $(which stat) $DIR/$tfile
21509 error "Expected Block $trunc_blk got $blk for $tfile"
21512 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
21513 error "Expected Size $trunc_sz got $sz for $tfile"
21518 # Create file with a hole and write actual two blocks. Block count
21521 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
21522 conv=fsync || error "Create file : $DIR/$tfile"
21524 # Calculate the final truncate size.
21525 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
21528 # truncate to size $trunc_sz bytes. Strip the last block
21529 # The block count must drop to 8
21531 $TRUNCATE $DIR/$tfile $trunc_sz ||
21532 error "truncate $tfile to $trunc_sz failed"
21534 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
21535 sz=$(stat --format=%s $DIR/$tfile)
21536 blk=$(stat --format=%b $DIR/$tfile)
21538 if [[ $blk -ne $trunc_bsz ]]; then
21539 $(which stat) $DIR/$tfile
21540 error "Expected Block $trunc_bsz got $blk for $tfile"
21543 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
21544 error "Expected Size $trunc_sz got $sz for $tfile"
21546 run_test 317 "Verify blocks get correctly update after truncate"
21549 local old_max_active=$($LCTL get_param -n \
21550 llite.*.max_read_ahead_async_active 2>/dev/null)
21552 $LCTL set_param llite.*.max_read_ahead_async_active=256
21553 local max_active=$($LCTL get_param -n \
21554 llite.*.max_read_ahead_async_active 2>/dev/null)
21555 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
21557 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
21558 error "set max_read_ahead_async_active should succeed"
21560 $LCTL set_param llite.*.max_read_ahead_async_active=512
21561 max_active=$($LCTL get_param -n \
21562 llite.*.max_read_ahead_async_active 2>/dev/null)
21563 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
21565 # restore @max_active
21566 [ $old_max_active -ne 0 ] && $LCTL set_param \
21567 llite.*.max_read_ahead_async_active=$old_max_active
21569 local old_threshold=$($LCTL get_param -n \
21570 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
21571 local max_per_file_mb=$($LCTL get_param -n \
21572 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
21574 local invalid=$(($max_per_file_mb + 1))
21576 llite.*.read_ahead_async_file_threshold_mb=$invalid\
21577 && error "set $invalid should fail"
21579 local valid=$(($invalid - 1))
21581 llite.*.read_ahead_async_file_threshold_mb=$valid ||
21582 error "set $valid should succeed"
21583 local threshold=$($LCTL get_param -n \
21584 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
21585 [ $threshold -eq $valid ] || error \
21586 "expect threshold $valid got $threshold"
21588 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
21590 run_test 318 "Verify async readahead tunables"
21593 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
21595 local before=$(date +%s)
21597 local mdir=$DIR/$tdir
21598 local file=$mdir/xxx
21600 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
21603 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
21604 $LCTL set_param fail_val=5 fail_loc=0x8000032c
21605 $LFS mv -m1 $file &
21608 dd if=$file of=/dev/null
21610 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
21611 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
21613 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
21615 run_test 319 "lost lease lock on migrate error"
21617 test_398a() { # LU-4198
21618 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21619 $LCTL set_param ldlm.namespaces.*.lru_size=clear
21621 # request a new lock on client
21622 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21624 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
21625 local lock_count=$($LCTL get_param -n \
21626 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
21627 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
21629 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
21631 # no lock cached, should use lockless IO and not enqueue new lock
21632 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
21633 lock_count=$($LCTL get_param -n \
21634 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
21635 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
21637 run_test 398a "direct IO should cancel lock otherwise lockless"
21639 test_398b() { # LU-4198
21640 which fio || skip_env "no fio installed"
21641 $LFS setstripe -c -1 $DIR/$tfile
21644 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
21647 echo "mix direct rw ${size}M to OST0 by fio with $njobs jobs..."
21648 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
21649 --numjobs=$njobs --fallocate=none \
21650 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21651 --filename=$DIR/$tfile &
21654 echo "mix buffer rw ${size}M to OST0 by fio with $njobs jobs..."
21655 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE \
21656 --numjobs=$njobs --fallocate=none \
21657 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21658 --filename=$DIR/$tfile || true
21663 run_test 398b "DIO and buffer IO race"
21665 test_398c() { # LU-4198
21666 which fio || skip_env "no fio installed"
21668 saved_debug=$($LCTL get_param -n debug)
21669 $LCTL set_param debug=0
21671 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
21672 ((size /= 1024)) # by megabytes
21673 ((size /= 2)) # write half of the OST at most
21674 [ $size -gt 40 ] && size=40 #reduce test time anyway
21676 $LFS setstripe -c 1 $DIR/$tfile
21678 # it seems like ldiskfs reserves more space than necessary if the
21679 # writing blocks are not mapped, so it extends the file firstly
21680 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
21681 cancel_lru_locks osc
21683 # clear and verify rpc_stats later
21684 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
21687 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
21688 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
21689 --numjobs=$njobs --fallocate=none --ioengine=libaio \
21690 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21691 --filename=$DIR/$tfile
21692 [ $? -eq 0 ] || error "fio write error"
21694 [ $($LCTL get_param -n \
21695 ldlm.namespaces.${FSNAME}-OST0000-osc-ffff*.lock_count) -eq 0 ] ||
21696 error "Locks were requested while doing AIO"
21698 # get the percentage of 1-page I/O
21699 pct=$($LCTL get_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats |
21700 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
21702 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
21704 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
21705 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
21706 --numjobs=$njobs --fallocate=none --ioengine=libaio \
21707 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21708 --filename=$DIR/$tfile
21709 [ $? -eq 0 ] || error "fio mixed read write error"
21712 $LCTL set_param debug="$saved_debug"
21714 run_test 398c "run fio to test AIO"
21717 local read_write=$1
21718 if [ "$read_write" = "write" ]; then
21719 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
21720 elif [ "$read_write" = "read" ]; then
21721 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
21723 error "argument error"
21726 # turn off debug for performance testing
21727 local saved_debug=$($LCTL get_param -n debug)
21728 $LCTL set_param debug=0
21730 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21732 # get ost1 size - $FSNAME-OST0000
21733 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
21734 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
21735 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
21737 if [ "$read_write" = "read" ]; then
21738 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
21741 local start_time=$(date +%s.%N)
21742 $dd_cmd bs=1M count=$blocks oflag=sync ||
21743 error "real dd $read_write error"
21744 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
21746 if [ "$read_write" = "write" ]; then
21750 # define OBD_FAIL_OST_FAKE_RW 0x238
21751 do_facet ost1 $LCTL set_param fail_loc=0x238
21753 local start_time=$(date +%s.%N)
21754 $dd_cmd bs=1M count=$blocks oflag=sync ||
21755 error "fake dd $read_write error"
21756 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
21758 if [ "$read_write" = "write" ]; then
21760 cancel_lru_locks osc
21761 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
21762 error "$tfile size not $blocks MB"
21764 do_facet ost1 $LCTL set_param fail_loc=0
21766 echo "fake $read_write $duration_fake vs. normal $read_write" \
21767 "$duration in seconds"
21768 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
21769 error_not_in_vm "fake write is slower"
21771 $LCTL set_param -n debug="$saved_debug"
21774 test_399a() { # LU-7655 for OST fake write
21775 remote_ost_nodsh && skip "remote OST with nodsh"
21779 run_test 399a "fake write should not be slower than normal write"
21781 test_399b() { # LU-8726 for OST fake read
21782 remote_ost_nodsh && skip "remote OST with nodsh"
21783 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
21784 skip_env "ldiskfs only test"
21789 run_test 399b "fake read should not be slower than normal read"
21791 test_400a() { # LU-1606, was conf-sanity test_74
21792 if ! which $CC > /dev/null 2>&1; then
21793 skip_env "$CC is not installed"
21796 local extra_flags=''
21797 local out=$TMP/$tfile
21798 local prefix=/usr/include/lustre
21801 # Oleg removes c files in his test rig so test if any c files exist
21802 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
21803 skip_env "Needed c test files are missing"
21805 if ! [[ -d $prefix ]]; then
21806 # Assume we're running in tree and fixup the include path.
21807 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
21808 extra_flags+=" -L$LUSTRE/utils/.lib"
21811 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
21812 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
21813 error "client api broken"
21817 run_test 400a "Lustre client api program can compile and link"
21819 test_400b() { # LU-1606, LU-5011
21821 local out=$TMP/$tfile
21822 local prefix=/usr/include/linux/lustre
21824 # We use a hard coded prefix so that this test will not fail
21825 # when run in tree. There are headers in lustre/include/lustre/
21826 # that are not packaged (like lustre_idl.h) and have more
21827 # complicated include dependencies (like config.h and lnet/types.h).
21828 # Since this test about correct packaging we just skip them when
21829 # they don't exist (see below) rather than try to fixup cppflags.
21831 if ! which $CC > /dev/null 2>&1; then
21832 skip_env "$CC is not installed"
21835 for header in $prefix/*.h; do
21836 if ! [[ -f "$header" ]]; then
21840 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
21841 continue # lustre_ioctl.h is internal header
21844 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
21845 error "cannot compile '$header'"
21849 run_test 400b "packaged headers can be compiled"
21851 test_401a() { #LU-7437
21852 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
21853 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
21855 #count the number of parameters by "list_param -R"
21856 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
21857 #count the number of parameters by listing proc files
21858 local proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
21859 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
21860 echo "proc_dirs='$proc_dirs'"
21861 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
21862 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
21865 [ $params -eq $procs ] ||
21866 error "found $params parameters vs. $procs proc files"
21868 # test the list_param -D option only returns directories
21869 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
21870 #count the number of parameters by listing proc directories
21871 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
21874 [ $params -eq $procs ] ||
21875 error "found $params parameters vs. $procs proc files"
21877 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
21880 local save=$($LCTL get_param -n jobid_var)
21883 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
21884 error "no error returned when setting bad parameters"
21886 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
21887 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
21889 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
21890 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
21891 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
21893 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
21896 local jobid_var_old=$($LCTL get_param -n jobid_var)
21897 local jobid_var_new
21899 $LCTL set_param jobid_var= &&
21900 error "no error returned for 'set_param a='"
21902 jobid_var_new=$($LCTL get_param -n jobid_var)
21903 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
21904 error "jobid_var was changed by setting without value"
21906 $LCTL set_param jobid_var &&
21907 error "no error returned for 'set_param a'"
21909 jobid_var_new=$($LCTL get_param -n jobid_var)
21910 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
21911 error "jobid_var was changed by setting without value"
21913 run_test 401c "Verify 'lctl set_param' without value fails in either format."
21916 local jobid_var_old=$($LCTL get_param -n jobid_var)
21917 local jobid_var_new
21918 local new_value="foo=bar"
21920 $LCTL set_param jobid_var=$new_value ||
21921 error "'set_param a=b' did not accept a value containing '='"
21923 jobid_var_new=$($LCTL get_param -n jobid_var)
21924 [[ "$jobid_var_new" == "$new_value" ]] ||
21925 error "'set_param a=b' failed on a value containing '='"
21927 # Reset the jobid_var to test the other format
21928 $LCTL set_param jobid_var=$jobid_var_old
21929 jobid_var_new=$($LCTL get_param -n jobid_var)
21930 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
21931 error "failed to reset jobid_var"
21933 $LCTL set_param jobid_var $new_value ||
21934 error "'set_param a b' did not accept a value containing '='"
21936 jobid_var_new=$($LCTL get_param -n jobid_var)
21937 [[ "$jobid_var_new" == "$new_value" ]] ||
21938 error "'set_param a b' failed on a value containing '='"
21940 $LCTL set_param jobid_var $jobid_var_old
21941 jobid_var_new=$($LCTL get_param -n jobid_var)
21942 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
21943 error "failed to reset jobid_var"
21945 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
21948 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
21949 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
21950 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
21951 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
21952 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
21953 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
21954 remote_mds_nodsh && skip "remote MDS with nodsh"
21956 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
21957 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
21958 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
21959 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
21960 echo "Touch failed - OK"
21962 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
21965 local file1=$DIR/$tfile.1
21966 local file2=$DIR/$tfile.2
21967 local tfile=$TMP/$tfile
21969 rm -f $file1 $file2 $tfile
21974 # 30 sec OBD_TIMEOUT in ll_getattr()
21975 # right before populating st_nlink
21976 $LCTL set_param fail_loc=0x80001409
21977 stat -c %h $file1 > $tfile &
21979 # create an alias, drop all locks and reclaim the dentry
21981 cancel_lru_locks mdc
21982 cancel_lru_locks osc
21983 sysctl -w vm.drop_caches=2
21987 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
21989 rm -f $tfile $file1 $file2
21991 run_test 403 "i_nlink should not drop to zero due to aliasing"
21993 test_404() { # LU-6601
21994 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
21995 skip "Need server version newer than 2.8.52"
21996 remote_mds_nodsh && skip "remote MDS with nodsh"
21998 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
21999 awk '/osp .*-osc-MDT/ { print $4}')
22002 for osp in $mosps; do
22003 echo "Deactivate: " $osp
22004 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
22005 local stat=$(do_facet $SINGLEMDS $LCTL dl |
22006 awk -vp=$osp '$4 == p { print $2 }')
22007 [ $stat = IN ] || {
22008 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
22009 error "deactivate error"
22011 echo "Activate: " $osp
22012 do_facet $SINGLEMDS $LCTL --device %$osp activate
22013 local stat=$(do_facet $SINGLEMDS $LCTL dl |
22014 awk -vp=$osp '$4 == p { print $2 }')
22015 [ $stat = UP ] || {
22016 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
22017 error "activate error"
22021 run_test 404 "validate manual {de}activated works properly for OSPs"
22024 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
22025 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
22026 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
22027 skip "Layout swap lock is not supported"
22029 check_swap_layouts_support
22031 test_mkdir $DIR/$tdir
22032 swap_lock_test -d $DIR/$tdir ||
22033 error "One layout swap locked test failed"
22035 run_test 405 "Various layout swap lock tests"
22038 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22039 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
22040 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
22041 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22042 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
22043 skip "Need MDS version at least 2.8.50"
22045 local def_stripe_size=$($LFS getstripe -S $MOUNT)
22046 local test_pool=$TESTNAME
22048 pool_add $test_pool || error "pool_add failed"
22049 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
22050 error "pool_add_targets failed"
22052 save_layout_restore_at_exit $MOUNT
22054 # parent set default stripe count only, child will stripe from both
22055 # parent and fs default
22056 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
22057 error "setstripe $MOUNT failed"
22058 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
22059 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
22060 for i in $(seq 10); do
22061 local f=$DIR/$tdir/$tfile.$i
22062 touch $f || error "touch failed"
22063 local count=$($LFS getstripe -c $f)
22064 [ $count -eq $OSTCOUNT ] ||
22065 error "$f stripe count $count != $OSTCOUNT"
22066 local offset=$($LFS getstripe -i $f)
22067 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
22068 local size=$($LFS getstripe -S $f)
22069 [ $size -eq $((def_stripe_size * 2)) ] ||
22070 error "$f stripe size $size != $((def_stripe_size * 2))"
22071 local pool=$($LFS getstripe -p $f)
22072 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
22075 # change fs default striping, delete parent default striping, now child
22076 # will stripe from new fs default striping only
22077 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
22078 error "change $MOUNT default stripe failed"
22079 $LFS setstripe -c 0 $DIR/$tdir ||
22080 error "delete $tdir default stripe failed"
22081 for i in $(seq 11 20); do
22082 local f=$DIR/$tdir/$tfile.$i
22083 touch $f || error "touch $f failed"
22084 local count=$($LFS getstripe -c $f)
22085 [ $count -eq 1 ] || error "$f stripe count $count != 1"
22086 local offset=$($LFS getstripe -i $f)
22087 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
22088 local size=$($LFS getstripe -S $f)
22089 [ $size -eq $def_stripe_size ] ||
22090 error "$f stripe size $size != $def_stripe_size"
22091 local pool=$($LFS getstripe -p $f)
22092 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
22095 unlinkmany $DIR/$tdir/$tfile. 1 20
22097 local f=$DIR/$tdir/$tfile
22098 pool_remove_all_targets $test_pool $f
22099 pool_remove $test_pool $f
22101 run_test 406 "DNE support fs default striping"
22104 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22105 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
22106 skip "Need MDS version at least 2.8.55"
22107 remote_mds_nodsh && skip "remote MDS with nodsh"
22109 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
22110 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
22111 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
22112 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
22113 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
22115 #define OBD_FAIL_DT_TXN_STOP 0x2019
22116 for idx in $(seq $MDSCOUNT); do
22117 do_facet mds$idx "lctl set_param fail_loc=0x2019"
22119 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
22120 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
22121 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
22124 run_test 407 "transaction fail should cause operation fail"
22127 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
22129 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
22130 lctl set_param fail_loc=0x8000040a
22131 # let ll_prepare_partial_page() fail
22132 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
22136 # create at least 100 unused inodes so that
22137 # shrink_icache_memory(0) should not return 0
22138 touch $DIR/$tfile-{0..100}
22139 rm -f $DIR/$tfile-{0..100}
22142 echo 2 > /proc/sys/vm/drop_caches
22144 run_test 408 "drop_caches should not hang due to page leaks"
22148 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22150 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
22151 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
22152 touch $DIR/$tdir/guard || error "(2) Fail to create"
22154 local PREFIX=$(str_repeat 'A' 128)
22155 echo "Create 1K hard links start at $(date)"
22156 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
22157 error "(3) Fail to hard link"
22159 echo "Links count should be right although linkEA overflow"
22160 stat $DIR/$tdir/guard || error "(4) Fail to stat"
22161 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
22162 [ $linkcount -eq 1001 ] ||
22163 error "(5) Unexpected hard links count: $linkcount"
22165 echo "List all links start at $(date)"
22166 ls -l $DIR/$tdir/foo > /dev/null ||
22167 error "(6) Fail to list $DIR/$tdir/foo"
22169 echo "Unlink hard links start at $(date)"
22170 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
22171 error "(7) Fail to unlink"
22172 echo "Unlink hard links finished at $(date)"
22174 run_test 409 "Large amount of cross-MDTs hard links on the same file"
22178 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
22179 skip "Need client version at least 2.9.59"
22181 # Create a file, and stat it from the kernel
22182 local testfile=$DIR/$tfile
22185 local run_id=$RANDOM
22186 local my_ino=$(stat --format "%i" $testfile)
22188 # Try to insert the module. This will always fail as the
22189 # module is designed to not be inserted.
22190 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
22193 # Anything but success is a test failure
22195 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
22196 error "no inode match"
22198 run_test 410 "Test inode number returned from kernel thread"
22200 cleanup_test411_cgroup() {
22206 local cg_basedir=/sys/fs/cgroup/memory
22208 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
22209 skip "no setup for cgroup"
22211 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
22212 error "test file creation failed"
22213 cancel_lru_locks osc
22215 # Create a very small memory cgroup to force a slab allocation error
22216 local cgdir=$cg_basedir/osc_slab_alloc
22217 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
22218 trap "cleanup_test411_cgroup $cgdir" EXIT
22219 echo 2M > $cgdir/memory.kmem.limit_in_bytes
22220 echo 1M > $cgdir/memory.limit_in_bytes
22222 # Should not LBUG, just be killed by oom-killer
22223 # dd will return 0 even allocation failure in some environment.
22224 # So don't check return value
22225 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
22226 cleanup_test411_cgroup $cgdir
22230 run_test 411 "Slab allocation error with cgroup does not LBUG"
22233 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22234 if [ $MDS1_VERSION -lt $(version_code 2.10.55) ]; then
22235 skip "Need server version at least 2.10.55"
22238 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
22239 error "mkdir failed"
22240 $LFS getdirstripe $DIR/$tdir
22241 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
22242 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
22243 error "expect $((MDSCOUT - 1)) get $stripe_index"
22244 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
22245 [ $stripe_count -eq 2 ] ||
22246 error "expect 2 get $stripe_count"
22248 run_test 412 "mkdir on specific MDTs"
22252 local stripe_count=$2
22253 local mdts=$(comma_list $(mdts_nodes))
22256 local lmv_qos_prio_free
22257 local lmv_qos_threshold_rr
22258 local lmv_qos_maxage
22259 local lod_qos_prio_free
22260 local lod_qos_threshold_rr
22261 local lod_qos_maxage
22265 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
22266 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
22267 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
22269 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
22270 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
22271 stack_trap "$LCTL set_param \
22272 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null" EXIT
22273 stack_trap "$LCTL set_param \
22274 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
22275 stack_trap "$LCTL set_param \
22276 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" EXIT
22278 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
22279 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
22280 lod_qos_prio_free=${lod_qos_prio_free%%%}
22281 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
22282 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
22283 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
22284 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
22285 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
22286 stack_trap "do_nodes $mdts $LCTL set_param \
22287 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null" EXIT
22288 stack_trap "do_nodes $mdts $LCTL set_param \
22289 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null" \
22291 stack_trap "do_nodes $mdts $LCTL set_param \
22292 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" EXIT
22295 echo "Mkdir (stripe_count $stripe_count) roundrobin:"
22297 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
22298 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
22300 testdir=$DIR/$tdir-s$stripe_count/rr
22302 for i in $(seq $((100 * MDSCOUNT))); do
22303 eval $mkdir_cmd $testdir/subdir$i ||
22304 error "$mkdir_cmd subdir$i failed"
22307 for i in $(seq $MDSCOUNT); do
22308 count=$($LFS getdirstripe -i $testdir/* |
22309 grep ^$((i - 1))$ | wc -l)
22310 echo "$count directories created on MDT$((i - 1))"
22311 [ $count -eq 100 ] || error "subdirs are not evenly distributed"
22313 if [ $stripe_count -gt 1 ]; then
22314 count=$($LFS getdirstripe $testdir/* |
22315 grep -P "^\s+$((i - 1))\t" | wc -l)
22316 echo "$count stripes created on MDT$((i - 1))"
22317 # deviation should < 5% of average
22318 [ $count -lt $((95 * stripe_count)) ] ||
22319 [ $count -gt $((105 * stripe_count)) ] &&
22320 error "stripes are not evenly distributed"
22324 $LCTL set_param lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null
22325 do_nodes $mdts $LCTL set_param \
22326 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null
22329 echo "Check for uneven MDTs: "
22339 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
22340 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
22341 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
22343 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
22344 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
22347 for ((i = 1; i < ${#ffree[@]}; i++)); do
22348 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
22349 if [ $tmp -gt $max ]; then
22353 if [ $tmp -lt $min ]; then
22359 [ ${ffree[min_index]} -eq 0 ] &&
22360 skip "no free files in MDT$min_index"
22361 [ ${ffree[min_index]} -gt 100000000 ] &&
22362 skip "too much free files in MDT$min_index"
22364 # Check if we need to generate uneven MDTs
22366 local diff=$(((max - min) * 100 / min))
22367 local value="$(generate_string 1024)"
22369 while [ $diff -lt $threshold ]; do
22370 # generate uneven MDTs, create till $threshold% diff
22371 echo -n "weight diff=$diff% must be > $threshold% ..."
22372 count=$((${ffree[min_index]} / 10))
22373 # 50 sec per 10000 files in vm
22374 [ $count -gt 40000 ] && [ "$SLOW" = "no" ] &&
22375 skip "$count files to create"
22376 echo "Fill MDT$min_index with $count files"
22377 [ -d $DIR/$tdir-MDT$min_index ] ||
22378 $LFS mkdir -i $min_index $DIR/$tdir-MDT$min_index ||
22379 error "mkdir $tdir-MDT$min_index failed"
22380 for i in $(seq $count); do
22381 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE \
22382 $DIR/$tdir-MDT$min_index/f$j_$i > /dev/null ||
22383 error "create f$j_$i failed"
22384 setfattr -n user.413b -v $value \
22385 $DIR/$tdir-MDT$min_index/f$j_$i ||
22386 error "setfattr f$j_$i failed"
22389 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
22390 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
22391 max=$(((${ffree[max_index]} >> 8) * \
22392 (${bavail[max_index]} * bsize >> 16)))
22393 min=$(((${ffree[min_index]} >> 8) * \
22394 (${bavail[min_index]} * bsize >> 16)))
22395 diff=$(((max - min) * 100 / min))
22398 echo "MDT filesfree available: ${ffree[@]}"
22399 echo "MDT blocks available: ${bavail[@]}"
22400 echo "weight diff=$diff%"
22403 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
22405 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
22406 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
22407 # decrease statfs age, so that it can be updated in time
22408 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
22409 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
22413 testdir=$DIR/$tdir-s$stripe_count/qos
22415 for i in $(seq $((100 * MDSCOUNT))); do
22416 eval $mkdir_cmd $testdir/subdir$i ||
22417 error "$mkdir_cmd subdir$i failed"
22420 for i in $(seq $MDSCOUNT); do
22421 count=$($LFS getdirstripe -i $testdir/* | grep ^$((i - 1))$ |
22423 echo "$count directories created on MDT$((i - 1))"
22425 if [ $stripe_count -gt 1 ]; then
22426 count=$($LFS getdirstripe $testdir/* |
22427 grep -P "^\s+$((i - 1))\t" | wc -l)
22428 echo "$count stripes created on MDT$((i - 1))"
22432 max=$($LFS getdirstripe -i $testdir/* | grep ^$max_index$ | wc -l)
22433 min=$($LFS getdirstripe -i $testdir/* | grep ^$min_index$ | wc -l)
22435 # D-value should > 10% of averge
22436 [ $((max - min)) -lt 10 ] &&
22437 error "subdirs shouldn't be evenly distributed"
22440 if [ $stripe_count -gt 1 ]; then
22441 max=$($LFS getdirstripe $testdir/* |
22442 grep -P "^\s+$max_index\t" | wc -l)
22443 min=$($LFS getdirstripe $testdir/* |
22444 grep -P "^\s+$min_index\t" | wc -l)
22445 [ $((max - min)) -le $((10 * stripe_count)) ] &&
22446 error "stripes shouldn't be evenly distributed"|| true
22451 [ $MDSCOUNT -lt 2 ] &&
22452 skip "We need at least 2 MDTs for this test"
22454 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
22455 skip "Need server version at least 2.12.52"
22459 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
22460 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
22461 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
22462 mkdir $DIR/$tdir-s$stripe_count/qos || error "mkdir failed"
22463 test_qos_mkdir "$LFS mkdir -c $stripe_count" $stripe_count
22466 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
22469 [ $MDSCOUNT -lt 2 ] &&
22470 skip "We need at least 2 MDTs for this test"
22472 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
22473 skip "Need server version at least 2.12.52"
22477 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
22478 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
22479 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
22480 mkdir $DIR/$tdir-s$stripe_count/qos || error "mkdir failed"
22481 $LFS setdirstripe -D -c $stripe_count \
22482 $DIR/$tdir-s$stripe_count/rr ||
22483 error "setdirstripe failed"
22484 $LFS setdirstripe -D -c $stripe_count \
22485 $DIR/$tdir-s$stripe_count/qos ||
22486 error "setdirstripe failed"
22487 test_qos_mkdir "mkdir" $stripe_count
22490 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
22493 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
22494 $LCTL set_param fail_loc=0x80000521
22495 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
22498 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
22501 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22502 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22503 skip "Need server version at least 2.11.52"
22513 # this test may be slow on ZFS
22514 [ "$mds1_FSTYPE" == "zfs" ] && total=100
22516 # though this test is designed for striped directory, let's test normal
22517 # directory too since lock is always saved as CoS lock.
22518 test_mkdir $DIR/$tdir || error "mkdir $tdir"
22519 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
22528 start_time=$(date +%s)
22529 for i in $(seq $total); do
22530 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
22533 end_time=$(date +%s)
22534 duration=$((end_time - start_time))
22536 kill -9 $setattr_pid
22538 echo "rename $total files took $duration sec"
22539 [ $duration -lt 100 ] || error "rename took $duration sec"
22541 run_test 415 "lock revoke is not missing"
22544 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
22545 skip "Need server version at least 2.11.55"
22547 # define OBD_FAIL_OSD_TXN_START 0x19a
22548 do_facet mds1 lctl set_param fail_loc=0x19a
22550 lfs mkdir -c $MDSCOUNT $DIR/$tdir
22554 run_test 416 "transaction start failure won't cause system hung"
22558 do_nodes $(comma_list $(mdts_nodes)) \
22559 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
22560 do_nodes $(comma_list $(mdts_nodes)) \
22561 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
22562 do_nodes $(comma_list $(mdts_nodes)) \
22563 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
22567 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22568 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
22569 skip "Need MDS version at least 2.11.56"
22571 trap cleanup_417 RETURN EXIT
22573 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
22574 do_nodes $(comma_list $(mdts_nodes)) \
22575 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
22576 $LFS migrate -m 0 $DIR/$tdir.1 &&
22577 error "migrate dir $tdir.1 should fail"
22579 do_nodes $(comma_list $(mdts_nodes)) \
22580 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
22581 $LFS mkdir -i 1 $DIR/$tdir.2 &&
22582 error "create remote dir $tdir.2 should fail"
22584 do_nodes $(comma_list $(mdts_nodes)) \
22585 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
22586 $LFS mkdir -c 2 $DIR/$tdir.3 &&
22587 error "create striped dir $tdir.3 should fail"
22590 run_test 417 "disable remote dir, striped dir and dir migration"
22592 # Checks that the outputs of df [-i] and lfs df [-i] match
22594 # usage: check_lfs_df <blocks | inodes> <mountpoint>
22604 [ "$1" == "blocks" ] && inodes= || inodes="-i"
22606 for count in {1..100}; do
22610 # read the lines of interest
22611 df_out=($(df -P $inodes $dir | tail -n +2)) ||
22612 error "df $inodes $dir | tail -n +2 failed"
22613 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
22614 error "lfs df $inodes $dir | grep summary: failed"
22616 # skip first substrings of each output as they are different
22617 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
22618 # compare the two outputs
22620 for i in {1..5}; do
22621 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
22629 lfs df $inodes $dir
22630 error "df and lfs df $1 output mismatch: " \
22631 "df ${inodes}: ${df_out[*]}, " \
22632 "lfs df ${inodes}: ${lfs_df_out[*]}"
22637 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22639 local dir=$DIR/$tdir
22640 local numfiles=$((RANDOM % 4096 + 2))
22641 local numblocks=$((RANDOM % 256 + 1))
22643 wait_delete_completed
22646 # check block output
22647 check_lfs_df blocks $dir
22648 # check inode output
22649 check_lfs_df inodes $dir
22651 # create a single file and retest
22652 echo "Creating a single file and testing"
22653 createmany -o $dir/$tfile- 1 &>/dev/null ||
22654 error "creating 1 file in $dir failed"
22655 check_lfs_df blocks $dir
22656 check_lfs_df inodes $dir
22658 # create a random number of files
22659 echo "Creating $((numfiles - 1)) files and testing"
22660 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
22661 error "creating $((numfiles - 1)) files in $dir failed"
22663 # write a random number of blocks to the first test file
22664 echo "Writing $numblocks 4K blocks and testing"
22665 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
22666 count=$numblocks &>/dev/null ||
22667 error "dd to $dir/${tfile}-0 failed"
22670 check_lfs_df blocks $dir
22671 check_lfs_df inodes $dir
22673 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
22674 error "unlinking $numfiles files in $dir failed"
22676 run_test 418 "df and lfs df outputs match"
22680 local dir=$DIR/$tdir
22685 cancel_lru_locks mdc
22687 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
22688 $LCTL set_param fail_loc=0x1410
22690 $LCTL set_param fail_loc=0
22693 run_test 419 "Verify open file by name doesn't crash kernel"
22697 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
22698 skip "Need MDS version at least 2.12.53"
22700 local SAVE_UMASK=$(umask)
22701 local dir=$DIR/$tdir
22702 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
22706 mkdir -m03777 $dir/testdir
22707 ls -dn $dir/testdir
22708 # Need to remove trailing '.' when SELinux is enabled
22709 local dirperms=$(ls -dn $dir/testdir |
22710 awk '{ sub(/\.$/, "", $1); print $1}')
22711 [ $dirperms == "drwxrwsrwt" ] ||
22712 error "incorrect perms on $dir/testdir"
22714 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
22715 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
22716 ls -n $dir/testdir/testfile
22717 local fileperms=$(ls -n $dir/testdir/testfile |
22718 awk '{ sub(/\.$/, "", $1); print $1}')
22719 [ $fileperms == "-rwxr-xr-x" ] ||
22720 error "incorrect perms on $dir/testdir/testfile"
22724 run_test 420 "clear SGID bit on non-directories for non-members"
22731 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22732 skip "Need MDS version at least 2.12.54"
22734 test_mkdir $DIR/$tdir
22735 createmany -o $DIR/$tdir/f 3
22736 cnt=$(ls -1 $DIR/$tdir | wc -l)
22737 [ $cnt != 3 ] && error "unexpected #files: $cnt"
22739 fid1=$(lfs path2fid $DIR/$tdir/f1)
22740 fid2=$(lfs path2fid $DIR/$tdir/f2)
22741 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
22743 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
22744 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
22746 cnt=$(ls -1 $DIR/$tdir | wc -l)
22747 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
22749 rm -f $DIR/$tdir/f3 || error "can't remove f3"
22750 createmany -o $DIR/$tdir/f 3
22751 cnt=$(ls -1 $DIR/$tdir | wc -l)
22752 [ $cnt != 3 ] && error "unexpected #files: $cnt"
22754 fid1=$(lfs path2fid $DIR/$tdir/f1)
22755 fid2=$(lfs path2fid $DIR/$tdir/f2)
22756 echo "remove using fsname $FSNAME"
22757 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
22759 cnt=$(ls -1 $DIR/$tdir | wc -l)
22760 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
22762 run_test 421a "simple rm by fid"
22769 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22770 skip "Need MDS version at least 2.12.54"
22772 test_mkdir $DIR/$tdir
22773 createmany -o $DIR/$tdir/f 3
22774 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
22777 FID1=$(lfs path2fid $DIR/$tdir/f1)
22778 FID2=$(lfs path2fid $DIR/$tdir/f2)
22779 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
22781 kill -USR1 $MULTIPID
22784 cnt=$(ls $DIR/$tdir | wc -l)
22785 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
22787 run_test 421b "rm by fid on open file"
22793 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22794 skip "Need MDS version at least 2.12.54"
22796 test_mkdir $DIR/$tdir
22797 createmany -o $DIR/$tdir/f 3
22798 touch $DIR/$tdir/$tfile
22799 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
22800 cnt=$(ls -1 $DIR/$tdir | wc -l)
22801 [ $cnt != 184 ] && error "unexpected #files: $cnt"
22803 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
22804 $LFS rmfid $DIR $FID1 || error "rmfid failed"
22806 cnt=$(ls $DIR/$tdir | wc -l)
22807 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
22809 run_test 421c "rm by fid against hardlinked files"
22815 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22816 skip "Need MDS version at least 2.12.54"
22818 test_mkdir $DIR/$tdir
22819 createmany -o $DIR/$tdir/f 4097
22820 cnt=$(ls -1 $DIR/$tdir | wc -l)
22821 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
22823 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
22824 $LFS rmfid $DIR $FIDS || error "rmfid failed"
22826 cnt=$(ls $DIR/$tdir | wc -l)
22828 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
22830 run_test 421d "rmfid en masse"
22836 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22837 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22838 skip "Need MDS version at least 2.12.54"
22840 mkdir -p $DIR/$tdir
22841 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
22842 createmany -o $DIR/$tdir/striped_dir/f 512
22843 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22844 [ $cnt != 512 ] && error "unexpected #files: $cnt"
22846 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
22847 sed "s/[/][^:]*://g")
22848 $LFS rmfid $DIR $FIDS || error "rmfid failed"
22850 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
22852 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
22854 run_test 421e "rmfid in DNE"
22860 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22861 skip "Need MDS version at least 2.12.54"
22863 test_mkdir $DIR/$tdir
22865 cnt=$(ls -1 $DIR/$tdir | wc -l)
22866 [ $cnt != 1 ] && error "unexpected #files: $cnt"
22868 FID=$(lfs path2fid $DIR/$tdir/f)
22869 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
22870 # rmfid should fail
22871 cnt=$(ls -1 $DIR/$tdir | wc -l)
22872 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
22874 chmod a+rw $DIR/$tdir
22876 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
22877 # rmfid should fail
22878 cnt=$(ls -1 $DIR/$tdir | wc -l)
22879 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
22882 $RUNAS touch $DIR/$tdir/f
22883 FID=$(lfs path2fid $DIR/$tdir/f)
22884 echo "rmfid as root"
22885 $LFS rmfid $DIR $FID || error "rmfid as root failed"
22886 cnt=$(ls -1 $DIR/$tdir | wc -l)
22887 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
22890 $RUNAS touch $DIR/$tdir/f
22891 cnt=$(ls -1 $DIR/$tdir | wc -l)
22892 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
22893 FID=$(lfs path2fid $DIR/$tdir/f)
22894 # rmfid w/o user_fid2path mount option should fail
22895 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
22896 cnt=$(ls -1 $DIR/$tdir | wc -l)
22897 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
22899 umount_client $MOUNT || error "failed to umount client"
22900 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
22901 error "failed to mount client'"
22903 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
22904 # rmfid should succeed
22905 cnt=$(ls -1 $DIR/$tdir | wc -l)
22906 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
22908 # rmfid shouldn't allow to remove files due to dir's permission
22909 chmod a+rwx $DIR/$tdir
22912 FID=$(lfs path2fid $DIR/$tdir/f)
22913 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
22915 umount_client $MOUNT || error "failed to umount client"
22916 mount_client $MOUNT "$MOUNT_OPTS" ||
22917 error "failed to mount client'"
22920 run_test 421f "rmfid checks permissions"
22926 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22927 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22928 skip "Need MDS version at least 2.12.54"
22930 mkdir -p $DIR/$tdir
22931 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
22932 createmany -o $DIR/$tdir/striped_dir/f 512
22933 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22934 [ $cnt != 512 ] && error "unexpected #files: $cnt"
22936 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
22937 sed "s/[/][^:]*://g")
22939 rm -f $DIR/$tdir/striped_dir/f1*
22940 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22941 removed=$((512 - cnt))
22943 # few files have been just removed, so we expect
22944 # rmfid to fail on their fids
22945 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
22946 [ $removed != $errors ] && error "$errors != $removed"
22948 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
22950 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
22952 run_test 421g "rmfid to return errors properly"
22955 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
22956 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
22957 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
22958 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
22959 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
22961 local amc=$(at_max_get client)
22962 local amo=$(at_max_get mds1)
22963 local timeout=`lctl get_param -n timeout`
22965 at_max_set 0 client
22968 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
22969 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
22970 fail_val=$(((2*timeout + 10)*1000))
22971 touch $DIR/$tdir/d3/file &
22973 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
22974 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
22975 fail_val=$((2*timeout + 5))
22976 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
22980 sleep $((2 * timeout))
22984 touch $DIR/$tdir/d2/file3
22985 touch $DIR/$tdir/d2/file4
22986 touch $DIR/$tdir/d2/file5
22989 at_max_set $amc client
22990 at_max_set $amo mds1
22992 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
22993 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
22994 error "Watchdog is always throttled"
22996 run_test 422 "kill a process with RPC in progress"
23009 # ensure statfs cache is expired
23012 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
23013 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
23017 run_test 423 "statfs should return a right data"
23020 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
23021 $LCTL set_param fail_loc=0x80000522
23022 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
23025 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
23028 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
23029 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
23030 skip "Need server version at least 2.9.55"
23032 start_full_debug_logging
23036 stop_full_debug_logging
23040 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
23041 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
23042 awk '/The barrier for/ { print $7 }')
23045 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
23050 barrier_expired() {
23053 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
23054 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
23055 awk '/will be expired/ { print $7 }')
23057 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
23066 echo "Start barrier_freeze at: $(date)"
23067 #define OBD_FAIL_BARRIER_DELAY 0x2202
23068 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
23069 # Do not reduce barrier time - See LU-11873
23070 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
23073 local b_status=$(barrier_stat)
23074 echo "Got barrier status at: $(date)"
23075 [ "$b_status" = "'freezing_p1'" ] ||
23076 error "(1) unexpected barrier status $b_status"
23078 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
23080 b_status=$(barrier_stat)
23081 [ "$b_status" = "'frozen'" ] ||
23082 error "(2) unexpected barrier status $b_status"
23084 local expired=$(barrier_expired)
23085 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
23086 sleep $((expired + 3))
23088 b_status=$(barrier_stat)
23089 [ "$b_status" = "'expired'" ] ||
23090 error "(3) unexpected barrier status $b_status"
23092 # Do not reduce barrier time - See LU-11873
23093 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
23094 error "(4) fail to freeze barrier"
23096 b_status=$(barrier_stat)
23097 [ "$b_status" = "'frozen'" ] ||
23098 error "(5) unexpected barrier status $b_status"
23100 echo "Start barrier_thaw at: $(date)"
23101 #define OBD_FAIL_BARRIER_DELAY 0x2202
23102 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
23103 do_facet mgs $LCTL barrier_thaw $FSNAME &
23106 b_status=$(barrier_stat)
23107 echo "Got barrier status at: $(date)"
23108 [ "$b_status" = "'thawing'" ] ||
23109 error "(6) unexpected barrier status $b_status"
23111 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
23113 b_status=$(barrier_stat)
23114 [ "$b_status" = "'thawed'" ] ||
23115 error "(7) unexpected barrier status $b_status"
23117 #define OBD_FAIL_BARRIER_FAILURE 0x2203
23118 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
23119 do_facet mgs $LCTL barrier_freeze $FSNAME
23121 b_status=$(barrier_stat)
23122 [ "$b_status" = "'failed'" ] ||
23123 error "(8) unexpected barrier status $b_status"
23125 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
23126 do_facet mgs $LCTL barrier_thaw $FSNAME
23130 run_test 801a "write barrier user interfaces and stat machine"
23135 mkdir $DIR/$tdir || error "(1) fail to mkdir"
23136 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
23137 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
23138 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
23139 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
23141 cancel_lru_locks mdc
23143 # 180 seconds should be long enough
23144 do_facet mgs $LCTL barrier_freeze $FSNAME 180
23146 local b_status=$(barrier_stat)
23147 [ "$b_status" = "'frozen'" ] ||
23148 error "(6) unexpected barrier status $b_status"
23150 mkdir $DIR/$tdir/d0/d10 &
23153 touch $DIR/$tdir/d1/f13 &
23156 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
23159 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
23162 rm -f $DIR/$tdir/d4/f12 &
23165 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
23167 # To guarantee taht the 'stat' is not blocked
23168 b_status=$(barrier_stat)
23169 [ "$b_status" = "'frozen'" ] ||
23170 error "(8) unexpected barrier status $b_status"
23172 # let above commands to run at background
23175 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
23176 ps -p $touch_pid || error "(10) touch should be blocked"
23177 ps -p $ln_pid || error "(11) link should be blocked"
23178 ps -p $mv_pid || error "(12) rename should be blocked"
23179 ps -p $rm_pid || error "(13) unlink should be blocked"
23181 b_status=$(barrier_stat)
23182 [ "$b_status" = "'frozen'" ] ||
23183 error "(14) unexpected barrier status $b_status"
23185 do_facet mgs $LCTL barrier_thaw $FSNAME
23186 b_status=$(barrier_stat)
23187 [ "$b_status" = "'thawed'" ] ||
23188 error "(15) unexpected barrier status $b_status"
23190 wait $mkdir_pid || error "(16) mkdir should succeed"
23191 wait $touch_pid || error "(17) touch should succeed"
23192 wait $ln_pid || error "(18) link should succeed"
23193 wait $mv_pid || error "(19) rename should succeed"
23194 wait $rm_pid || error "(20) unlink should succeed"
23198 run_test 801b "modification will be blocked by write barrier"
23201 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23205 stop mds2 || error "(1) Fail to stop mds2"
23207 do_facet mgs $LCTL barrier_freeze $FSNAME 30
23209 local b_status=$(barrier_stat)
23210 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
23211 do_facet mgs $LCTL barrier_thaw $FSNAME
23212 error "(2) unexpected barrier status $b_status"
23215 do_facet mgs $LCTL barrier_rescan $FSNAME ||
23216 error "(3) Fail to rescan barrier bitmap"
23218 # Do not reduce barrier time - See LU-11873
23219 do_facet mgs $LCTL barrier_freeze $FSNAME 20
23221 b_status=$(barrier_stat)
23222 [ "$b_status" = "'frozen'" ] ||
23223 error "(4) unexpected barrier status $b_status"
23225 do_facet mgs $LCTL barrier_thaw $FSNAME
23226 b_status=$(barrier_stat)
23227 [ "$b_status" = "'thawed'" ] ||
23228 error "(5) unexpected barrier status $b_status"
23230 local devname=$(mdsdevname 2)
23232 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
23234 do_facet mgs $LCTL barrier_rescan $FSNAME ||
23235 error "(7) Fail to rescan barrier bitmap"
23239 run_test 801c "rescan barrier bitmap"
23241 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
23242 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
23243 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
23244 saved_MOUNT_OPTS=$MOUNT_OPTS
23250 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
23251 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
23252 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
23253 MOUNT_OPTS=$saved_MOUNT_OPTS
23258 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
23259 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
23260 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
23261 skip "Need server version at least 2.9.55"
23263 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
23265 mkdir $DIR/$tdir || error "(1) fail to mkdir"
23267 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
23268 error "(2) Fail to copy"
23270 trap cleanup_802a EXIT
23272 # sync by force before remount as readonly
23273 sync; sync_all_data; sleep 3; sync_all_data
23277 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
23278 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
23279 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
23281 echo "Mount the server as read only"
23282 setupall server_only || error "(3) Fail to start servers"
23284 echo "Mount client without ro should fail"
23285 mount_client $MOUNT &&
23286 error "(4) Mount client without 'ro' should fail"
23288 echo "Mount client with ro should succeed"
23289 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
23290 mount_client $MOUNT ||
23291 error "(5) Mount client with 'ro' should succeed"
23293 echo "Modify should be refused"
23294 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
23296 echo "Read should be allowed"
23297 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
23298 error "(7) Read should succeed under ro mode"
23302 run_test 802a "simulate readonly device"
23305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23306 remote_mds_nodsh && skip "remote MDS with nodsh"
23308 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
23309 skip "readonly option not available"
23311 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
23313 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
23314 error "(2) Fail to copy"
23316 # write back all cached data before setting MDT to readonly
23320 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
23321 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
23323 echo "Modify should be refused"
23324 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
23326 echo "Read should be allowed"
23327 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
23328 error "(7) Read should succeed under ro mode"
23331 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
23333 run_test 802b "be able to set MDTs to readonly"
23336 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23337 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
23338 skip "MDS needs to be newer than 2.10.54"
23340 mkdir -p $DIR/$tdir
23341 # Create some objects on all MDTs to trigger related logs objects
23342 for idx in $(seq $MDSCOUNT); do
23343 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
23344 $DIR/$tdir/dir${idx} ||
23345 error "Fail to create $DIR/$tdir/dir${idx}"
23349 wait_delete_completed # ensure old test cleanups are finished
23350 echo "before create:"
23352 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
23354 for i in {1..10}; do
23355 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
23356 error "Fail to create $DIR/$tdir/foo$i"
23360 echo "after create:"
23362 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
23364 # allow for an llog to be cleaned up during the test
23365 [ $after_used -ge $((before_used + 10 - 1)) ] ||
23366 error "before ($before_used) + 10 > after ($after_used)"
23368 for i in {1..10}; do
23369 rm -rf $DIR/$tdir/foo$i ||
23370 error "Fail to remove $DIR/$tdir/foo$i"
23373 sleep 3 # avoid MDT return cached statfs
23374 wait_delete_completed
23375 echo "after unlink:"
23377 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
23379 # allow for an llog to be created during the test
23380 [ $after_used -le $((before_used + 1)) ] ||
23381 error "after ($after_used) > before ($before_used) + 1"
23383 run_test 803 "verify agent object for remote object"
23386 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23387 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
23388 skip "MDS needs to be newer than 2.10.54"
23389 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
23391 mkdir -p $DIR/$tdir
23392 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
23393 error "Fail to create $DIR/$tdir/dir0"
23395 local fid=$($LFS path2fid $DIR/$tdir/dir0)
23396 local dev=$(mdsdevname 2)
23398 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23399 grep ${fid} || error "NOT found agent entry for dir0"
23401 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
23402 error "Fail to create $DIR/$tdir/dir1"
23404 touch $DIR/$tdir/dir1/foo0 ||
23405 error "Fail to create $DIR/$tdir/dir1/foo0"
23406 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
23409 for idx in $(seq $MDSCOUNT); do
23410 dev=$(mdsdevname $idx)
23411 do_facet mds${idx} \
23412 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23413 grep ${fid} && rc=$idx
23416 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
23417 error "Fail to rename foo0 to foo1"
23418 if [ $rc -eq 0 ]; then
23419 for idx in $(seq $MDSCOUNT); do
23420 dev=$(mdsdevname $idx)
23421 do_facet mds${idx} \
23422 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23423 grep ${fid} && rc=$idx
23427 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
23428 error "Fail to rename foo1 to foo2"
23429 if [ $rc -eq 0 ]; then
23430 for idx in $(seq $MDSCOUNT); do
23431 dev=$(mdsdevname $idx)
23432 do_facet mds${idx} \
23433 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23434 grep ${fid} && rc=$idx
23438 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
23440 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
23441 error "Fail to link to $DIR/$tdir/dir1/foo2"
23442 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
23443 error "Fail to rename foo2 to foo0"
23444 unlink $DIR/$tdir/dir1/foo0 ||
23445 error "Fail to unlink $DIR/$tdir/dir1/foo0"
23446 rm -rf $DIR/$tdir/dir0 ||
23447 error "Fail to rm $DIR/$tdir/dir0"
23449 for idx in $(seq $MDSCOUNT); do
23450 dev=$(mdsdevname $idx)
23454 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
23456 start mds${idx} $dev $MDS_MOUNT_OPTS ||
23457 error "mount mds$idx failed"
23458 df $MOUNT > /dev/null 2>&1
23460 # e2fsck should not return error
23462 error "e2fsck detected error on MDT${idx}: rc=$rc"
23465 run_test 804 "verify agent entry for remote entry"
23468 do_facet $SINGLEMDS zfs set quota=$old $fsset
23469 unlinkmany $DIR/$tdir/f- 1000000
23474 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
23475 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
23476 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
23477 skip "netfree not implemented before 0.7"
23478 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
23479 skip "Need MDS version at least 2.10.57"
23486 local pref="osd-zfs.$FSNAME-MDT0000."
23488 # limit available space on MDS dataset to meet nospace issue
23489 # quickly. then ZFS 0.7.2 can use reserved space if asked
23490 # properly (using netfree flag in osd_declare_destroy()
23491 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
23492 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
23494 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
23495 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
23496 let "usedkb=usedkb-freekb"
23497 let "freekb=freekb/2"
23498 if let "freekb > 5000"; then
23501 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
23502 trap cleanup_805 EXIT
23504 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
23505 error "Can't set PFL layout"
23506 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
23507 rm -rf $DIR/$tdir || error "not able to remove"
23508 do_facet $SINGLEMDS zfs set quota=$old $fsset
23511 run_test 805 "ZFS can remove from full fs"
23517 local size=$($LFS getsom -s $file)
23518 local expect=$(stat -c %s $file)
23520 [[ $size == $expect ]] ||
23521 error "$file expected size: $expect, got: $size"
23523 local blocks=$($LFS getsom -b $file)
23524 expect=$(stat -c %b $file)
23525 [[ $blocks == $expect ]] ||
23526 error "$file expected blocks: $expect, got: $blocks"
23531 local size=$($LFS getsom -s $1)
23534 [[ $size == $expect ]] ||
23535 error "$file expected size: $expect, got: $size"
23539 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
23540 skip "Need MDS version at least 2.11.52"
23544 touch $DIR/$tfile || error "touch $tfile failed"
23546 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
23547 save_lustre_params client "llite.*.xattr_cache" > $save
23548 lctl set_param llite.*.xattr_cache=0
23549 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
23551 # single-threaded write
23552 echo "Test SOM for single-threaded write"
23553 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
23554 error "write $tfile failed"
23555 check_lsom_size $DIR/$tfile $bs
23558 local size=$(($num * $bs))
23562 echo "Test SOM for single client multi-threaded($num) write"
23563 $TRUNCATE $DIR/$tfile 0
23564 for ((i = 0; i < $num; i++)); do
23565 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23567 offset=$((offset + $bs))
23569 for (( i=0; i < $num; i++ )); do
23572 check_lsom_size $DIR/$tfile $size
23574 $TRUNCATE $DIR/$tfile 0
23575 for ((i = 0; i < $num; i++)); do
23576 offset=$((offset - $bs))
23577 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23580 for (( i=0; i < $num; i++ )); do
23583 check_lsom_size $DIR/$tfile $size
23585 # multi-client writes
23586 num=$(get_node_count ${CLIENTS//,/ })
23587 size=$(($num * $bs))
23591 echo "Test SOM for multi-client ($num) writes"
23592 $TRUNCATE $DIR/$tfile 0
23593 for client in ${CLIENTS//,/ }; do
23594 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23597 offset=$((offset + $bs))
23599 for (( i=0; i < $num; i++ )); do
23602 check_lsom_size $DIR/$tfile $offset
23605 $TRUNCATE $DIR/$tfile 0
23606 for client in ${CLIENTS//,/ }; do
23607 offset=$((offset - $bs))
23608 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23612 for (( i=0; i < $num; i++ )); do
23615 check_lsom_size $DIR/$tfile $size
23618 echo "Test SOM for truncate"
23619 $TRUNCATE $DIR/$tfile 1048576
23620 check_lsom_size $DIR/$tfile 1048576
23621 $TRUNCATE $DIR/$tfile 1234
23622 check_lsom_size $DIR/$tfile 1234
23624 # verify SOM blocks count
23625 echo "Verify SOM block count"
23626 $TRUNCATE $DIR/$tfile 0
23627 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
23628 error "failed to write file $tfile"
23629 check_lsom_data $DIR/$tfile
23631 run_test 806 "Verify Lazy Size on MDS"
23634 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
23635 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
23636 skip "Need MDS version at least 2.11.52"
23638 # Registration step
23639 changelog_register || error "changelog_register failed"
23640 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
23641 changelog_users $SINGLEMDS | grep -q $cl_user ||
23642 error "User $cl_user not found in changelog_users"
23644 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
23645 save_lustre_params client "llite.*.xattr_cache" > $save
23646 lctl set_param llite.*.xattr_cache=0
23647 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
23649 rm -rf $DIR/$tdir || error "rm $tdir failed"
23650 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
23651 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
23652 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
23653 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
23654 error "truncate $tdir/trunc failed"
23657 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
23658 error "write $tfile failed"
23660 # multi-client wirtes
23661 local num=$(get_node_count ${CLIENTS//,/ })
23665 echo "Test SOM for multi-client ($num) writes"
23666 touch $DIR/$tfile || error "touch $tfile failed"
23667 $TRUNCATE $DIR/$tfile 0
23668 for client in ${CLIENTS//,/ }; do
23669 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23672 offset=$((offset + $bs))
23674 for (( i=0; i < $num; i++ )); do
23678 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
23679 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
23680 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
23681 check_lsom_data $DIR/$tdir/trunc
23682 check_lsom_data $DIR/$tdir/single_dd
23683 check_lsom_data $DIR/$tfile
23686 # Deregistration step
23687 changelog_deregister || error "changelog_deregister failed"
23689 run_test 807 "verify LSOM syncing tool"
23691 check_som_nologged()
23693 local lines=$($LFS changelog $FSNAME-MDT0000 |
23694 grep 'x=trusted.som' | wc -l)
23695 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
23699 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
23700 skip "Need MDS version at least 2.11.55"
23702 # Registration step
23703 changelog_register || error "changelog_register failed"
23705 touch $DIR/$tfile || error "touch $tfile failed"
23708 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
23709 error "write $tfile failed"
23712 $TRUNCATE $DIR/$tfile 1234
23715 $TRUNCATE $DIR/$tfile 1048576
23718 # Deregistration step
23719 changelog_deregister || error "changelog_deregister failed"
23721 run_test 808 "Check trusted.som xattr not logged in Changelogs"
23726 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
23730 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
23731 skip "Need MDS version at least 2.11.56"
23733 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
23734 error "failed to create DoM-only file $DIR/$tfile"
23735 touch $DIR/$tfile || error "touch $tfile failed"
23736 check_som_nodata $DIR/$tfile
23738 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
23739 error "write $tfile failed"
23740 check_som_nodata $DIR/$tfile
23742 $TRUNCATE $DIR/$tfile 1234
23743 check_som_nodata $DIR/$tfile
23745 $TRUNCATE $DIR/$tfile 4097
23746 check_som_nodata $DIR/$file
23748 run_test 809 "Verify no SOM xattr store for DoM-only files"
23751 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23752 $GSS && skip_env "could not run with gss"
23753 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
23754 skip "OST < 2.12.58 doesn't align checksum"
23757 stack_trap "set_checksums $ORIG_CSUM" EXIT
23758 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
23763 for csum in $CKSUM_TYPES; do
23764 #define OBD_FAIL_OSC_NO_GRANT 0x411
23765 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
23766 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
23768 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
23769 before=$(md5sum $DIR/$tfile)
23770 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
23771 after=$(md5sum $DIR/$tfile)
23772 [ "$before" == "$after" ] ||
23773 error "$csum: $before != $after bs=$1 seek=$2"
23777 run_test 810 "partial page writes on ZFS (LU-11663)"
23780 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
23781 skip "OST < 2.12.51 doesn't support this fail_loc"
23782 [ "$SHARED_KEY" = true ] &&
23783 skip "OSC connections never go IDLE with Shared-Keys enabled"
23785 $LFS setstripe -c 1 -i 0 $DIR/$tfile
23786 # ensure ost1 is connected
23787 stat $DIR/$tfile >/dev/null || error "can't stat"
23788 wait_osc_import_state client ost1 FULL
23789 # no locks, no reqs to let the connection idle
23790 cancel_lru_locks osc
23792 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
23793 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
23794 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
23795 wait_osc_import_state client ost1 CONNECTING
23796 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
23798 stat $DIR/$tfile >/dev/null || error "can't stat file"
23800 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
23802 test_812b() { # LU-12378
23803 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
23804 skip "OST < 2.12.51 doesn't support this fail_loc"
23805 [ "$SHARED_KEY" = true ] &&
23806 skip "OSC connections never go IDLE with Shared-Keys enabled"
23808 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
23809 # ensure ost1 is connected
23810 stat $DIR/$tfile >/dev/null || error "can't stat"
23811 wait_osc_import_state client ost1 FULL
23812 # no locks, no reqs to let the connection idle
23813 cancel_lru_locks osc
23815 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
23816 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
23817 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
23818 wait_osc_import_state client ost1 CONNECTING
23819 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
23821 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
23822 wait_osc_import_state client ost1 IDLE
23824 run_test 812b "do not drop no resend request for idle connect"
23827 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
23828 [ -z "$file_heat_sav" ] && skip "no file heat support"
23839 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
23840 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
23842 $LCTL set_param -n llite.*.file_heat=1
23843 echo "Turn on file heat"
23844 echo "Period second: $period_second, Decay percentage: $decay_pct"
23846 echo "QQQQ" > $DIR/$tfile
23847 echo "QQQQ" > $DIR/$tfile
23848 echo "QQQQ" > $DIR/$tfile
23849 cat $DIR/$tfile > /dev/null
23850 cat $DIR/$tfile > /dev/null
23851 cat $DIR/$tfile > /dev/null
23852 cat $DIR/$tfile > /dev/null
23854 local out=$($LFS heat_get $DIR/$tfile)
23856 $LFS heat_get $DIR/$tfile
23857 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23858 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23859 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23860 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23862 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
23863 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
23864 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
23865 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
23867 sleep $((period_second + 3))
23868 echo "Sleep $((period_second + 3)) seconds..."
23869 # The recursion formula to calculate the heat of the file f is as
23871 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
23872 # Where Hi is the heat value in the period between time points i*I and
23873 # (i+1)*I; Ci is the access count in the period; the symbol P refers
23874 # to the weight of Ci.
23875 out=$($LFS heat_get $DIR/$tfile)
23876 $LFS heat_get $DIR/$tfile
23877 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23878 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23879 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23880 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23882 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
23883 error "read sample ($readsample) is wrong"
23884 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
23885 error "write sample ($writesample) is wrong"
23886 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
23887 error "read bytes ($readbyte) is wrong"
23888 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
23889 error "write bytes ($writebyte) is wrong"
23891 echo "QQQQ" > $DIR/$tfile
23892 echo "QQQQ" > $DIR/$tfile
23893 echo "QQQQ" > $DIR/$tfile
23894 cat $DIR/$tfile > /dev/null
23895 cat $DIR/$tfile > /dev/null
23896 cat $DIR/$tfile > /dev/null
23897 cat $DIR/$tfile > /dev/null
23899 sleep $((period_second + 3))
23900 echo "Sleep $((period_second + 3)) seconds..."
23902 out=$($LFS heat_get $DIR/$tfile)
23903 $LFS heat_get $DIR/$tfile
23904 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23905 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23906 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23907 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23909 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
23910 4 * $decay_pct) / 100") -eq 1 ] ||
23911 error "read sample ($readsample1) is wrong"
23912 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
23913 3 * $decay_pct) / 100") -eq 1 ] ||
23914 error "write sample ($writesample1) is wrong"
23915 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
23916 20 * $decay_pct) / 100") -eq 1 ] ||
23917 error "read bytes ($readbyte1) is wrong"
23918 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
23919 15 * $decay_pct) / 100") -eq 1 ] ||
23920 error "write bytes ($writebyte1) is wrong"
23922 echo "Turn off file heat for the file $DIR/$tfile"
23923 $LFS heat_set -o $DIR/$tfile
23925 echo "QQQQ" > $DIR/$tfile
23926 echo "QQQQ" > $DIR/$tfile
23927 echo "QQQQ" > $DIR/$tfile
23928 cat $DIR/$tfile > /dev/null
23929 cat $DIR/$tfile > /dev/null
23930 cat $DIR/$tfile > /dev/null
23931 cat $DIR/$tfile > /dev/null
23933 out=$($LFS heat_get $DIR/$tfile)
23934 $LFS heat_get $DIR/$tfile
23935 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23936 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23937 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23938 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23940 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
23941 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
23942 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
23943 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
23945 echo "Trun on file heat for the file $DIR/$tfile"
23946 $LFS heat_set -O $DIR/$tfile
23948 echo "QQQQ" > $DIR/$tfile
23949 echo "QQQQ" > $DIR/$tfile
23950 echo "QQQQ" > $DIR/$tfile
23951 cat $DIR/$tfile > /dev/null
23952 cat $DIR/$tfile > /dev/null
23953 cat $DIR/$tfile > /dev/null
23954 cat $DIR/$tfile > /dev/null
23956 out=$($LFS heat_get $DIR/$tfile)
23957 $LFS heat_get $DIR/$tfile
23958 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23959 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23960 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23961 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23963 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
23964 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
23965 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
23966 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
23968 $LFS heat_set -c $DIR/$tfile
23969 $LCTL set_param -n llite.*.file_heat=0
23970 echo "Turn off file heat support for the Lustre filesystem"
23972 echo "QQQQ" > $DIR/$tfile
23973 echo "QQQQ" > $DIR/$tfile
23974 echo "QQQQ" > $DIR/$tfile
23975 cat $DIR/$tfile > /dev/null
23976 cat $DIR/$tfile > /dev/null
23977 cat $DIR/$tfile > /dev/null
23978 cat $DIR/$tfile > /dev/null
23980 out=$($LFS heat_get $DIR/$tfile)
23981 $LFS heat_get $DIR/$tfile
23982 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23983 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23984 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23985 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23987 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
23988 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
23989 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
23990 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
23992 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
23995 run_test 813 "File heat verfication"
23999 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
24000 echo -n y >> $DIR/$tfile
24001 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
24002 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
24004 run_test 814 "sparse cp works as expected (LU-12361)"
24008 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
24009 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
24011 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
24014 [ "$SHARED_KEY" = true ] &&
24015 skip "OSC connections never go IDLE with Shared-Keys enabled"
24017 $LFS setstripe -c 1 -i 0 $DIR/$tfile
24018 # ensure ost1 is connected
24019 stat $DIR/$tfile >/dev/null || error "can't stat"
24020 wait_osc_import_state client ost1 FULL
24021 # no locks, no reqs to let the connection idle
24022 cancel_lru_locks osc
24023 lru_resize_disable osc
24026 before=$($LCTL get_param -n \
24027 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
24029 wait_osc_import_state client ost1 IDLE
24030 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
24031 now=$($LCTL get_param -n \
24032 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
24033 [ $before == $now ] || error "lru_size changed $before != $now"
24035 run_test 816 "do not reset lru_resize on idle reconnect"
24039 exportfs -u localhost:$DIR/nfsexp
24044 systemctl restart nfs-server.service || skip "failed to restart nfsd"
24046 mkdir -p $DIR/nfsexp
24047 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
24048 error "failed to export nfs"
24050 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
24051 stack_trap cleanup_817 EXIT
24053 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
24054 error "failed to mount nfs to $tmpdir"
24056 cp /bin/true $tmpdir
24057 $DIR/nfsexp/true || error "failed to execute 'true' command"
24059 run_test 817 "nfsd won't cache write lock for exec file"
24063 $LFS setstripe -c1 -i0 $DIR/$tfile
24064 $LFS setstripe -c1 -i1 $DIR/$tfile
24066 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
24067 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
24068 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
24069 error "start $SINGLEMDS failed"
24072 run_test 818 "unlink with failed llog"
24075 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24076 cancel_lru_locks osc
24077 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
24078 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
24079 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
24082 run_test 819a "too big niobuf in read"
24085 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
24086 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
24087 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24088 cancel_lru_locks osc
24092 run_test 819b "too big niobuf in write"
24095 function test_820_start_ost() {
24098 for num in $(seq $OSTCOUNT); do
24099 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
24104 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
24107 umount_client $MOUNT || error "umount failed"
24108 for num in $(seq $OSTCOUNT); do
24112 # mount client with no active OSTs
24113 # so that the client can't initialize max LOV EA size
24114 # from OSC notifications
24115 mount_client $MOUNT || error "mount failed"
24116 # delay OST starting to keep this 0 max EA size for a while
24117 test_820_start_ost &
24119 # create a directory on MDS2
24120 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
24121 error "Failed to create directory"
24122 # open intent should update default EA size
24123 # see mdc_update_max_ea_from_body()
24124 # notice this is the very first RPC to MDS2
24125 cp /etc/services $DIR/$tdir/mds2 ||
24126 error "Failed to copy files to mds$n"
24128 run_test 820 "update max EA from open intent"
24131 # tests that do cleanup/setup should be run at the end
24135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24138 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
24139 $LCTL set_param fail_loc=0x903
24141 cancel_lru_locks MGC
24143 FAIL_ON_ERROR=true cleanup
24144 FAIL_ON_ERROR=true setup
24146 run_test 900 "umount should not race with any mgc requeue thread"
24148 # LUS-6253/LU-11185
24154 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24156 # some get_param have a bug to handle dot in param name
24157 cancel_lru_locks MGC
24158 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
24159 olds=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
24160 umount_client $MOUNT || error "umount failed"
24161 mount_client $MOUNT || error "mount failed"
24162 cancel_lru_locks MGC
24163 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
24164 news=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
24166 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
24167 [ $olds -lt $news ] && error "mgs lock leak ($olds != $news)"
24171 run_test 901 "don't leak a mgc lock on client umount"
24175 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
24176 skip "client does not have LU-13377 fix"
24177 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
24178 $LCTL set_param fail_loc=0x1415
24179 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24180 cancel_lru_locks osc
24183 run_test 902 "test short write doesn't hang lustre"
24186 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
24187 check_and_cleanup_lustre
24188 if [ "$I_MOUNTED" != "yes" ]; then
24189 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true